Codebase list lwjgl / upstream/2.4.2+dfsg
Imported Upstream version 2.4.2+dfsg Gabriele Giacone 13 years ago
671 changed file(s) with 97219 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 <project name="LWJGL" default="all" basedir=".">
1
2 <property name="build.sysclasspath" value="last" />
3
4 <import file="platform_build/build-definitions.xml"/>
5 <import file="platform_build/build-generator.xml"/>
6 <import file="platform_build/build-applet.xml"/>
7 <import file="platform_build/build-webstart.xml"/>
8
9 <!-- ================================================================== -->
10 <!-- Everything below this line is targets. -->
11 <!-- Do not modify, unless you know what you're doing -->
12 <!-- ================================================================== -->
13
14 <!-- ================================================================== -->
15 <!-- Initialize build -->
16 <!-- ================================================================== -->
17 <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
35 <!-- 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
42 <!-- Creates a distribution of LWJGL -->
43 <target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
44 <!-- Warn user -->
45 <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" />
65 <!-- 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 -->
81 <copy todir="${lwjgl.temp}/doc">
82 <fileset dir="${lwjgl.docs}">
83 <patternset refid="lwjgl-docs.fileset" />
84 </fileset>
85 </copy>
86
87 <!-- create distribution from files in libs/ and temp/ -->
88 <antcall target="-distribution_javadoc" />
89 <antcall target="-distribution_source" />
90 <antcall target="-distribute" />
91 </target>
92
93 <target name="all" description="Creates the Java archives and the natives for the current platform" depends="jars, compile_native"/>
94
95 <!-- Create ONLY the jar archives -->
96 <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, generate-all, compile, -createjars">
97 <antcall target="-jars_NoDEP" />
98 </target>
99
100 <target name="-jars_NoDEP">
101 <move todir="libs/">
102 <fileset dir="${lwjgl.temp}/jar">
103 <include name="*.jar"/>
104 </fileset>
105 </move>
106 </target>
107
108 <!-- Packages the java files -->
109 <target name="-createdebugjars">
110 <!-- Create lwjgl.jar -->
111 <jar destfile="${lwjgl.temp}/jar/lwjgl-debug.jar" taskname="lwjgl-debug.jar">
112 <fileset refid="lwjgl.fileset" />
113 <manifest>
114 <attribute name="Sealed" value="true"/>
115 </manifest>
116 </jar>
117 </target>
118
119 <!-- Packages the java files -->
120 <target name="-createjars">
121 <!-- Create lwjgl.jar -->
122 <jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar">
123 <fileset refid="lwjgl.fileset" />
124 <manifest>
125 <attribute name="Sealed" value="true"/>
126 <attribute name="Trusted-Library" value="true"/>
127 </manifest>
128 </jar>
129
130 <!-- Create lwjgl_util_applet.jar -->
131 <jar destfile="${lwjgl.temp}/jar/lwjgl_util_applet.jar" taskname="lwjgl_util_applet.jar">
132 <fileset refid="lwjgl_util_applet.fileset" />
133 <manifest>
134 <attribute name="Sealed" value="true"/>
135 <attribute name="Trusted-Library" value="true"/>
136 </manifest>
137 </jar>
138
139 <!-- Create lwjgl_test.jar -->
140 <jar destfile="${lwjgl.temp}/jar/lwjgl_test.jar" taskname="lwjgl_test.jar">
141 <fileset refid="lwjgl_test.fileset" />
142 <fileset refid="lwjgl_test_extra.fileset" />
143 </jar>
144
145 <!-- Create lwjgl_util.jar -->
146 <jar destfile="${lwjgl.temp}/jar/lwjgl_util.jar" taskname="lwjgl_util.jar">
147 <fileset refid="lwjgl_util.fileset" />
148 </jar>
149 </target>
150
151 <!-- Distributes files -->
152 <target name="-distribute">
153 <delete>
154 <fileset dir="${lwjgl.temp}/native/" includes="**/*"/>
155 </delete>
156
157 <copy todir="${lwjgl.temp}/jar">
158 <fileset dir="${lwjgl.lib}/" includes="*.jar"/>
159 </copy>
160 <copy todir="${lwjgl.temp}/native/windows">
161 <fileset dir="${lwjgl.lib}/windows">
162 <patternset refid="lwjgl-windows.fileset" />
163 </fileset>
164 </copy>
165 <copy todir="${lwjgl.temp}/native/linux">
166 <fileset dir="${lwjgl.lib}/linux">
167 <patternset refid="lwjgl-linux.fileset" />
168 </fileset>
169 </copy>
170 <copy todir="${lwjgl.temp}/native/macosx">
171 <fileset dir="${lwjgl.lib}/macosx">
172 <patternset refid="lwjgl-macosx.fileset" />
173 </fileset>
174 </copy>
175 <copy todir="${lwjgl.temp}/native/solaris">
176 <fileset dir="${lwjgl.lib}/solaris">
177 <patternset refid="lwjgl-solaris.fileset" />
178 </fileset>
179 </copy>
180
181 <!-- create base package -->
182 <zip destfile="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip">
183 <zipfileset dir="${lwjgl.temp}" prefix="lwjgl-${lwjgl.version}/">
184 <patternset refid="lwjgl_base"/>
185 </zipfileset>
186 </zip>
187
188 <!-- create applet package -->
189 <zip destfile="${lwjgl.dist}/lwjgl_applet-${lwjgl.version}.zip">
190 <zipfileset dir="." prefix="lwjgl_applet-${lwjgl.version}/">
191 <patternset refid="lwjgl_applet"/>
192 </zipfileset>
193 </zip>
194 </target>
195
196 <!-- Creates a versioned distribution of javadocs -->
197 <target name="-distribution_javadoc">
198 <zip destfile="${lwjgl.dist}/lwjgl-docs-${lwjgl.version}.zip" basedir="${lwjgl.docs}" includes="javadoc/**" />
199 </target>
200
201 <!-- Creates a versioned distribution of the source code -->
202 <target name="-distribution_source">
203 <zip destfile="${lwjgl.dist}/lwjgl-source-${lwjgl.version}.zip">
204 <fileset refid="lwjgl.source.fileset" />
205 </zip>
206 </target>
207
208 <!-- Generates the native headers from source files -->
209 <target name="headers" description="invokes javah on java classes" depends="compile">
210 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
211 <class name="org.lwjgl.LinuxSysImplementation" />
212 <class name="org.lwjgl.opengl.LinuxEvent" />
213 <class name="org.lwjgl.opengl.LinuxMouse" />
214 <class name="org.lwjgl.opengl.LinuxKeyboard" />
215 <class name="org.lwjgl.opengl.LinuxDisplay" />
216 <class name="org.lwjgl.opengl.LinuxPeerInfo" />
217 <class name="org.lwjgl.opengl.LinuxPbufferPeerInfo" />
218 <class name="org.lwjgl.opengl.LinuxDisplayPeerInfo" />
219 <class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo" />
220 <class name="org.lwjgl.opengl.LinuxContextImplementation" />
221 <class name="org.lwjgl.opengl.LinuxCanvasImplementation" />
222 </javah>
223
224 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
225 <class name="org.lwjgl.opengl.WindowsKeyboard" />
226 <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" />
227 <class name="org.lwjgl.opengl.WindowsDisplay" />
228 <class name="org.lwjgl.opengl.WindowsRegistry" />
229 <class name="org.lwjgl.WindowsSysImplementation" />
230 <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo" />
231 <class name="org.lwjgl.opengl.WindowsPeerInfo" />
232 <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" />
233 <class name="org.lwjgl.opengl.WindowsContextImplementation" />
234 </javah>
235
236 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
237 <class name="org.lwjgl.MacOSXSysImplementation" />
238 <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
239 <class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
240 <class name="org.lwjgl.opengl.MacOSXPeerInfo" />
241 <class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" />
242 <class name="org.lwjgl.opengl.MacOSXDisplay" />
243 <class name="org.lwjgl.opengl.MacOSXContextImplementation" />
244 </javah>
245
246 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
247 <class name="org.lwjgl.opengl.AWTSurfaceLock" />
248 <class name="org.lwjgl.DefaultSysImplementation" />
249 <class name="org.lwjgl.input.Cursor" />
250 <class name="org.lwjgl.input.Keyboard" />
251 <class name="org.lwjgl.input.Mouse" />
252 <class name="org.lwjgl.openal.AL" />
253 <class name="org.lwjgl.opengl.GLContext" />
254 <class name="org.lwjgl.opengl.Pbuffer" />
255 </javah>
256 </target>
257
258 <target name="touch-version">
259 <touch file="${lwjgl.src.native}/windows/org_lwjgl_opengl_Display.c"/>
260 <touch file="${lwjgl.src.native}/linux/org_lwjgl_opengl_Display.c"/>
261 <touch file="${lwjgl.src.native}/macosx/org_lwjgl_opengl_Display.m"/>
262 </target>
263
264 <target name="version-mismatch">
265 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version">
266 <filterchain>
267 <tokenfilter>
268 <containsstring contains="JNI_VERSION ="/>
269 </tokenfilter>
270 </filterchain>
271 </loadfile>
272 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/LinuxSysImplementation.java" property="lwjgl.java.linux.version">
273 <filterchain>
274 <tokenfilter>
275 <containsstring contains="JNI_VERSION ="/>
276 </tokenfilter>
277 </filterchain>
278 </loadfile>
279 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version">
280 <filterchain>
281 <tokenfilter>
282 <containsstring contains="JNI_VERSION ="/>
283 </tokenfilter>
284 </filterchain>
285 </loadfile>
286 <loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version">
287 <filterchain>
288 <tokenfilter>
289 <containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/>
290 </tokenfilter>
291 </filterchain>
292 </loadfile>
293 <loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version">
294 <filterchain>
295 <tokenfilter>
296 <containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
297 </tokenfilter>
298 </filterchain>
299 </loadfile>
300 <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
301 <filterchain>
302 <tokenfilter>
303 <containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/>
304 </tokenfilter>
305 </filterchain>
306 </loadfile>
307 <echo>
308 lwjgl.java.windows.version = ${lwjgl.java.windows.version}
309 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
310 lwjgl.java.linux.version = ${lwjgl.java.linux.version}
311 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
312 lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
313 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
314 </echo>
315 </target>
316
317 <macrodef name="version-check">
318 <attribute name="platform"/>
319 <sequential>
320 <java classname="org.lwjgl.test.NativeTest" logError="false" resultproperty="nativetest.res" outputproperty="nativetest.out" errorproperty="nativetest.err" fork="true">
321 <jvmarg value="-Djava.library.path=libs/@{platform}"/>
322 <classpath>
323 <pathelement path="${lwjgl.bin}"/>
324 <pathelement path="${java.class.path}"/>
325 </classpath>
326 </java>
327
328 <fail message="Unable to load native library: ${nativetest.err}">
329 <condition>
330 <not>
331 <equals arg1="OK" arg2="${nativetest.out}"/>
332 </not>
333 </condition>
334 </fail>
335
336 <echo message="Successfully executed NativeTest"/>
337 </sequential>
338 </macrodef>
339
340 <!-- Compiles the Java source code -->
341 <target name="compile" description="Compiles the java source code" depends="-initialize">
342 <javac debug="yes" destdir="${lwjgl.bin}" source="1.4" target="1.4" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
343 <src path="${lwjgl.src}/java/"/>
344 <src path="${lwjgl.src}/generated/"/>
345 <include name="org/lwjgl/*.java"/>
346 <include name="org/lwjgl/input/**"/>
347 <include name="org/lwjgl/opengl/**"/>
348 <include name="org/lwjgl/openal/**"/>
349 <include name="org/lwjgl/util/**"/>
350 <exclude name="org/lwjgl/util/generator/**"/>
351 </javac>
352 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.4" target="1.4" taskname="test" />
353 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.4" target="1.4" taskname="examples" />
354 </target>
355
356 <target name="compile_native" depends="headers, touch-version, version-mismatch" description="Compiles the native files">
357 <condition property="lwjgl.platform.windows">
358 <os family="windows" />
359 </condition>
360 <antcall target="-compile_native_win32" />
361
362 <condition property="lwjgl.platform.linux">
363 <os name="Linux" />
364 </condition>
365 <antcall target="-compile_native_linux" />
366
367 <condition property="lwjgl.platform.solaris">
368 <os name="SunOS" />
369 </condition>
370 <antcall target="-compile_native_solaris" />
371
372 <condition property="lwjgl.platform.macosx">
373 <os name="Mac OS X" />
374 </condition>
375 <antcall target="-compile_native_macosx" />
376 </target>
377
378 <!-- Compiles LWJGL on Win32 platforms -->
379 <target name="-compile_native_win32" if="lwjgl.platform.windows">
380 <ant antfile="platform_build/windows_ant/build.xml" inheritAll="false"/>
381 <copy todir="${lwjgl.lib}/windows">
382 <fileset dir="${lwjgl.bin}/lwjgl" includes="lwjgl*.dll"/>
383 </copy>
384 <version-check platform="windows"/>
385 </target>
386
387 <!-- Compiles LWJGL on Linux platforms -->
388 <target name="-compile_native_linux" if="lwjgl.platform.linux">
389 <ant antfile="platform_build/linux_ant/build.xml" inheritAll="false"/>
390 <copy todir="${lwjgl.lib}/linux">
391 <fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
392 </copy>
393 <!-- headless issues <version-check platform="linux"/> -->
394 </target>
395
396 <!-- Compiles LWJGL on solaris platforms -->
397 <target name="-compile_native_solaris" if="lwjgl.platform.solaris">
398 <!-- Reusing the linux ant task, but copy the output to solaris -->
399 <ant antfile="platform_build/linux_ant/build.xml" inheritAll="false"/>
400 <copy todir="${lwjgl.lib}/solaris">
401 <fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
402 </copy>
403 <version-check platform="solaris"/>
404 </target>
405
406 <!-- Compiles LWJGL on Mac platforms -->
407 <target name="-compile_native_macosx" if="lwjgl.platform.macosx">
408 <ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/>
409 <copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
410 <version-check platform="macosx"/>
411 </target>
412
413 <target name="repack200" description="Pack200-repack a jar file">
414 <pack200 src="${input}" destfile="${output}" repack="true"/>
415 </target>
416
417 <target name="pack200" description="Pack200 a jar file">
418 <pack200 src="${input}" destfile="${output}"/>
419 </target>
420
421 <target name="lzma" description="LZMA compress a file">
422 <java fork="true" classname="SevenZip.LzmaAlone">
423 <classpath>
424 <pathelement location="platform_build/JLzma.jar"/>
425 </classpath>
426 <jvmarg value="-Xmx512m"/>
427 <arg value="e"/>
428 <arg value="${input}"/>
429 <arg value="${output}"/>
430 </java>
431 </target>
432
433 <target name="compress-sign-class">
434 <antcall target="repack200">
435 <param name="input" value="${dir}${jarfile}.jar"/>
436 <param name="output" value="${dir}${jarfile}-repack.jar"/>
437 </antcall>
438 <signjar jar="${dir}${jarfile}-repack.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
439 <antcall target="pack200">
440 <param name="input" value="${dir}${jarfile}-repack.jar"/>
441 <param name="output" value="${dir}${jarfile}.jar.pack"/>
442 </antcall>
443 <antcall target="lzma">
444 <param name="input" value="${dir}${jarfile}.jar.pack"/>
445 <param name="output" value="${dir}${jarfile}.jar.pack.lzma"/>
446 </antcall>
447 <delete file="${dir}${jarfile}-repack.jar"/>
448 <delete file="${dir}${jarfile}.jar.pack"/>
449 <delete file="${dir}${jarfile}.jar"/>
450 </target>
451
452 <target name="compress-resource">
453 <antcall target="lzma">
454 <param name="input" value="${input}"/>
455 <param name="output" value="${output}"/>
456 </antcall>
457 </target>
458
459 <target name="applettest" depends="applet">
460 <exec executable="appletviewer">
461 <arg value="-J-Djava.security.policy=applet/appletviewer.policy"/>
462 <arg path="applet/applet.html"/>
463 </exec>
464 </target>
465
466 <target name="runtest" depends="all">
467 <fail message="test.mainclass is not set. Use 'ant -Dtest.mainclass=&lt;main-class&gt; runtest'" unless="test.mainclass"/>
468 <condition property="native_path" value="libs/windows">
469 <os family="windows" />
470 </condition>
471
472 <condition property="native_path" value="libs/linux">
473 <or>
474 <os name="Linux" />
475 <os name="SunOS" />
476 </or>
477 </condition>
478
479 <condition property="native_path" value="libs/macosx">
480 <os name="Mac OS X" />
481 </condition>
482 <property name="native_path_expanded" location="${native_path}"/>
483 <java classname="${test.mainclass}" classpath="res:${lwjgl.lib}/lwjgl.jar:${lwjgl.lib}/lwjgl_util.jar:${lwjgl.lib}/lwjgl_test.jar:${lwjgl.lib}/jinput.jar" fork="true">
484 <sysproperty key="org.lwjgl.util.Debug" value="true"/>
485 <sysproperty key="java.library.path" value="${native_path_expanded}"/>
486 <arg line="${args}"/>
487 </java>
488 </target>
489
490 <!-- Creates the Javadoc -->
491 <target name="javadoc" description="Creates javadoc from java source code">
492 <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.4" windowtitle="LWJGL API" useexternalfile="true">
493 <fileset refid="lwjgl.javadoc.fileset" />
494 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
495 <bottom><![CDATA[<i>Copyright &#169; 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
496 </javadoc>
497 </target>
498 </project>
0 <project name="applet">
1
2 <!-- Create our packer task -->
3 <taskdef name="pack200" classname="com.sun.tools.apache.ant.pack200.Pack200Task" classpath="platform_build/Pack200Task.jar"/>
4
5 <target name="applet" depends="all">
6 <antcall target="-applet">
7 <param name="keystore" value="applet/lwjglkeystore"/>
8 <param name="alias" value="lwjgl"/>
9 <param name="password" value="123456"/>
10 </antcall>
11 </target>
12
13 <target name="applet-release">
14 <input message="Please enter the keystore" addproperty="keystore.location" defaultvalue="applet/lwjglkeystore"/>
15 <input message="Please enter the keystore alias" addproperty="keystore.alias" defaultvalue="lwjgl"/>
16 <input message="Please type the password for the keystore" addproperty="sign.pwd" defaultvalue="123456"/>
17
18 <antcall target="-applet">
19 <!--
20 <param name="keystore" value="signing/matzon_java_code_signing.keystore"/>
21 <param name="alias" value="oddlabs_java_code_signing"/>
22 <param name="password" value="${sign.pwd}"/>
23 -->
24 <param name="keystore" value="${keystore.location}"/>
25 <param name="alias" value="${keystore.alias}"/>
26 <param name="password" value="${sign.pwd}"/>
27 </antcall>
28 </target>
29
30 <target name="-applet">
31
32 <!-- Create lwjgl_applet.jar -->
33 <jar destfile="applet/lwjgl_applet.jar" taskname="lwjgl_applet.jar">
34 <fileset refid="lwjgl_applet.fileset" />
35 </jar>
36
37 <!-- create each of the native jars -->
38 <jar destfile="applet/windows_natives.jar" taskname="windows_natives.jar">
39 <fileset dir="${lwjgl.lib}/windows">
40 <patternset refid="lwjgl-windows.fileset"/>
41 </fileset>
42 </jar>
43 <signjar jar="applet/windows_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
44
45 <jar destfile="applet/linux_natives.jar" taskname="linux_natives.jar">
46 <fileset dir="${lwjgl.lib}/linux">
47 <patternset refid="lwjgl-linux.fileset"/>
48 </fileset>
49 </jar>
50 <signjar jar="applet/linux_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
51
52 <jar destfile="applet/macosx_natives.jar" taskname="macosx_natives.jar">
53 <fileset dir="${lwjgl.lib}/macosx">
54 <patternset refid="lwjgl-macosx.fileset"/>
55 </fileset>
56 </jar>
57 <signjar jar="applet/macosx_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
58
59 <jar destfile="applet/solaris_natives.jar" taskname="solaris_natives.jar">
60 <fileset dir="${lwjgl.lib}/solaris">
61 <patternset refid="lwjgl-solaris.fileset"/>
62 </fileset>
63 </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>
69
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}"/>
81
82 <!-- 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"/>
86 </antcall>
87 <antcall target="compress-resource">
88 <param name="input" value="applet/lwjgl-debug.jar"/>
89 <param name="output" value="applet/lwjgl-debug.jar.lzma"/>
90 </antcall>
91
92 <antcall target="compress-resource">
93 <param name="input" value="applet/lwjgl_util.jar"/>
94 <param name="output" value="applet/lwjgl_util.jar.lzma"/>
95 </antcall>
96 <antcall target="compress-resource">
97 <param name="input" value="applet/jinput.jar"/>
98 <param name="output" value="applet/jinput.jar.lzma"/>
99 </antcall>
100 <antcall target="compress-resource">
101 <param name="input" value="applet/lwjgl_applet.jar"/>
102 <param name="output" value="applet/lwjgl_applet.jar.lzma"/>
103 </antcall>
104 <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>
108 <antcall target="compress-sign-class">
109 <param name="dir" value="applet/"/>
110 <param name="jarfile" value="lwjgl"/>
111 </antcall>
112 <antcall target="compress-sign-class">
113 <param name="dir" value="applet/"/>
114 <param name="jarfile" value="lwjgl-debug"/>
115 </antcall>
116 <antcall target="compress-sign-class">
117 <param name="dir" value="applet/"/>
118 <param name="jarfile" value="lwjgl_util"/>
119 </antcall>
120 <antcall target="compress-sign-class">
121 <param name="dir" value="applet/"/>
122 <param name="jarfile" value="jinput"/>
123 </antcall>
124 <antcall target="compress-sign-class">
125 <param name="dir" value="applet/"/>
126 <param name="jarfile" value="lwjgl_applet"/>
127 </antcall>
128 <antcall target="compress-resource">
129 <param name="input" value="applet/windows_natives.jar"/>
130 <param name="output" value="applet/windows_natives.jar.lzma"/>
131 </antcall>
132 <antcall target="compress-resource">
133 <param name="input" value="applet/macosx_natives.jar"/>
134 <param name="output" value="applet/macosx_natives.jar.lzma"/>
135 </antcall>
136 <antcall target="compress-resource">
137 <param name="input" value="applet/linux_natives.jar"/>
138 <param name="output" value="applet/linux_natives.jar.lzma"/>
139 </antcall>
140 <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"/>
148 </antcall>
149 </target>
150 </project>
0 <project name="definitions">
1 <!-- ================================================================== -->
2 <!-- Global properties for build -->
3 <!-- ================================================================== -->
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.4.2" />
15
16 <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/>
17 <!-- ================================================================== -->
18 <!-- Filesets used for targets -->
19 <!-- ================================================================== -->
20
21 <!-- Files to include in the lwjgl.jar file -->
22 <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/**" />
28 </fileset>
29
30 <fileset id="lwjgl_util_applet.fileset" dir="${lwjgl.bin}">
31 <exclude name="**.*"/>
32 <include name="org/lwjgl/util/applet/**"/>
33 </fileset>
34
35 <!-- Files to include in the lwjgl_test.jar file -->
36 <fileset id="lwjgl_test.fileset" dir="${lwjgl.bin}">
37 <exclude name="**.*" />
38 <include name="org/lwjgl/test/**" />
39 <include name="org/lwjgl/examples/**" />
40 </fileset>
41
42 <!-- More files to include in the lwjgl_test.jar file -->
43 <fileset id="lwjgl_test_extra.fileset" dir="${lwjgl.src}/java">
44 <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>
53
54 <!-- Files to include in the lwjgl_util.jar file -->
55 <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/**" />
60 </fileset>
61
62 <!-- Files to include in the lwjgl_applet.jar file -->
63 <fileset id="lwjgl_applet.fileset" dir="${lwjgl.bin}">
64 <exclude name="**.*"/>
65 <include name="org/lwjgl/test/applet/**"/>
66 <include name="org/lwjgl/test/opengl/awt/AWTGearsCanvas.class"/>
67 </fileset>
68
69 <!-- Files to make Javadoc from -->
70 <fileset id="lwjgl.javadoc.fileset" dir="${lwjgl.src}">
71 <include name="**/*.java" />
72 <exclude name="native/**" />
73 <exclude name="templates/**" />
74 <exclude name="java/org/lwjgl/test/**" />
75 <exclude name="java/org/lwjgl/examples/**" />
76 <exclude name="java/org/lwjgl/util/generator/**" />
77 </fileset>
78
79 <!-- Files to include in doc package -->
80 <patternset id="lwjgl-docs.fileset">
81 <include name="CREDITS" />
82 <include name="LICENSE" />
83 <include name="README" />
84 <include name="lwjgl_hidden_switches.text" />
85 <include name="3rdparty/*" />
86 </patternset>
87
88 <!-- Files to include in windows package -->
89 <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" />
96 </patternset>
97
98 <!-- Files to include in linux, glibc2.3 package -->
99 <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" />
104 </patternset>
105
106 <!-- Files to include in mac os x package -->
107 <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" />
112 </patternset>
113
114 <!-- Files to include in solaris package -->
115 <patternset id="lwjgl-solaris.fileset">
116 <include name="liblwjgl*.so" />
117 <include name="libopenal.so" />
118 </patternset>
119
120 <!-- Files to include in source distribution -->
121 <fileset id="lwjgl.source.fileset" dir=".">
122 <include name="build.xml" />
123 <include name="src/**" />
124 <include name="platform_build/**/*" />
125 </fileset>
126
127 <!-- files in the base package -->
128 <patternset id="lwjgl_base">
129 <include name="**" />
130 <exclude name="res/ILtest.*" />
131 <exclude name="res/Missing_you.mod" />
132 <exclude name="res/phero*.*" />
133 </patternset>
134
135 <!-- files in the optional package -->
136 <patternset id="lwjgl_optional">
137 <include name="res/**" />
138 <exclude name="res/logo/**" />
139 <exclude name="res/spaceinvaders/**" />
140 <exclude name="res/*.wav" />
141 <exclude name="res/*.xpm" />
142 <include name="doc/CREDITS" />
143 <include name="doc/LICENSE" />
144 <include name="doc/README" />
145 </patternset>
146
147 <!-- files in the lwjgl_applet package -->
148 <patternset id="lwjgl_applet">
149 <include name="applet/**" />
150 <exclude name="applet/appletviewer.policy" />
151 <exclude name="applet/lwjglkeystore" />
152 </patternset>
153
154 <uptodate property="lwjgl.main.built" targetfile="${lwjgl.lib}/windows/lwjgl.dll" >
155 <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c*"/>
156 <srcfiles dir= "${lwjgl.src.native}/windows" includes="*.c"/>
157 </uptodate>
158 </project>
0 <project name="generator">
1
2 <!-- clean the generated files -->
3 <target name="clean-generated" description="Deletes the generated java and native source">
4 <delete quiet="true" failonerror="false">
5 <fileset dir="${lwjgl.src}/generated" includes="**"/>
6 <fileset dir="${lwjgl.src.native}/generated" includes="**"/>
7 </delete>
8 </target>
9
10 <!-- Compiles the Java generator source code -->
11 <target name="generators" description="Compiles the native method generators">
12 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
13 <compilerarg value="-Xlint:all"/>
14 </javac>
15 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.4" target="1.4" taskname="generator">
16 <include name="org/lwjgl/opengl/GLSync.java"/>
17 <include name="org/lwjgl/opengl/PointerWrapper.java"/>
18 </javac>
19 </target>
20
21 <!-- Proxy target to generate it all -->
22 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references" description="Generates java and native source"/>
23
24 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references" description="Generates java and native source"/>
25
26 <!-- Generate OpenAL -->
27 <target name="generate-openal" depends="generators" description="Generates java and native source for AL">
28 <apply executable="apt" parallel="true">
29 <arg value="-nocompile"/>
30 <arg value="-factory"/>
31 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
32 <arg value="-cp"/>
33 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
34 <arg value="-s"/>
35 <arg path="${lwjgl.src}/generated"/>
36 <arg value="-d"/>
37 <arg path="${lwjgl.src.native}/generated"/>
38 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
39 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java"/>
40 </apply>
41 </target>
42
43 <!-- Generate OpenAL [DEBUG] -->
44 <target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
45 <apply executable="apt" parallel="true">
46 <arg value="-nocompile"/>
47 <arg value="-factory"/>
48 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
49 <arg value="-cp"/>
50 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
51 <arg value="-s"/>
52 <arg path="${lwjgl.src}/generated"/>
53 <arg value="-d"/>
54 <arg path="${lwjgl.src.native}/generated"/>
55 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
56 <arg value="-Ageneratechecks"/>
57 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java"/>
58 </apply>
59 </target>
60
61 <!-- Generate OpenGL -->
62 <target name="generate-opengl" depends="generators" description="Generates java and native source for GL">
63 <apply executable="apt" parallel="true">
64 <arg value="-nocompile"/>
65 <arg value="-factory"/>
66 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
67 <arg value="-cp"/>
68 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
69 <arg value="-s"/>
70 <arg path="${lwjgl.src}/generated"/>
71 <arg value="-d"/>
72 <arg path="${lwjgl.src.native}/generated"/>
73 <arg value="-Acontextspecific"/>
74 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
75 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
76 </apply>
77 </target>
78
79 <!-- Generate OpenGL [DEBUG] -->
80 <target name="generate-opengl-debug" depends="generators" description="Generates java and native source for GL">
81 <apply executable="apt" parallel="true">
82 <arg value="-nocompile"/>
83 <arg value="-factory"/>
84 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
85 <arg value="-cp"/>
86 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
87 <arg value="-s"/>
88 <arg path="${lwjgl.src}/generated"/>
89 <arg value="-d"/>
90 <arg path="${lwjgl.src.native}/generated"/>
91 <arg value="-Ageneratechecks"/>
92 <arg value="-Acontextspecific"/>
93 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
94 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
95 </apply>
96 </target>
97
98 <!-- Generate references -->
99 <target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
100 <apply executable="apt" parallel="true">
101 <arg value="-nocompile"/>
102 <arg value="-factory"/>
103 <arg value="org.lwjgl.util.generator.ReferencesGeneratorProcessorFactory"/>
104 <arg value="-cp"/>
105 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
106 <arg value="-s"/>
107 <arg path="${lwjgl.src}/generated"/>
108 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
109 </apply>
110 </target>
111
112 <!-- Generate context capabilities -->
113 <target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
114 <apply executable="apt" parallel="true">
115 <arg value="-nocompile"/>
116 <arg value="-factory"/>
117 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
118 <arg value="-cp"/>
119 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
120 <arg value="-s"/>
121 <arg path="${lwjgl.src}/generated"/>
122 <arg value="-Acontextspecific"/>
123 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
124 </apply>
125 </target>
126
127 <!-- Generate context capabilities [DEBUG] -->
128 <target name="generate-opengl-capabilities-debug" depends="generators" description="Generates java and native source for GL">
129 <apply executable="apt" parallel="true">
130 <arg value="-nocompile"/>
131 <arg value="-factory"/>
132 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
133 <arg value="-cp"/>
134 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
135 <arg value="-s"/>
136 <arg path="${lwjgl.src}/generated"/>
137 <arg value="-Ageneratechecks"/>
138 <arg value="-Acontextspecific"/>
139 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
140 </apply>
141 </target>
142 </project>
0 <project name="webstart">
1 <target name="webstart_demo" depends="jars">
2 <antcall target="-webstart_demo">
3 <param name="keystore" value="applet/lwjglkeystore"/>
4 <param name="alias" value="lwjgl"/>
5 <param name="password" value="123456"/>
6 </antcall>
7 </target>
8
9 <target name="webstart_demo-release" depends="jars">
10 <input message="Please type the password for the keystore" addproperty="sign.pwd"/>
11
12 <antcall target="-webstart_demo">
13 <param name="keystore" value="signing/matzon_java_code_signing.keystore"/>
14 <param name="alias" value="oddlabs_java_code_signing"/>
15 <param name="password" value="${sign.pwd}"/>
16 </antcall>
17 </target>
18
19 <!-- -->
20 <target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos">
21
22 <!-- delete existing temp -->
23 <delete dir="${lwjgl.temp}"/>
24
25 <!-- unzip common files -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/>
27
28 <!-- move files to unified structure -->
29 <move todir="${lwjgl.temp}/jnlp/temp">
30 <fileset dir="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/">
31 <include name="**"/>
32 </fileset>
33 </move>
34
35 <!-- move relevant files to root -->
36 <move todir="${lwjgl.temp}/jnlp/" flatten="true">
37 <fileset dir="${lwjgl.temp}/jnlp/temp">
38 <include name="**/**.jar"/>
39 </fileset>
40 </move>
41
42 <!-- create native jars -->
43 <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows"/>
44 <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux"/>
45 <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx"/>
46 <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris"/>
47
48 <!-- create media jar -->
49 <jar destfile="${lwjgl.temp}/jnlp/media.jar" basedir="${lwjgl.res}"/>
50
51 <!-- sign 'em -->
52 <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
53 <signjar jar="${lwjgl.temp}/jnlp/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
54 <signjar jar="${lwjgl.temp}/jnlp/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
55 <signjar jar="${lwjgl.temp}/jnlp/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
56 <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
57 <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
58 <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
59 </target>
60 </project>
0 <project name="webstart">
1 <target name="webstart_demo" depends="jars">
2 <antcall target="-webstart_demo">
3 <param name="keystore" value="applet/lwjglkeystore"/>
4 <param name="alias" value="lwjgl"/>
5 <param name="password" value="123456"/>
6 </antcall>
7 </target>
8
9 <target name="webstart_demo-release">
10 <input message="Please type the password for the keystore" addproperty="sign.pwd"/>
11
12 <antcall target="-webstart_demo">
13 <param name="keystore" value="signing/matzon_java_code_signing.keystore"/>
14 <param name="alias" value="oddlabs_java_code_signing"/>
15 <param name="password" value="${sign.pwd}"/>
16 </antcall>
17 </target>
18
19 <!-- -->
20 <target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos">
21
22 <!-- delete existing temp -->
23 <delete dir="${lwjgl.temp}"/>
24
25 <!-- unzip common files -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/>
27
28 <!-- move files to unified structure -->
29 <move todir="${lwjgl.temp}/jnlp/temp">
30 <fileset dir="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/">
31 <include name="**"/>
32 </fileset>
33 </move>
34
35 <!-- move relevant files to root -->
36 <move todir="${lwjgl.temp}/jnlp/" flatten="true">
37 <fileset dir="${lwjgl.temp}/jnlp/temp">
38 <include name="**/**.jar"/>
39 </fileset>
40 </move>
41
42 <!-- create native jars -->
43 <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows"/>
44 <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux"/>
45 <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx"/>
46 <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris"/>
47
48 <!-- add media and trusted info -->
49 <jar destfile="${lwjgl.temp}/jnlp/lwjgl_test.jar" update="true">
50 <manifest>
51 <attribute name="Sealed" value="true"/>
52 <attribute name="Trusted-Only" value="true"/>
53 </manifest>
54 </jar>
55
56 <jar destfile="${lwjgl.temp}/jnlp/lwjgl_util.jar" update="true">
57 <fileset dir="${lwjgl.res}"/>
58 <manifest>
59 <attribute name="Sealed" value="true"/>
60 <attribute name="Trusted-Library" value="true"/>
61 </manifest>
62 </jar>
63
64 <jar destfile="${lwjgl.temp}/jnlp/jinput.jar" update="true">
65 <manifest>
66 <attribute name="Sealed" value="true"/>
67 <attribute name="Trusted-Library" value="true"/>
68 </manifest>
69 </jar>
70
71 <!-- sign 'em -->
72 <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
73 <signjar jar="${lwjgl.temp}/jnlp/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
74 <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
75
76 <signjar jar="${lwjgl.temp}/jnlp/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
77 <signjar jar="${lwjgl.temp}/jnlp/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
78 <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
79 <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
80
81 <signjar jar="${lwjgl.temp}/jnlp/lwjgl_test.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
82
83 </target>
84 </project>
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, linux" basedir="../../bin/lwjgl" default="compile">
3 <property name="native" location="../../src/native"/>
4 <property name="libname32" value="liblwjgl.so"/>
5 <property name="libname64" value="liblwjgl64.so"/>
6 <property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lpthread -L${java.home}/lib/i386 -ljawt" />
7 <property name="libs64" value="-L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" />
8 <property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
9
10 <target name="clean">
11 <delete>
12 <fileset dir="x32"/>
13 <fileset dir="x64"/>
14 <fileset dir="." includes="*.o"/>
15 <fileset dir="." includes="*.so"/>
16 </delete>
17 </target>
18
19 <target name="compile">
20 <exec executable="uname" outputproperty="hwplatform">
21 <arg value="-m"/>
22 </exec>
23 <condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
24 <os name="SunOS" />
25 </condition>
26 <condition property="cflags_pthread" value="-pthreads" else="-pthread">
27 <os name="SunOS" />
28 </condition>
29 <condition property="version_script_flags32" value="" else="-Wl,--version-script=${native}/linux/lwjgl.map">
30 <os name="SunOS" />
31 </condition>
32 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script=${native}/linux/lwjgl.map">
33 <and>
34 <os name="SunOS" />
35 </and>
36 </condition>
37 <condition property="cflags64" value="-O2 -m64 -Wall -c -fPIC -std=c99 -Wunused" else="-O2 -Wall -c -fPIC -std=c99 -Wunused">
38 <os name="SunOS" />
39 </condition>
40
41 <property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
42 <property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
43
44 <condition property="build.32bit.only">
45 <not>
46 <or>
47 <equals arg1="${hwplatform}" arg2="x86_64"/>
48 <equals arg1="${hwplatform}" arg2="i86pc"/>
49 </or>
50 </not>
51 </condition>
52
53 <!-- On linux, the 64 bit jre doesn't have the 32 bit libs -->
54 <condition property="build.64bit.only">
55 <and>
56 <os name="Linux"/>
57 <equals arg1="${hwplatform}" arg2="x86_64"/>
58 </and>
59 </condition>
60
61 <antcall target="compile32"/>
62 <antcall target="compile64"/>
63 </target>
64
65 <target name="compile32" unless="build.64bit.only">
66 <mkdir dir="x32"/>
67 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
68 <arg line="${cflags32} ${cflags_pthread}"/>
69 <arg value="-I${java.home}/include"/>
70 <arg value="-I${java.home}/include/linux"/>
71 <arg value="-I${java.home}/../include"/>
72 <arg value="-I${java.home}/../include/linux"/>
73 <arg value="-I${java.home}/../include/solaris"/>
74 <arg value="-I${native}/common"/>
75 <arg value="-I${native}/linux"/>
76 <mapper type="glob" from="*.c" to="*.o"/>
77 <fileset dir="${native}/linux" includes="*.c"/>
78 <fileset dir="${native}/generated" includes="*.c"/>
79 <fileset dir="${native}/common" includes="*.c"/>
80 </apply>
81 <apply dir="." parallel="true" executable="gcc" failonerror="true">
82 <srcfile/>
83 <arg line="${linker_flags32}"/>
84 <fileset dir="x32" includes="*.o"/>
85 </apply>
86 <apply dir="." parallel="true" executable="strip" failonerror="true">
87 <fileset file="${libname32}"/>
88 </apply>
89 </target>
90
91 <target name="compile64" unless="build.32bit.only">
92 <mkdir dir="x64"/>
93 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
94 <arg line="${cflags64} ${cflags_pthread}"/>
95 <arg value="-I${java.home}/include"/>
96 <arg value="-I${java.home}/include/linux"/>
97 <arg value="-I${java.home}/../include"/>
98 <arg value="-I${java.home}/../include/linux"/>
99 <arg value="-I${java.home}/../include/solaris"/>
100 <arg value="-I${native}/common"/>
101 <arg value="-I${native}/linux"/>
102 <mapper type="glob" from="*.c" to="*.o"/>
103 <fileset dir="${native}/linux" includes="*.c"/>
104 <fileset dir="${native}/generated" includes="*.c"/>
105 <fileset dir="${native}/common" includes="*.c"/>
106 </apply>
107 <apply dir="." parallel="true" executable="gcc" failonerror="true">
108 <srcfile/>
109 <arg line="${linker_flags64}"/>
110 <fileset dir="x64" includes="*.o"/>
111 </apply>
112 <apply dir="." parallel="true" executable="strip" failonerror="true">
113 <fileset file="${libname64}"/>
114 </apply>
115 </target>
116 </project>
0 #!/bin/sh
1
2 nm -g "$1"/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1-
3 nm -g "$1"/*.o | grep "JNI_" | cut -d ' ' -f3 | cut -c 1-
0
1 <project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
2 <property name="native" location="../../src/native"/>
3
4 <target name="init">
5 <mkdir dir="ppc"/>
6 <mkdir dir="i386"/>
7 <mkdir dir="x86_64"/>
8 </target>
9
10 <target name="clean">
11 <delete failonerror="false">
12 <fileset dir="i386"/>
13 <fileset dir="x86_64"/>
14 <fileset dir="ppc"/>
15 <fileset dir="." includes="liblwjgl.jnilib"/>
16 <fileset dir="." includes="lwjgl.symbols"/>
17 </delete>
18 </target>
19
20 <target name="compile">
21 <apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
22 <arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I${native}/common -I${native}/macosx"/>
23 <!-- Map from *.m and *.c to .o -->
24 <mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
25 <fileset dir="${native}/macosx" includes="*.m"/>
26 <fileset dir="${native}/macosx" includes="*.c"/>
27 <fileset dir="${native}/common" includes="*.c"/>
28 <fileset dir="${native}/generated" includes="*.c"/>
29 </apply>
30 </target>
31
32 <target name="link">
33 <apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
34 <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/>
35 <fileset dir="${objdir}" includes="*.o"/>
36 </apply>
37 <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
38 <arg line="-S -X"/>
39 <fileset dir="." file="${libname}"/>
40 </apply>
41 </target>
42
43 <target name="nativelibrary" depends="init">
44 <property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
45 <property name="ppc_sdkroot" location="/Developer/SDKs/MacOSX10.3.9.sdk"/>
46 <property name="x86_64_sdkroot" location="/Developer/SDKs/MacOSX10.5.sdk"/>
47 <property name="universal_flags" value="-isysroot ${universal_sdkroot}"/>
48 <property name="ppc_flags" value="-isysroot ${ppc_sdkroot}"/>
49 <antcall target="compile">
50 <param name="dstdir" location="ppc"/>
51 <param name="compiler" value="gcc-4.0"/>
52 <param name="sdkroot" location="${ppc_sdkroot}"/>
53 <param name="cflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
54 </antcall>
55 <antcall target="compile">
56 <param name="dstdir" location="i386"/>
57 <param name="compiler" value="gcc-4.0"/>
58 <param name="sdkroot" location="${universal_sdkroot}"/>
59 <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
60 </antcall>
61 <antcall target="compile">
62 <param name="dstdir" location="x86_64"/>
63 <param name="compiler" value="gcc-4.0"/>
64 <param name="sdkroot" location="${universal_sdkroot}"/>
65 <param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
66 </antcall>
67 <exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
68 <arg path="../../platform_build/macosx_ant/build-symbol-list"/>
69 <arg path="i386"/>
70 </exec>
71 <antcall target="link">
72 <param name="objdir" location="ppc"/>
73 <param name="libname" value="liblwjgl-ppc.jnilib"/>
74 <param name="linker" value="gcc-4.0"/>
75 <param name="linkerflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
76 </antcall>
77 <antcall target="link">
78 <param name="objdir" location="i386"/>
79 <param name="libname" value="liblwjgl-i386.jnilib"/>
80 <param name="linker" value="gcc-4.0"/>
81 <param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
82 </antcall>
83 <antcall target="link">
84 <param name="objdir" location="x86_64"/>
85 <param name="libname" value="liblwjgl-i86_64.jnilib"/>
86 <param name="linker" value="gcc-4.0"/>
87 <param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
88 </antcall>
89 <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
90 <arg value="-create"/>
91 <srcfile/>
92 <arg value="-output"/>
93 <arg path="liblwjgl.jnilib"/>
94 <fileset file="ppc/liblwjgl-ppc.jnilib"/>
95 <fileset file="i386/liblwjgl-i386.jnilib"/>
96 <fileset file="x86_64/liblwjgl-i86_64.jnilib"/>
97 </apply>
98 </target>
99 </project>
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, native code" basedir="../../bin/lwjgl" default="compile">
3 <property name="native" location="../../src/native"/>
4 <property environment="env"/>
5 <property name="mingwprefix" location="x86_64-pc-mingw32-"/>
6 <property name="mingwhome" location="c:/MinGW64"/>
7 <property name="strip" location="${mingwhome}/${mingwprefix}strip"/>
8 <property name="gcc" location="${mingwhome}/${mingwprefix}gcc"/>
9 <property name="dlltool" location="${mingwhome}/${mingwprefix}dlltool"/>
10 <property name="dllname" value="lwjgl64.dll"/>
11
12 <target name="compile_dir">
13 <apply dir="." failonerror="true" executable="${gcc}" dest="." skipemptyfilesets="true">
14 <arg line="-c -Wall -O2 -std=gnu99 -D_JNI_IMPLEMENTATION_"/>
15 <arg value="-I${dxhome}/include"/>
16 <arg value="-I${alhome}/include"/>
17 <arg value="-I${jdkhome}/include"/>
18 <arg value="-I${jdkhome}/include/win32"/>
19 <arg value="-I${native}/common"/>
20 <arg value="-I${native}/windows"/>
21 <srcfile/>
22 <fileset dir="${native}/windows" includes="*.c"/>
23 <fileset dir="${native}/common" includes="*.c"/>
24 <fileset dir="${native}/generated" includes="*.c"/>
25 <mapper type="glob" from="*.c" to="*.o"/>
26 </apply>
27 </target>
28
29 <target name="link">
30 <echo file="jawt.def">
31 EXPORTS
32 JAWT_GetAWT
33 </echo>
34 <exec dir="." executable="${dlltool}" failonerror="true">
35 <arg line="--def jawt.def --kill-at --dllname jawt.dll --output-lib libjawt.a"/>
36 </exec>
37 <apply dir="." parallel="true" executable="${gcc}" failonerror="true">
38 <arg value="-Wl,--kill-at"/>
39 <arg line="-shared -o ${dllname}"/>
40 <srcfile/>
41 <arg line="libjawt.a"/>
42 <arg value="-L${java.home}/../lib"/>
43 <arg value="-L${alhome}/libs"/>
44 <arg line="${libs}"/>
45 <fileset dir="." includes="*.o"/>
46 </apply>
47 </target>
48
49 <target name="clean">
50 <delete>
51 <fileset dir="." includes="*.o"/>
52 <fileset dir="." includes="*.dll"/>
53 </delete>
54 </target>
55
56 <target name="compile">
57 <property name="libs" value="-lkernel32 -lole32 -lopengl32 -lversion -luser32 -lgdi32 -ladvapi32 -lwinmm"/>
58 <antcall target="compile_dir"/>
59 <antcall target="link"/>
60 <apply dir="." executable="${strip}">
61 <fileset file="${dllname}"/>
62 </apply>
63 </target>
64 </project>
65
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, native code" basedir="../../bin/lwjgl" default="compile">
3 <property name="native" location="../../src/native"/>
4 <property environment="env"/>
5 <property name="sdkhome" location="${env.MSSDK}"/>
6
7 <target name="compile_dir">
8 <apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
9 <arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
10 <arg value="/I${sdkhome}\include"/>
11 <arg value="/I${java.home}\..\include"/>
12 <arg value="/I${java.home}\..\include\win32"/>
13 <arg value="/I${native}\common"/>
14 <arg value="/I${native}\windows"/>
15 <srcfile/>
16 <fileset dir="${native}/windows" includes="*.c"/>
17 <fileset dir="${native}/common" includes="*.c"/>
18 <fileset dir="${native}/generated" includes="*.c"/>
19 <mapper type="glob" from="*.c" to="*.obj"/>
20 </apply>
21 </target>
22
23 <target name="link">
24 <apply dir="." parallel="true" executable="cl" failonerror="true">
25 <arg line="/LD /nologo"/>
26 <srcfile/>
27 <arg line="/Fe${dllname} /link"/>
28 <arg value="/LIBPATH:${java.home}\..\lib"/>
29 <arg value="/LIBPATH:${sdkhomelib}"/>
30 <arg value="/OPT:REF"/>
31 <arg value="/OPT:ICF"/>
32 <arg line="/DLL /DELAYLOAD:jawt.dll ${libs}"/>
33 <fileset dir="." includes="*.obj"/>
34 </apply>
35 </target>
36
37 <target name="clean">
38 <delete>
39 <fileset dir="." includes="*.obj"/>
40 <fileset dir="." includes="*.dll"/>
41 <fileset dir="." includes="*.exp"/>
42 <fileset dir="." includes="*.lib"/>
43 </delete>
44 </target>
45
46 <target name="compile">
47 <condition property="sdkhomelib" value="${sdkhome}\lib" else="${sdkhome}\lib\x64">
48 <equals arg1="${os.arch}" arg2="x86"/>
49 </condition>
50 <condition property="dllname" value="lwjgl.dll" else="lwjgl64.dll">
51 <equals arg1="${os.arch}" arg2="x86"/>
52 </condition>
53 <echo message="${sdkhomelib}"/>
54 <property name="libs" value="Kernel32.lib ole32.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib Comctl32.lib"/>
55 <antcall target="compile_dir"/>
56 <antcall target="link"/>
57 </target>
58 </project>
59
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl;
32
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;
40
41 /**
42 * <p>A class to check buffer boundaries in general. If there is unsufficient space
43 * in the buffer when the call is made then a buffer overflow would otherwise
44 * occur and cause unexpected behaviour, a crash, or worse, a security risk.
45 *
46 * Internal class, don't use.
47 * </p>
48 * @author cix_foo <cix_foo@users.sourceforge.net>
49 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision: 3279 $
51 * $Id: BufferChecks.java 3279 2010-03-11 21:06:49Z spasi $
52 */
53 public class BufferChecks {
54 /** Static methods only! */
55 private BufferChecks() {
56 }
57
58 /**
59 * Helper methods to ensure a function pointer is not-null (0)
60 */
61 public static void checkFunctionAddress(long pointer) {
62 if (pointer == 0) {
63 throw new IllegalStateException("Function is not supported");
64 }
65 }
66
67 /**
68 * Helper methods to ensure a ByteBuffer is null-terminated
69 */
70 public static void checkNullTerminated(ByteBuffer buf) {
71 if (buf.get(buf.limit() - 1) != 0) {
72 throw new IllegalArgumentException("Missing null termination");
73 }
74 }
75
76 public static void checkNullTerminated(ByteBuffer buf, int count) {
77 int nullFound = 0;
78 for ( int i = buf.position(); i < buf.limit(); i++ ) {
79 if ( buf.get(i) == 0 )
80 nullFound++;
81 }
82
83 if ( nullFound < count )
84 throw new IllegalArgumentException("Missing null termination");
85 }
86
87 /** Helper methods to ensure an IntBuffer is null-terminated */
88 public static void checkNullTerminated(IntBuffer buf) {
89 if ( buf.get(buf.limit() - 1) != 0 ) {
90 throw new IllegalArgumentException("Missing null termination");
91 }
92 }
93
94 public static void checkNotNull(Object o) {
95 if (o == null)
96 throw new IllegalArgumentException("Null argument");
97 }
98
99 /**
100 * Helper methods to ensure a buffer is direct (and, implicitly, non-null).
101 */
102 public static void checkDirect(ByteBuffer buf) {
103 if (!buf.isDirect()) {
104 throw new IllegalArgumentException("ByteBuffer is not direct");
105 }
106 }
107
108 public static void checkDirect(ShortBuffer buf) {
109 if (!buf.isDirect()) {
110 throw new IllegalArgumentException("ShortBuffer is not direct");
111 }
112 }
113
114 public static void checkDirect(IntBuffer buf) {
115 if (!buf.isDirect()) {
116 throw new IllegalArgumentException("IntBuffer is not direct");
117 }
118 }
119
120 public static void checkDirect(LongBuffer buf) {
121 if (!buf.isDirect()) {
122 throw new IllegalArgumentException("LongBuffer is not direct");
123 }
124 }
125
126 public static void checkDirect(FloatBuffer buf) {
127 if (!buf.isDirect()) {
128 throw new IllegalArgumentException("FloatBuffer is not direct");
129 }
130 }
131
132 public static void checkDirect(DoubleBuffer buf) {
133 if (!buf.isDirect()) {
134 throw new IllegalArgumentException("DoubleBuffer is not direct");
135 }
136 }
137
138 /**
139 * This is a separate call to help inline checkBufferSize.
140 */
141 private static void throwBufferSizeException(Buffer buf, int size) {
142 throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size);
143 }
144
145 /**
146 * Helper method to ensure a buffer is big enough to receive data from a
147 * glGet* operation.
148 *
149 * @param buf
150 * The buffer to check
151 * @param size
152 * The minimum buffer size
153 * @throws IllegalArgumentException
154 */
155 public static void checkBufferSize(Buffer buf, int size) {
156 if (buf.remaining() < size) {
157 throwBufferSizeException(buf, size);
158 }
159 }
160
161 public static void checkBuffer(ByteBuffer buf, int size) {
162 checkBufferSize(buf, size);
163 checkDirect(buf);
164 }
165
166 public static void checkBuffer(ShortBuffer buf, int size) {
167 checkBufferSize(buf, size);
168 checkDirect(buf);
169 }
170
171 public static void checkBuffer(IntBuffer buf, int size) {
172 checkBufferSize(buf, size);
173 checkDirect(buf);
174 }
175
176 public static void checkBuffer(LongBuffer buf, int size) {
177 checkBufferSize(buf, size);
178 checkDirect(buf);
179 }
180
181 public static void checkBuffer(FloatBuffer buf, int size) {
182 checkBufferSize(buf, size);
183 checkDirect(buf);
184 }
185
186 public static void checkBuffer(DoubleBuffer buf, int size) {
187 checkBufferSize(buf, size);
188 checkDirect(buf);
189 }
190 }
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 import java.nio.Buffer;
34 import java.nio.ByteBuffer;
35 import java.nio.ByteOrder;
36 import java.nio.CharBuffer;
37 import java.nio.DoubleBuffer;
38 import java.nio.FloatBuffer;
39 import java.nio.IntBuffer;
40 import java.nio.LongBuffer;
41 import java.nio.ShortBuffer;
42
43 /**
44 * Some often-used Buffer code for creating native buffers of the appropriate size.
45 *
46 * @author $Author: matzon $
47 * @version $Revision: 2983 $
48 * $Id: BufferUtils.java 2983 2008-04-07 18:36:09Z matzon $
49 */
50
51 public final class BufferUtils {
52
53 /**
54 * Construct a direct native-ordered bytebuffer with the specified size.
55 * @param size The size, in bytes
56 * @return a ByteBuffer
57 */
58 public static ByteBuffer createByteBuffer(int size) {
59 return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
60 }
61
62 /**
63 * Construct a direct native-order shortbuffer with the specified number
64 * of elements.
65 * @param size The size, in shorts
66 * @return a ShortBuffer
67 */
68 public static ShortBuffer createShortBuffer(int size) {
69 return createByteBuffer(size << 1).asShortBuffer();
70 }
71
72 /**
73 * Construct a direct native-order charbuffer with the specified number
74 * of elements.
75 * @param size The size, in chars
76 * @return an CharBuffer
77 */
78 public static CharBuffer createCharBuffer(int size) {
79 return createByteBuffer(size << 1).asCharBuffer();
80 }
81
82 /**
83 * Construct a direct native-order intbuffer with the specified number
84 * of elements.
85 * @param size The size, in ints
86 * @return an IntBuffer
87 */
88 public static IntBuffer createIntBuffer(int size) {
89 return createByteBuffer(size << 2).asIntBuffer();
90 }
91
92 /**
93 * Construct a direct native-order longbuffer with the specified number
94 * of elements.
95 * @param size The size, in longs
96 * @return an LongBuffer
97 */
98 public static LongBuffer createLongBuffer(int size) {
99 return createByteBuffer(size << 3).asLongBuffer();
100 }
101
102 /**
103 * Construct a direct native-order floatbuffer with the specified number
104 * of elements.
105 * @param size The size, in floats
106 * @return a FloatBuffer
107 */
108 public static FloatBuffer createFloatBuffer(int size) {
109 return createByteBuffer(size << 2).asFloatBuffer();
110 }
111
112 /**
113 * Construct a direct native-order doublebuffer with the specified number
114 * of elements.
115 * @param size The size, in floats
116 * @return a FloatBuffer
117 */
118 public static DoubleBuffer createDoubleBuffer(int size) {
119 return createByteBuffer(size << 3).asDoubleBuffer();
120 }
121
122 /**
123 * @return n, where buffer_element_size=2^n.
124 */
125 public static int getElementSizeExponent(Buffer buf) {
126 if (buf instanceof ByteBuffer)
127 return 0;
128 else if (buf instanceof ShortBuffer || buf instanceof CharBuffer)
129 return 1;
130 else if (buf instanceof FloatBuffer || buf instanceof IntBuffer)
131 return 2;
132 else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer)
133 return 3;
134 else
135 throw new IllegalStateException("Unsupported buffer type: " + buf);
136 }
137
138 /**
139 * A helper function which is used to get the byte offset in an arbitrary buffer
140 * based on its position
141 * @return the position of the buffer, in BYTES
142 */
143 public static int getOffset(Buffer buffer) {
144 return buffer.position() << getElementSizeExponent(buffer);
145 }
146
147 }
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 /**
35 *
36 * @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 $
39 */
40 abstract class DefaultSysImplementation implements SysImplementation {
41 public native int getJNIVersion();
42 public native void setDebug(boolean debug);
43
44 public long getTimerResolution() {
45 return 1000;
46 }
47
48 public boolean has64Bit() {
49 return false;
50 }
51
52 public abstract long getTime();
53 public abstract void alert(String title, String message);
54 public abstract String getClipboard();
55 }
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 import javax.swing.JOptionPane;
34 import javax.swing.UIManager;
35
36 /**
37 * A SysImplementation which delegates as much as it can to J2SE.
38 * <p>
39 * @author $Author: matzon $
40 * @version $Revision: 2983 $
41 * $Id: J2SESysImplementation.java 2983 2008-04-07 18:36:09Z matzon $
42 */
43 abstract class J2SESysImplementation extends DefaultSysImplementation {
44
45 public long getTime() {
46 return System.currentTimeMillis();
47 }
48
49 public void alert(String title, String message) {
50 try {
51 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
52 } catch(Exception e) {
53 LWJGLUtil.log("Caught exception while setting LAF: " + e);
54 }
55 JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
56 }
57
58 public String getClipboard() {
59 try {
60 java.awt.datatransfer.Clipboard clipboard = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
61 java.awt.datatransfer.Transferable transferable = clipboard.getContents(null);
62 if (transferable.isDataFlavorSupported(java.awt.datatransfer.DataFlavor.stringFlavor)) {
63 return (String)transferable.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor);
64 }
65 } catch (Exception e) {
66 LWJGLUtil.log("Exception while getting clipboard: " + e);
67 }
68 return null;
69 }
70
71
72 }
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 * <p>
35 * This exception is supplied to make exception handling more generic for LWJGL
36 * specific exceptions
37 * </p>
38 *
39 * @author Brian Matzon <brian@matzon.dk>
40 * @version $Revision: 2983 $
41 * $Id: LWJGLException.java 2983 2008-04-07 18:36:09Z matzon $
42 */
43 public class LWJGLException extends Exception {
44
45 private static final long serialVersionUID = 1L;
46
47 /**
48 * Plain c'tor
49 */
50 public LWJGLException() {
51 super();
52 }
53
54 /**
55 * Creates a new LWJGLException
56 *
57 * @param msg
58 * String identifier for exception
59 */
60 public LWJGLException(String msg) {
61 super(msg);
62 }
63
64 /**
65 * @param message
66 * @param cause
67 */
68 public LWJGLException(String message, Throwable cause) {
69 super(message, cause);
70 }
71
72 /**
73 * @param cause
74 */
75 public LWJGLException(Throwable cause) {
76 super(cause);
77 }
78 }
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 import java.io.File;
34 import java.lang.reflect.Method;
35 import java.nio.ByteBuffer;
36 import java.security.AccessController;
37 import java.security.PrivilegedAction;
38 import java.security.PrivilegedActionException;
39 import java.security.PrivilegedExceptionAction;
40 import java.util.ArrayList;
41 import java.util.List;
42 import java.util.StringTokenizer;
43
44
45 /**
46 * <p>
47 * Internal library methods
48 * </p>
49 *
50 * @author Brian Matzon <brian@matzon.dk>
51 * @version $Revision: 2983 $
52 * $Id: LWJGLUtil.java 2983 2008-04-07 18:36:09Z matzon $
53 */
54 public class LWJGLUtil {
55 public static final int PLATFORM_LINUX = 1;
56 public static final int PLATFORM_MACOSX = 2;
57 public static final int PLATFORM_WINDOWS = 3;
58 public static final String PLATFORM_LINUX_NAME = "linux";
59 public static final String PLATFORM_MACOSX_NAME = "macosx";
60 public static final String PLATFORM_WINDOWS_NAME = "windows";
61
62 /** LWJGL Logo - 16 by 16 pixels */
63 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
64 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
65 -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,
66 -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
67 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -11, -11, -11, -1,
68 -115, -113, -111, -1, 118, -126, -115, -1, 125, -115, -101, -1, -124, -103, -86, -1, -108, -73, -43, -1,
69 58, 125, -75, -1, 72, -122, -70, -1, -38, -25, -15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
70 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, -8, -5, -1, -100, -98, -96, -1, 0, 0, 0, -1, 0, 0, 0, -1,
71 0, 0, 0, -1, 0, 0, 0, -1, -28, -28, -28, -1, -124, -83, -48, -1, 58, 125, -75, -1, 91, -110, -63, -1, -4,
72 -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -111, -74, -43,
73 -1, 95, 95, 95, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 34, 34, 34, -1, -1, -1, -1, -1, -24, -16, -10,
74 -1, 57, 124, -75, -1, 58, 125, -75, -1, -60, -40, -23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
75 -1, -1, -1, -1, -58, -39, -23, -1, -127, -85, -50, -1, 29, 29, 29, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
76 -1, 102, 102, 102, -1, -1, -1, -1, -1, -48, -32, -19, -1, 58, 125, -75, -1, 58, 125, -75, -1, -115, -76,
77 -44, -1, -1, -1, -1, -1, -14, -14, -14, -1, -91, -91, -91, -1, -33, -33, -33, -1, -94, -63, -36, -1, -80,
78 -59, -42, -1, 10, 10, 10, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -88, -88, -88, -1, -1, -1, -1, -1,
79 -105, -70, -40, -1, 58, 125, -75, -1, 58, 125, -75, -1, 113, -95, -54, -1, -1, -1, -1, -1, -95, -95, -95,
80 -1, 0, 0, 0, -1, 1, 1, 1, -1, 35, 35, 35, -1, -52, -52, -52, -1, -48, -48, -48, -1, -91, -91, -91, -1,
81 -124, -124, -124, -1, 92, 92, 92, -1, -17, -17, -17, -1, -1, -1, -1, -1, 96, -106, -61, -1, 58, 125, -75,
82 -1, 58, 125, -75, -1, 109, -98, -56, -1, -1, -1, -1, -1, 94, 94, 94, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
83 -1, -49, -49, -49, -1, 31, 31, 31, -1, 3, 3, 3, -1, 43, 43, 43, -1, 108, 108, 108, -1, -58, -58, -58, -1,
84 -6, -4, -3, -1, -98, -65, -38, -1, 119, -91, -52, -1, 76, -119, -68, -1, 124, -88, -50, -1, -1, -1, -1, -1,
85 27, 27, 27, -1, 0, 0, 0, -1, 0, 0, 0, -1, 23, 23, 23, -1, -42, -42, -42, -1, 1, 1, 1, -1, 0, 0, 0, -1, 0,
86 0, 0, -1, 0, 0, 0, -1, 82, 82, 82, -1, -27, -27, -27, -1, 61, 61, 61, -1, 104, 104, 104, -1, -90, -90, -89,
87 -1, -38, -34, -31, -1, -1, -1, -1, -1, 116, 116, 116, -1, 14, 14, 14, -1, 0, 0, 0, -1, 89, 89, 89, -1,
88 -107, -107, -107, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -111, -111, -111, -1, -101, -101,
89 -101, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, 67, 67, 67, -1, -1, -1, -1, -1, -18, -18,
90 -18, -1, -116, -116, -116, -1, -65, -65, -65, -1, 86, 86, 86, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0,
91 0, 0, -1, -45, -45, -45, -1, 88, 88, 88, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 51, 51,
92 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -3, -2, -1, -1, -1, -1, -1, -64, -64, -64, -1, 64, 64, 64, -1,
93 2, 2, 2, -1, 0, 0, 0, -1, 27, 27, 27, -1, -5, -5, -5, -1, 23, 23, 23, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
94 0, -1, 0, 0, 0, -1, 120, 120, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -46, -31, -18, -1, 126, -87, -50,
95 -1, -32, -22, -13, -1, -1, -1, -1, -1, -44, -44, -44, -1, 109, 109, 109, -1, -124, -124, -124, -1, -45,
96 -45, -45, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -67, -67, -67, -1, -1, -1,
97 -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, 102, -102, -59, -1, 61, 127, -74, -1, -126, -84, -48, -1, -28, -19,
98 -11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -27, -27, -27, -1, 45, 45, 45, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
99 0, -1, 12, 12, 12, -1, -10, -10, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -30, -20, -12,
100 -1, 77, -119, -68, -1, 58, 125, -75, -1, 62, -128, -74, -1, -121, -80, -46, -1, -25, -17, -10, -1, -1, -1,
101 -1, -1, -2, -2, -2, -1, -68, -68, -68, -1, 79, 79, 79, -1, 3, 3, 3, -1, 74, 74, 74, -1, -1, -1, -1, -1, -1,
102 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -21, -14, -8, -1, -116, -77, -44, -1, 86, -112,
103 -64, -1, 80, -116, -67, -1, 119, -91, -52, -1, -19, -13, -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
104 -1, -1, -33, -33, -33, -1, -26, -26, -26, -1, -1, -1, -1, -1
105 });
106
107 /** LWJGL Logo - 32 by 32 pixels */
108 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
109 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
110 -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,
111 -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,
112 -20, -1, -109, -73, -42, -1, 111, -96, -55, -1, 92, -109, -62, -1, 96, -106, -61, -1, 122, -89, -51, -1,
113 -84, -56, -32, -1, -19, -13, -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
114 -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,
115 -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,
116 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -3, -2, -1, -75, -50, -29, -1, 90, -110, -63, -1,
117 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
118 58, 125, -75, -1, 69, -123, -71, -1, -95, -63, -36, -1, -4, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
119 -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,
120 -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,
121 -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -4, -4, -1, -30, -22, -15, -1, -72, -49, -29, -1, -82, -55, -32,
122 -1, -93, -62, -36, -1, -104, -70, -40, -1, -116, -77, -45, -1, -127, -84, -49, -1, 110, -97, -56, -1, 61,
123 127, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 114, -94, -54, -1, -11, -8, -5, -1, -1,
124 -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,
125 -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,
126 -1, -1, -1, -1, -1, -1, -1, -1, -1, -40, -40, -40, -1, 49, 49, 49, -1, 36, 36, 36, -1, 49, 49, 49, -1, 64,
127 64, 64, -1, 82, 82, 82, -1, 101, 101, 101, -1, 116, 116, 116, -1, -113, -113, -113, -1, -9, -8, -8, -1,
128 -84, -56, -33, -1, 59, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 121, -89, -51,
129 -1, -4, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
130 -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,
131 -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, 104, 104, 104, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
132 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -74, -74, -74, -1, -2, -2, -2, -1, -122, -82,
133 -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -82, -54, -31, -1, -1, -1,
134 -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,
135 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -45, -30, -18,
136 -1, -31, -22, -14, -1, 40, 40, 40, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0,
137 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, -34, -34, -34, -1, -1, -1, -1, -1, -11, -8, -5, -1, 91, -110, -63, -1,
138 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70, -1, -12, -8, -5, -1, -1, -1, -1, -1,
139 -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,
140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -20, -13, -8, -1, 100, -103, -59, -1, -41, -39, -37,
141 -1, 5, 5, 5, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1,
142 36, 36, 36, -1, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -64, -43, -25, -1, 57, 124, -75, -1, 58,
143 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -85, -56, -32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
144 -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,
145 -1, -1, -1, -1, -2, -1, -1, -1, 120, -90, -52, -1, 123, -89, -51, -1, -98, -98, -98, -1, 0, 0, 0, -1, 0, 0,
146 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 101, 101, 101, -1, -1,
147 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -30, -20, -12, -1, 55, 123, -76, -1, 58, 125, -75, -1, 58, 125,
148 -75, -1, 58, 125, -75, -1, 102, -102, -59, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
149 -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, -61,
150 -41, -24, -1, 57, 125, -75, -1, -78, -52, -31, -1, 88, 88, 88, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1,
151 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -87, -87, -87, -1, -1, -1, -1, -1, -1, -1,
152 -1, -1, -1, -1, -1, -1, -68, -46, -27, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125,
153 -75, -1, 64, -127, -73, -1, -18, -12, -7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
154 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, 90, -110, -63, -1, 61,
155 127, -74, -1, -35, -27, -19, -1, 28, 28, 28, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
156 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 7, 7, 7, -1, -25, -25, -25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
157 -1, -1, -123, -82, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57,
158 125, -75, -1, -52, -34, -20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2,
159 -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -70, -46, -27, -1, 58, 125, -75, -1, 87, -112, -65,
160 -1, -48, -47, -47, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
161 0, -1, 0, 0, 0, -1, 51, 51, 51, -1, -3, -3, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, -4, -3, -1, 80,
162 -117, -67, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57, 125, -75, -1,
163 -79, -52, -30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, -54, -54, -1, 55, 55, 55, -1, 97,
164 97, 97, -1, -94, -94, -94, -1, -35, -35, -35, -1, -28, -20, -13, -1, -79, -53, -31, -1, -76, -51, -30, -1,
165 -26, -26, -26, -1, 35, 35, 35, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
166 0, -1, 0, 0, 0, -1, 114, 114, 114, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -40, -27, -16, -1,
167 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
168 -96, -64, -37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, 102, 102, -1, 0, 0, 0, -1, 0, 0, 0,
169 -1, 0, 0, 0, -1, 6, 6, 6, -1, 39, 39, 39, -1, 102, 102, 102, -1, -44, -44, -44, -1, -1, -1, -1, -1, -10,
170 -10, -10, -1, -48, -48, -48, -1, -105, -105, -105, -1, 94, 94, 94, -1, 39, 39, 39, -1, 4, 4, 4, -1, 0, 0,
171 0, -1, 3, 3, 3, -1, -64, -64, -64, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -94, -63, -37, -1,
172 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
173 -98, -65, -38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, -5, -5, -1, 37, 37, 37, -1, 0, 0, 0, -1, 0, 0, 0,
174 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 92, 92, 92, -1, -1, -1, -1, -1, -22, -22, -22, -1,
175 -113, -113, -113, -1, -75, -75, -75, -1, -23, -23, -23, -1, -3, -3, -3, -1, -25, -25, -25, -1, -78, -78,
176 -78, -1, -67, -67, -67, -1, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, -99, -57,
177 -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75,
178 -1, -95, -63, -36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -37, -37, -37, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0,
179 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -125, -125, -125, -1, -1, -1, -1, -1, 95, 95,
180 95, -1, 0, 0, 0, -1, 0, 0, 0, -1, 11, 11, 11, -1, 55, 55, 55, -1, 118, 118, 118, -1, -73, -73, -73, -1,
181 -16, -16, -16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -16, -11, -7, -1, 75, -120, -69, -1, 61,
182 127, -74, -1, 57, 124, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
183 -78, -52, -30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -102, -102, -102, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
184 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -59, -59, -59, -1, -9, -9, -9, -1, 29, 29, 29, -1,
185 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 7, 7, 7, -1, 60, 60, 60, -1,
186 -33, -33, -33, -1, -1, -1, -1, -1, -5, -4, -3, -1, -4, -3, -2, -1, -13, -9, -6, -1, -52, -35, -21, -1, -98,
187 -66, -38, -1, 114, -95, -55, -1, 76, -119, -69, -1, 58, 125, -75, -1, -55, -36, -21, -1, -1, -1, -1, -1,
188 -1, -1, -1, -1, 86, 86, 86, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
189 -1, 15, 15, 15, -1, -7, -7, -7, -1, -47, -47, -47, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1,
190 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -114, -114, -114, -1, -1, -1, -1, -1, -7,
191 -7, -7, -1, -124, -124, -124, -1, 112, 112, 112, -1, -80, -80, -80, -1, -22, -22, -22, -1, -1, -1, -1, -1,
192 -7, -5, -4, -1, -36, -24, -14, -1, -10, -7, -4, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 21, 21, -1, 0, 0,
193 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 78, 78, 78, -1, -1, -1, -1, -1,
194 -111, -111, -111, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
195 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -69, -69, -69, -1, -1, -1, -1, -1, -98, -98, -98, -1, 0, 0, 0, -1, 0, 0,
196 0, -1, 0, 0, 0, -1, 4, 4, 4, -1, 47, 47, 47, -1, 112, 112, 112, -1, -80, -80, -80, -1, -26, -26, -26, -1,
197 -2, -2, -2, -1, -1, -1, -1, -1, 57, 57, 57, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
198 0, -1, 0, 0, 0, -1, -112, -112, -112, -1, -1, -1, -1, -1, 77, 77, 77, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
199 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 16, 16, 16, -1, -16, -16, -16, -1,
200 -1, -1, -1, -1, 90, 90, 90, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
201 -1, 0, 0, 0, -1, 9, 9, 9, -1, 50, 50, 50, -1, -79, -79, -79, -1, -10, -10, -10, -1, -95, -95, -95, -1, 53,
202 53, 53, -1, 2, 2, 2, -1, 0, 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, -47, -47, -47, -1, -11, -11, -11, -1, 19,
203 19, 19, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0,
204 0, 0, -1, 69, 69, 69, -1, -2, -2, -2, -1, -8, -8, -8, -1, 29, 29, 29, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
205 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 43, 43, 43, -1, -1,
206 -1, -1, -1, -1, -1, -1, -1, -4, -4, -4, -1, -66, -66, -66, -1, 80, 80, 80, -1, 5, 5, 5, -1, 37, 37, 37, -1,
207 -7, -7, -7, -1, -62, -62, -62, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
208 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -122, -122, -122, -1, -1, -1, -1, -1, -46, -46, -46, -1, 1,
209 1, 1, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
210 0, -1, 0, 0, 0, -1, 67, 67, 67, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2,
211 -2, -1, -36, -36, -36, -1, -32, -32, -32, -1, -1, -1, -1, -1, -107, -107, -107, -1, 0, 0, 0, -1, 0, 0, 0,
212 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 1, 1, -1, -56, -56,
213 -56, -1, -1, -1, -1, -1, -114, -114, -114, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
214 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -120, -120, -120, -1, -1, -1, -1, -1,
215 -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,
216 -1, -33, -33, -33, -1, 41, 41, 41, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0,
217 0, 0, -1, 0, 0, 0, -1, 24, 24, 24, -1, -11, -11, -11, -1, -1, -1, -1, -1, 74, 74, 74, -1, 0, 0, 0, -1, 0,
218 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
219 0, -1, -49, -49, -49, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
220 -15, -10, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -7, -7, -7, -1, -75, -75, -75, -1, 75,
221 75, 75, -1, 6, 6, 6, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 82, 82, 82, -1, -1, -1, -1,
222 -1, -8, -8, -8, -1, 16, 16, 16, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
223 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 28, 28, 28, -1, -8, -8, -8, -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -122, -81, -47, -1, -112, -75, -43, -1, -22, -15, -9,
225 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -37, -37, -37, -1, 120, 120, 120, -1,
226 27, 27, 27, -1, 0, 0, 0, -1, 0, 0, 0, -1, -106, -106, -106, -1, -1, -1, -1, -1, -58, -58, -58, -1, 0, 0, 0,
227 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1,
228 0, 0, 0, -1, 90, 90, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
229 -1, -1, -1, -1, -1, -61, -40, -23, -1, 58, 125, -75, -1, 67, -125, -72, -1, -108, -72, -42, -1, -19, -13,
230 -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, -12, -12, -1, -89, -89, -89,
231 -1, -123, -123, -123, -1, -12, -12, -12, -1, -1, -1, -1, -1, -122, -122, -122, -1, 0, 0, 0, -1, 0, 0, 0,
232 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1,
233 -99, -99, -99, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
234 -1, -1, -6, -5, -3, -1, 93, -108, -62, -1, 58, 125, -75, -1, 58, 125, -75, -1, 70, -123, -71, -1, -104,
235 -69, -40, -1, -17, -12, -7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
236 -1, -1, -1, -1, -1, -1, -1, -1, -1, -101, -101, -101, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
237 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 5, 5, 5, -1, -35, -35, -35, -1, -1,
238 -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,
239 -59, -39, -23, -1, 59, 126, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70,
240 -1, -98, -66, -38, -1, -14, -10, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
241 -1, -1, -1, -1, -5, -5, -5, -1, -114, -114, -114, -1, 37, 37, 37, -1, 1, 1, 1, -1, 0, 0, 0, -1, 0, 0, 0,
242 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 44, 44, 44, -1, -4, -4, -4, -1, -1, -1, -1, -1, -1,
243 -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,
244 -113, -75, -43, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75,
245 -1, 74, -121, -69, -1, -93, -62, -36, -1, -13, -9, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
246 -1, -1, -1, -1, -1, -1, -1, -1, -6, -6, -6, -1, -80, -80, -80, -1, 69, 69, 69, -1, 4, 4, 4, -1, 0, 0, 0,
247 -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 110, 110, 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
248 -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, -4, -3,
249 -2, -1, -123, -81, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58,
250 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -88, -59, -34, -1, -10, -7, -4, -1, -1, -1, -1, -1, -1,
251 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, -46, -46, -46, -1, 104, 104,
252 104, -1, 14, 14, 14, -1, 0, 0, 0, -1, 1, 1, 1, -1, -72, -72, -72, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
253 -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,
254 -1, -1, -1, -1, -2, -2, -1, -1, -79, -53, -30, -1, 76, -119, -68, -1, 57, 125, -75, -1, 58, 125, -75, -1,
255 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -65, -44, -25,
256 -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,
257 -1, -1, -20, -20, -20, -1, -109, -109, -109, -1, -101, -101, -101, -1, -3, -3, -3, -1, -1, -1, -1, -1, -1,
258 -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,
259 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -13, -9, -6, -1, -75, -50, -29, -1, -127,
260 -84, -48, -1, 101, -103, -59, -1, 97, -105, -60, -1, 108, -98, -56, -1, -113, -75, -43, -1, -59, -39, -23,
261 -1, -9, -6, -4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
262 -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,
263 -1, -1, -1
264 });
265
266 /** Debug flag. */
267 public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug");
268
269 static {
270 LWJGLIcon16x16.flip();
271 LWJGLIcon32x32.flip();
272 }
273
274 /**
275 * @see #PLATFORM_WINDOWS
276 * @see #PLATFORM_LINUX
277 * @see #PLATFORM_MACOSX
278 * @return the current platform type
279 */
280 public static int getPlatform() {
281 String osName = getPrivilegedProperty("os.name");
282
283 if (osName.startsWith("Windows")) {
284 return PLATFORM_WINDOWS;
285 } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) {
286 return PLATFORM_LINUX;
287 } else if (osName.startsWith("Mac OS X")) {
288 return PLATFORM_MACOSX;
289 } else {
290 throw new LinkageError("Unknown platform: " + osName);
291 }
292 }
293
294
295 /**
296 * @see #PLATFORM_WINDOWS_NAME
297 * @see #PLATFORM_LINUX_NAME
298 * @see #PLATFORM_MACOSX_NAME
299 * @return current platform name
300 */
301 public static String getPlatformName() {
302 switch (LWJGLUtil.getPlatform()) {
303 case LWJGLUtil.PLATFORM_LINUX:
304 return PLATFORM_LINUX_NAME;
305 case LWJGLUtil.PLATFORM_MACOSX:
306 return PLATFORM_MACOSX_NAME;
307 case LWJGLUtil.PLATFORM_WINDOWS:
308 return PLATFORM_WINDOWS_NAME;
309 default:
310 return "unknown";
311 }
312 }
313
314 /**
315 * Locates the paths required by a library.
316 *
317 * @param libname Local Library Name to search the classloader with ("openal").
318 * @param platform_lib_name The native library name ("libopenal.so")
319 * @param classloader The classloader to ask for library paths
320 * @return Paths to located libraries, if any
321 */
322 public static String[] getLibraryPaths(String libname, String platform_lib_name, ClassLoader classloader) {
323 return getLibraryPaths(libname, new String[]{platform_lib_name}, classloader);
324 }
325
326 /**
327 * Locates the paths required by a library.
328 *
329 * @param libname Local Library Name to search the classloader with ("openal").
330 * @param platform_lib_names The list of possible library names ("libopenal.so")
331 * @param classloader The classloader to ask for library paths
332 * @return Paths to located libraries, if any
333 */
334 public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) {
335 // need to pass path of possible locations of library to native side
336 List possible_paths = new ArrayList();
337
338 String classloader_path = getPathFromClassLoader(libname, classloader);
339 if (classloader_path != null) {
340 log("getPathFromClassLoader: Path found: " + classloader_path);
341 possible_paths.add(classloader_path);
342 }
343
344 for (int i = 0; i < platform_lib_names.length; i++) {
345 String platform_lib_name = platform_lib_names[i];
346 String lwjgl_classloader_path = getPathFromClassLoader("lwjgl", classloader);
347 if (lwjgl_classloader_path != null) {
348 log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
349 possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
350 + File.separator + platform_lib_name);
351 }
352
353 // add Installer path
354 String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath");
355 if (alternative_path != null) {
356 possible_paths.add(alternative_path + File.separator + platform_lib_name);
357 }
358
359 // Add all possible paths from java.library.path
360 String java_library_path = getPrivilegedProperty("java.library.path");
361
362 StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator);
363 while (st.hasMoreTokens()) {
364 String path = st.nextToken();
365 possible_paths.add(path + File.separator + platform_lib_name);
366 }
367
368 //add current path
369 String current_dir = getPrivilegedProperty("user.dir");
370 possible_paths.add(current_dir + File.separator + platform_lib_name);
371
372 //add pure library (no path, let OS search)
373 possible_paths.add(platform_lib_name);
374 }
375
376 //create needed string array
377 String[] paths = new String[possible_paths.size()];
378 possible_paths.toArray(paths);
379 return paths;
380 }
381
382 static void execPrivileged(final String[] cmd_array) throws Exception {
383 try {
384 Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() {
385 public Object run() throws Exception {
386 return Runtime.getRuntime().exec(cmd_array);
387 }
388 });
389 // Close unused streams to make sure the child process won't hang
390 process.getInputStream().close();
391 process.getOutputStream().close();
392 process.getErrorStream().close();
393 } catch (PrivilegedActionException e) {
394 throw (Exception)e.getCause();
395 }
396 }
397
398 private static String getPrivilegedProperty(final String property_name) {
399 return (String)AccessController.doPrivileged(new PrivilegedAction() {
400 public Object run() {
401 return System.getProperty(property_name);
402 }
403 });
404 }
405
406 /**
407 * Tries to locate named library from the current ClassLoader
408 * This method exists because native libraries are loaded from native code, and as such
409 * is exempt from ClassLoader library loading rutines. It therefore always fails.
410 * We therefore invoke the protected method of the ClassLoader to see if it can
411 * locate it.
412 *
413 * @param libname Name of library to search for
414 * @param classloader Classloader to use
415 * @return Absolute path to library if found, otherwise null
416 */
417 private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
418 try {
419 log("getPathFromClassLoader: searching for: " + libname);
420 Class c = classloader.getClass();
421 while (c != null) {
422 final Class clazz = c;
423 try {
424 return (String)AccessController.doPrivileged(new PrivilegedExceptionAction() {
425 public Object run() throws Exception {
426 Method findLibrary = clazz.getDeclaredMethod("findLibrary", new Class[]{String.class});
427 findLibrary.setAccessible(true);
428 Object[] arguments = new Object[] {libname};
429 String path = (String)findLibrary.invoke(classloader, arguments);
430 return path;
431 }
432 });
433 } catch (PrivilegedActionException e) {
434 log("Failed to locate findLibrary method: " + e.getCause());
435 c = c.getSuperclass();
436 }
437 }
438 } catch (Exception e) {
439 log("Failure locating " + e + " using classloader:" + e);
440 }
441 return null;
442 }
443
444 /**
445 * Gets a boolean property as a privileged action.
446 */
447 private static boolean getPrivilegedBoolean(final String property_name) {
448 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
449 public Object run() {
450 return new Boolean(Boolean.getBoolean(property_name));
451 }
452 });
453 return value.booleanValue();
454 }
455
456 /**
457 * Prints the given message to System.err if DEBUG is true.
458 *
459 * @param msg Message to print
460 */
461 public static void log(String msg) {
462 if (DEBUG) {
463 System.err.println(msg);
464 }
465 }
466
467 /**
468 * Method to determine if the current system is running a version of
469 * Mac OS X better than the given version. This is only useful for Mac OS X
470 * specific code and will not work for any other platform.
471 */
472 public static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required) {
473 String os_version = getPrivilegedProperty("os.version");
474 StringTokenizer version_tokenizer = new StringTokenizer(os_version, ".");
475 int major;
476 int minor;
477 try {
478 String major_str = version_tokenizer.nextToken();
479 String minor_str = version_tokenizer.nextToken();
480 major = Integer.parseInt(major_str);
481 minor = Integer.parseInt(minor_str);
482 } catch (Exception e) {
483 LWJGLUtil.log("Exception occurred while trying to determine OS version: " + e);
484 // Best guess, no
485 return false;
486 }
487 return major > major_required || (major == major_required && minor >= minor_required);
488 }
489
490 }
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 /**
35 *
36 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3298 $
38 * $Id: LinuxSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
39 */
40 final class LinuxSysImplementation extends J2SESysImplementation {
41 private final static int JNI_VERSION = 18;
42
43 static {
44 java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
45 }
46
47 public int getRequiredJNIVersion() {
48 return JNI_VERSION;
49 }
50
51 public boolean openURL(final String url) {
52 // Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
53 // right anyway.
54
55 String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
56
57 for (int i = 0; i < browsers.length; i ++) {
58 final String browser = browsers[i];
59 try {
60 LWJGLUtil.execPrivileged(new String[] { browser, url });
61 return true;
62 } catch (Exception e) {
63 // Ignore
64 e.printStackTrace(System.err);
65 }
66 }
67
68 // Seems to have failed
69 return false;
70 }
71
72 public boolean has64Bit() {
73 return true;
74 }
75 }
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 import java.awt.Toolkit;
34
35 import com.apple.eio.FileManager;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3298 $
41 * $Id: MacOSXSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
42 */
43 final class MacOSXSysImplementation extends J2SESysImplementation {
44 private final static int JNI_VERSION = 18;
45
46 static {
47 // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
48 Toolkit.getDefaultToolkit();
49 }
50
51 public int getRequiredJNIVersion() {
52 return JNI_VERSION;
53 }
54
55 public boolean openURL(String url) {
56 try {
57 FileManager.openURL(url);
58 return true;
59 } catch (Exception e) {
60 LWJGLUtil.log("Exception occurred while trying to invoke browser: " + e);
61 return false;
62 }
63 }
64 }
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 import java.nio.ByteBuffer;
34 import java.nio.ShortBuffer;
35 import java.nio.IntBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.LongBuffer;
38 import java.nio.DoubleBuffer;
39 import java.nio.ByteOrder;
40
41 /**
42 * Utility class to cache thread local direct buffers so when we are passed a non-direct buffer,
43 * we can put its contents into a cached direct buffer and use that at the native side instead.
44 *
45 * Internal class, don't use.
46 * @author elias_naur <elias_naur@users.sourceforge.net>
47 * @version $Revision: 2762 $
48 * $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $
49 */
50 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() {
55 return new CachedBuffers(INITIAL_BUFFER_SIZE);
56 }
57 };
58
59 private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
60 CachedBuffers buffers = (CachedBuffers)thread_buffer.get();
61 int current_byte_size = buffers.byte_buffer.capacity();
62 if (minimum_byte_size > current_byte_size) {
63 buffers = new CachedBuffers(minimum_byte_size);
64 thread_buffer.set(buffers);
65 }
66 return buffers;
67 }
68
69 public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) {
70 BufferChecks.checkBufferSize(buf, size);
71 return wrapNoCopyDirect(buf);
72 }
73
74 public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) {
75 BufferChecks.checkBufferSize(buf, size);
76 return wrapNoCopyDirect(buf);
77 }
78
79 public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) {
80 BufferChecks.checkBufferSize(buf, size);
81 return wrapNoCopyDirect(buf);
82 }
83
84 public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) {
85 BufferChecks.checkBufferSize(buf, size);
86 return wrapNoCopyDirect(buf);
87 }
88
89 public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) {
90 BufferChecks.checkBufferSize(buf, size);
91 return wrapNoCopyDirect(buf);
92 }
93
94 public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) {
95 BufferChecks.checkBufferSize(buf, size);
96 return wrapNoCopyDirect(buf);
97 }
98
99 public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) {
100 BufferChecks.checkBufferSize(buf, size);
101 return wrapDirect(buf);
102 }
103
104 public static ShortBuffer wrapBuffer(ShortBuffer buf, int size) {
105 BufferChecks.checkBufferSize(buf, size);
106 return wrapDirect(buf);
107 }
108
109 public static IntBuffer wrapBuffer(IntBuffer buf, int size) {
110 BufferChecks.checkBufferSize(buf, size);
111 return wrapDirect(buf);
112 }
113
114 public static LongBuffer wrapBuffer(LongBuffer buf, int size) {
115 BufferChecks.checkBufferSize(buf, size);
116 return wrapDirect(buf);
117 }
118
119 public static FloatBuffer wrapBuffer(FloatBuffer buf, int size) {
120 BufferChecks.checkBufferSize(buf, size);
121 return wrapDirect(buf);
122 }
123
124 public static DoubleBuffer wrapBuffer(DoubleBuffer buf, int size) {
125 BufferChecks.checkBufferSize(buf, size);
126 return wrapDirect(buf);
127 }
128
129 public static ByteBuffer wrapDirect(ByteBuffer buffer) {
130 if (!buffer.isDirect())
131 return doWrap(buffer);
132 return buffer;
133 }
134
135 public static ShortBuffer wrapDirect(ShortBuffer buffer) {
136 if (!buffer.isDirect())
137 return doWrap(buffer);
138 return buffer;
139 }
140
141 public static FloatBuffer wrapDirect(FloatBuffer buffer) {
142 if (!buffer.isDirect())
143 return doWrap(buffer);
144 return buffer;
145 }
146
147 public static IntBuffer wrapDirect(IntBuffer buffer) {
148 if (!buffer.isDirect())
149 return doWrap(buffer);
150 return buffer;
151 }
152
153 public static LongBuffer wrapDirect(LongBuffer buffer) {
154 if (!buffer.isDirect())
155 return doWrap(buffer);
156 return buffer;
157 }
158
159 public static DoubleBuffer wrapDirect(DoubleBuffer buffer) {
160 if (!buffer.isDirect())
161 return doWrap(buffer);
162 return buffer;
163 }
164
165 public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) {
166 if (!buffer.isDirect())
167 return doNoCopyWrap(buffer);
168 return buffer;
169 }
170
171 public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) {
172 if (!buffer.isDirect())
173 return doNoCopyWrap(buffer);
174 return buffer;
175 }
176
177 public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) {
178 if (!buffer.isDirect())
179 return doNoCopyWrap(buffer);
180 return buffer;
181 }
182
183 public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) {
184 if (!buffer.isDirect())
185 return doNoCopyWrap(buffer);
186 return buffer;
187 }
188
189 public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) {
190 if (!buffer.isDirect())
191 return doNoCopyWrap(buffer);
192 return buffer;
193 }
194
195 public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) {
196 if (!buffer.isDirect())
197 return doNoCopyWrap(buffer);
198 return buffer;
199 }
200
201 public static void copy(ByteBuffer src, ByteBuffer dst) {
202 if (dst != null && !dst.isDirect()) {
203 int saved_position = dst.position();
204 dst.put(src);
205 dst.position(saved_position);
206 }
207 }
208
209 public static void copy(ShortBuffer src, ShortBuffer dst) {
210 if (dst != null && !dst.isDirect()) {
211 int saved_position = dst.position();
212 dst.put(src);
213 dst.position(saved_position);
214 }
215 }
216
217 public static void copy(IntBuffer src, IntBuffer dst) {
218 if (dst != null && !dst.isDirect()) {
219 int saved_position = dst.position();
220 dst.put(src);
221 dst.position(saved_position);
222 }
223 }
224
225 public static void copy(FloatBuffer src, FloatBuffer dst) {
226 if (dst != null && !dst.isDirect()) {
227 int saved_position = dst.position();
228 dst.put(src);
229 dst.position(saved_position);
230 }
231 }
232
233 public static void copy(LongBuffer src, LongBuffer dst) {
234 if (dst != null && !dst.isDirect()) {
235 int saved_position = dst.position();
236 dst.put(src);
237 dst.position(saved_position);
238 }
239 }
240
241 public static void copy(DoubleBuffer src, DoubleBuffer dst) {
242 if (dst != null && !dst.isDirect()) {
243 int saved_position = dst.position();
244 dst.put(src);
245 dst.position(saved_position);
246 }
247 }
248
249 private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) {
250 ByteBuffer direct_buffer = lookupBuffer(buffer);
251 direct_buffer.limit(buffer.limit());
252 direct_buffer.position(buffer.position());
253 return direct_buffer;
254 }
255
256 private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) {
257 ShortBuffer direct_buffer = lookupBuffer(buffer);
258 direct_buffer.limit(buffer.limit());
259 direct_buffer.position(buffer.position());
260 return direct_buffer;
261 }
262
263 private static IntBuffer doNoCopyWrap(IntBuffer buffer) {
264 IntBuffer direct_buffer = lookupBuffer(buffer);
265 direct_buffer.limit(buffer.limit());
266 direct_buffer.position(buffer.position());
267 return direct_buffer;
268 }
269
270 private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) {
271 FloatBuffer direct_buffer = lookupBuffer(buffer);
272 direct_buffer.limit(buffer.limit());
273 direct_buffer.position(buffer.position());
274 return direct_buffer;
275 }
276
277 private static LongBuffer doNoCopyWrap(LongBuffer buffer) {
278 LongBuffer direct_buffer = lookupBuffer(buffer);
279 direct_buffer.limit(buffer.limit());
280 direct_buffer.position(buffer.position());
281 return direct_buffer;
282 }
283
284 private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) {
285 DoubleBuffer direct_buffer = lookupBuffer(buffer);
286 direct_buffer.limit(buffer.limit());
287 direct_buffer.position(buffer.position());
288 return direct_buffer;
289 }
290
291 private static ByteBuffer lookupBuffer(ByteBuffer buffer) {
292 return getCachedBuffers(buffer.remaining()).byte_buffer;
293 }
294
295 private static ByteBuffer doWrap(ByteBuffer buffer) {
296 ByteBuffer direct_buffer = lookupBuffer(buffer);
297 direct_buffer.clear();
298 int saved_position = buffer.position();
299 direct_buffer.put(buffer);
300 buffer.position(saved_position);
301 direct_buffer.flip();
302 return direct_buffer;
303 }
304
305 private static ShortBuffer lookupBuffer(ShortBuffer buffer) {
306 CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2);
307 return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big;
308 }
309
310 private static ShortBuffer doWrap(ShortBuffer buffer) {
311 ShortBuffer direct_buffer = lookupBuffer(buffer);
312 direct_buffer.clear();
313 int saved_position = buffer.position();
314 direct_buffer.put(buffer);
315 buffer.position(saved_position);
316 direct_buffer.flip();
317 return direct_buffer;
318 }
319
320 private static FloatBuffer lookupBuffer(FloatBuffer buffer) {
321 CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
322 return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big;
323 }
324
325 private static FloatBuffer doWrap(FloatBuffer buffer) {
326 FloatBuffer direct_buffer = lookupBuffer(buffer);
327 direct_buffer.clear();
328 int saved_position = buffer.position();
329 direct_buffer.put(buffer);
330 buffer.position(saved_position);
331 direct_buffer.flip();
332 return direct_buffer;
333 }
334
335 private static IntBuffer lookupBuffer(IntBuffer buffer) {
336 CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
337 return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big;
338 }
339
340 private static IntBuffer doWrap(IntBuffer buffer) {
341 IntBuffer direct_buffer = lookupBuffer(buffer);
342 direct_buffer.clear();
343 int saved_position = buffer.position();
344 direct_buffer.put(buffer);
345 buffer.position(saved_position);
346 direct_buffer.flip();
347 return direct_buffer;
348 }
349
350 private static LongBuffer lookupBuffer(LongBuffer buffer) {
351 CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
352 return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big;
353 }
354
355 private static LongBuffer doWrap(LongBuffer buffer) {
356 LongBuffer direct_buffer = lookupBuffer(buffer);
357 direct_buffer.clear();
358 int saved_position = buffer.position();
359 direct_buffer.put(buffer);
360 buffer.position(saved_position);
361 direct_buffer.flip();
362 return direct_buffer;
363 }
364
365 private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) {
366 CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
367 return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big;
368 }
369
370 private static DoubleBuffer doWrap(DoubleBuffer buffer) {
371 DoubleBuffer direct_buffer = lookupBuffer(buffer);
372 direct_buffer.clear();
373 int saved_position = buffer.position();
374 direct_buffer.put(buffer);
375 buffer.position(saved_position);
376 direct_buffer.flip();
377 return direct_buffer;
378 }
379
380 private final static class CachedBuffers {
381 private final ByteBuffer byte_buffer;
382 private final ShortBuffer short_buffer_big;
383 private final IntBuffer int_buffer_big;
384 private final FloatBuffer float_buffer_big;
385 private final LongBuffer long_buffer_big;
386 private final DoubleBuffer double_buffer_big;
387 private final ShortBuffer short_buffer_little;
388 private final IntBuffer int_buffer_little;
389 private final FloatBuffer float_buffer_little;
390 private final LongBuffer long_buffer_little;
391 private final DoubleBuffer double_buffer_little;
392
393 private CachedBuffers(int size) {
394 this.byte_buffer = ByteBuffer.allocateDirect(size);
395 this.short_buffer_big = byte_buffer.asShortBuffer();
396 this.int_buffer_big = byte_buffer.asIntBuffer();
397 this.float_buffer_big = byte_buffer.asFloatBuffer();
398 this.long_buffer_big = byte_buffer.asLongBuffer();
399 this.double_buffer_big = byte_buffer.asDoubleBuffer();
400 this.byte_buffer.order(ByteOrder.LITTLE_ENDIAN);
401 this.short_buffer_little = byte_buffer.asShortBuffer();
402 this.int_buffer_little = byte_buffer.asIntBuffer();
403 this.float_buffer_little = byte_buffer.asFloatBuffer();
404 this.long_buffer_little = byte_buffer.asLongBuffer();
405 this.double_buffer_little = byte_buffer.asDoubleBuffer();
406 }
407 }
408 }
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 import java.io.File;
34 import java.lang.reflect.Method;
35 import java.net.MalformedURLException;
36 import java.net.URL;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import java.security.PrivilegedExceptionAction;
40
41 import org.lwjgl.input.Mouse;
42
43 /**
44 * <p>
45 * System class (named Sys so as not to conflict with java.lang.System)
46 * </p>
47 * @author cix_foo <cix_foo@users.sourceforge.net>
48 * @version $Revision: 3328 $
49 * $Id: Sys.java 3328 2010-04-15 18:03:54Z matzon $
50 */
51 public final class Sys {
52 /** The native library name */
53 private static final String JNI_LIBRARY_NAME = "lwjgl";
54
55 /** Current version of library */
56 private static final String VERSION = "2.4.2";
57
58 /** The implementation instance to delegate platform specific behavior to */
59 private final static SysImplementation implementation;
60
61 private final static String POSTFIX64BIT = "64";
62
63 private static void doLoadLibrary(final String lib_name) {
64 AccessController.doPrivileged(new PrivilegedAction() {
65 public Object run() {
66 String library_path = System.getProperty("org.lwjgl.librarypath");
67 if (library_path != null) {
68 System.load(library_path + File.separator +
69 System.mapLibraryName(lib_name));
70 } else {
71 System.loadLibrary(lib_name);
72 }
73 return null;
74 }
75 });
76 }
77
78 private static void loadLibrary(final String lib_name) {
79 try {
80 doLoadLibrary(lib_name);
81 } catch (UnsatisfiedLinkError e) {
82 if (implementation.has64Bit()) {
83 try {
84 doLoadLibrary(lib_name + POSTFIX64BIT);
85 return;
86 } catch (UnsatisfiedLinkError e2) {
87 LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
88 }
89 }
90 // Throw original error
91 throw e;
92 }
93 }
94
95 static {
96 implementation = createImplementation();
97 loadLibrary(JNI_LIBRARY_NAME);
98
99 int native_jni_version = implementation.getJNIVersion();
100 int required_version = implementation.getRequiredJNIVersion();
101 if (native_jni_version != required_version)
102 throw new LinkageError("Version mismatch: jar version is '" + required_version +
103 "', native libary version is '" + native_jni_version + "'");
104 implementation.setDebug(LWJGLUtil.DEBUG);
105 }
106
107 private static SysImplementation createImplementation() {
108 switch (LWJGLUtil.getPlatform()) {
109 case LWJGLUtil.PLATFORM_LINUX:
110 return new LinuxSysImplementation();
111 case LWJGLUtil.PLATFORM_WINDOWS:
112 return new WindowsSysImplementation();
113 case LWJGLUtil.PLATFORM_MACOSX:
114 return new MacOSXSysImplementation();
115 default:
116 throw new IllegalStateException("Unsupported platform");
117 }
118 }
119
120 /**
121 * No constructor for Sys.
122 */
123 private Sys() {
124 }
125
126 /**
127 * Return the version of the core LWJGL libraries as a String.
128 */
129 public static String getVersion() {
130 return VERSION;
131 }
132
133 /**
134 * Initialization. This is just a dummy method to trigger the static constructor.
135 */
136 public static void initialize() {
137 }
138
139 /**
140 * Obtains the number of ticks that the hires timer does in a second. This method is fast;
141 * it should be called as frequently as possible, as it recalibrates the timer.
142 *
143 * @return timer resolution in ticks per second or 0 if no timer is present.
144 */
145 public static long getTimerResolution() {
146 return implementation.getTimerResolution();
147 }
148
149 /**
150 * Gets the current value of the hires timer, in ticks. When the Sys class is first loaded
151 * the hires timer is reset to 0. If no hires timer is present then this method will always
152 * return 0.<p><strong>NOTEZ BIEN</strong> that the hires timer WILL wrap around.
153 *
154 * @return the current hires time, in ticks (always >= 0)
155 */
156 public static long getTime() {
157 return implementation.getTime() & 0x7FFFFFFFFFFFFFFFL;
158 }
159
160 /**
161 * Attempt to display a modal alert to the user. This method should be used
162 * when a game fails to initialize properly or crashes out losing its display
163 * in the process. It is provided because AWT may not be available on the target
164 * platform, although on Mac and Linux and other platforms supporting AWT we
165 * delegate the task to AWT instead of doing it ourselves.
166 * <p>
167 * The alert should display the title and the message and then the current
168 * thread should block until the user dismisses the alert - typically with an
169 * OK button click.
170 * <p>
171 * It may be that the user's system has no windowing system installed for some
172 * reason, in which case this method may do nothing at all, or attempt to provide
173 * some console output.
174 *
175 * @param title The title of the alert. We suggest using the title of your game.
176 * @param message The message text for the alert.
177 */
178 public static void alert(String title, String message) {
179 boolean grabbed = Mouse.isGrabbed();
180 if (grabbed) {
181 Mouse.setGrabbed(false);
182 }
183 if (title == null)
184 title = "";
185 if (message == null)
186 message = "";
187 implementation.alert(title, message);
188 if (grabbed) {
189 Mouse.setGrabbed(true);
190 }
191 }
192
193 /**
194 * Open the system web browser and point it at the specified URL. It is recommended
195 * that this not be called whilst your game is running, but on application exit in
196 * a shutdown hook, as the screen resolution will not be reset when the browser is
197 * brought into view.
198 * <p>
199 * There is no guarantee that this will work, nor that we can detect if it has
200 * failed - hence we don't return success code or throw an Exception. This is just a
201 * best attempt at opening the URL given - don't rely on it to work!
202 * <p>
203 * @param url The URL. Ensure that the URL is properly encoded.
204 * @return false if we are CERTAIN the call has failed
205 */
206 public static boolean openURL(String url) {
207 // Attempt to use Webstart if we have it available
208 try {
209 // 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});
214 }
215 });
216 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});
221 }
222 });
223 try {
224 Boolean ret = (Boolean) showDocumentMethod.invoke(basicService, new Object[] {new URL(url)});
225 return ret.booleanValue();
226 } catch (MalformedURLException e) {
227 e.printStackTrace(System.err);
228 return false;
229 }
230 } catch (Exception ue) {
231 return implementation.openURL(url);
232 }
233 }
234
235 /**
236 * Get the contents of the system clipboard. The system might not have a
237 * clipboard (particularly if it doesn't even have a keyboard) in which case
238 * we return null. Otherwise we return a String, which may be the empty
239 * string "".
240 *
241 * @return a String, or null if there is no system clipboard.
242 */
243 public static String getClipboard() {
244 return implementation.getClipboard();
245 }
246 }
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 *
35 * System class platform specific method interface
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @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 $
41 */
42 interface SysImplementation {
43 /**
44 * Return the required version of the native library
45 */
46 int getRequiredJNIVersion();
47
48 /**
49 * Return the version of the native library
50 */
51 int getJNIVersion();
52
53 void setDebug(boolean debug);
54
55 /**
56 * Obtains the number of ticks that the hires timer does in a second.
57 *
58 * @return timer resolution in ticks per second or 0 if no timer is present.
59 */
60 long getTimerResolution();
61
62 long getTime();
63
64 void alert(String title, String message);
65
66 boolean openURL(String url);
67
68 String getClipboard();
69
70 /**
71 * Returns true there exists a separate 64 bit library
72 * on the platform
73 */
74 boolean has64Bit();
75 }
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 import java.security.PrivilegedExceptionAction;
34 import java.security.PrivilegedActionException;
35 import java.security.AccessController;
36 import java.lang.reflect.Method;
37
38 import org.lwjgl.opengl.Display;
39
40 /**
41 * <p>
42 * @author $Author: spasi $
43 * @version $Revision: 3300 $
44 * $Id: WindowsSysImplementation.java 3300 2010-03-31 20:56:07Z spasi $
45 */
46 final class WindowsSysImplementation extends DefaultSysImplementation {
47 private final static int JNI_VERSION = 22;
48
49 static {
50 Sys.initialize();
51 }
52
53 public int getRequiredJNIVersion() {
54 return JNI_VERSION;
55 }
56
57 public long getTimerResolution() {
58 return 1000;
59 }
60
61 public long getTime() {
62 return nGetTime();
63 }
64 private static native long nGetTime();
65
66 public final boolean has64Bit() {
67 return true;
68 }
69
70 private static long getHwnd() {
71 if (!Display.isCreated())
72 return 0;
73 /* Use reflection since we can't make Display.getImplementation
74 * public
75 */
76 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);
80 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);
84 getHwnd_method.setAccessible(true);
85 Long hwnd = (Long)getHwnd_method.invoke(display_impl, null);
86 return hwnd;
87 }
88 });
89 return hwnd_obj.longValue();
90 } catch (PrivilegedActionException e) {
91 throw new Error(e);
92 }
93 }
94
95 public void alert(String title, String message) {
96 if(!Display.isCreated()) {
97 initCommonControls();
98 }
99 nAlert(getHwnd(), title, message);
100 }
101 private static native void nAlert(long parent_hwnd, String title, String message);
102 private static native void initCommonControls();
103
104 public boolean openURL(final String url) {
105 try {
106 LWJGLUtil.execPrivileged(new String[]{"rundll32", "url.dll,FileProtocolHandler", url});
107 return true;
108 } catch (Exception e) {
109 LWJGLUtil.log("Failed to open url (" + url + "): " + e.getMessage());
110 return false;
111 }
112 }
113
114 public String getClipboard() {
115 return nGetClipboard();
116 }
117 private static native String nGetClipboard();
118 }
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.examples;
32
33 import org.lwjgl.Sys;
34 import org.lwjgl.input.Keyboard;
35 import org.lwjgl.openal.AL;
36 import org.lwjgl.opengl.Display;
37 import org.lwjgl.opengl.GL11;
38
39 /**
40 *
41 * This is a <em>very basic</em> skeleton to init a game and run it.
42 *
43 * @author $Author: matzon $
44 * @version $Revision: 3108 $
45 * $Id: Game.java 3108 2008-07-02 20:00:49Z matzon $
46 */
47 public class Game {
48
49 /** Game title */
50 public static final String GAME_TITLE = "My Game";
51
52 /** Desired frame time */
53 private static final int FRAMERATE = 60;
54
55 /** Exit the game */
56 private static boolean finished;
57
58 /** A rotating square! */
59 private static float angle;
60
61 /**
62 * No constructor needed - this class is static
63 */
64 private Game() {}
65
66 /**
67 * Application init
68 * @param args Commandline args
69 */
70 public static void main(String[] args) {
71 try {
72 init();
73 run();
74 } catch (Exception e) {
75 e.printStackTrace(System.err);
76 Sys.alert(GAME_TITLE, "An error occured and the game will exit.");
77 } finally {
78 cleanup();
79 }
80
81 System.exit(0);
82 }
83
84 /**
85 * Initialise the game
86 * @throws Exception if init fails
87 */
88 private static void init() throws Exception {
89 // Create a fullscreen window with 1:1 orthographic 2D projection, and with
90 // mouse, keyboard, and gamepad inputs.
91 Display.setTitle(GAME_TITLE);
92 Display.setFullscreen(true);
93
94 // Enable vsync if we can
95 Display.setVSyncEnabled(true);
96
97 Display.create();
98
99 // Start up the sound system
100 AL.create();
101
102 // TODO: Load in your textures etc here
103
104 // Put the window into orthographic projection mode with 1:1 pixel ratio.
105 // 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
113 }
114
115 /**
116 * Runs the game (the "main loop")
117 */
118 private static void run() {
119 while (!finished) {
120 // Always call Window.update(), all the time
121 Display.update();
122
123 if (Display.isCloseRequested()) {
124 // Check for O/S close requests
125 finished = true;
126 } else if (Display.isActive()) {
127 // The window is in the foreground, so we should play the game
128 logic();
129 render();
130 Display.sync(FRAMERATE);
131 } else {
132 // The window is not in the foreground, so we can allow other stuff to run and
133 // infrequently update
134 try {
135 Thread.sleep(100);
136 } catch (InterruptedException e) {
137 }
138 logic();
139 if (Display.isVisible() || Display.isDirty()) {
140 // Only bother rendering if the window is visible or dirty
141 render();
142 }
143 }
144 }
145 }
146
147 /**
148 * Do any game-specific cleanup
149 */
150 private static void cleanup() {
151 // TODO: save anything you want to disk here
152
153 // Stop the sound
154 AL.destroy();
155
156 // Close the window
157 Display.destroy();
158 }
159
160 /**
161 * Do all calculations, handle input, etc.
162 */
163 private static void logic() {
164 // Example input handler: we'll check for the ESC key and finish the game instantly when it's pressed
165 if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
166 finished = true;
167 }
168
169 // TODO: all your game logic goes here.
170 angle += 2.0f % 360;
171 }
172
173 /**
174 * Render the current frame
175 */
176 private static void render() {
177 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
178
179 // 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();
191 }
192 }
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.examples.spaceinvaders;
32
33 /**
34 * An entity which represents one of our space invader aliens.
35 *
36 * @author Kevin Glass
37 * @author Brian Matzon
38 */
39 public class AlienEntity extends Entity {
40
41 /** Movement made downwards when a border is hit */
42 private static final int DOWNWARD_MOVEMENT = 10;
43
44 /** Border at which player dies */
45 private static final int BOTTOM_BORDER = 570;
46
47 /** Right border at which to shift direction */
48 private static final int RIGHT_BORDER = 750;
49
50 /** Left border at which to shift direction */
51 private static final int LEFT_BORDER = 10;
52
53 /** The speed at which the alient moves horizontally */
54 private float moveSpeed = 75;
55
56 /** The game in which the entity exists */
57 private Game game;
58
59 /** The animation frames */
60 private Sprite[] frames = new Sprite[4];
61
62 /** The time since the last frame change took place */
63 private long lastFrameChange;
64
65 /** The frame duration in milliseconds, i.e. how long any given frame of animation lasts */
66 private long frameDuration = 250;
67
68 /** The current frame of animation being displayed */
69 private int frameNumber;
70
71 /**
72 * Create a new alien entity
73 *
74 * @param game The game in which this entity is being created
75 * @param x The intial x location of this alien
76 * @param y The intial y location of this alient
77 */
78 public AlienEntity(Game game, int x, int y) {
79 super(game.getSprite("alien.gif"), x, y);
80
81 // setup the animatin frames
82 frames[0] = sprite;
83 frames[1] = game.getSprite("alien2.gif");
84 frames[2] = sprite;
85 frames[3] = game.getSprite("alien3.gif");
86
87 this.game = game;
88 dx = -moveSpeed;
89 }
90
91 /**
92 * Request that this alien moved based on time elapsed
93 *
94 * @param delta The time that has elapsed since last move
95 */
96 public void move(long delta) {
97 // since the move tells us how much time has passed
98 // by we can use it to drive the animation, however
99 // its the not the prettiest solution
100 lastFrameChange += delta;
101
102 // if we need to change the frame, update the frame number
103 // and flip over the sprite in use
104 if (lastFrameChange > frameDuration) {
105 // reset our frame change time counter
106 lastFrameChange = 0;
107
108 // update the frame
109 frameNumber++;
110 if (frameNumber >= frames.length) {
111 frameNumber = 0;
112 }
113
114 sprite = frames[frameNumber];
115 }
116
117 // if we have reached the left hand side of the screen and
118 // are moving left then request a logic update
119 if ((dx < 0) && (x < LEFT_BORDER)) {
120 game.updateLogic();
121 }
122 // and vice vesa, if we have reached the right hand side of
123 // the screen and are moving right, request a logic update
124 if ((dx > 0) && (x > RIGHT_BORDER)) {
125 game.updateLogic();
126 }
127
128 // proceed with normal move
129 super.move(delta);
130 }
131
132 /**
133 * Update the game logic related to aliens
134 */
135 public void doLogic() {
136 // swap over horizontal movement and move down the
137 // screen a bit
138 dx = -dx;
139 y += DOWNWARD_MOVEMENT;
140
141 // if we've reached the bottom of the screen then the player
142 // dies
143 if (y > BOTTOM_BORDER) {
144 game.notifyDeath();
145 }
146 }
147
148 /**
149 * Notification that this alien has collided with another entity
150 *
151 * @param other The other entity
152 */
153 public void collidedWith(Entity other) {
154 // collisions with aliens are handled elsewhere
155 }
156 }
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.examples.spaceinvaders;
32
33 import java.awt.Rectangle;
34
35 /**
36 * An entity represents any element that appears in the game. The
37 * entity is responsible for resolving collisions and movement
38 * based on a set of properties defined either by subclass or externally.
39 *
40 * Note that doubles are used for positions. This may seem strange
41 * given that pixels locations are integers. However, using double means
42 * that an entity can move a partial pixel. It doesn't of course mean that
43 * they will be display half way through a pixel but allows us not lose
44 * accuracy as we move.
45 *
46 * @author Kevin Glass
47 */
48 public abstract class Entity {
49
50 /** The current x location of this entity */
51 protected float x;
52
53 /** The current y location of this entity */
54 protected float y;
55
56 /** The sprite that represents this entity */
57 protected Sprite sprite;
58
59 /** The current speed of this entity horizontally (pixels/sec) */
60 protected float dx;
61
62 /** The current speed of this entity vertically (pixels/sec) */
63 protected float dy;
64
65 /** The rectangle used for this entity during collisions resolution */
66 private Rectangle me = new Rectangle();
67
68 /** The rectangle used for other entities during collision resolution */
69 private Rectangle him = new Rectangle();
70
71 /**
72 * 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
75 * @param x The initial x location of this entity
76 * @param y The initial y location of this entity
77 */
78 public Entity(Sprite sprite, int x, int y) {
79 this.sprite = sprite;
80 this.x = x;
81 this.y = y;
82 }
83
84 /**
85 * Request that this entity move itself based on a certain ammount
86 * of time passing.
87 *
88 * @param delta The ammount of time that has passed in milliseconds
89 */
90 public void move(long delta) {
91 // update the location of the entity based on move speeds
92 x += (delta * dx) / 1000;
93 y += (delta * dy) / 1000;
94 }
95
96 /**
97 * Set the horizontal speed of this entity
98 *
99 * @param dx The horizontal speed of this entity (pixels/sec)
100 */
101 public void setHorizontalMovement(float dx) {
102 this.dx = dx;
103 }
104
105 /**
106 * Set the vertical speed of this entity
107 *
108 * @param dy The vertical speed of this entity (pixels/sec)
109 */
110 public void setVerticalMovement(float dy) {
111 this.dy = dy;
112 }
113
114 /**
115 * Get the horizontal speed of this entity
116 *
117 * @return The horizontal speed of this entity (pixels/sec)
118 */
119 public float getHorizontalMovement() {
120 return dx;
121 }
122
123 /**
124 * Get the vertical speed of this entity
125 *
126 * @return The vertical speed of this entity (pixels/sec)
127 */
128 public float getVerticalMovement() {
129 return dy;
130 }
131
132 /**
133 * Draw this entity to the graphics context provided
134 */
135 public void draw() {
136 sprite.draw((int) x, (int) y);
137 }
138
139 /**
140 * Do the logic associated with this entity. This method
141 * will be called periodically based on game events
142 */
143 public void doLogic() {
144 }
145
146 /**
147 * Get the x location of this entity
148 *
149 * @return The x location of this entity
150 */
151 public int getX() {
152 return (int) x;
153 }
154
155 /**
156 * Get the y location of this entity
157 *
158 * @return The y location of this entity
159 */
160 public int getY() {
161 return (int) y;
162 }
163
164 /**
165 * Check if this entity collised with another.
166 *
167 * @param other The other entity to check collision against
168 * @return True if the entities collide with each other
169 */
170 public boolean collidesWith(Entity other) {
171 me.setBounds((int) x, (int) y, sprite.getWidth(), sprite.getHeight());
172 him.setBounds((int) other.x, (int) other.y, other.sprite.getWidth(), other.sprite.getHeight());
173
174 return me.intersects(him);
175 }
176
177 /**
178 * Notification that this entity collided with another.
179 *
180 * @param other The entity with which this entity collided.
181 */
182 public abstract void collidedWith(Entity other);
183 }
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.examples.spaceinvaders;
32
33 import java.util.ArrayList;
34
35 import org.lwjgl.LWJGLException;
36 import org.lwjgl.Sys;
37 import org.lwjgl.input.Keyboard;
38 import org.lwjgl.input.Mouse;
39 import org.lwjgl.opengl.Display;
40 import org.lwjgl.opengl.DisplayMode;
41 import org.lwjgl.opengl.GL11;
42
43 /**
44 * 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 *
47 * Display management will consist of a loop that cycles round all
48 * entities in the game asking them to move and then drawing them
49 * in the appropriate place. With the help of an inner class it
50 * will also allow the player to control the main ship.
51 *
52 * As a mediator it will be informed when entities within our game
53 * detect events (e.g. alient killed, played died) and will take
54 * appropriate game actions.
55 *
56 * <p>
57 * NOTE:<br>
58 * 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 * 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 * at the time of writing).
63 * You can find the original article here:<br>
64 * <a href="http://www.cokeandcode.com/" target="_blank">http://www.cokeandcode.com</a>
65 * </p>
66 *
67 * @author Kevin Glass
68 * @author Brian Matzon
69 */
70 public class Game {
71
72 /** The normal title of the window */
73 private String WINDOW_TITLE = "Space Invaders 104 (for LWJGL)";
74
75 /** The width of the game display area */
76 private int width = 800;
77
78 /** The height of the game display area */
79 private int height = 600;
80
81 /** The loader responsible for converting images into OpenGL textures */
82 private TextureLoader textureLoader;
83
84 /** The list of all the entities that exist in our game */
85 private ArrayList entities = new ArrayList();
86
87 /** The list of entities that need to be removed from the game this loop */
88 private ArrayList removeList = new ArrayList();
89
90 /** The entity representing the player */
91 private ShipEntity ship;
92
93 /** List of shots */
94 private ShotEntity[] shots;
95
96 /** The message to display which waiting for a key press */
97 private Sprite message;
98
99 /** The sprite containing the "Press Any Key" message */
100 private Sprite pressAnyKey;
101
102 /** The sprite containing the "You win!" message */
103 private Sprite youWin;
104
105 /** The sprite containing the "You lose!" message */
106 private Sprite gotYou;
107
108 /** Last shot index */
109 private int shotIndex;
110
111 /** The speed at which the player's ship should move (pixels/sec) */
112 private float moveSpeed = 300;
113
114 /** The time at which last fired a shot */
115 private long lastFire = 0;
116
117 /** The interval between our players shot (ms) */
118 private long firingInterval = 500;
119
120 /** The number of aliens left on the screen */
121 private int alienCount;
122
123 /** True if we're holding up game play until a key has been pressed */
124 private boolean waitingForKeyPress = true;
125
126 /** True if game logic needs to be applied this loop, normally as a result of a game event */
127 private boolean logicRequiredThisLoop = false;
128
129 /** The time at which the last rendering looped started from the point of view of the game logic */
130 private long lastLoopTime = getTime();
131
132 /** True if the fire key has been released */
133 private boolean fireHasBeenReleased = false;
134
135 /** The time since the last record of fps */
136 private long lastFpsTime = 0;
137
138 /** The recorded fps */
139 private int fps;
140
141 private static long timerTicksPerSecond = Sys.getTimerResolution();
142
143 /** True if the game is currently "running", i.e. the game loop is looping */
144 public static boolean gameRunning = true;
145
146 /** SoundManager to make sound with */
147 private SoundManager soundManager;
148
149 /** Whether we're running in fullscreen mode */
150 private boolean fullscreen;
151
152 /** ID of shot effect */
153 private int SOUND_SHOT;
154
155 /** ID of hit effect */
156 private int SOUND_HIT;
157
158 /** ID of start sound */
159 private int SOUND_START;
160
161 /** ID of win sound */
162 private int SOUND_WIN;
163
164 /** ID of loose sound */
165 private int SOUND_LOOSE;
166
167 /** Mouse movement on x axis */
168 private int mouseX;
169
170 /** Is this an application or applet */
171 private static boolean isApplication = false;
172
173 /**
174 * Construct our game and set it running.
175 * @param fullscreen
176 *
177 * @param renderingType The type of rendering to use (should be one of the contansts from ResourceFactory)
178 */
179 public Game(boolean fullscreen) {
180 this.fullscreen = fullscreen;
181 initialize();
182 }
183
184 /**
185 * Get the high resolution time in milliseconds
186 *
187 * @return The high resolution time in milliseconds
188 */
189 public static long getTime() {
190 // we get the "timer ticks" from the high resolution timer
191 // multiply by 1000 so our end result is in milliseconds
192 // then divide by the number of ticks in a second giving
193 // us a nice clear time in milliseconds
194 return (Sys.getTime() * 1000) / timerTicksPerSecond;
195 }
196
197 /**
198 * Sleep for a fixed number of milliseconds.
199 *
200 * @param duration The amount of time in milliseconds to sleep for
201 */
202 public static void sleep(long duration) {
203 try {
204 Thread.sleep((duration * timerTicksPerSecond) / 1000);
205 } catch (InterruptedException inte) {
206 }
207 }
208
209 /**
210 * Intialise the common elements for the game
211 */
212 public void initialize() {
213 // initialize the window beforehand
214 try {
215 setDisplayMode();
216 Display.setTitle(WINDOW_TITLE);
217 Display.setFullscreen(fullscreen);
218 Display.create();
219
220 // grab the mouse, dont want that hideous cursor when we're playing!
221 if (isApplication) {
222 Mouse.setGrabbed(true);
223 }
224
225 // enable textures since we're going to use these for our sprites
226 GL11.glEnable(GL11.GL_TEXTURE_2D);
227
228 // 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);
238
239 textureLoader = new TextureLoader();
240
241 // create our sound manager, and initialize it with 7 channels
242 // 1 channel for sounds, 6 for effects - this should be enough
243 // since we have a most 4 shots on screen at any one time, which leaves
244 // us with 2 channels for explosions.
245 soundManager = new SoundManager();
246 soundManager.initialize(8);
247
248 // load our sound data
249 SOUND_SHOT = soundManager.addSound("shot.wav");
250 SOUND_HIT = soundManager.addSound("hit.wav");
251 SOUND_START = soundManager.addSound("start.wav");
252 SOUND_WIN = soundManager.addSound("win.wav");
253 SOUND_LOOSE = soundManager.addSound("loose.wav");
254 } catch (LWJGLException le) {
255 System.out.println("Game exiting - exception in initialization:");
256 le.printStackTrace();
257 Game.gameRunning = false;
258 return;
259 }
260
261 // get our sprites
262 gotYou = getSprite("gotyou.gif");
263 pressAnyKey = getSprite("pressanykey.gif");
264 youWin = getSprite("youwin.gif");
265
266 message = pressAnyKey;
267
268 // setup 5 shots
269 shots = new ShotEntity[5];
270 for (int i = 0; i < shots.length; i++) {
271 shots[i] = new ShotEntity(this, "shot.gif", 0, 0);
272 }
273
274 // setup the initial game state
275 startGame();
276 }
277
278 /**
279 * Sets the display mode for fullscreen mode
280 */
281 private boolean setDisplayMode() {
282 try {
283 // get modes
284 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(width, height, -1, -1, -1, -1, 60, 60);
285
286 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
287 "width=" + width,
288 "height=" + height,
289 "freq=" + 60,
290 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
291 });
292 return true;
293 } catch (Exception e) {
294 e.printStackTrace();
295 System.out.println("Unable to enter fullscreen, continuing in windowed mode");
296 }
297
298 return false;
299 }
300
301 /**
302 * Start a fresh game, this should clear out any old data and
303 * create a new set.
304 */
305 private void startGame() {
306 // clear out any existing entities and intialise a new set
307 entities.clear();
308 initEntities();
309 }
310
311 /**
312 * Initialise the starting state of the entities (ship and aliens). Each
313 * entitiy will be added to the overall list of entities in the game.
314 */
315 private void initEntities() {
316 // create the player ship and place it roughly in the center of the screen
317 ship = new ShipEntity(this, "ship.gif", 370, 550);
318 entities.add(ship);
319
320 // create a block of aliens (5 rows, by 12 aliens, spaced evenly)
321 alienCount = 0;
322 for (int row = 0; row < 5; row++) {
323 for (int x = 0; x < 12; x++) {
324 Entity alien = new AlienEntity(this, 100 + (x * 50), (50) + row * 30);
325 entities.add(alien);
326 alienCount++;
327 }
328 }
329 }
330
331 /**
332 * Notification from a game entity that the logic of the game
333 * should be run at the next opportunity (normally as a result of some
334 * game event)
335 */
336 public void updateLogic() {
337 logicRequiredThisLoop = true;
338 }
339
340 /**
341 * Remove an entity from the game. The entity removed will
342 * no longer move or be drawn.
343 *
344 * @param entity The entity that should be removed
345 */
346 public void removeEntity(Entity entity) {
347 removeList.add(entity);
348 }
349
350 /**
351 * Notification that the player has died.
352 */
353 public void notifyDeath() {
354 if (!waitingForKeyPress) {
355 soundManager.playSound(SOUND_LOOSE);
356 }
357 message = gotYou;
358 waitingForKeyPress = true;
359 }
360
361 /**
362 * Notification that the player has won since all the aliens
363 * are dead.
364 */
365 public void notifyWin() {
366 message = youWin;
367 waitingForKeyPress = true;
368 soundManager.playSound(SOUND_WIN);
369 }
370
371 /**
372 * Notification that an alien has been killed
373 */
374 public void notifyAlienKilled() {
375 // reduce the alient count, if there are none left, the player has won!
376 alienCount--;
377
378 if (alienCount == 0) {
379 notifyWin();
380 }
381
382 // if there are still some aliens left then they all need to get faster, so
383 // 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) {
388 // speed up by 2%
389 entity.setHorizontalMovement(entity.getHorizontalMovement() * 1.02f);
390 }
391 }
392
393 soundManager.playEffect(SOUND_HIT);
394 }
395
396 /**
397 * Attempt to fire a shot from the player. Its called "try"
398 * since we must first check that the player can fire at this
399 * point, i.e. has he/she waited long enough between shots
400 */
401 public void tryToFire() {
402 // check that we have waiting long enough to fire
403 if (System.currentTimeMillis() - lastFire < firingInterval) {
404 return;
405 }
406
407 // if we waited long enough, create the shot entity, and record the time.
408 lastFire = System.currentTimeMillis();
409 ShotEntity shot = shots[shotIndex++ % shots.length];
410 shot.reinitialize(ship.getX() + 10, ship.getY() - 30);
411 entities.add(shot);
412
413 soundManager.playEffect(SOUND_SHOT);
414 }
415
416 /**
417 * Run the main game loop. This method keeps rendering the scene
418 * and requesting that the callback update its screen.
419 */
420 private void gameLoop() {
421 while (Game.gameRunning) {
422 // clear screen
423 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
424 GL11.glMatrixMode(GL11.GL_MODELVIEW);
425 GL11.glLoadIdentity();
426
427 // let subsystem paint
428 frameRendering();
429
430 // update window contents
431 Display.update();
432 }
433
434 // clean up
435 soundManager.destroy();
436 Display.destroy();
437 }
438
439 /**
440 * Notification that a frame is being rendered. Responsible for
441 * running game logic and rendering the scene.
442 */
443 public void frameRendering() {
444 //SystemTimer.sleep(lastLoopTime+10-SystemTimer.getTime());
445 Display.sync(60);
446
447 // work out how long its been since the last update, this
448 // will be used to calculate how far the entities should
449 // move this loop
450 long delta = getTime() - lastLoopTime;
451 lastLoopTime = getTime();
452 lastFpsTime += delta;
453 fps++;
454
455 // update our FPS counter if a second has passed
456 if (lastFpsTime >= 1000) {
457 Display.setTitle(WINDOW_TITLE + " (FPS: " + fps + ")");
458 lastFpsTime = 0;
459 fps = 0;
460 }
461
462 // cycle round asking each entity to move itself
463 if (!waitingForKeyPress && !soundManager.isPlayingSound()) {
464 for (int i = 0; i < entities.size(); i++) {
465 Entity entity = (Entity) entities.get(i);
466 entity.move(delta);
467 }
468 }
469
470 // 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);
473 entity.draw();
474 }
475
476 // brute force collisions, compare every entity against
477 // every other entity. If any of them collide notify
478 // both entities that the collision has occured
479 for (int p = 0; p < entities.size(); p++) {
480 for (int s = p + 1; s < entities.size(); s++) {
481 Entity me = (Entity) entities.get(p);
482 Entity him = (Entity) entities.get(s);
483
484 if (me.collidesWith(him)) {
485 me.collidedWith(him);
486 him.collidedWith(me);
487 }
488 }
489 }
490
491 // remove any entity that has been marked for clear up
492 entities.removeAll(removeList);
493 removeList.clear();
494
495 // if a game event has indicated that game logic should
496 // be resolved, cycle round every entity requesting that
497 // their personal logic should be considered.
498 if (logicRequiredThisLoop) {
499 for (int i = 0; i < entities.size(); i++) {
500 Entity entity = (Entity) entities.get(i);
501 entity.doLogic();
502 }
503
504 logicRequiredThisLoop = false;
505 }
506
507 // if we're waiting for an "any key" press then draw the
508 // current message
509 if (waitingForKeyPress) {
510 message.draw(325, 250);
511 }
512
513 // resolve the movemfent of the ship. First assume the ship
514 // isn't moving. If either cursor key is pressed then
515 // update the movement appropraitely
516 ship.setHorizontalMovement(0);
517
518 // get mouse movement on x axis. We need to get it now, since
519 // we can only call getDX ONCE! - secondary calls will yield 0, since
520 // there haven't been any movement since last call.
521 mouseX = Mouse.getDX();
522
523 // we delegate input checking to submethod since we want to check
524 // for keyboard, mouse & controller
525 boolean leftPressed = hasInput(Keyboard.KEY_LEFT);
526 boolean rightPressed = hasInput(Keyboard.KEY_RIGHT);
527 boolean firePressed = hasInput(Keyboard.KEY_SPACE);
528
529 if (!waitingForKeyPress && !soundManager.isPlayingSound()) {
530 if ((leftPressed) && (!rightPressed)) {
531 ship.setHorizontalMovement(-moveSpeed);
532 } else if ((rightPressed) && (!leftPressed)) {
533 ship.setHorizontalMovement(moveSpeed);
534 }
535
536 // if we're pressing fire, attempt to fire
537 if (firePressed) {
538 tryToFire();
539 }
540 } else {
541 if (!firePressed) {
542 fireHasBeenReleased = true;
543 }
544 if ((firePressed) && (fireHasBeenReleased) && !soundManager.isPlayingSound()) {
545 waitingForKeyPress = false;
546 fireHasBeenReleased = false;
547 startGame();
548 soundManager.playSound(SOUND_START);
549 }
550 }
551
552 // if escape has been pressed, stop the game
553 if ((Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) && isApplication) {
554 Game.gameRunning = false;
555 }
556 }
557
558 /**
559 * @param key_left
560 * @return
561 */
562 private boolean hasInput(int direction) {
563 switch(direction) {
564 case Keyboard.KEY_LEFT:
565 return
566 Keyboard.isKeyDown(Keyboard.KEY_LEFT) ||
567 mouseX < 0;
568
569 case Keyboard.KEY_RIGHT:
570 return
571 Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ||
572 mouseX > 0;
573
574 case Keyboard.KEY_SPACE:
575 return
576 Keyboard.isKeyDown(Keyboard.KEY_SPACE) ||
577 Mouse.isButtonDown(0);
578 }
579 return false;
580 }
581
582 /**
583 * The entry point into the game. We'll simply create an
584 * instance of class which will start the display and game
585 * loop.
586 *
587 * @param argv The arguments that are passed into our game
588 */
589 public static void main(String argv[]) {
590 isApplication = true;
591 System.out.println("Use -fullscreen for fullscreen mode");
592 new Game((argv.length > 0 && argv[0].equalsIgnoreCase("-fullscreen"))).execute();
593 System.exit(0);
594 }
595
596 /**
597 *
598 */
599 public void execute() {
600 gameLoop();
601 }
602
603 /**
604 * Create or get a sprite which displays the image that is pointed
605 * to in the classpath by "ref"
606 *
607 * @param ref A reference to the image to load
608 * @return A sprite that can be drawn onto the current graphics context.
609 */
610 public Sprite getSprite(String ref) {
611 return new Sprite(textureLoader, ref);
612 }
613 }
0 package org.lwjgl.examples.spaceinvaders;
1
2
3 import java.applet.Applet;
4 import java.awt.BorderLayout;
5 import java.awt.Canvas;
6 import org.lwjgl.LWJGLException;
7 import org.lwjgl.opengl.Display;
8
9 public class GameApplet extends Applet {
10
11 /** The Canvas where the LWJGL Display is added */
12 Canvas display_parent;
13
14 /** Thread which runs the main game loop */
15 Thread gameThread;
16
17 /** The Game instance */
18 Game game;
19
20 /**
21 * Once the Canvas is created its add notify method will call this method to
22 * start the LWJGL Display and game loop in another thread.
23 */
24 public void startLWJGL() {
25 gameThread = new Thread() {
26 public void run() {
27
28 try {
29 Display.setParent(display_parent);
30
31 } catch (LWJGLException e) {
32 e.printStackTrace();
33 }
34 // start game
35 game = new Game(false);
36 game.execute();
37 }
38 };
39 gameThread.start();
40 }
41
42
43 /**
44 * Tell game loop to stop running, after which the LWJGL Display will be destoryed.
45 * The main thread will wait for the Display.destroy() to complete
46 */
47 private void stopLWJGL() {
48 Game.gameRunning = false;
49 try {
50 gameThread.join();
51 } catch (InterruptedException e) {
52 e.printStackTrace();
53 }
54 }
55
56 public void start() {
57
58 }
59
60 public void stop() {
61
62 }
63
64 /**
65 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
66 * stopLWJGL() to stop main game loop and to destroy the Display
67 */
68 public void destroy() {
69 remove(display_parent);
70 super.destroy();
71 System.out.println("Clear up");
72 }
73
74 /**
75 * 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
77 * applet is destroyed.
78 */
79 public void init() {
80 setLayout(new BorderLayout());
81 try {
82 display_parent = new Canvas() {
83 public final void addNotify() {
84 super.addNotify();
85 startLWJGL();
86 }
87 public final void removeNotify() {
88 stopLWJGL();
89 super.removeNotify();
90 }
91 };
92 display_parent.setSize(getWidth(),getHeight());
93 add(display_parent);
94 display_parent.setFocusable(true);
95 display_parent.requestFocus();
96 display_parent.setIgnoreRepaint(true);
97 setVisible(true);
98 } catch (Exception e) {
99 System.err.println(e);
100 throw new RuntimeException("Unable to create display");
101 }
102 }
103 }
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.examples.spaceinvaders;
32
33 /**
34 * The entity that represents the players ship
35 *
36 * @author Kevin Glass
37 * @author Brian Matzon
38 */
39 public class ShipEntity extends Entity {
40
41 /** Right border at which to disallow further movement */
42 private static final int RIGHT_BORDER = 750;
43
44 /** Left border at which to disallow further movement */
45 private static final int LEFT_BORDER = 10;
46
47 /** The game in which the ship exists */
48 private Game game;
49
50 /**
51 * Create a new entity to represent the players ship
52 *
53 * @param game The game in which the ship is being created
54 * @param ref The reference to the sprite to show for the ship
55 * @param x The initial x location of the player's ship
56 * @param y The initial y location of the player's ship
57 */
58 public ShipEntity(Game game,String ref,int x,int y) {
59 super(game.getSprite(ref), x, y);
60
61 this.game = game;
62 }
63
64 /**
65 * Request that the ship move itself based on an elapsed ammount of
66 * time
67 *
68 * @param delta The time that has elapsed since last move (ms)
69 */
70 public void move(long delta) {
71 // if we're moving left and have reached the left hand side
72 // of the screen, don't move
73 if ((dx < 0) && (x < LEFT_BORDER)) {
74 return;
75 }
76 // if we're moving right and have reached the right hand side
77 // of the screen, don't move
78 if ((dx > 0) && (x > RIGHT_BORDER)) {
79 return;
80 }
81
82 super.move(delta);
83 }
84
85 /**
86 * Notification that the player's ship has collided with something
87 *
88 * @param other The entity with which the ship has collided
89 */
90 public void collidedWith(Entity other) {
91 // if its an alien, notify the game that the player
92 // is dead
93 if (other instanceof AlienEntity) {
94 game.notifyDeath();
95 }
96 }
97 }
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.examples.spaceinvaders;
32
33 /**
34 * An entity representing a shot fired by the player's ship
35 *
36 * @author Kevin Glass
37 * @author Brian Matzon
38 */
39 public class ShotEntity extends Entity {
40
41 /** Top border at which shots are outside */
42 private static final int TOP_BORDER = -100;
43
44 /** The vertical speed at which the players shot moves */
45 private float moveSpeed = -300;
46
47 /** The game in which this entity exists */
48 private Game game;
49
50 /** True if this shot has been "used", i.e. its hit something */
51 private boolean used = false;
52
53 /**
54 * Create a new shot from the player
55 *
56 * @param game The game in which the shot has been created
57 * @param sprite The sprite representing this shot
58 * @param x The initial x location of the shot
59 * @param y The initial y location of the shot
60 */
61 public ShotEntity(Game game, String sprite, int x, int y) {
62 super(game.getSprite(sprite), x, y);
63
64 this.game = game;
65 dy = moveSpeed;
66 }
67
68 /**
69 * Reinitializes this entity, for reuse
70 *
71 * @param x new x coordinate
72 * @param y new y coordinate
73 */
74 public void reinitialize(int x, int y) {
75 this.x = x;
76 this.y = y;
77 used = false;
78 }
79
80 /**
81 * Request that this shot moved based on time elapsed
82 *
83 * @param delta The time that has elapsed since last move
84 */
85 public void move(long delta) {
86 // proceed with normal move
87 super.move(delta);
88
89 // if we shot off the screen, remove ourselfs
90 if (y < TOP_BORDER) {
91 game.removeEntity(this);
92 }
93 }
94
95 /**
96 * Notification that this shot has collided with another
97 * entity
98 *
99 * @param other The other entity with which we've collided
100 */
101 public void collidedWith(Entity other) {
102 // prevents double kills, if we've already hit something,
103 // don't collide
104 if (used) {
105 return;
106 }
107
108 // if we've hit an alien, kill it!
109 if (other instanceof AlienEntity) {
110 // remove the affected entities
111 game.removeEntity(this);
112 game.removeEntity(other);
113
114 // notify the game that the alien has been killed
115 game.notifyAlienKilled();
116 used = true;
117 }
118 }
119 }
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.examples.spaceinvaders;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.openal.AL;
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.util.WaveData;
40
41
42 /**
43 * <p>
44 * Simple sound manager for OpenAL using n sources accessed in
45 * a round robin schedule. Source n is reserved for a single buffer and checking for
46 * whether it's playing.
47 * </p>
48 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: SoundManager.java 2983 2008-04-07 18:36:09Z matzon $
51 */
52 public class SoundManager {
53
54 /** We support at most 256 buffers*/
55 private int[] buffers = new int[256];
56
57 /** Number of sources is limited tby user (and hardware) */
58 private int[] sources;
59
60 /** Our internal scratch buffer */
61 private IntBuffer scratchBuffer = BufferUtils.createIntBuffer(256);
62
63 /** Whether we're running in no sound mode */
64 private boolean soundOutput;
65
66 /** Current index in our buffers */
67 private int bufferIndex;
68
69 /** Current index in our source list */
70 private int sourceIndex;
71
72 /**
73 * Creates a new SoundManager
74 */
75 public SoundManager() {
76 }
77
78 /**
79 * Plays a sound effect
80 * @param buffer Buffer index to play gotten from addSound
81 */
82 public void playEffect(int buffer) {
83 if(soundOutput) {
84 // make sure we never choose last channel, since it is used for special sounds
85 int channel = sources[(sourceIndex++ % (sources.length-1))];
86
87 // link buffer and source, and play it
88 AL10.alSourcei(channel, AL10.AL_BUFFER, buffers[buffer]);
89 AL10.alSourcePlay(channel);
90 }
91 }
92
93 /**
94 * Plays a sound on last source
95 * @param buffer Buffer index to play gotten from addSound
96 */
97 public void playSound(int buffer) {
98 if(soundOutput) {
99 AL10.alSourcei(sources[sources.length-1], AL10.AL_BUFFER, buffers[buffer]);
100 AL10.alSourcePlay(sources[sources.length-1]);
101 }
102 }
103
104 /**
105 * Whether a sound is playing on last source
106 * @return true if a source is playing right now on source n
107 */
108 public boolean isPlayingSound() {
109 return AL10.alGetSourcei(sources[sources.length-1], AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING;
110 }
111
112 /**
113 * Initializes the SoundManager
114 *
115 * @param sources Number of sources to create
116 */
117 public void initialize(int channels) {
118 try {
119 AL.create();
120
121 // allocate sources
122 scratchBuffer.limit(channels);
123 AL10.alGenSources(scratchBuffer);
124 scratchBuffer.rewind();
125 scratchBuffer.get(sources = new int[channels]);
126
127 // could we allocate all channels?
128 if(AL10.alGetError() != AL10.AL_NO_ERROR) {
129 throw new LWJGLException("Unable to allocate " + channels + " sources");
130 }
131
132 // we have sound
133 soundOutput = true;
134 } catch (LWJGLException le) {
135 le.printStackTrace();
136 System.out.println("Sound disabled");
137 }
138 }
139
140 /**
141 * Adds a sound to the Sound Managers pool
142 *
143 * @param path Path to file to load
144 * @return index into SoundManagers buffer list
145 */
146 public int addSound(String path) {
147 // Generate 1 buffer entry
148 scratchBuffer.rewind().position(0).limit(1);
149 AL10.alGenBuffers(scratchBuffer);
150 buffers[bufferIndex] = scratchBuffer.get(0);
151
152 // load wave data from buffer
153 WaveData wavefile = WaveData.create("spaceinvaders/" + path);
154
155 // copy to buffers
156 AL10.alBufferData(buffers[bufferIndex], wavefile.format, wavefile.data, wavefile.samplerate);
157
158 // unload file again
159 wavefile.dispose();
160
161 // return index for this sound
162 return bufferIndex++;
163 }
164
165 /**
166 * Destroy this SoundManager
167 */
168 public void destroy() {
169 if(soundOutput) {
170
171 // stop playing sounds
172 scratchBuffer.position(0).limit(sources.length);
173 scratchBuffer.put(sources).flip();
174 AL10.alSourceStop(scratchBuffer);
175
176 // destroy sources
177 AL10.alDeleteSources(scratchBuffer);
178
179 // destroy buffers
180 scratchBuffer.position(0).limit(bufferIndex);
181 scratchBuffer.put(buffers, 0, bufferIndex).flip();
182 AL10.alDeleteBuffers(scratchBuffer);
183
184 // destory OpenAL
185 AL.destroy();
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 package org.lwjgl.examples.spaceinvaders;
32
33 import java.io.IOException;
34
35 import org.lwjgl.opengl.GL11;
36
37 /**
38 * Implementation of sprite that uses an OpenGL quad and a texture
39 * to render a given image to the screen.
40 *
41 * @author Kevin Glass
42 * @author Brian Matzon
43 */
44 public class Sprite {
45
46 /** The texture that stores the image for this sprite */
47 private Texture texture;
48
49 /** The width in pixels of this sprite */
50 private int width;
51
52 /** The height in pixels of this sprite */
53 private int height;
54
55 /**
56 * Create a new sprite from a specified image.
57 *
58 * @param window The window in which the sprite will be displayed
59 * @param ref A reference to the image on which this sprite should be based
60 */
61 public Sprite(TextureLoader loader, String ref) {
62 try {
63 texture = loader.getTexture("spaceinvaders/" + ref);
64 width = texture.getImageWidth();
65 height = texture.getImageHeight();
66 } catch (IOException ioe) {
67 ioe.printStackTrace();
68 System.exit(-1);
69 }
70 }
71
72 /**
73 * Get the width of this sprite in pixels
74 *
75 * @return The width of this sprite in pixels
76 */
77 public int getWidth() {
78 return texture.getImageWidth();
79 }
80
81 /**
82 * Get the height of this sprite in pixels
83 *
84 * @return The height of this sprite in pixels
85 */
86 public int getHeight() {
87 return texture.getImageHeight();
88 }
89
90 /**
91 * Draw the sprite at the specified location
92 *
93 * @param x The x location at which to draw this sprite
94 * @param y The y location at which to draw this sprite
95 */
96 public void draw(int x, int y) {
97 // store the current model matrix
98 GL11.glPushMatrix();
99
100 // bind to the appropriate texture for this sprite
101 texture.bind();
102
103 // translate to the right location and prepare to draw
104 GL11.glTranslatef(x, y, 0);
105
106 // draw a quad textured to match the sprite
107 GL11.glBegin(GL11.GL_QUADS);
108 {
109 GL11.glTexCoord2f(0, 0);
110 GL11.glVertex2f(0, 0);
111
112 GL11.glTexCoord2f(0, texture.getHeight());
113 GL11.glVertex2f(0, height);
114
115 GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
116 GL11.glVertex2f(width, height);
117
118 GL11.glTexCoord2f(texture.getWidth(), 0);
119 GL11.glVertex2f(width, 0);
120 }
121 GL11.glEnd();
122
123 // restore the model view matrix to prevent contamination
124 GL11.glPopMatrix();
125 }
126 }
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.examples.spaceinvaders;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * A texture to be bound within OpenGL. This object is responsible for
37 * keeping track of a given OpenGL texture and for calculating the
38 * texturing mapping coordinates of the full image.
39 *
40 * Since textures need to be powers of 2 the actual texture may be
41 * considerably bigged that the source image and hence the texture
42 * mapping coordinates need to be adjusted to matchup drawing the
43 * sprite against the texture.
44 *
45 * @author Kevin Glass
46 * @author Brian Matzon
47 */
48 public class Texture {
49
50 /** The GL target type */
51 private int target;
52
53 /** The GL texture ID */
54 private int textureID;
55
56 /** The height of the image */
57 private int height;
58
59 /** The width of the image */
60 private int width;
61
62 /** The width of the texture */
63 private int texWidth;
64
65 /** The height of the texture */
66 private int texHeight;
67
68 /** The ratio of the width of the image to the texture */
69 private float widthRatio;
70
71 /** The ratio of the height of the image to the texture */
72 private float heightRatio;
73
74 /**
75 * Create a new texture
76 *
77 * @param target The GL target
78 * @param textureID The GL texture ID
79 */
80 public Texture(int target, int textureID) {
81 this.target = target;
82 this.textureID = textureID;
83 }
84
85 /**
86 * Bind the specified GL context to a texture
87 *
88 * @param gl The GL context to bind to
89 */
90 public void bind() {
91 GL11.glBindTexture(target, textureID);
92 }
93
94 /**
95 * Set the height of the image
96 *
97 * @param height The height of the image
98 */
99 public void setHeight(int height) {
100 this.height = height;
101 setHeight();
102 }
103
104 /**
105 * Set the width of the image
106 *
107 * @param width The width of the image
108 */
109 public void setWidth(int width) {
110 this.width = width;
111 setWidth();
112 }
113
114 /**
115 * Get the height of the original image
116 *
117 * @return The height of the original image
118 */
119 public int getImageHeight() {
120 return height;
121 }
122
123 /**
124 * Get the width of the original image
125 *
126 * @return The width of the original image
127 */
128 public int getImageWidth() {
129 return width;
130 }
131
132 /**
133 * Get the height of the physical texture
134 *
135 * @return The height of physical texture
136 */
137 public float getHeight() {
138 return heightRatio;
139 }
140
141 /**
142 * Get the width of the physical texture
143 *
144 * @return The width of physical texture
145 */
146 public float getWidth() {
147 return widthRatio;
148 }
149
150 /**
151 * Set the height of this texture
152 *
153 * @param texHeight The height of the texture
154 */
155 public void setTextureHeight(int texHeight) {
156 this.texHeight = texHeight;
157 setHeight();
158 }
159
160 /**
161 * Set the width of this texture
162 *
163 * @param texWidth The width of the texture
164 */
165 public void setTextureWidth(int texWidth) {
166 this.texWidth = texWidth;
167 setWidth();
168 }
169
170 /**
171 * Set the height of the texture. This will update the
172 * ratio also.
173 */
174 private void setHeight() {
175 if (texHeight != 0) {
176 heightRatio = ((float) height) / texHeight;
177 }
178 }
179
180 /**
181 * Set the width of the texture. This will update the
182 * ratio also.
183 */
184 private void setWidth() {
185 if (texWidth != 0) {
186 widthRatio = ((float) width) / texWidth;
187 }
188 }
189 }
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.examples.spaceinvaders;
32
33 import java.awt.Color;
34 import java.awt.Graphics;
35 import java.awt.color.ColorSpace;
36 import java.awt.image.BufferedImage;
37 import java.awt.image.ColorModel;
38 import java.awt.image.ComponentColorModel;
39 import java.awt.image.DataBuffer;
40 import java.awt.image.DataBufferByte;
41 import java.awt.image.Raster;
42 import java.awt.image.WritableRaster;
43 import java.io.BufferedInputStream;
44 import java.io.IOException;
45 import java.net.URL;
46 import java.nio.ByteBuffer;
47 import java.nio.ByteOrder;
48 import java.nio.IntBuffer;
49 import java.util.HashMap;
50 import java.util.Hashtable;
51
52 import javax.imageio.ImageIO;
53
54 import org.lwjgl.BufferUtils;
55 import org.lwjgl.opengl.GL11;
56
57 /**
58 * A utility class to load textures for OpenGL. This source is based
59 * on a texture that can be found in the Java Gaming (www.javagaming.org)
60 * Wiki. It has been simplified slightly for explicit 2D graphics use.
61 *
62 * OpenGL uses a particular image format. Since the images that are
63 * loaded from disk may not match this format this loader introduces
64 * a intermediate image which the source image is copied into. In turn,
65 * this image is used as source for the OpenGL texture.
66 *
67 * @author Kevin Glass
68 * @author Brian Matzon
69 */
70 public class TextureLoader {
71 /** The table of textures that have been loaded in this loader */
72 private HashMap table = new HashMap();
73
74 /** The colour model including alpha for the GL image */
75 private ColorModel glAlphaColorModel;
76
77 /** The colour model for the GL image */
78 private ColorModel glColorModel;
79
80 /** Scratch buffer for texture ID's */
81 private IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1);
82
83 /**
84 * Create a new texture loader based on the game panel
85 *
86 * @param gl The GL content in which the textures should be loaded
87 */
88 public TextureLoader() {
89 glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
90 new int[] {8,8,8,8},
91 true,
92 false,
93 ComponentColorModel.TRANSLUCENT,
94 DataBuffer.TYPE_BYTE);
95
96 glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
97 new int[] {8,8,8,0},
98 false,
99 false,
100 ComponentColorModel.OPAQUE,
101 DataBuffer.TYPE_BYTE);
102 }
103
104 /**
105 * Create a new texture ID
106 *
107 * @return A new texture ID
108 */
109 private int createTextureID() {
110 GL11.glGenTextures(textureIDBuffer);
111 return textureIDBuffer.get(0);
112 }
113
114 /**
115 * Load a texture
116 *
117 * @param resourceName The location of the resource to load
118 * @return The loaded texture
119 * @throws IOException Indicates a failure to access the resource
120 */
121 public Texture getTexture(String resourceName) throws IOException {
122 Texture tex = (Texture) table.get(resourceName);
123
124 if (tex != null) {
125 return tex;
126 }
127
128 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
134 table.put(resourceName,tex);
135
136 return tex;
137 }
138
139 /**
140 * Load a texture into OpenGL from a image reference on
141 * disk.
142 *
143 * @param resourceName The location of the resource to load
144 * @param target The GL target to load the texture against
145 * @param dstPixelFormat The pixel format of the screen
146 * @param minFilter The minimising filter
147 * @param magFilter The magnification filter
148 * @return The loaded texture
149 * @throws IOException Indicates a failure to access the resource
150 */
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);
166 texture.setWidth(bufferedImage.getWidth());
167 texture.setHeight(bufferedImage.getHeight());
168
169 if (bufferedImage.getColorModel().hasAlpha()) {
170 srcPixelFormat = GL11.GL_RGBA;
171 } 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
183 // 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
197 /**
198 * Get the closest greater power of 2 to the fold number
199 *
200 * @param fold The target number
201 * @return The power of 2
202 */
203 private int get2Fold(int fold) {
204 int ret = 2;
205 while (ret < fold) {
206 ret *= 2;
207 }
208 return ret;
209 }
210
211 /**
212 * Convert the buffered image to a texture
213 *
214 * @param bufferedImage The image to convert to a texture
215 * @param texture The texture to store the data into
216 * @return A buffer containing the data
217 */
218 private ByteBuffer convertImageData(BufferedImage bufferedImage,Texture texture) {
219 ByteBuffer imageBuffer = null;
220 WritableRaster raster;
221 BufferedImage texImage;
222
223 int texWidth = 2;
224 int texHeight = 2;
225
226 // find the closest power of 2 for the width and height
227 // of the produced texture
228 while (texWidth < bufferedImage.getWidth()) {
229 texWidth *= 2;
230 }
231 while (texHeight < bufferedImage.getHeight()) {
232 texHeight *= 2;
233 }
234
235 texture.setTextureHeight(texHeight);
236 texture.setTextureWidth(texWidth);
237
238 // create a raster that can be used by OpenGL as a source
239 // for a texture
240 if (bufferedImage.getColorModel().hasAlpha()) {
241 raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,4,null);
242 texImage = new BufferedImage(glAlphaColorModel,raster,false,new Hashtable());
243 } else {
244 raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,3,null);
245 texImage = new BufferedImage(glColorModel,raster,false,new Hashtable());
246 }
247
248 // copy the source image into the produced image
249 Graphics g = texImage.getGraphics();
250 g.setColor(new Color(0f,0f,0f,0f));
251 g.fillRect(0,0,texWidth,texHeight);
252 g.drawImage(bufferedImage,0,0,null);
253
254 // build a byte buffer from the temporary image
255 // 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);
261 imageBuffer.flip();
262
263 return imageBuffer;
264 }
265
266 /**
267 * Load a given resource as a buffered image
268 *
269 * @param ref The location of the resource to load
270 * @return The loaded buffered image
271 * @throws IOException Indicates a failure to find a resource
272 */
273 private BufferedImage loadImage(String ref) throws IOException {
274 URL url = TextureLoader.class.getClassLoader().getResource(ref);
275
276 if (url == null) {
277 throw new IOException("Cannot find: " + ref);
278 }
279
280 BufferedImage bufferedImage = ImageIO.read(new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(ref)));
281
282 return bufferedImage;
283 }
284 }
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.input;
32
33 /**
34 * A game controller of some sort that will provide input. The controller
35 * presents buttons and axes. Buttons are either pressed or not pressed. Axis
36 * provide analogue values.
37 *
38 * @author Kevin Glass
39 */
40 public interface Controller {
41 /**
42 * Get the name assigned to this controller.
43 *
44 * @return The name assigned to this controller
45 */
46 public String getName();
47
48 /**
49 * Get the index of this controller in the collection
50 *
51 * @return The index of this controller in the collection
52 */
53 public int getIndex();
54
55 /**
56 * Retrieve the number of buttons available on this controller
57 *
58 * @return The number of butotns available on this controller
59 */
60 public int getButtonCount();
61
62 /**
63 * Get the name of the specified button. Be warned, often this is
64 * as exciting as "Button X"
65 *
66 * @param index The index of the button whose name should be retrieved
67 * @return The name of the button requested
68 */
69 public String getButtonName(int index);
70
71 /**
72 * Check if a button is currently pressed
73 *
74 * @param index The button to check
75 * @return True if the button is currently pressed
76 */
77 public boolean isButtonPressed(int index);
78
79 /**
80 * Poll the controller for new data. This will also update
81 * events
82 */
83 public void poll();
84
85 /**
86 * Get the X-Axis value of the POV on this controller
87 *
88 * @return The X-Axis value of the POV on this controller
89 */
90 public float getPovX();
91
92 /**
93 * Get the Y-Axis value of the POV on this controller
94 *
95 * @return The Y-Axis value of the POV on this controller
96 */
97 public float getPovY();
98
99 /**
100 * Get the dead zone for a specified axis
101 *
102 * @param index The index of the axis for which to retrieve the dead zone
103 * @return The dead zone for the specified axis
104 */
105 public float getDeadZone(int index);
106
107 /**
108 * Set the dead zone for the specified axis
109 *
110 * @param index The index of hte axis for which to set the dead zone
111 * @param zone The dead zone to use for the specified axis
112 */
113 public void setDeadZone(int index,float zone);
114
115 /**
116 * Retrieve the number of axes available on this controller.
117 *
118 * @return The number of axes available on this controller.
119 */
120 public int getAxisCount();
121
122 /**
123 * Get the name that's given to the specified axis
124 *
125 * @param index The index of the axis whose name should be retrieved
126 * @return The name of the specified axis.
127 */
128 public String getAxisName(int index);
129
130 /**
131 * Retrieve the value thats currently available on a specified axis. The
132 * value will always be between 1.0 and -1.0 and will calibrate as values
133 * 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 *
136 * @param index The index of axis to be read
137 * @return The value from the specified axis.
138 */
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 *
145 * @return The value from the X axis
146 */
147 public float getXAxisValue();
148
149 /**
150 * Get the dead zone for the X axis.
151 *
152 * @return The dead zone for the X axis
153 */
154 public float getXAxisDeadZone();
155
156 /**
157 * Set the dead zone for the X axis
158 *
159 * @param zone The dead zone to use for the X axis
160 */
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 *
167 * @return The value from the Y axis
168 */
169 public float getYAxisValue();
170
171 /**
172 * Get the dead zone for the Y axis.
173 *
174 * @return The dead zone for the Y axis
175 */
176 public float getYAxisDeadZone();
177
178 /**
179 * Set the dead zone for the Y axis
180 *
181 * @param zone The dead zone to use for the Y axis
182 */
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 *
189 * @return The value from the Z axis
190 */
191 public float getZAxisValue();
192
193 /**
194 * Get the dead zone for the Z axis.
195 *
196 * @return The dead zone for the Z axis
197 */
198 public float getZAxisDeadZone();
199
200 /**
201 * Set the dead zone for the Z axis
202 *
203 * @param zone The dead zone to use for the Z axis
204 */
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 *
211 * @return The value from the RX axis
212 */
213 public float getRXAxisValue();
214
215 /**
216 * Get the dead zone for the RX axis.
217 *
218 * @return The dead zone for the RX axis
219 */
220 public float getRXAxisDeadZone();
221
222 /**
223 * Set the dead zone for the RX axis
224 *
225 * @param zone The dead zone to use for the RX axis
226 */
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 *
233 * @return The value from the RY axis
234 */
235 public float getRYAxisValue();
236
237 /**
238 * Get the dead zone for the RY axis.
239 *
240 * @return The dead zone for the RY axis
241 */
242 public float getRYAxisDeadZone();
243
244 /**
245 * Set the dead zone for the RY axis
246 *
247 * @param zone The dead zone to use for the RY axis
248 */
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 *
255 * @return The value from the RZ axis
256 */
257 public float getRZAxisValue();
258
259 /**
260 * Get the dead zone for the RZ axis.
261 *
262 * @return The dead zone for the RZ axis
263 */
264 public float getRZAxisDeadZone();
265
266 /**
267 * Set the dead zone for the RZ axis
268 *
269 * @param zone The dead zone to use for the RZ axis
270 */
271 public void setRZAxisDeadZone(float zone);
272 }
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.input;
32
33 /**
34 * An event occuring on a controller.
35 *
36 * @author Kevin Glass
37 */
38 class ControllerEvent {
39 /** Indicates the event was caused by a button */
40 public static final int BUTTON = 1;
41 /** Indicates the event was caused by a axis */
42 public static final int AXIS = 2;
43 /** Indicates the event was caused by a pov X */
44 public static final int POVX = 3;
45 /** Indicates the event was caused by a pov Y */
46 public static final int POVY = 4;
47
48 /** The controller generating the event */
49 private Controller source;
50 /** The index of the input (axis or button) that generated the event */
51 private int index;
52 /** Type of control that generated the event */
53 private int type;
54 /** True if this event was caused by the x axis */
55 private boolean xaxis;
56 /** True if this event was caused by the y axis */
57 private boolean yaxis;
58 /** The time stamp of this event */
59 private long timeStamp;
60
61 /**
62 * Create a new event
63 *
64 * @param source The source of the event
65 * @param timeStamp The time stamp given for this event
66 * @param type The type of control generating this event
67 * @param index The index of the input that generated the event
68 * @param xaxis True if this event was caused by the x-axis
69 * @param yaxis True if this event was caused by the y-axis
70 */
71 public ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
72 this.source = source;
73 this.timeStamp = timeStamp;
74 this.type = type;
75 this.index = index;
76 this.xaxis = xaxis;
77 this.yaxis = yaxis;
78 }
79
80 /**
81 * Get the time stamp given for this event. As with nanoTime()
82 * this value means nothing other than giving ordering
83 *
84 * @return The time stamp given for this event
85 */
86 public long getTimeStamp() {
87 return timeStamp;
88 }
89
90 /**
91 * Get the controller that generated this event
92 *
93 * @return The controller that generated this event
94 */
95 public Controller getSource() {
96 return source;
97 }
98
99 /**
100 * Get the index of the control generating this event
101 *
102 * @return The index of the control generating this event
103 */
104 public int getControlIndex() {
105 return index;
106 }
107
108 /**
109 * Check if this event was generated by a button
110 *
111 * @return True if this event was generated by a button
112 */
113 public boolean isButton() {
114 return type == BUTTON;
115 }
116
117 /**
118 * Check if this event was generated by a axis
119 *
120 * @return True if this event was generated by a axis
121 */
122 public boolean isAxis() {
123 return type == AXIS;
124 }
125
126 /**
127 * Check if this event was generated by a pov
128 *
129 * @return True if this event was generated by a pov
130 */
131 public boolean isPovY() {
132 return type == POVY;
133 }
134 /**
135 *
136 * Check if this event was generated by a pov
137 *
138 * @return True if this event was generated by a pov
139 */
140 public boolean isPovX() {
141 return type == POVX;
142 }
143
144 /**
145 * Check if this event was caused by the X axis
146 *
147 * @return True if this event was caused by the X axis
148 */
149 public boolean isXAxis() {
150 return xaxis;
151 }
152
153 /**
154 * Check if this event was caused by the Y axis
155 *
156 * @return True if this event was caused by the Y axis
157 */
158 public boolean isYAxis() {
159 return yaxis;
160 }
161
162 /*
163 * @see java.lang.Object#toString()
164 */
165 public String toString() {
166 return "["+source+" type="+type+" xaxis="+xaxis+" yaxis="+yaxis+"]";
167 }
168 }
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.input;
32
33 import java.util.ArrayList;
34
35 import net.java.games.input.ControllerEnvironment;
36
37 import org.lwjgl.LWJGLException;
38
39 /**
40 * The collection of controllers currently connected.
41 *
42 * @author Kevin Glass
43 */
44 public class Controllers {
45 /** The controllers available */
46 private static ArrayList controllers = new ArrayList();
47 /** The number of controllers */
48 private static int controllerCount;
49
50 /** The current list of events */
51 private static ArrayList events = new ArrayList();
52 /** The current event */
53 private static ControllerEvent event;
54
55 /** Whether controllers were created */
56 private static boolean created;
57
58 /**
59 * Initialise the controllers collection
60 *
61 * @throws LWJGLException Indicates a failure to initialise the controller library.
62 */
63 public static void create() throws LWJGLException {
64 if (created)
65 return;
66
67 try {
68 ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();
69
70 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))) {
77 lollers.add(c);
78 }
79 }
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
86 createController(c);
87 }
88
89 created = true;
90 } catch (Throwable e) {
91 throw new LWJGLException("Failed to initialise controllers",e);
92 }
93 }
94
95 /**
96 * Utility to create a controller based on its potential sub-controllers
97 *
98 * @param c The controller to add
99 */
100 private static void createController(net.java.games.input.Controller c) {
101 net.java.games.input.Controller[] sub = c.getControllers();
102 if (sub.length == 0) {
103 JInputController controller = new JInputController(controllerCount,c);
104
105 controllers.add(controller);
106 controllerCount++;
107 } else {
108 for (int i=0;i<sub.length;i++) {
109 createController(sub[i]);
110 }
111 }
112 }
113
114 /**
115 * Get a controller from the collection
116 *
117 * @param index The index of the controller to retrieve
118 * @return The controller requested
119 */
120 public static Controller getController(int index) {
121 return (Controller) controllers.get(index);
122 }
123
124 /**
125 * Retrieve a count of the number of controllers
126 *
127 * @return The number of controllers available
128 */
129 public static int getControllerCount() {
130 return controllers.size();
131 }
132
133 /**
134 * Poll the controllers available. This will both update their state
135 * and generate events that must be cleared.
136 */
137 public static void poll() {
138 for (int i=0;i<controllers.size();i++) {
139 getController(i).poll();
140 }
141 }
142
143 /**
144 * Clear any events stored for the controllers in this set
145 */
146 public static void clearEvents() {
147 events.clear();
148 }
149
150 /**
151 * Move to the next event that has been stored.
152 *
153 * @return True if there is still an event to process
154 */
155 public static boolean next() {
156 if (events.size() == 0) {
157 event = null;
158 return false;
159 }
160
161 event = (ControllerEvent) events.remove(0);
162
163 return event != null;
164 }
165
166 /**
167 * @return True if Controllers has been created
168 */
169 public static boolean isCreated() {
170 return created;
171 }
172
173 /**
174 * Destroys any resources used by the controllers
175 */
176 public static void destroy() {
177 // FIXME! not currently possible to destroy a controller
178
179 // if (!created)
180 // return;
181 // created = false;
182 //
183 // // nuke each controller
184 // for (int i=0;i<controllers.size();i++) {
185 // //
186 // }
187 //
188 // // cleanup
189 // event = null;
190 // events.clear();
191 // controllers.clear();
192 // controllerCount = 0;
193 }
194
195 /**
196 * Get the source of the current event
197 *
198 * @return The source of the current event
199 */
200 public static Controller getEventSource() {
201 return event.getSource();
202 }
203
204 /**
205 * Get the index of the control that caused the current event
206 *
207 * @return The index of the control that cause the current event
208 */
209 public static int getEventControlIndex() {
210 return event.getControlIndex();
211 }
212
213 /**
214 * Check if the current event was caused by a button
215 *
216 * @return True if the current event was caused by a button
217 */
218 public static boolean isEventButton() {
219 return event.isButton();
220 }
221
222 /**
223 * Check if the current event was caused by a axis
224 *
225 * @return True if the current event was caused by a axis
226 */
227 public static boolean isEventAxis() {
228 return event.isAxis();
229 }
230
231 /**
232 * Check if the current event was caused by movement on the x-axis
233 *
234 * @return True if the current event was cause by movement on the x-axis
235 */
236 public static boolean isEventXAxis() {
237 return event.isXAxis();
238 }
239
240 /**
241 * Check if the current event was caused by movement on the y-axis
242 *
243 * @return True if the current event was caused by movement on the y-axis
244 */
245 public static boolean isEventYAxis() {
246 return event.isYAxis();
247 }
248
249 /**
250 * Check if the current event was cause by the POV x-axis
251 *
252 * @return True if the current event was caused by the POV x-axis
253 */
254 public static boolean isEventPovX() {
255 return event.isPovX();
256 }
257
258 /**
259 * Check if the current event was cause by the POV x-axis
260 *
261 * @return True if the current event was caused by the POV x-axis
262 */
263 public static boolean isEventPovY() {
264 return event.isPovY();
265 }
266
267 /**
268 * Get the timestamp assigned to the current event
269 *
270 * @return The timestamp assigned ot the current event
271 */
272 public static long getEventNanoseconds() {
273 return event.getTimeStamp();
274 }
275
276 /**
277 * Add an event to the stack of events that have been caused
278 *
279 * @param event The event to add to the list
280 */
281 static void addEvent(ControllerEvent event) {
282 if (event != null) {
283 events.add(event);
284 }
285 }
286 }
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.input;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.LWJGLUtil;
38 import org.lwjgl.NondirectBufferWrapper;
39 import org.lwjgl.Sys;
40
41 /**
42 *
43 * A class representing a native cursor. Instances of this
44 * class can be used with Mouse.setCursor(), if available.
45 *
46 * @author elias_naur <elias_naur@users.sourceforge.net>
47 * @version $Revision: 2983 $
48 * $Id: Cursor.java 2983 2008-04-07 18:36:09Z matzon $
49 */
50
51 public class Cursor {
52 /** 1 bit transparency for native cursor */
53 public static final int CURSOR_ONE_BIT_TRANSPARENCY = 1;
54
55 /** 8 bit alhpa native cursor */
56 public static final int CURSOR_8_BIT_ALPHA = 2;
57
58 /** animation native cursor */
59 public static final int CURSOR_ANIMATION = 4;
60
61 /** First element to display */
62 private final CursorElement[] cursors;
63
64 /** Index into list of cursors */
65 private int index = 0;
66
67 private boolean destroyed;
68
69 /**
70 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
71 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
72 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
73 * The constructor will copy the images and delays, so there's no need to keep them around.
74 *
75 * @param width cursor image width
76 * @param height cursor image height
77 * @param xHotspot the x coordinate of the cursor hotspot
78 * @param yHotspot the y coordinate of the cursor hotspot
79 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
80 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
81 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
82 * @throws LWJGLException if the cursor could not be created for any reason
83 */
84 public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
85 synchronized (OpenGLPackageAccess.global_lock) {
86 if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
87 throw new LWJGLException("Native cursors not supported");
88 images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
89 if (delays != null)
90 delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
91 if (!Mouse.isCreated())
92 throw new IllegalStateException("Mouse must be created before creating cursor objects");
93 if (width*height*numImages > images.remaining())
94 throw new IllegalArgumentException("width*height*numImages > images.remaining()");
95 if (xHotspot >= width || xHotspot < 0)
96 throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
97 if (yHotspot >= height || yHotspot < 0)
98 throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");
99
100 Sys.initialize();
101
102 // Hmm
103 yHotspot = height - 1 - yHotspot;
104
105 // create cursor (or cursors if multiple images supplied)
106 cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
107 }
108 }
109
110 /**
111 * Gets the minimum size of a native cursor. Can only be called if
112 * The Mouse is created and cursor caps includes at least
113 * CURSOR_ONE_BIT_TRANSPARANCY.
114 *
115 * @return the maximum size of a native cursor
116 */
117 public static int getMinCursorSize() {
118 synchronized (OpenGLPackageAccess.global_lock) {
119 if (!Mouse.isCreated())
120 throw new IllegalStateException("Mouse must be created.");
121 return Mouse.getImplementation().getMinCursorSize();
122 }
123 }
124
125 /**
126 * Gets the maximum size of a native cursor. Can only be called if
127 * The Mouse is created and cursor caps includes at least
128 * CURSOR_ONE_BIT_TRANSPARANCY.
129 *
130 * @return the maximum size of a native cursor
131 */
132 public static int getMaxCursorSize() {
133 synchronized (OpenGLPackageAccess.global_lock) {
134 if (!Mouse.isCreated())
135 throw new IllegalStateException("Mouse must be created.");
136 return Mouse.getImplementation().getMaxCursorSize();
137 }
138 }
139
140 /**
141 * Get the capabilities of the native cursor. Return a bit mask of the native cursor capabilities.
142 * The CURSOR_ONE_BIT_TRANSPARANCY indicates support for cursors with one bit transparancy,
143 * the CURSOR_8_BIT_ALPHA indicates support for 8 bit alpha and CURSOR_ANIMATION indicates
144 * support for cursor animations.
145 *
146 * @return A bit mask with native cursor capabilities.
147 */
148 public static int getCapabilities() {
149 synchronized (OpenGLPackageAccess.global_lock) {
150 if (Mouse.getImplementation() != null)
151 return Mouse.getImplementation().getNativeCursorCapabilities();
152 else
153 return OpenGLPackageAccess.createImplementation().getNativeCursorCapabilities();
154 }
155 }
156
157 /**
158 * Creates the actual cursor, using a platform specific class
159 */
160 private static CursorElement[] createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
161 // create copy and flip images to match ogl
162 IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
163 flipImages(width, height, numImages, images, images_copy);
164
165 // Win32 doesn't (afaik) allow for animation based cursors, except when they're
166 // in the .ani format, which we don't support.
167 // The cursor animation was therefor developed using java side time tracking.
168 // unfortunately X flickers when changing cursor. We therefore check for either
169 // Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
170 // might want to split it into a X/Win/Mac cursor if it gets too cluttered
171
172 CursorElement[] cursors;
173 switch (LWJGLUtil.getPlatform()) {
174 case LWJGLUtil.PLATFORM_MACOSX:
175 /* Fall through */
176 case LWJGLUtil.PLATFORM_WINDOWS:
177 // create our cursor elements
178 cursors = new CursorElement[numImages];
179 for(int i=0; i<numImages; i++) {
180
181 // iterate through the images, and make sure that the pixels are either 0xffxxxxxx or 0x00000000
182 int size = width * height;
183 for(int j=0; j<size; j++) {
184 int index = j + (i*size);
185 int alpha = images_copy.get(index) >> 24 & 0xff;
186 if(alpha != 0xff) {
187 images_copy.put(index, 0);
188 }
189 }
190
191 Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
192 long delay = (delays != null) ? delays.get(i) : 0;
193 long timeout = System.currentTimeMillis();
194 cursors[i] = new CursorElement(handle, delay, timeout);
195
196 // offset to next image
197 images_copy.position(width*height*(i+1));
198 }
199 break;
200 case LWJGLUtil.PLATFORM_LINUX:
201 // create our cursor elements
202 Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, numImages, images_copy, delays);
203 CursorElement cursor_element = new CursorElement(handle, -1, -1);
204 cursors = new CursorElement[]{cursor_element};
205 break;
206 default:
207 throw new RuntimeException("Unknown OS");
208 }
209 return cursors;
210 }
211
212 /**
213 * Flips the images so they're oriented according to opengl
214 *
215 * @param width Width of image
216 * @param height Height of images
217 * @param numImages How many images to flip
218 * @param images Source images
219 * @param images_copy Destination images
220 */
221 private static void flipImages(int width, int height, int numImages, IntBuffer images, IntBuffer images_copy) {
222 for (int i = 0; i < numImages; i++) {
223 int start_index = i*width*height;
224 flipImage(width, height, start_index, images, images_copy);
225 }
226 }
227
228 /**
229 * @param width Width of image
230 * @param height Height of images
231 * @param start_index index into source buffer to copy to
232 * @param images Source images
233 * @param images_copy Destination images
234 */
235 private static void flipImage(int width, int height, int start_index, IntBuffer images, IntBuffer images_copy) {
236 for (int y = 0; y < height>>1; y++) {
237 int index_y_1 = y*width + start_index;
238 int index_y_2 = (height - y - 1)*width + start_index;
239 for (int x = 0; x < width; x++) {
240 int index1 = index_y_1 + x;
241 int index2 = index_y_2 + x;
242 int temp_pixel = images.get(index1 + images.position());
243 images_copy.put(index1, images.get(index2 + images.position()));
244 images_copy.put(index2, temp_pixel);
245 }
246 }
247 }
248
249 /**
250 * Gets the native handle associated with the cursor object.
251 */
252 Object getHandle() {
253 checkValid();
254 return cursors[index].cursorHandle;
255 }
256
257 private void checkValid() {
258 if (destroyed)
259 throw new IllegalStateException("The cursor is destroyed");
260 }
261
262 /**
263 * Destroy the native cursor. If the cursor is current,
264 * the current native cursor is set to null (the default
265 * OS cursor)
266 */
267 public void destroy() {
268 synchronized (OpenGLPackageAccess.global_lock) {
269 if (destroyed)
270 return;
271 if (Mouse.getNativeCursor() == this) {
272 try {
273 Mouse.setNativeCursor(null);
274 } catch (LWJGLException e) {
275 // ignore
276 }
277 }
278 for(int i=0; i<cursors.length; i++) {
279 Mouse.getImplementation().destroyCursor(cursors[i].cursorHandle);
280 }
281 destroyed = true;
282 }
283 }
284
285 /**
286 * Sets the timout property to the time it should be changed
287 */
288 protected void setTimeout() {
289 checkValid();
290 cursors[index].timeout = System.currentTimeMillis() + cursors[index].delay;
291 }
292
293 /**
294 * Determines whether this cursor has timed out
295 * @return true if the this cursor has timed out, false if not
296 */
297 protected boolean hasTimedOut() {
298 checkValid();
299 return cursors.length > 1 && cursors[index].timeout < System.currentTimeMillis();
300 }
301
302 /**
303 * Changes to the next cursor
304 */
305 protected void nextCursor() {
306 checkValid();
307 index = ++index % cursors.length;
308 }
309
310 /**
311 * A single cursor element, used when animating
312 */
313 private static class CursorElement {
314 /** Handle to cursor */
315 final Object cursorHandle;
316
317 /** How long a delay this element should have */
318 final long delay;
319
320 /** Absolute time this element times out */
321 long timeout;
322
323 CursorElement(Object cursorHandle, long delay, long timeout) {
324 this.cursorHandle = cursorHandle;
325 this.delay = delay;
326 this.timeout = timeout;
327 }
328 }
329 }
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.input;
32
33 import java.util.ArrayList;
34
35 import net.java.games.input.Component;
36 import net.java.games.input.Event;
37 import net.java.games.input.EventQueue;
38
39 /**
40 * A wrapper round a JInput controller that attempts to make the interface
41 * more useable.
42 *
43 * @author Kevin Glass
44 */
45 class JInputController implements Controller {
46 /** The JInput controller this class is wrapping */
47 private net.java.games.input.Controller target;
48 /** The index that has been assigned to this controller */
49 private int index;
50 /** The Buttons that have been detected on the JInput controller */
51 private ArrayList buttons = new ArrayList();
52 /** The Axes that have been detected on the JInput controller */
53 private ArrayList axes = new ArrayList();
54 /** The POVs that have been detected on the JInput controller */
55 private ArrayList pov = new ArrayList();
56 /** The state of the buttons last check */
57 private boolean[] buttonState;
58 /** The values that were read from the pov last check */
59 private float[] povValues;
60 /** The values that were read from the axes last check */
61 private float[] axesValue;
62 /** The maximum values read for each axis */
63 private float[] axesMax;
64 /** The dead zones for each axis */
65 private float[] deadZones;
66 /** The index of the X axis or -1 if no X axis is defined */
67 private int xaxis = -1;
68 /** The index of the Y axis or -1 if no Y axis is defined */
69 private int yaxis = -1;
70 /** The index of the X axis or -1 if no Z axis is defined */
71 private int zaxis = -1;
72 /** The index of the RX axis or -1 if no RX axis is defined */
73 private int rxaxis = -1;
74 /** The index of the RY axis or -1 if no RY axis is defined */
75 private int ryaxis = -1;
76 /** The index of the RZ axis or -1 if no RZ axis is defined */
77 private int rzaxis = -1;
78
79 /**
80 * Create a new controller that wraps round a JInput controller and hopefully
81 * makes it easier to use.
82 *
83 * @param index The index this controller has been assigned to
84 * @param target The target JInput controller this class is wrapping
85 */
86 public JInputController(int index,net.java.games.input.Controller target) {
87 this.target = target;
88 this.index = index;
89
90 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]);
97 } else {
98 axes.add(sourceAxes[i]);
99 }
100 }
101
102 buttonState = new boolean[buttons.size()];
103 povValues = new float[pov.size()];
104 axesValue = new float[axes.size()];
105 int buttonsCount = 0;
106 int axesCount = 0;
107
108 // 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;
112 buttonsCount++;
113 } else if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.POV)) {
114 // no account for POV yet
115 // pov.add(sourceAxes[i]);
116 } else {
117 axesValue[axesCount] = sourceAxes[i].getPollData();
118 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.X)) {
119 xaxis = axesCount;
120 }
121 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.Y)) {
122 yaxis = axesCount;
123 }
124 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.Z)) {
125 zaxis = axesCount;
126 }
127 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RX)) {
128 rxaxis = axesCount;
129 }
130 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RY)) {
131 ryaxis = axesCount;
132 }
133 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RZ)) {
134 rzaxis = axesCount;
135 }
136
137 axesCount++;
138 }
139 }
140
141 axesMax = new float[axes.size()];
142 deadZones = new float[axes.size()];
143
144 for (int i=0;i<axesMax.length;i++) {
145 axesMax[i] = 1.0f;
146 deadZones[i] = 0.05f;
147 }
148 }
149
150 /*
151 * @see org.lwjgl.input.Controller#getName()
152 */
153 public String getName() {
154 String name = target.getName();
155 return name;
156 }
157
158 /*
159 * @see org.lwjgl.input.Controller#getIndex()
160 */
161 public int getIndex() {
162 return index;
163 }
164
165 /*
166 * @see org.lwjgl.input.Controller#getButtonCount()
167 */
168 public int getButtonCount() {
169 return buttons.size();
170 }
171
172 /*
173 * @see org.lwjgl.input.Controller#getButtonName(int)
174 */
175 public String getButtonName(int index) {
176 Component button = (Component) buttons.get(index);
177
178 return button.getName();
179 }
180
181 /*
182 * @see org.lwjgl.input.Controller#isButtonPressed(int)
183 */
184 public boolean isButtonPressed(int index) {
185 return buttonState[index];
186 }
187
188 /*
189 * @see org.lwjgl.input.Controller#poll()
190 */
191 public void poll() {
192 target.poll();
193
194 Event event = new Event();
195 EventQueue queue = target.getEventQueue();
196
197 while (queue.getNextEvent(event)) {
198 // handle button event
199 if (buttons.contains(event.getComponent())) {
200 Component button = event.getComponent();
201 int buttonIndex = buttons.indexOf(button);
202 buttonState[buttonIndex] = event.getValue() != 0;
203
204 // fire button pressed event
205 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
206 }
207
208 // handle pov events
209 if (pov.contains(event.getComponent())) {
210 Component povComponent = event.getComponent();
211 int povIndex = pov.indexOf(povComponent);
212 float prevX = getPovX();
213 float prevY = getPovY();
214 povValues[povIndex] = event.getValue();
215
216 if (prevX != getPovX()) {
217 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
218 }
219 if (prevY != getPovY()) {
220 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
221 }
222 }
223
224 // handle axis updates
225 if (axes.contains(event.getComponent())) {
226 Component axis = event.getComponent();
227 int axisIndex = axes.indexOf(axis);
228 float value = axis.getPollData();
229
230 // fixed dead zone since most axis don't report it :(
231 if (Math.abs(value) < deadZones[axisIndex]) {
232 value = 0;
233 }
234 if (Math.abs(value) < axis.getDeadZone()) {
235 value = 0;
236 }
237 if (Math.abs(value) > axesMax[axisIndex]) {
238 axesMax[axisIndex] = Math.abs(value);
239 }
240
241 // normalize the value based on maximum value read in the past
242 value /= axesMax[axisIndex];
243 // fire event
244 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
245 axisIndex == xaxis,axisIndex == yaxis));
246 axesValue[axisIndex] = value;
247 }
248 }
249 }
250
251 /*
252 * @see org.lwjgl.input.Controller#getAxisCount()
253 */
254 public int getAxisCount() {
255 return axes.size();
256 }
257
258 /*
259 * @see org.lwjgl.input.Controller#getAxisName(int)
260 */
261 public String getAxisName(int index) {
262 Component axis = (Component) axes.get(index);
263
264 return axis.getName();
265 }
266
267 /*
268 * @see org.lwjgl.input.Controller#getAxisValue(int)
269 */
270 public float getAxisValue(int index) {
271 return axesValue[index];
272 }
273
274 /*
275 * @see org.lwjgl.input.Controller#getXAxisValue()
276 */
277 public float getXAxisValue() {
278 if (xaxis == -1) {
279 return 0;
280 }
281
282 return getAxisValue(xaxis);
283 }
284
285 /*
286 * @see org.lwjgl.input.Controller#getYAxisValue()
287 */
288 public float getYAxisValue() {
289 if (yaxis == -1) {
290 return 0;
291 }
292
293 return getAxisValue(yaxis);
294 }
295
296 /*
297 * @see org.lwjgl.input.Controller#getXAxisDeadZone()
298 */
299 public float getXAxisDeadZone() {
300 if (xaxis == -1) {
301 return 0;
302 }
303
304 return getDeadZone(xaxis);
305 }
306
307 /*
308 * @see org.lwjgl.input.Controller#getYAxisDeadZone()
309 */
310 public float getYAxisDeadZone() {
311 if (yaxis == -1) {
312 return 0;
313 }
314
315 return getDeadZone(yaxis);
316 }
317
318 /*
319 * @see org.lwjgl.input.Controller#setXAxisDeadZone(float)
320 */
321 public void setXAxisDeadZone(float zone) {
322 setDeadZone(xaxis,zone);
323 }
324
325 /*
326 * @see org.lwjgl.input.Controller#setYAxisDeadZone(float)
327 */
328 public void setYAxisDeadZone(float zone) {
329 setDeadZone(yaxis,zone);
330 }
331
332 /*
333 * @see org.lwjgl.input.Controller#getDeadZone(int)
334 */
335 public float getDeadZone(int index) {
336 return deadZones[index];
337 }
338
339 /*
340 * @see org.lwjgl.input.Controller#setDeadZone(int, float)
341 */
342 public void setDeadZone(int index, float zone) {
343 deadZones[index] = zone;
344 }
345
346 /*
347 * @see org.lwjgl.input.Controller#getZAxisValue()
348 */
349 public float getZAxisValue() {
350 if (zaxis == -1) {
351 return 0;
352 }
353
354 return getAxisValue(zaxis);
355 }
356
357 /*
358 * @see org.lwjgl.input.Controller#getZAxisDeadZone()
359 */
360 public float getZAxisDeadZone() {
361 if (zaxis == -1) {
362 return 0;
363 }
364
365 return getDeadZone(zaxis);
366 }
367
368 /*
369 * @see org.lwjgl.input.Controller#setZAxisDeadZone(float)
370 */
371 public void setZAxisDeadZone(float zone) {
372 setDeadZone(zaxis,zone);
373 }
374
375 /*
376 * @see org.lwjgl.input.Controller#getRXAxisValue()
377 */
378 public float getRXAxisValue() {
379 if (rxaxis == -1) {
380 return 0;
381 }
382
383 return getAxisValue(rxaxis);
384 }
385
386 /*
387 * @see org.lwjgl.input.Controller#getRXAxisDeadZone()
388 */
389 public float getRXAxisDeadZone() {
390 if (rxaxis == -1) {
391 return 0;
392 }
393
394 return getDeadZone(rxaxis);
395 }
396
397 /*
398 * @see org.lwjgl.input.Controller#setRXAxisDeadZone(float)
399 */
400 public void setRXAxisDeadZone(float zone) {
401 setDeadZone(rxaxis,zone);
402 }
403
404 /*
405 * @see org.lwjgl.input.Controller#getRYAxisValue()
406 */
407 public float getRYAxisValue() {
408 if (ryaxis == -1) {
409 return 0;
410 }
411
412 return getAxisValue(ryaxis);
413 }
414
415 /*
416 * @see org.lwjgl.input.Controller#getRYAxisDeadZone()
417 */
418 public float getRYAxisDeadZone() {
419 if (ryaxis == -1) {
420 return 0;
421 }
422
423 return getDeadZone(ryaxis);
424 }
425
426 /*
427 * @see org.lwjgl.input.Controller#setRYAxisDeadZone(float)
428 */
429 public void setRYAxisDeadZone(float zone) {
430 setDeadZone(ryaxis,zone);
431 }
432
433 /*
434 * @see org.lwjgl.input.Controller#getRZAxisValue()
435 */
436 public float getRZAxisValue() {
437 if (rzaxis == -1) {
438 return 0;
439 }
440
441 return getAxisValue(rzaxis);
442 }
443
444 /*
445 * @see org.lwjgl.input.Controller#getRZAxisDeadZone()
446 */
447 public float getRZAxisDeadZone() {
448 if (rzaxis == -1) {
449 return 0;
450 }
451
452 return getDeadZone(rzaxis);
453 }
454
455 /*
456 * @see org.lwjgl.input.Controller#setRZAxisDeadZone(float)
457 */
458 public void setRZAxisDeadZone(float zone) {
459 setDeadZone(rzaxis,zone);
460 }
461
462 /*
463 * @see org.lwjgl.input.Controller#getPovX()
464 */
465 public float getPovX() {
466 if (pov.size() == 0) {
467 return 0;
468 }
469
470 float value = povValues[0];
471
472 if ((value == Component.POV.DOWN_LEFT) ||
473 (value == Component.POV.UP_LEFT) ||
474 (value == Component.POV.LEFT)) {
475 return -1;
476 }
477 if ((value == Component.POV.DOWN_RIGHT) ||
478 (value == Component.POV.UP_RIGHT) ||
479 (value == Component.POV.RIGHT)) {
480 return 1;
481 }
482
483 return 0;
484 }
485
486 /*
487 * @see org.lwjgl.input.Controller#getPovY()
488 */
489 public float getPovY() {
490 if (pov.size() == 0) {
491 return 0;
492 }
493
494 float value = povValues[0];
495
496 if ((value == Component.POV.DOWN_LEFT) ||
497 (value == Component.POV.DOWN_RIGHT) ||
498 (value == Component.POV.DOWN)) {
499 return 1;
500 }
501 if ((value == Component.POV.UP_LEFT) ||
502 (value == Component.POV.UP_RIGHT) ||
503 (value == Component.POV.UP)) {
504 return -1;
505 }
506
507 return 0;
508 }
509
510
511 }
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.input;
32
33 import java.lang.reflect.Field;
34 import java.lang.reflect.Modifier;
35 import java.nio.ByteBuffer;
36 import java.util.HashMap;
37 import java.util.Map;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.Sys;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.InputImplementation;
44
45 /**
46 * <br>
47 * A raw Keyboard interface. This can be used to poll the current state of the
48 * keys, or read all the keyboard presses / releases since the last read.
49 *
50 * @author cix_foo <cix_foo@users.sourceforge.net>
51 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 2983 $
54 * $Id: Keyboard.java 2983 2008-04-07 18:36:09Z matzon $
55 */
56 public class Keyboard {
57 /** Internal use - event size in bytes */
58 public static final int EVENT_SIZE = 4 + 1 + 4 + 8 + 1;
59
60 /**
61 * The special character meaning that no
62 * character was translated for the event.
63 */
64 public static final int CHAR_NONE = '\0';
65
66 /**
67 * The special keycode meaning that only the
68 * translated character is valid.
69 */
70 public static final int KEY_NONE = 0x00;
71
72 public static final int KEY_ESCAPE = 0x01;
73 public static final int KEY_1 = 0x02;
74 public static final int KEY_2 = 0x03;
75 public static final int KEY_3 = 0x04;
76 public static final int KEY_4 = 0x05;
77 public static final int KEY_5 = 0x06;
78 public static final int KEY_6 = 0x07;
79 public static final int KEY_7 = 0x08;
80 public static final int KEY_8 = 0x09;
81 public static final int KEY_9 = 0x0A;
82 public static final int KEY_0 = 0x0B;
83 public static final int KEY_MINUS = 0x0C; /* - on main keyboard */
84 public static final int KEY_EQUALS = 0x0D;
85 public static final int KEY_BACK = 0x0E; /* backspace */
86 public static final int KEY_TAB = 0x0F;
87 public static final int KEY_Q = 0x10;
88 public static final int KEY_W = 0x11;
89 public static final int KEY_E = 0x12;
90 public static final int KEY_R = 0x13;
91 public static final int KEY_T = 0x14;
92 public static final int KEY_Y = 0x15;
93 public static final int KEY_U = 0x16;
94 public static final int KEY_I = 0x17;
95 public static final int KEY_O = 0x18;
96 public static final int KEY_P = 0x19;
97 public static final int KEY_LBRACKET = 0x1A;
98 public static final int KEY_RBRACKET = 0x1B;
99 public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */
100 public static final int KEY_LCONTROL = 0x1D;
101 public static final int KEY_A = 0x1E;
102 public static final int KEY_S = 0x1F;
103 public static final int KEY_D = 0x20;
104 public static final int KEY_F = 0x21;
105 public static final int KEY_G = 0x22;
106 public static final int KEY_H = 0x23;
107 public static final int KEY_J = 0x24;
108 public static final int KEY_K = 0x25;
109 public static final int KEY_L = 0x26;
110 public static final int KEY_SEMICOLON = 0x27;
111 public static final int KEY_APOSTROPHE = 0x28;
112 public static final int KEY_GRAVE = 0x29; /* accent grave */
113 public static final int KEY_LSHIFT = 0x2A;
114 public static final int KEY_BACKSLASH = 0x2B;
115 public static final int KEY_Z = 0x2C;
116 public static final int KEY_X = 0x2D;
117 public static final int KEY_C = 0x2E;
118 public static final int KEY_V = 0x2F;
119 public static final int KEY_B = 0x30;
120 public static final int KEY_N = 0x31;
121 public static final int KEY_M = 0x32;
122 public static final int KEY_COMMA = 0x33;
123 public static final int KEY_PERIOD = 0x34; /* . on main keyboard */
124 public static final int KEY_SLASH = 0x35; /* / on main keyboard */
125 public static final int KEY_RSHIFT = 0x36;
126 public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */
127 public static final int KEY_LMENU = 0x38; /* left Alt */
128 public static final int KEY_SPACE = 0x39;
129 public static final int KEY_CAPITAL = 0x3A;
130 public static final int KEY_F1 = 0x3B;
131 public static final int KEY_F2 = 0x3C;
132 public static final int KEY_F3 = 0x3D;
133 public static final int KEY_F4 = 0x3E;
134 public static final int KEY_F5 = 0x3F;
135 public static final int KEY_F6 = 0x40;
136 public static final int KEY_F7 = 0x41;
137 public static final int KEY_F8 = 0x42;
138 public static final int KEY_F9 = 0x43;
139 public static final int KEY_F10 = 0x44;
140 public static final int KEY_NUMLOCK = 0x45;
141 public static final int KEY_SCROLL = 0x46; /* Scroll Lock */
142 public static final int KEY_NUMPAD7 = 0x47;
143 public static final int KEY_NUMPAD8 = 0x48;
144 public static final int KEY_NUMPAD9 = 0x49;
145 public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */
146 public static final int KEY_NUMPAD4 = 0x4B;
147 public static final int KEY_NUMPAD5 = 0x4C;
148 public static final int KEY_NUMPAD6 = 0x4D;
149 public static final int KEY_ADD = 0x4E; /* + on numeric keypad */
150 public static final int KEY_NUMPAD1 = 0x4F;
151 public static final int KEY_NUMPAD2 = 0x50;
152 public static final int KEY_NUMPAD3 = 0x51;
153 public static final int KEY_NUMPAD0 = 0x52;
154 public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */
155 public static final int KEY_F11 = 0x57;
156 public static final int KEY_F12 = 0x58;
157 public static final int KEY_F13 = 0x64; /* (NEC PC98) */
158 public static final int KEY_F14 = 0x65; /* (NEC PC98) */
159 public static final int KEY_F15 = 0x66; /* (NEC PC98) */
160 public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
161 public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
162 public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
163 public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
164 public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */
165 public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */
166 public static final int KEY_AT = 0x91; /* (NEC PC98) */
167 public static final int KEY_COLON = 0x92; /* (NEC PC98) */
168 public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */
169 public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */
170 public static final int KEY_STOP = 0x95; /* (NEC PC98) */
171 public static final int KEY_AX = 0x96; /* (Japan AX) */
172 public static final int KEY_UNLABELED = 0x97; /* (J3100) */
173 public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
174 public static final int KEY_RCONTROL = 0x9D;
175 public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
176 public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
177 public static final int KEY_SYSRQ = 0xB7;
178 public static final int KEY_RMENU = 0xB8; /* right Alt */
179 public static final int KEY_PAUSE = 0xC5; /* Pause */
180 public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
181 public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
182 public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */
183 public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */
184 public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */
185 public static final int KEY_END = 0xCF; /* End on arrow keypad */
186 public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */
187 public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
188 public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
189 public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
190 public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
191 /**
192 * The left windows key, mapped to KEY_LMETA
193 *
194 * @deprecated Use KEY_LMETA instead
195 */
196 public static final int KEY_LWIN = KEY_LMETA; /* Left Windows key */
197 public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */
198 /**
199 * The right windows key, mapped to KEY_RMETA
200 *
201 * @deprecated Use KEY_RMETA instead
202 */
203 public static final int KEY_RWIN = KEY_RMETA; /* Right Windows key */
204 public static final int KEY_APPS = 0xDD; /* AppMenu key */
205 public static final int KEY_POWER = 0xDE;
206 public static final int KEY_SLEEP = 0xDF;
207
208 /* public static final int STATE_ON = 0;
209 public static final int STATE_OFF = 1;
210 public static final int STATE_UNKNOWN = 2;
211 */
212 public static final int KEYBOARD_SIZE = 256;
213
214 /** Buffer size in events */
215 private static final int BUFFER_SIZE = 50;
216
217 /** Key names */
218 private static final String[] keyName = new String[255];
219 private static final Map keyMap = new HashMap(253);
220 private static int counter;
221
222 static {
223 // Use reflection to find out key names
224 Field[] field = Keyboard.class.getFields();
225 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);
235 keyName[key] = name;
236 keyMap.put(name, new Integer(key));
237 counter ++;
238 }
239
240 }
241 } catch (Exception e) {
242 }
243
244 }
245
246 /** The number of keys supported */
247 private static final int keyCount = counter;
248
249 /** Has the keyboard been created? */
250 private static boolean created;
251
252 /** Are repeat events enabled? */
253 private static boolean repeat_enabled;
254
255 /** The keys status from the last poll */
256 private static final ByteBuffer keyDownBuffer = BufferUtils.createByteBuffer(KEYBOARD_SIZE);
257
258 /**
259 * The key events from the last read: a sequence of pairs of key number,
260 * followed by state. The state is followed by
261 * a 4 byte code point representing the translated character.
262 */
263 private static ByteBuffer readBuffer;
264
265 /** current event */
266 private static KeyEvent current_event = new KeyEvent();
267
268 /** scratch event */
269 private static KeyEvent tmp_event = new KeyEvent();
270
271 /** One time initialization */
272 private static boolean initialized;
273
274 private static InputImplementation implementation;
275
276 /**
277 * Keyboard cannot be constructed.
278 */
279 private Keyboard() {
280 }
281
282 /**
283 * Static initialization
284 */
285 private static void initialize() {
286 if (initialized)
287 return;
288 Sys.initialize();
289 initialized = true;
290 }
291
292 /**
293 * "Create" the keyboard with the given implementation. This is used
294 * reflectively from AWTInputAdapter.
295 *
296 * @throws LWJGLException if the keyboard could not be created for any reason
297 */
298 private static void create(InputImplementation impl) throws LWJGLException {
299 if (created)
300 return;
301 if (!initialized)
302 initialize();
303 implementation = impl;
304 implementation.createKeyboard();
305 created = true;
306 readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE);
307 reset();
308 }
309
310 /**
311 * "Create" the keyboard. The display must first have been created. The
312 * reason for this is so the keyboard has a window to "focus" in.
313 *
314 * @throws LWJGLException if the keyboard could not be created for any reason
315 */
316 public static void create() throws LWJGLException {
317 synchronized (OpenGLPackageAccess.global_lock) {
318 if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
319
320 create(OpenGLPackageAccess.createImplementation());
321 }
322 }
323
324 private static void reset() {
325 readBuffer.limit(0);
326 for (int i = 0; i < keyDownBuffer.remaining(); i++)
327 keyDownBuffer.put(i, (byte)0);
328 current_event.reset();
329 }
330
331 /**
332 * @return true if the keyboard has been created
333 */
334 public static boolean isCreated() {
335 synchronized (OpenGLPackageAccess.global_lock) {
336 return created;
337 }
338 }
339
340 /**
341 * "Destroy" the keyboard
342 */
343 public static void destroy() {
344 synchronized (OpenGLPackageAccess.global_lock) {
345 if (!created)
346 return;
347 created = false;
348 implementation.destroyKeyboard();
349 reset();
350 }
351 }
352
353 /**
354 * Polls the keyboard for its current state. Access the polled values using the
355 * <code>isKeyDown</code> method.
356 * By using this method, it is possible to "miss" keyboard keys if you don't
357 * poll fast enough.
358 *
359 * To use buffered values, you have to call <code>next</code> for each event you
360 * want to read. You can query which key caused the event by using
361 * <code>getEventKey</code>. To get the state of that key, for that event, use
362 * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the
363 * character for that event.
364 *
365 * NOTE: This method does not query the operating system for new events. To do that,
366 * Display.processMessages() (or Display.update()) must be called first.
367 *
368 * @see org.lwjgl.input.Keyboard#isKeyDown(int key)
369 * @see org.lwjgl.input.Keyboard#next()
370 * @see org.lwjgl.input.Keyboard#getEventKey()
371 * @see org.lwjgl.input.Keyboard#getEventKeyState()
372 * @see org.lwjgl.input.Keyboard#getEventCharacter()
373 */
374 public static void poll() {
375 synchronized (OpenGLPackageAccess.global_lock) {
376 if (!created)
377 throw new IllegalStateException("Keyboard must be created before you can poll the device");
378 implementation.pollKeyboard(keyDownBuffer);
379 read();
380 }
381 }
382
383 private static void read() {
384 readBuffer.compact();
385 implementation.readKeyboard(readBuffer);
386 readBuffer.flip();
387 }
388
389 /**
390 * Checks to see if a key is down.
391 * @param key Keycode to check
392 * @return true if the key is down according to the last poll()
393 */
394 public static boolean isKeyDown(int key) {
395 synchronized (OpenGLPackageAccess.global_lock) {
396 if (!created)
397 throw new IllegalStateException("Keyboard must be created before you can query key state");
398 return keyDownBuffer.get(key) != 0;
399 }
400 }
401
402 /**
403 * Checks whether one of the state keys are "active"
404 *
405 * @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ)
406 * @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown
407 */
408 /* public static int isStateKeySet(int key) {
409 if (!created)
410 throw new IllegalStateException("Keyboard must be created before you can query key state");
411 return implementation.isStateKeySet(key);
412 }
413 */
414 /**
415 * Gets a key's name
416 * @param key The key
417 * @return a String with the key's human readable name in it or null if the key is unnamed
418 */
419 public static synchronized String getKeyName(int key) {
420 return keyName[key];
421 }
422
423 /**
424 * Get's a key's index. If the key is unrecognised then KEY_NONE is returned.
425 * @param keyName The key name
426 */
427 public static synchronized int getKeyIndex(String keyName) {
428 Integer ret = (Integer) keyMap.get(keyName);
429 if (ret == null)
430 return KEY_NONE;
431 else
432 return ret.intValue();
433 }
434
435 /**
436 * Gets the number of keyboard events waiting after doing a buffer enabled poll().
437 * @return the number of keyboard events
438 */
439 public static int getNumKeyboardEvents() {
440 synchronized (OpenGLPackageAccess.global_lock) {
441 if (!created)
442 throw new IllegalStateException("Keyboard must be created before you can read events");
443 int old_position = readBuffer.position();
444 int num_events = 0;
445 while (readNext(tmp_event) && (!tmp_event.repeat || repeat_enabled))
446 num_events++;
447 readBuffer.position(old_position);
448 return num_events;
449 }
450 }
451
452 /**
453 * Gets the next keyboard event. You can query which key caused the event by using
454 * <code>getEventKey</code>. To get the state of that key, for that event, use
455 * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the
456 * character for that event.
457 *
458 * @see org.lwjgl.input.Keyboard#getEventKey()
459 * @see org.lwjgl.input.Keyboard#getEventKeyState()
460 * @see org.lwjgl.input.Keyboard#getEventCharacter()
461 * @return true if a keyboard event was read, false otherwise
462 */
463 public static boolean next() {
464 synchronized (OpenGLPackageAccess.global_lock) {
465 if (!created)
466 throw new IllegalStateException("Keyboard must be created before you can read events");
467
468 boolean result;
469 while ((result = readNext(current_event)) && current_event.repeat && !repeat_enabled)
470 ;
471 return result;
472 }
473 }
474
475 /**
476 * Controls whether repeat events are reported or not. If repeat events
477 * are enabled, key down events are reported when a key is pressed and held for
478 * a OS dependent amount of time. To distinguish a repeat event from a normal event,
479 * use isRepeatEvent().
480 *
481 * @see org.lwjgl.input.Keyboard#getEventKey()
482 */
483 public static void enableRepeatEvents(boolean enable) {
484 synchronized (OpenGLPackageAccess.global_lock) {
485 repeat_enabled = enable;
486 }
487 }
488
489 /**
490 * Check whether repeat events are currently reported or not.
491 *
492 * @return true is repeat events are reported, false if not.
493 * @see org.lwjgl.input.Keyboard#getEventKey()
494 */
495 public static boolean areRepeatEventsEnabled() {
496 synchronized (OpenGLPackageAccess.global_lock) {
497 return repeat_enabled;
498 }
499 }
500
501 private static boolean readNext(KeyEvent event) {
502 if (readBuffer.hasRemaining()) {
503 event.key = readBuffer.getInt() & 0xFF;
504 event.state = readBuffer.get() != 0;
505 event.character = readBuffer.getInt();
506 event.nanos = readBuffer.getLong();
507 event.repeat = readBuffer.get() == 1;
508 return true;
509 } else
510 return false;
511 }
512
513 /**
514 * @return Number of keys on this keyboard
515 */
516 public static int getKeyCount() {
517 return keyCount;
518 }
519
520 /**
521 * @return The character from the current event
522 */
523 public static char getEventCharacter() {
524 synchronized (OpenGLPackageAccess.global_lock) {
525 return (char)current_event.character;
526 }
527 }
528
529 /**
530 * Please note that the key code returned is NOT valid against the
531 * current keyboard layout. To get the actual character pressed call
532 * getEventCharacter
533 *
534 * @return The key from the current event
535 */
536 public static int getEventKey() {
537 synchronized (OpenGLPackageAccess.global_lock) {
538 return current_event.key;
539 }
540 }
541
542 /**
543 * Gets the state of the tkey that generated the
544 * current event
545 *
546 * @return True if key was down, or false if released
547 */
548 public static boolean getEventKeyState() {
549 synchronized (OpenGLPackageAccess.global_lock) {
550 return current_event.state;
551 }
552 }
553
554 /**
555 * Gets the time in nanoseconds of the current event.
556 * Only useful for relative comparisons with other
557 * Keyboard events, as the absolute time has no defined
558 * origin.
559 * @return The time in nanoseconds of the current event
560 */
561 public static long getEventNanoseconds() {
562 synchronized (OpenGLPackageAccess.global_lock) {
563 return current_event.nanos;
564 }
565 }
566
567 /**
568 * @see org.lwjgl.input.Keyboard#enableRepeatEvents(boolean)
569 * @return true if the current event is a repeat event, false if
570 * the current event is not a repeat even or if repeat events are disabled.
571 */
572 public static boolean isRepeatEvent() {
573 synchronized (OpenGLPackageAccess.global_lock) {
574 return current_event.repeat;
575 }
576 }
577
578 private final static class KeyEvent {
579 /** The current keyboard character being examined */
580 private int character;
581
582 /** The current keyboard event key being examined */
583 private int key;
584
585 /** The current state of the key being examined in the event queue */
586 private boolean state;
587
588 /** The current event time */
589 private long nanos;
590
591 /** Is the current event a repeated event? */
592 private boolean repeat;
593
594 private void reset() {
595 character = 0;
596 key = 0;
597 state = false;
598 repeat = false;
599 }
600 }
601 }
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.input;
32
33 import java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35 import java.security.AccessController;
36 import java.security.PrivilegedAction;
37 import java.util.HashMap;
38 import java.util.Map;
39
40 import org.lwjgl.BufferUtils;
41 import org.lwjgl.LWJGLException;
42 import org.lwjgl.LWJGLUtil;
43 import org.lwjgl.Sys;
44 import org.lwjgl.opengl.Display;
45 import org.lwjgl.opengl.InputImplementation;
46
47
48 /**
49 * <br>
50 * A raw Mouse interface. This can be used to poll the current state of the
51 * mouse buttons, and determine the mouse movement delta since the last poll.
52 *
53 * n buttons supported, n being a native limit. A scrolly wheel is also
54 * supported, if one such is available. Movement is reported as delta from
55 * last position or as an absolute position. If the window has been created
56 * the absolute position will be clamped to 0 - width | height.
57 *
58 * @author cix_foo <cix_foo@users.sourceforge.net>
59 * @author elias_naur <elias_naur@users.sourceforge.net>
60 * @author Brian Matzon <brian@matzon.dk>
61 * @version $Revision: 3297 $
62 * $Id: Mouse.java 3297 2010-03-27 16:04:30Z kappa1 $
63 */
64 public class Mouse {
65 /** Internal use - event size in bytes */
66 public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4 + 8;
67
68 /** Has the mouse been created? */
69 private static boolean created;
70
71 /** The mouse buttons status from the last poll */
72 private static ByteBuffer buttons;
73
74 /** Mouse absolute X position in pixels */
75 private static int x;
76
77 /** Mouse absolute Y position in pixels */
78 private static int y;
79
80 /** Buffer to hold the deltas dx, dy and dwheel */
81 private static IntBuffer coord_buffer;
82
83 /** Delta X */
84 private static int dx;
85
86 /** Delta Y */
87 private static int dy;
88
89 /** Delta Z */
90 private static int dwheel;
91
92 /** Number of buttons supported by the mouse */
93 private static int buttonCount = -1;
94
95 /** Does this mouse support a scroll wheel */
96 private static boolean hasWheel;
97
98 /** The current native cursor, if any */
99 private static Cursor currentCursor;
100
101 /** Button names. These are set upon create(), to names like BUTTON0, BUTTON1, etc. */
102 private static String[] buttonName;
103
104 /** hashmap of button names, for fast lookup */
105 private static final Map buttonMap = new HashMap(16);
106
107 /** Lazy initialization */
108 private static boolean initialized;
109
110 /** The mouse button events from the last read */
111 private static ByteBuffer readBuffer;
112
113 /** The current mouse event button being examined */
114 private static int eventButton;
115
116 /** The current state of the button being examined in the event queue */
117 private static boolean eventState;
118
119 /** The current delta of the mouse in the event queue */
120 private static int event_dx;
121 private static int event_dy;
122 private static int event_dwheel;
123 /** The current absolute position of the mouse in the event queue */
124 private static int event_x;
125 private static int event_y;
126 private static long event_nanos;
127 /** The position of the mouse it was grabbed at */
128 private static int grab_x;
129 private static int grab_y;
130
131 /** Buffer size in events */
132 private static final int BUFFER_SIZE = 50;
133
134 private static boolean isGrabbed;
135
136 private static InputImplementation implementation;
137
138 /** Whether we need cursor animation emulation */
139 private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS ||
140 LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX;
141
142 private static final boolean allowNegativeMouseCoords = getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
143
144 /**
145 * Mouse cannot be constructed.
146 */
147 private Mouse() {
148 }
149
150 /**
151 * Gets the currently bound native cursor, if any.
152 *
153 * @return the currently bound native cursor, if any.
154 */
155 public static Cursor getNativeCursor() {
156 synchronized (OpenGLPackageAccess.global_lock) {
157 return currentCursor;
158 }
159 }
160
161 /**
162 * Binds a native cursor. If the cursor argument is null, any
163 * currently bound native cursor is disabled, and the cursor reverts
164 * to the default operating system supplied cursor.
165 *
166 * NOTE: The native cursor is not constrained to the window, but
167 * relative events will not be generated if the cursor is outside.
168 *
169 * @param cursor the native cursor object to bind. May be null.
170 * @return The previous Cursor object set, or null.
171 * @throws LWJGLException if the cursor could not be set for any reason
172 */
173 public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException {
174 synchronized (OpenGLPackageAccess.global_lock) {
175 if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0)
176 throw new IllegalStateException("Mouse doesn't support native cursors");
177 Cursor oldCursor = currentCursor;
178 currentCursor = cursor;
179 if (isCreated()) {
180 if (currentCursor != null) {
181 implementation.setNativeCursor(currentCursor.getHandle());
182 currentCursor.setTimeout();
183 } else {
184 implementation.setNativeCursor(null);
185 }
186 }
187 return oldCursor;
188 }
189 }
190
191 /**
192 * Set the position of the cursor. If the cursor is not grabbed,
193 * the native cursor is moved to the new position.
194 *
195 * @param new_x The x coordinate of the new cursor position in OpenGL coordinates relative
196 * to the window origin.
197 * @param new_y The y coordinate of the new cursor position in OpenGL coordinates relative
198 * to the window origin.
199 */
200 public static void setCursorPosition(int new_x, int new_y) {
201 synchronized (OpenGLPackageAccess.global_lock) {
202 if (!isCreated())
203 throw new IllegalStateException("Mouse is not created");
204 x = event_x = new_x;
205 y = event_y = new_y;
206 if (!isGrabbed() && (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) {
207 implementation.setCursorPosition(x, y);
208 }
209 else {
210 grab_x = new_x;
211 grab_y = new_y;
212 }
213 }
214 }
215
216 /**
217 * Static initialization
218 */
219 private static void initialize() {
220 Sys.initialize();
221
222 // Assign names to all the buttons
223 buttonName = new String[16];
224 for (int i = 0; i < 16; i++) {
225 buttonName[i] = "BUTTON" + i;
226 buttonMap.put(buttonName[i], new Integer(i));
227 }
228
229 initialized = true;
230 }
231
232 private static void resetMouse() {
233 dx = dy = dwheel = 0;
234 readBuffer.position(readBuffer.limit());
235 }
236
237 static InputImplementation getImplementation() {
238 return implementation;
239 }
240
241 /**
242 * "Create" the mouse with the given custom implementation. This is used
243 * reflectively by AWTInputAdapter.
244 *
245 * @throws LWJGLException if the mouse could not be created for any reason
246 */
247 private static void create(InputImplementation impl) throws LWJGLException {
248 if (created)
249 return;
250 if (!initialized)
251 initialize();
252 implementation = impl;
253 implementation.createMouse();
254 hasWheel = implementation.hasWheel();
255 created = true;
256
257 // set mouse buttons
258 buttonCount = implementation.getButtonCount();
259 buttons = BufferUtils.createByteBuffer(buttonCount);
260 coord_buffer = BufferUtils.createIntBuffer(3);
261 if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0)
262 setNativeCursor(currentCursor);
263 readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE);
264 readBuffer.limit(0);
265 setGrabbed(isGrabbed);
266 }
267
268 /**
269 * "Create" the mouse. The display must first have been created.
270 * Initially, the mouse is not grabbed and the delta values are reported
271 * with respect to the center of the display.
272 *
273 * @throws LWJGLException if the mouse could not be created for any reason
274 */
275 public static void create() throws LWJGLException {
276 synchronized (OpenGLPackageAccess.global_lock) {
277 if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
278
279 create(OpenGLPackageAccess.createImplementation());
280 }
281 }
282
283 /**
284 * @return true if the mouse has been created
285 */
286 public static boolean isCreated() {
287 synchronized (OpenGLPackageAccess.global_lock) {
288 return created;
289 }
290 }
291
292 /**
293 * "Destroy" the mouse.
294 */
295 public static void destroy() {
296 synchronized (OpenGLPackageAccess.global_lock) {
297 if (!created) return;
298 created = false;
299 buttons = null;
300 coord_buffer = null;
301
302 implementation.destroyMouse();
303 }
304 }
305
306 /**
307 * Polls the mouse for its current state. Access the polled values using the
308 * get<value> methods.
309 * By using this method, it is possible to "miss" mouse click events if you don't
310 * poll fast enough.
311 *
312 * To use buffered values, you have to call <code>next</code> for each event you
313 * want to read. You can query which button caused the event by using
314 * <code>getEventButton</code>. To get the state of that button, for that event, use
315 * <code>getEventButtonState</code>.
316 *
317 * NOTE: This method does not query the operating system for new events. To do that,
318 * Display.processMessages() (or Display.update()) must be called first.
319 *
320 * @see org.lwjgl.input.Mouse#next()
321 * @see org.lwjgl.input.Mouse#getEventButton()
322 * @see org.lwjgl.input.Mouse#getEventButtonState()
323 * @see org.lwjgl.input.Mouse#isButtonDown(int button)
324 * @see org.lwjgl.input.Mouse#getX()
325 * @see org.lwjgl.input.Mouse#getY()
326 * @see org.lwjgl.input.Mouse#getDX()
327 * @see org.lwjgl.input.Mouse#getDY()
328 * @see org.lwjgl.input.Mouse#getDWheel()
329 */
330 public static void poll() {
331 synchronized (OpenGLPackageAccess.global_lock) {
332 if (!created) throw new IllegalStateException("Mouse must be created before you can poll it");
333 implementation.pollMouse(coord_buffer, buttons);
334
335 /* If we're grabbed, poll returns mouse deltas, if not it returns absolute coordinates */
336 int poll_coord1 = coord_buffer.get(0);
337 int poll_coord2 = coord_buffer.get(1);
338 /* The wheel is always relative */
339 int poll_dwheel = coord_buffer.get(2);
340
341 if (isGrabbed()) {
342 dx += poll_coord1;
343 dy += poll_coord2;
344 x += poll_coord1;
345 y += poll_coord2;
346 } else {
347 dx = poll_coord1 - x;
348 dy = poll_coord2 - y;
349 x = poll_coord1;
350 y = poll_coord2;
351 }
352 if(!allowNegativeMouseCoords) {
353 x = Math.min(implementation.getWidth() - 1, Math.max(0, x));
354 y = Math.min(implementation.getHeight() - 1, Math.max(0, y));
355 }
356 dwheel += poll_dwheel;
357 read();
358 }
359 }
360
361 private static void read() {
362 readBuffer.compact();
363 implementation.readMouse(readBuffer);
364 readBuffer.flip();
365 }
366
367 /**
368 * See if a particular mouse button is down.
369 *
370 * @param button The index of the button you wish to test (0..getButtonCount-1)
371 * @return true if the specified button is down
372 */
373 public static boolean isButtonDown(int button) {
374 synchronized (OpenGLPackageAccess.global_lock) {
375 if (!created) throw new IllegalStateException("Mouse must be created before you can poll the button state");
376 if (button >= buttonCount || button < 0)
377 return false;
378 else
379 return buttons.get(button) == 1;
380 }
381 }
382
383 /**
384 * Gets a button's name
385 * @param button The button
386 * @return a String with the button's human readable name in it or null if the button is unnamed
387 */
388 public static String getButtonName(int button) {
389 synchronized (OpenGLPackageAccess.global_lock) {
390 if (button >= buttonName.length || button < 0)
391 return null;
392 else
393 return buttonName[button];
394 }
395 }
396
397 /**
398 * Get's a button's index. If the button is unrecognised then -1 is returned.
399 * @param buttonName The button name
400 */
401 public static int getButtonIndex(String buttonName) {
402 synchronized (OpenGLPackageAccess.global_lock) {
403 Integer ret = (Integer) buttonMap.get(buttonName);
404 if (ret == null)
405 return -1;
406 else
407 return ret.intValue();
408 }
409 }
410
411 /**
412 * Gets the next mouse event. You can query which button caused the event by using
413 * <code>getEventButton()</code> (if any). To get the state of that key, for that event, use
414 * <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>,
415 * <code>getEventDY()</code> and <code>getEventDZ()</code>.
416 * @see org.lwjgl.input.Mouse#getEventButton()
417 * @see org.lwjgl.input.Mouse#getEventButtonState()
418 * @return true if a mouse event was read, false otherwise
419 */
420 public static boolean next() {
421 synchronized (OpenGLPackageAccess.global_lock) {
422 if (!created) throw new IllegalStateException("Mouse must be created before you can read events");
423 if (readBuffer.hasRemaining()) {
424 eventButton = readBuffer.get();
425 eventState = readBuffer.get() != 0;
426 if (isGrabbed()) {
427 event_dx = readBuffer.getInt();
428 event_dy = readBuffer.getInt();
429 event_x += event_dx;
430 event_y += event_dy;
431 } else {
432 int new_event_x = readBuffer.getInt();
433 int new_event_y = readBuffer.getInt();
434 event_dx = new_event_x - event_x;
435 event_dy = new_event_y - event_y;
436 event_x = new_event_x;
437 event_y = new_event_y;
438 }
439 event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x));
440 event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y));
441 event_dwheel = readBuffer.getInt();
442 event_nanos = readBuffer.getLong();
443 return true;
444 } else
445 return false;
446 }
447 }
448
449 /**
450 * @return Current events button. Returns -1 if no button state was changed
451 */
452 public static int getEventButton() {
453 synchronized (OpenGLPackageAccess.global_lock) {
454 return eventButton;
455 }
456 }
457
458 /**
459 * Get the current events button state.
460 * @return Current events button state.
461 */
462 public static boolean getEventButtonState() {
463 synchronized (OpenGLPackageAccess.global_lock) {
464 return eventState;
465 }
466 }
467
468 /**
469 * @return Current events delta x. Only valid when the mouse is grabbed.
470 */
471 public static int getEventDX() {
472 synchronized (OpenGLPackageAccess.global_lock) {
473 return event_dx;
474 }
475 }
476
477 /**
478 * @return Current events delta y. Only valid when the mouse is grabbed.
479 */
480 public static int getEventDY() {
481 synchronized (OpenGLPackageAccess.global_lock) {
482 return event_dy;
483 }
484 }
485
486 /**
487 * @return Current events absolute x. Only valid when the mouse is not grabbed.
488 */
489 public static int getEventX() {
490 synchronized (OpenGLPackageAccess.global_lock) {
491 return event_x;
492 }
493 }
494
495 /**
496 * @return Current events absolute y. Only valid when the mouse is not grabbed.
497 */
498 public static int getEventY() {
499 synchronized (OpenGLPackageAccess.global_lock) {
500 return event_y;
501 }
502 }
503
504 /**
505 * @return Current events delta z
506 */
507 public static int getEventDWheel() {
508 synchronized (OpenGLPackageAccess.global_lock) {
509 return event_dwheel;
510 }
511 }
512
513 /**
514 * Gets the time in nanoseconds of the current event.
515 * Only useful for relative comparisons with other
516 * Mouse events, as the absolute time has no defined
517 * origin.
518 *
519 * @return The time in nanoseconds of the current event
520 */
521 public static long getEventNanoseconds() {
522 synchronized (OpenGLPackageAccess.global_lock) {
523 return event_nanos;
524 }
525 }
526
527 /**
528 * Retrieves the absolute position. It will be clamped to
529 * 0...width-1.
530 *
531 * @return Absolute x axis position of mouse
532 */
533 public static int getX() {
534 synchronized (OpenGLPackageAccess.global_lock) {
535 return x;
536 }
537 }
538
539 /**
540 * Retrieves the absolute position. It will be clamped to
541 * 0...height-1.
542 *
543 * @return Absolute y axis position of mouse
544 */
545 public static int getY() {
546 synchronized (OpenGLPackageAccess.global_lock) {
547 return y;
548 }
549 }
550
551 /**
552 * @return Movement on the x axis since last time getDX() was called. Only valid when the mouse is grabbed.
553 */
554 public static int getDX() {
555 synchronized (OpenGLPackageAccess.global_lock) {
556 int result = dx;
557 dx = 0;
558 return result;
559 }
560 }
561
562 /**
563 * @return Movement on the y axis since last time getDY() was called. Only valid when the mouse is grabbed.
564 */
565 public static int getDY() {
566 synchronized (OpenGLPackageAccess.global_lock) {
567 int result = dy;
568 dy = 0;
569 return result;
570 }
571 }
572
573 /**
574 * @return Movement of the wheel since last time getDWheel() was called
575 */
576 public static int getDWheel() {
577 synchronized (OpenGLPackageAccess.global_lock) {
578 int result = dwheel;
579 dwheel = 0;
580 return result;
581 }
582 }
583
584 /**
585 * @return Number of buttons on this mouse
586 */
587 public static int getButtonCount() {
588 synchronized (OpenGLPackageAccess.global_lock) {
589 return buttonCount;
590 }
591 }
592
593 /**
594 * @return Whether or not this mouse has wheel support
595 */
596 public static boolean hasWheel() {
597 synchronized (OpenGLPackageAccess.global_lock) {
598 return hasWheel;
599 }
600 }
601
602 /**
603 * @return whether or not the mouse has grabbed the cursor
604 */
605 public static boolean isGrabbed() {
606 synchronized (OpenGLPackageAccess.global_lock) {
607 return isGrabbed;
608 }
609 }
610
611 /**
612 * Sets whether or not the mouse has grabbed the cursor
613 * (and thus hidden). If grab is false, the getX() and getY()
614 * will return delta movement in pixels clamped to the display
615 * dimensions, from the center of the display.
616 *
617 * @param grab whether the mouse should be grabbed
618 */
619 public static void setGrabbed(boolean grab) {
620 synchronized (OpenGLPackageAccess.global_lock) {
621 boolean grabbed = isGrabbed;
622 isGrabbed = grab;
623 if (isCreated()) {
624 if (grab && !grabbed) {
625 // store location mouse was grabbed
626 grab_x = x;
627 grab_y = y;
628 }
629 else if (!grab && grabbed) {
630 // move mouse back to location it was grabbed before ungrabbing
631 if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0)
632 implementation.setCursorPosition(grab_x, grab_y);
633 }
634
635 implementation.grabMouse(grab);
636 // Get latest values from native side
637 poll();
638 event_x = x;
639 event_y = y;
640 resetMouse();
641 }
642 }
643 }
644
645 /**
646 * Updates the cursor, so that animation can be changed if needed.
647 * This method is called automatically by the window on its update, and
648 * shouldn't be called otherwise
649 */
650 public static void updateCursor() {
651 synchronized (OpenGLPackageAccess.global_lock) {
652 if (emulateCursorAnimation && currentCursor != null && currentCursor.hasTimedOut() && Mouse.isInsideWindow()) {
653 currentCursor.nextCursor();
654 try {
655 setNativeCursor(currentCursor);
656 } catch (LWJGLException e) {
657 if (LWJGLUtil.DEBUG) e.printStackTrace();
658 }
659 }
660 }
661 }
662
663 /** Gets a boolean property as a privileged action. */
664 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));
668 }
669 });
670 return value.booleanValue();
671 }
672
673 /**
674 * Retrieves whether or not the mouse cursor is within the bounds of the window.
675 * If the mouse cursor was moved outside the display during a drag, then the result of calling
676 * this method will be true until the button is released.
677 * @return true if mouse is inside display, false otherwise.
678 */
679 public static boolean isInsideWindow() {
680 return implementation.isInsideWindow();
681 }
682 }
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.input;
32
33 import org.lwjgl.opengl.InputImplementation;
34 import org.lwjgl.opengl.Display;
35
36 import java.lang.reflect.Field;
37 import java.lang.reflect.Method;
38 import java.security.AccessController;
39 import java.security.PrivilegedExceptionAction;
40 import java.security.PrivilegedActionException;
41
42 /**
43 * This class contains utilities for accessing the org.lwjgl.opengl
44 * package through (privileged) reflection.
45 */
46 final class OpenGLPackageAccess {
47 final static Object global_lock;
48
49 static {
50 try {
51 global_lock = AccessController.doPrivileged(new PrivilegedExceptionAction() {
52 public Object run() throws Exception {
53 Field lock_field = Class.forName("org.lwjgl.opengl.GlobalLock").getDeclaredField("lock");
54 lock_field.setAccessible(true);
55 return lock_field.get(null);
56 }
57 });
58 } catch (PrivilegedActionException e) {
59 throw new Error(e);
60 }
61 }
62
63 static InputImplementation createImplementation() {
64 /* Use reflection since we can't make Display.getImplementation
65 * public
66 */
67 try {
68 return (InputImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() {
69 public Object run() throws Exception {
70 Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null);
71 getImplementation_method.setAccessible(true);
72 return getImplementation_method.invoke(null, null);
73 }
74 });
75 } catch (PrivilegedActionException e) {
76 throw new Error(e);
77 }
78 }
79 }
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.openal;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36
37 /**
38 * <p>
39 * The AL class implements the actual creation code for linking to the native library
40 * OpenAL.
41 * </p>
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 3182 $
45 * $Id: AL.java 3182 2009-03-17 21:36:18Z matzon $
46 */
47 public final class AL {
48 /** ALCdevice instance. */
49 protected static ALCdevice device;
50
51 /** Current ALCcontext. */
52 protected static ALCcontext context;
53
54 /** Have we been created? */
55 private static boolean created;
56
57 static {
58 Sys.initialize();
59 }
60
61 private AL() {
62 }
63
64 /**
65 * Native method to create AL instance
66 *
67 * @param oalPaths Array of strings containing paths to search for OpenAL library
68 */
69 private static native void nCreate(String oalPath) throws LWJGLException;
70
71 /**
72 * Native method to create AL instance from the Mac OS X 10.4 OpenAL framework.
73 * 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
76 */
77 private static native void nCreateDefault() throws LWJGLException;
78
79 /**
80 * Native method the destroy the AL
81 */
82 private static native void nDestroy();
83
84 /**
85 * @return true if AL has been created
86 */
87 public static boolean isCreated() {
88 return created;
89 }
90
91 /**
92 * Creates an OpenAL instance. Using this constructor will cause OpenAL to
93 * open the device using supplied device argument, and create a context using the context values
94 * supplied.
95 *
96 * @param deviceArguments Arguments supplied to native device
97 * @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100).
98 * @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)
102 throws LWJGLException {
103 create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true);
104 }
105
106 /**
107 * @param openDevice Whether to automatically open the device
108 * @see #create(String, int, int, boolean)
109 */
110 public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice)
111 throws LWJGLException {
112
113 if (created)
114 throw new IllegalStateException("Only one OpenAL context may be instantiated at any one time.");
115 String libname;
116 String[] library_names;
117 switch (LWJGLUtil.getPlatform()) {
118 case LWJGLUtil.PLATFORM_WINDOWS:
119 libname = "OpenAL32";
120 library_names = new String[]{"OpenAL64.dll", "OpenAL32.dll"};
121 break;
122 case LWJGLUtil.PLATFORM_LINUX:
123 libname = "openal";
124 library_names = new String[]{"libopenal64.so", "libopenal.so", "libopenal.so.0"};
125 break;
126 case LWJGLUtil.PLATFORM_MACOSX:
127 libname = "openal";
128 library_names = new String[]{"openal.dylib"};
129 break;
130 default:
131 throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
132 }
133 String[] oalPaths = LWJGLUtil.getLibraryPaths(libname, library_names, AL.class.getClassLoader());
134 LWJGLUtil.log("Found " + oalPaths.length + " OpenAL paths");
135 for (int i = 0; i < oalPaths.length; i++) {
136 try {
137 nCreate(oalPaths[i]);
138 created = true;
139 init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
140 break;
141 } catch (LWJGLException e) {
142 LWJGLUtil.log("Failed to load " + oalPaths[i] + ": " + e.getMessage());
143 }
144 }
145 if (!created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) {
146 // Try to load OpenAL from the framework instead
147 nCreateDefault();
148 created = true;
149 init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
150 }
151 if (!created)
152 throw new LWJGLException("Could not locate OpenAL library.");
153 }
154
155 private static void init(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice) throws LWJGLException {
156 try {
157 AL10.initNativeStubs();
158 ALC10.initNativeStubs();
159
160 if(openDevice) {
161 device = ALC10.alcOpenDevice(deviceArguments);
162 if (device == null)
163 throw new LWJGLException("Could not open ALC device");
164
165 if (contextFrequency == -1) {
166 context = ALC10.alcCreateContext(device, null);
167 } else {
168 context = ALC10.alcCreateContext(device,
169 ALCcontext.createAttributeList(contextFrequency, contextRefresh,
170 contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE));
171 }
172 ALC10.alcMakeContextCurrent(context);
173 }
174 } catch (LWJGLException e) {
175 destroy();
176 throw e;
177 }
178
179 ALC11.initialize();
180 }
181
182 /**
183 * Creates an OpenAL instance. The empty create will cause OpenAL to
184 * open the default device, and create a context using default values.
185 * This method used to use default values that the OpenAL implementation
186 * chose but this produces unexpected results on some systems; so now
187 * it defaults to 44100Hz mixing @ 60Hz refresh.
188 */
189 public static void create() throws LWJGLException {
190 create(null, 44100, 60, false);
191 }
192
193 /**
194 * Exit cleanly by calling destroy.
195 */
196 public static void destroy() {
197 if (context != null) {
198 ALC10.alcMakeContextCurrent(null);
199 ALC10.alcDestroyContext(context);
200 context = null;
201 }
202 if (device != null) {
203 boolean result = ALC10.alcCloseDevice(device);
204 device = null;
205 }
206 resetNativeStubs(AL10.class);
207 resetNativeStubs(ALC10.class);
208 resetNativeStubs(ALC11.class);
209
210 if (created)
211 nDestroy();
212 created = false;
213 }
214
215 private static native void resetNativeStubs(Class clazz);
216
217 /**
218 * @return handle to the default AL context.
219 */
220 public static ALCcontext getContext() {
221 return context;
222 }
223
224 /**
225 * @return handle to the default AL device.
226 */
227 public static ALCdevice getDevice() {
228 return device;
229 }
230 }
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.openal;
32
33 import java.nio.Buffer;
34 import java.nio.IntBuffer;
35 import java.util.HashMap;
36
37 import org.lwjgl.BufferChecks;
38 import org.lwjgl.LWJGLException;
39
40 /**
41 *
42 * <p>
43 * ALC introduces the notion of a Device. A Device can be, depending on the
44 * implementation, a hardware device, or a daemon/OS service/actual server. This
45 * mechanism also permits different drivers (and hardware) to coexist within the same
46 * system, as well as allowing several applications to share system resources for audio,
47 * including a single hardware output device. The details are left to the
48 * implementation, which has to map the available backends to unique device
49 * specifiers (represented as strings).
50 * </p>
51 *
52 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 2286 $
54 * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $
55 */
56 public final class ALC10 {
57
58 /** List of active contexts */
59 static HashMap contexts = new HashMap();
60
61 /** List of active devices */
62 static HashMap devices = new HashMap();
63
64 /** Bad value */
65 public static final int ALC_INVALID = 0;
66
67 /** Boolean False */
68 public static final int ALC_FALSE = 0;
69
70 /** Boolean True */
71 public static final int ALC_TRUE = 1;
72
73 /** Errors: No Error */
74 public static final int ALC_NO_ERROR = ALC_FALSE;
75
76 /** Major version query. */
77 public static final int ALC_MAJOR_VERSION = 0x1000;
78
79 /** Minor version query. */
80 public static final int ALC_MINOR_VERSION = 0x1001;
81
82 /**
83 * The size required for the zero-terminated attributes list, for the current context.
84 **/
85 public static final int ALC_ATTRIBUTES_SIZE = 0x1002;
86
87 /**
88 * Expects a destination of ALC_CURRENT_ATTRIBUTES_SIZE,
89 * and provides the attribute list for the current context of the specified device.
90 */
91 public static final int ALC_ALL_ATTRIBUTES = 0x1003;
92
93 /** The specifier string for the default device */
94 public static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004;
95
96 /** The specifier string for the device */
97 public static final int ALC_DEVICE_SPECIFIER = 0x1005;
98
99 /** The extensions string for diagnostics and printing */
100 public static final int ALC_EXTENSIONS = 0x1006;
101
102 /** Frequency for mixing output buffer, in units of Hz. */
103 public static final int ALC_FREQUENCY = 0x1007;
104
105 /** Refresh intervalls, in units of Hz. */
106 public static final int ALC_REFRESH = 0x1008;
107
108 /** Flag, indicating a synchronous context. */
109 public static final int ALC_SYNC = 0x1009;
110
111 /** The device argument does not name a valid device */
112 public static final int ALC_INVALID_DEVICE = 0xA001;
113
114 /** The context argument does not name a valid context */
115 public static final int ALC_INVALID_CONTEXT = 0xA002;
116
117 /**
118 * A function was called at inappropriate time, or in an inappropriate way,
119 * causing an illegal state. This can be an incompatible ALenum, object ID,
120 * and/or function.
121 */
122 public static final int ALC_INVALID_ENUM = 0xA003;
123
124 /**
125 * Illegal value passed as an argument to an AL call.
126 * Applies to parameter values, but not to enumerations.
127 */
128 public static final int ALC_INVALID_VALUE = 0xA004;
129
130 /**
131 * A function could not be completed, because there is not enough
132 * memory available.
133 */
134 public static final int ALC_OUT_OF_MEMORY = 0xA005;
135
136 static native void initNativeStubs() throws LWJGLException;
137
138 /**
139 * The application can obtain certain strings from ALC.
140 *
141 * <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
143 * <code>ALC_EXTENSIONS</code> - The extensions string for diagnostics and printing.
144 *
145 * In addition, printable error message strings are provided for all valid error tokens,
146 * including <code>ALC_NO_ERROR</code>,<code>ALC_INVALID_DEVICE</code>, <code>ALC_INVALID_CONTEXT</code>,
147 * <code>ALC_INVALID_ENUM</code>, <code>ALC_INVALID_VALUE</code>.
148 *
149 * @param pname Property to get
150 * @return String property from device
151 */
152 public static String alcGetString(ALCdevice device, int pname) {
153 String result;
154 result = nalcGetString(getDevice(device), pname);
155 Util.checkALCError(device);
156 return result;
157 }
158 native static String nalcGetString(long device, int pname);
159
160 /**
161 * The application can query ALC for information using an integer query function.
162 * For some tokens, <code>null</code> is a legal deviceHandle. In other cases, specifying a <code>null</code>
163 * device will generate an <code>ALC_INVALID_DEVICE</code> error. The application has to
164 * specify the size of the destination buffer provided. A <code>null</code> destination or a zero
165 * size parameter will cause ALC to ignore the query.
166 *
167 * <code>ALC_MAJOR_VERSION</code> - Major version query.
168 * <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
171 * for the specified device) is legal.
172 * <code>ALC_ALL_ATTRIBUTES</code> - Expects a destination of <code>ALC_CURRENT_ATTRIBUTES_SIZE</code>,
173 * and provides the attribute list for the current context of the specified device.
174 * <code>null</code> is an invalid device. <code>null</code> (no current context for the specified device)
175 * will return the default attributes defined by the specified device.
176 *
177 * @param pname Property to get
178 * @param integerdata ByteBuffer to write integers to
179 */
180 public static void alcGetInteger(ALCdevice device, int pname, IntBuffer integerdata) {
181 BufferChecks.checkDirect(integerdata);
182 nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), integerdata, integerdata.position());
183 Util.checkALCError(device);
184 }
185 native static void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
186
187 /**
188 * The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
189 * connect to a device (i.e. the server).
190 *
191 * If the function returns <code>null</code>, then no sound driver/device has been found. The
192 * argument is a null terminated string that requests a certain device or device
193 * configuration. If <code>null</code> is specified, the implementation will provide an
194 * implementation specific default.
195 *
196 * @param devicename name of device to open
197 * @return opened device, or null
198 */
199 public static ALCdevice alcOpenDevice(String devicename) {
200 long device_address = nalcOpenDevice(devicename);
201 if(device_address != 0) {
202 ALCdevice device = new ALCdevice(device_address);
203 synchronized (ALC10.devices) {
204 devices.put(new Long(device_address), device);
205 }
206 return device;
207 }
208 return null;
209 }
210 native static long nalcOpenDevice(String devicename);
211
212 /**
213 * The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to
214 * disconnect from a device (i.e. the server).
215 *
216 * If deviceHandle is <code>null</code> or invalid, an <code>ALC_INVALID_DEVICE</code> error will be
217 * generated. Once closed, a deviceHandle is invalid.
218 *
219 * @param device address of native device to close
220 */
221 public static boolean alcCloseDevice(ALCdevice device) {
222 boolean result = nalcCloseDevice(getDevice(device));
223 synchronized (devices) {
224 device.setInvalid();
225 devices.remove(new Long(device.device));
226 }
227 return result;
228
229 }
230 native static boolean nalcCloseDevice(long device);
231
232 /**
233 * A context is created using <code>alcCreateContext</code>. The device parameter has to be a valid
234 * device. The attribute list can be <code>null</code>, or a zero terminated list of integer pairs
235 * composed of valid ALC attribute tokens and requested values.
236 *
237 * Context creation will fail if the application requests attributes that, by themselves,
238 * can not be provided. Context creation will fail if the combination of specified
239 * attributes can not be provided. Context creation will fail if a specified attribute, or
240 * the combination of attributes, does not match the default values for unspecified
241 * attributes.
242 *
243 * @param device address of device to associate context to
244 * @param attrList Buffer to read attributes from
245 * @return New context, or null if creation failed
246 */
247 public static ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrList) {
248 long context_address = nalcCreateContext(getDevice(device), attrList);
249 Util.checkALCError(device);
250
251 if(context_address != 0) {
252 ALCcontext context = new ALCcontext(context_address);
253 synchronized (ALC10.contexts) {
254 contexts.put(new Long(context_address), context);
255 device.addContext(context);
256 }
257 return context;
258 }
259 return null;
260 }
261 native static long nalcCreateContext(long device, IntBuffer attrList);
262
263 /**
264 * To make a Context current with respect to AL Operation (state changes by issueing
265 * commands), <code>alcMakeContextCurrent</code> is used. The context parameter can be <code>null</code>
266 * or a valid context pointer. The operation will apply to the device that the context
267 * was created for.
268 *
269 * For each OS process (usually this means for each application), only one context can
270 * be current at any given time. All AL commands apply to the current context.
271 * Commands that affect objects shared among contexts (e.g. buffers) have side effects
272 * on other contexts.
273 *
274 * @param context address of context to make current
275 * @return true if successfull, false if not
276 */
277 public static int alcMakeContextCurrent(ALCcontext context) {
278 return nalcMakeContextCurrent(getContext(context));
279 }
280 native static int nalcMakeContextCurrent(long context);
281
282 /**
283 * The current context is the only context accessible to state changes by AL commands
284 * (aside from state changes affecting shared objects). However, multiple contexts can
285 * be processed at the same time. To indicate that a context should be processed (i.e.
286 * that internal execution state like offset increments are supposed to be performed),
287 * the application has to use <code>alcProcessContext</code>.
288 *
289 * Repeated calls to <code>alcProcessContext</code> are legal, and do not affect a context that is
290 * already marked as processing. The default state of a context created by
291 * alcCreateContext is that it is not marked as processing.
292 */
293 public static void alcProcessContext(ALCcontext context) {
294 nalcProcessContext(getContext(context));
295 }
296 native static void nalcProcessContext(long context);
297
298 /**
299 * The application can query for, and obtain an handle to, the current context for the
300 * application. If there is no current context, <code>null</code> is returned.
301 *
302 * @return Current ALCcontext
303 */
304 public static ALCcontext alcGetCurrentContext() {
305 ALCcontext context = null;
306 long context_address = nalcGetCurrentContext();
307 if(context_address != 0) {
308 synchronized (ALC10.contexts) {
309 context = (ALCcontext) ALC10.contexts.get(new Long(context_address));
310 }
311 }
312 return context;
313 }
314 native static long nalcGetCurrentContext();
315
316 /**
317 * The application can query for, and obtain an handle to, the device of a given context.
318 *
319 * @param context address of context to get device for
320 */
321 public static ALCdevice alcGetContextsDevice(ALCcontext context) {
322 ALCdevice device = null;
323 long device_address = nalcGetContextsDevice(getContext(context));
324 if (device_address != 0) {
325 synchronized (ALC10.devices) {
326 device = (ALCdevice) ALC10.devices.get(new Long(device_address));
327 }
328 }
329 return device;
330 }
331 native static long nalcGetContextsDevice(long context);
332
333 /**
334 * The application can suspend any context from processing (including the current
335 * one). To indicate that a context should be suspended from processing (i.e. that
336 * internal execution state like offset increments is not supposed to be changed), the
337 * application has to use <code>alcSuspendContext</code>.
338 *
339 * Repeated calls to <code>alcSuspendContext</code> are legal, and do not affect a context that is
340 * already marked as suspended. The default state of a context created by
341 * <code>alcCreateContext</code> is that it is marked as suspended.
342 *
343 * @param context address of context to suspend
344 */
345 public static void alcSuspendContext(ALCcontext context) {
346 nalcSuspendContext(getContext(context));
347 }
348 native static void nalcSuspendContext(long context);
349
350 /**
351 * The correct way to destroy a context is to first release it using <code>alcMakeCurrent</code> and
352 * <code>null</code>. Applications should not attempt to destroy a current context.
353 *
354 * @param context address of context to Destroy
355 */
356 public static void alcDestroyContext(ALCcontext context) {
357 synchronized(ALC10.contexts) {
358 ALCdevice device = alcGetContextsDevice(context);
359 nalcDestroyContext(getContext(context));
360 device.removeContext(context);
361 context.setInvalid();
362 }
363 }
364 native static void nalcDestroyContext(long context);
365
366 /**
367 * ALC uses the same conventions and mechanisms as AL for error handling. In
368 * particular, ALC does not use conventions derived from X11 (GLX) or Windows
369 * (WGL). The <code>alcGetError</code> function can be used to query ALC errors.
370 *
371 * Error conditions are specific to the device.
372 *
373 * ALC_NO_ERROR - The device handle or specifier does name an accessible driver/server.
374 * <code>ALC_INVALID_DEVICE</code> - The Context argument does not name a valid context.
375 * <code>ALC_INVALID_CONTEXT</code> - The Context argument does not name a valid context.
376 * <code>ALC_INVALID_ENUM</code> - A token used is not valid, or not applicable.
377 * <code>ALC_INVALID_VALUE</code> - An value (e.g. attribute) is not valid, or not applicable.
378 *
379 * @return Errorcode from ALC statemachine
380 */
381 public static int alcGetError(ALCdevice device) {
382 return nalcGetError(getDevice(device));
383 }
384 native static int nalcGetError(long device);
385
386 /**
387 * Verify that a given extension is available for the current context and the device it
388 * is associated with.
389 * A <code>null</code> name argument returns <code>ALC_FALSE</code>, as do invalid and unsupported string
390 * tokens.
391 *
392 * @param extName name of extension to find
393 * @return true if extension is available, false if not
394 */
395 public static boolean alcIsExtensionPresent(ALCdevice device, String extName) {
396 boolean result = nalcIsExtensionPresent(getDevice(device), extName);
397 Util.checkALCError(device);
398 return result;
399 }
400 native static boolean nalcIsExtensionPresent(long device, String extName);
401
402 /**
403 * Enumeration/token values are device independend, but tokens defined for
404 * extensions might not be present for a given device. But only the tokens defined
405 * by the AL core are guaranteed. Availability of extension tokens dependends on the ALC extension.
406 *
407 * Specifying a <code>null</code> name parameter will cause an <code>ALC_INVALID_VALUE</code> error.
408 *
409 * @param enumName name of enum to find
410 * @return value of enumeration
411 */
412 public static int alcGetEnumValue(ALCdevice device, String enumName) {
413 int result = nalcGetEnumValue(getDevice(device), enumName);
414 Util.checkALCError(device);
415 return result;
416 }
417 native static int nalcGetEnumValue(long device, String enumName);
418
419 static long getDevice(ALCdevice device) {
420 if(device != null) {
421 Util.checkALCValidDevice(device);
422 return device.device;
423 }
424 return 0L;
425 }
426
427 static long getContext(ALCcontext context) {
428 if(context != null) {
429 Util.checkALCValidContext(context);
430 return context.context;
431 }
432 return 0L;
433 }
434
435 }
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.openal;
32
33 import java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.BufferUtils;
37 import org.lwjgl.LWJGLException;
38 import org.lwjgl.LWJGLUtil;
39
40
41 /**
42 * <p>
43 * The ALC11 class implements features in OpenAL 1.1, specifically
44 * ALC methods and properties.
45 * </p>
46 *
47 * @author Brian Matzon <brian@matzon.dk>
48 * @see ALC10
49 * @version $Revision: 2286 $
50 * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $
51 */
52 public final class ALC11 {
53
54 public static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012;
55 public static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013;
56
57 public static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310;
58 public static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311;
59 public static final int ALC_CAPTURE_SAMPLES = 0x312;
60
61 /**
62 * The alcCaptureOpenDevice function allows the application to connect to a capture
63 * device. To obtain a list of all available capture devices, use getCaptureDevices a list of all
64 * capture devices will be returned. Retrieving ALC_CAPTURE_DEVICE_SPECIFIER with a valid capture device specified will result
65 * in the name of that device being returned as a single string.
66 *
67 * If the function returns null, then no sound driver/device has been found, or the
68 * requested format could not be fulfilled.
69 * The "deviceName" argument is a string that requests a certain device or
70 * device configuration. If null is specified, the implementation will provide an
71 * implementation specific default. The "frequency" and "format" arguments specify the format that
72 * audio data will be presented to the application, and match the values that can be passed to
73 * alBufferData. The implementation is expected to convert and resample to this format on
74 * behalf of the application. The "buffersize" argument specifies the number of sample frames
75 * to buffer in the AL, for example, requesting a format of AL_FORMAT_STEREO16 and
76 * a buffer size of 1024 would require the AL to store up to 1024 * 4 bytes of audio data.
77 * Note that the implementation may use a larger buffer than requested if it needs to, but the
78 * implementation will set up a buffer of at least the requested size.
79 * Specifying a compressed or extension-supplied format may result in failure, even if the
80 * extension is supplied for rendering.
81 *
82 * <i>LWJGL SPECIFIC: the actual created device is managed internally in lwjgl</i>
83 *
84 * @param devicename Name of device to open for capture
85 * @param frequency Frequency of samples to capture
86 * @param format Format of samples to capture
87 * @param buffersize Size of buffer to capture to
88 * @return ALCdevice if it was possible to open a device
89 */
90 public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) {
91 long device_address = nalcCaptureOpenDevice(devicename, frequency, format, buffersize);
92 if(device_address != 0) {
93 ALCdevice device = new ALCdevice(device_address);
94 synchronized (ALC10.devices) {
95 ALC10.devices.put(new Long(device_address), device);
96 }
97 return device;
98 }
99 return null;
100 }
101 static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize);
102
103 /**
104 * The alcCaptureCloseDevice function allows the application to disconnect from a capture
105 * device.
106 *
107 * The return code will be true or false, indicating success or failure. If
108 * the device is null or invalid, an ALC_INVALID_DEVICE error will be generated.
109 * Once closed, a capture device is invalid.
110 * @return true if device was successfully closed
111 */
112 public static boolean alcCaptureCloseDevice(ALCdevice device) {
113 boolean result = nalcCaptureCloseDevice(ALC10.getDevice(device));
114 synchronized (ALC10.devices) {
115 device.setInvalid();
116 ALC10.devices.remove(new Long(device.device));
117 }
118 return result;
119 }
120 static native boolean nalcCaptureCloseDevice(long device);
121
122 /**
123 * Once a capture device has been opened via alcCaptureOpenDevice, it is made to start
124 * recording audio via the alcCaptureStart entry point:
125 *
126 * Once started, the device will record audio to an internal ring buffer, the size of which was
127 * specified when opening the device.
128 * The application may query the capture device to discover how much data is currently
129 * available via the alcGetInteger with the ALC_CAPTURE_SAMPLES token. This will
130 * report the number of sample frames currently available.
131 */
132 public static void alcCaptureStart(ALCdevice device) {
133 nalcCaptureStart(ALC10.getDevice(device));
134 }
135 static native void nalcCaptureStart(long device);
136
137 /**
138 * If the application doesn't need to capture more audio for an amount of time, they can halt
139 * the device without closing it via the alcCaptureStop entry point.
140 * The implementation is encouraged to optimize for this case. The amount of audio
141 * samples available after restarting a stopped capture device is reset to zero. The
142 * application does not need to stop the capture device to read from it.
143 */
144 public static void alcCaptureStop(ALCdevice device) {
145 nalcCaptureStop(ALC10.getDevice(device));
146 }
147 static native void nalcCaptureStop(long device);
148
149 /**
150 * When the application feels there are enough samples available to process, it can obtain
151 * them from the AL via the alcCaptureSamples entry point.
152 *
153 * The "buffer" argument specifies an application-allocated buffer that can contain at least
154 * "samples" sample frames. The implementation may defer conversion and resampling until
155 * this point. Requesting more sample frames than are currently available is an error.
156 *
157 * @param buffer Buffer to store samples in
158 * @param samples Number of samples to request
159 */
160 public static void alcCaptureSamples(ALCdevice device, ByteBuffer buffer, int samples ) {
161 nalcCaptureSamples(ALC10.getDevice(device), buffer, buffer.position(), samples);
162 }
163 static native void nalcCaptureSamples(long device, ByteBuffer buffer, int position, int samples );
164
165 static native void initNativeStubs() throws LWJGLException;
166
167 /**
168 * Initializes ALC11, including any extensions
169 * @return true if initialization was successfull
170 */
171 static boolean initialize() {
172 try {
173 IntBuffer ib = BufferUtils.createIntBuffer(2);
174 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib);
175 ib.position(1);
176 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib);
177
178 int major = ib.get(0);
179 int minor = ib.get(1);
180
181 // checking for version 1.x+
182 if(major >= 1) {
183
184 // checking for version 1.1+
185 if(major > 1 || minor >= 1) {
186 ALC11.initNativeStubs();
187 AL11.initNativeStubs();
188 }
189 }
190 } catch (LWJGLException le) {
191 LWJGLUtil.log("failed to initialize ALC11: " + le);
192 return false;
193 }
194 return true;
195 }
196 }
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.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36
37 /**
38 * The ALCcontext class represents a context opened in OpenAL space.
39 *
40 * All operations of the AL core API affect a current AL context. Within the scope of AL,
41 * the ALC is implied - it is not visible as a handle or function parameter. Only one AL
42 * Context per process can be current at a time. Applications maintaining multiple AL
43 * Contexts, whether threaded or not, have to set the current context accordingly.
44 * Applications can have multiple threads that share one more or contexts. In other words,
45 * AL and ALC are threadsafe.
46 *
47 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2983 $
49 * $Id: ALCcontext.java 2983 2008-04-07 18:36:09Z matzon $
50 */
51 public final class ALCcontext {
52
53 /** Address of actual context */
54 final long context;
55
56 /** Whether this context is valid */
57 private boolean valid = false;
58
59 /**
60 * Creates a new instance of ALCcontext
61 *
62 * @param context address of actual context
63 */
64 ALCcontext(long context) {
65 this.context = context;
66 this.valid = true;
67 }
68
69 /*
70 * @see java.lang.Object#equals(java.lang.Object)
71 */
72 public boolean equals(Object context) {
73 if(context instanceof ALCcontext) {
74 return ((ALCcontext)context).context == this.context;
75 }
76 return super.equals(context);
77 }
78
79 /**
80 * Creates an attribute list in a ByteBuffer
81 * @param contextFrequency Frequency to add
82 * @param contextRefresh Refresh rate to add
83 * @param contextSynchronized Whether to synchronize the context
84 * @return
85 */
86 static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
87 IntBuffer attribList = BufferUtils.createIntBuffer(7);
88
89 attribList.put(ALC10.ALC_FREQUENCY);
90 attribList.put(contextFrequency);
91 attribList.put(ALC10.ALC_REFRESH);
92 attribList.put(contextRefresh);
93 attribList.put(ALC10.ALC_SYNC);
94 attribList.put(contextSynchronized);
95 attribList.put(0); //terminating int
96
97 return attribList;
98 }
99
100 /**
101 * Marks this context as invalid
102 *
103 */
104 void setInvalid() {
105 valid = false;
106 }
107
108 /**
109 * @return true if this context is still valid
110 */
111 public boolean isValid() {
112 return valid;
113 }
114 }
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.openal;
32
33 import java.util.HashMap;
34 import java.util.Iterator;
35
36 /**
37 * The ALCdevice class represents a device opened in OpenAL space.
38 *
39 * ALC introduces the notion of a Device. A Device can be, depending on the
40 * implementation, a hardware device, or a daemon/OS service/actual server. This
41 * mechanism also permits different drivers (and hardware) to coexist within the same
42 * system, as well as allowing several applications to share system resources for audio,
43 * including a single hardware output device. The details are left to the implementation,
44 * which has to map the available backends to unique device specifiers.
45 *
46 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 2983 $
48 * $Id: ALCdevice.java 2983 2008-04-07 18:36:09Z matzon $
49 */
50 public final class ALCdevice {
51
52 /** Address of actual device */
53 final long device;
54
55 /** Whether this device is valid */
56 private boolean valid = false;
57
58 /** List of contexts belonging to the device */
59 private HashMap contexts = new HashMap();
60
61 /**
62 * Creates a new instance of ALCdevice
63 *
64 * @param device address of actual device
65 */
66 ALCdevice(long device) {
67 this.device = device;
68 this.valid = true;
69 }
70
71 /*
72 * @see java.lang.Object#equals(java.lang.Object)
73 */
74 public boolean equals(Object device) {
75 if(device instanceof ALCdevice) {
76 return ((ALCdevice)device).device == this.device;
77 }
78 return super.equals(device);
79 }
80
81 /**
82 * Adds a context to the device
83 *
84 * @param context context to add to the list of contexts for this device
85 */
86 void addContext(ALCcontext context) {
87 synchronized (contexts) {
88 contexts.put(new Long(context.context), context);
89 }
90 }
91
92 /**
93 * Remove context associated with device
94 *
95 * @param context Context to disassociate with device
96 */
97 void removeContext(ALCcontext context) {
98 synchronized (contexts) {
99 contexts.remove(new Long(context.context));
100 }
101 }
102
103 /**
104 * Marks this device and all of its contexts invalid
105 */
106 void setInvalid() {
107 valid = false;
108 synchronized (contexts) {
109 for(Iterator i = contexts.values().iterator(); i.hasNext();) {
110 ALCcontext context = (ALCcontext) i.next();
111 context.setInvalid();
112 }
113 }
114 contexts.clear();
115 }
116
117 /**
118 * @return true if this device is still valid
119 */
120 public boolean isValid() {
121 return valid;
122 }
123 }
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.openal;
32
33 /**
34 * <br>
35 * Thrown by the debug build library of the LWJGL if any OpenAL operation
36 * causes an error.
37 *
38 * @author Brian Matzon <brian@matzon.dk>
39 * @version $Revision: 2983 $
40 * $Id: OpenALException.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42 public class OpenALException extends RuntimeException {
43
44 private static final long serialVersionUID = 1L;
45
46 /**
47 * Constructor for OpenALException.
48 */
49 public OpenALException() {
50 super();
51 }
52
53 /**
54 * Constructor that takes an AL error number
55 */
56 public OpenALException(int error_code) {
57 super("OpenAL error: " + AL10.alGetString(error_code) + " (" + error_code + ")");
58 }
59
60 /**
61 * Constructor for OpenALException.
62 * @param message
63 */
64 public OpenALException(String message) {
65 super(message);
66 }
67
68 /**
69 * Constructor for OpenALException.
70 * @param message
71 * @param cause
72 */
73 public OpenALException(String message, Throwable cause) {
74 super(message, cause);
75 }
76
77 /**
78 * Constructor for OpenALException.
79 * @param cause
80 */
81 public OpenALException(Throwable cause) {
82 super(cause);
83 }
84 }
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.openal;
32
33
34 /**
35 * Simple utility class for checking AL/ALC errors
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @author Brian Matzon <brian@matzon.dk>
39 * @version $Revision: 2983 $
40 */
41
42 public final class Util {
43 /** No c'tor */
44 private Util() {
45 }
46
47 /**
48 * Checks for any ALC errors and throws an unchecked exception on errors
49 * @param device Device for which to check ALC errors
50 */
51 public static void checkALCError(ALCdevice device) {
52 int err = ALC10.alcGetError(device);
53 if (err != ALC10.ALC_NO_ERROR)
54 throw new OpenALException(ALC10.alcGetString(AL.getDevice(), err));
55 }
56
57 /**
58 * Checks for any AL errors and throws an unchecked exception on errors
59 */
60 public static void checkALError() {
61 int err = AL10.alGetError();
62 if (err != AL10.AL_NO_ERROR)
63 throw new OpenALException(err);
64 }
65
66 /**
67 * Checks for a valid device
68 * @param device ALCdevice to check the validity of
69 */
70 public static void checkALCValidDevice(ALCdevice device) {
71 if(!device.isValid()) {
72 throw new OpenALException("Invalid device: " + device);
73 }
74 }
75
76 /**
77 * Checks for a valid context
78 * @param context ALCcontext to check the validity of
79 */
80 public static void checkALCValidContext(ALCcontext context) {
81 if(!context.isValid()) {
82 throw new OpenALException("Invalid context: " + context);
83 }
84 }
85 }
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
35 import java.nio.*;
36 import java.nio.charset.Charset;
37 import java.nio.charset.CharsetEncoder;
38
39 /** @author spasi */
40 final class APIUtils {
41
42 private static final int INITIAL_BUFFER_SIZE = 256;
43 private static final int INITIAL_LENGTHS_SIZE = 4;
44
45 private static final int BUFFERS_SIZE = 32;
46
47 private static final ThreadLocal arrayTL = new ThreadLocal() {
48 protected Object initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
49 };
50
51 private static final ThreadLocal bufferTL = new ThreadLocal() {
52 protected Object initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
53 };
54
55 private static final ThreadLocal lengthsTL = new ThreadLocal() {
56 protected Object initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); }
57 };
58
59 private static final ThreadLocal infiniteSeqTL = new ThreadLocal() {
60 protected Object initialValue() { return new InfiniteCharSequence(); }
61 };
62
63 private static final ThreadLocal buffersTL = new ThreadLocal() {
64 protected Object initialValue() { return new Buffers(); }
65 };
66
67 private static CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder();
68
69 private APIUtils() {
70 }
71
72 private static char[] getArray(final int size) {
73 char[] array = (char[])arrayTL.get();
74
75 if ( array.length < size ) {
76 int sizeNew = array.length << 1;
77 while ( sizeNew < size )
78 sizeNew <<= 1;
79
80 array = new char[size];
81 arrayTL.set(array);
82 }
83
84 return array;
85 }
86
87 static ByteBuffer getBufferByte(final int size) {
88 ByteBuffer buffer = (ByteBuffer)bufferTL.get();
89
90 if ( buffer.capacity() < size ) {
91 int sizeNew = buffer.capacity() << 1;
92 while ( sizeNew < size )
93 sizeNew <<= 1;
94
95 buffer = BufferUtils.createByteBuffer(size);
96 bufferTL.set(buffer);
97 } else
98 buffer.clear();
99
100 return buffer;
101 }
102
103 private static ByteBuffer getBufferByteOffset(final int size) {
104 ByteBuffer buffer = (ByteBuffer)bufferTL.get();
105
106 if ( buffer.capacity() < size ) {
107 int sizeNew = buffer.capacity() << 1;
108 while ( sizeNew < size )
109 sizeNew <<= 1;
110
111 final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
112 bufferNew.put(buffer);
113 bufferTL.set(buffer = bufferNew);
114 } else {
115 buffer.position(buffer.limit());
116 buffer.limit(buffer.capacity());
117 }
118
119 return buffer;
120 }
121
122 static ShortBuffer getBufferShort() { return ((Buffers)buffersTL.get()).shorts; }
123
124 static IntBuffer getBufferInt() { return ((Buffers)buffersTL.get()).ints; }
125
126 static LongBuffer getBufferLong() { return ((Buffers)buffersTL.get()).longs; }
127
128 static FloatBuffer getBufferFloat() { return ((Buffers)buffersTL.get()).floats; }
129
130 static DoubleBuffer getBufferDouble() { return ((Buffers)buffersTL.get()).doubles; }
131
132 static IntBuffer getLengths() {
133 return getLengths(1);
134 }
135
136 static IntBuffer getLengths(final int size) {
137 IntBuffer lengths = (IntBuffer)lengthsTL.get();
138
139 if ( lengths.capacity() < size ) {
140 int sizeNew = lengths.capacity();
141 while ( sizeNew < size )
142 sizeNew <<= 1;
143
144 lengths = BufferUtils.createIntBuffer(size);
145 lengthsTL.set(lengths);
146 } else
147 lengths.clear();
148
149 return lengths;
150 }
151
152 private static InfiniteCharSequence getInfiniteSeq() {
153 return (InfiniteCharSequence)infiniteSeqTL.get();
154 }
155
156 private static void encode(final ByteBuffer buffer, final CharSequence string) {
157 final InfiniteCharSequence infiniteSeq = getInfiniteSeq();
158 infiniteSeq.setString(string);
159 encoder.encode(infiniteSeq.buffer, buffer, true);
160 }
161
162 /**
163 * Reads a byte string from the specified buffer.
164 *
165 * @param buffer
166 *
167 * @return the buffer as a String.
168 */
169 static String getString(final ByteBuffer buffer) {
170 final int length = buffer.remaining();
171 final char[] charArray = getArray(length);
172
173 for ( int i = buffer.position(); i < buffer.limit(); i++ )
174 charArray[i - buffer.position()] = (char)buffer.get(i);
175
176 return new String(charArray, 0, length);
177 }
178
179 /**
180 * Returns a buffer containing the specified string as bytes.
181 *
182 * @param string
183 *
184 * @return the String as a ByteBuffer
185 */
186 static ByteBuffer getBuffer(final CharSequence string) {
187 final ByteBuffer buffer = getBufferByte(string.length());
188
189 encode(buffer, string);
190
191 buffer.flip();
192 return buffer;
193 }
194
195 /**
196 * Returns a buffer containing the specified string as bytes, starting at the specified offset.
197 *
198 * @param string
199 *
200 * @return the String as a ByteBuffer
201 */
202 static ByteBuffer getBuffer(final CharSequence string, final int offset) {
203 final ByteBuffer buffer = getBufferByteOffset(offset + string.length());
204
205 encode(buffer, string);
206
207 buffer.flip();
208 return buffer;
209 }
210
211 /**
212 * Returns a buffer containing the specified string as bytes, including null-termination.
213 *
214 * @param string
215 *
216 * @return the String as a ByteBuffer
217 */
218 static ByteBuffer getBufferNT(final CharSequence string) {
219 final ByteBuffer buffer = getBufferByte(string.length() + 1);
220
221 encode(buffer, string);
222
223 buffer.put((byte)0);
224 buffer.flip();
225 return buffer;
226 }
227
228 static int getTotalLength(final CharSequence[] strings) {
229 int length = 0;
230 for ( int i = 0; i < strings.length; i++ )
231 length += strings[i].length();
232
233 return length;
234 }
235
236 /**
237 * Returns a buffer containing the specified strings as bytes.
238 *
239 * @param strings
240 *
241 * @return the Strings as a ByteBuffer
242 */
243 static ByteBuffer getBuffer(final CharSequence[] strings) {
244 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
245
246 final InfiniteCharSequence infiniteSeq = getInfiniteSeq();
247 for ( int i = 0; i < strings.length; i++ ) {
248 infiniteSeq.setString(strings[i]);
249 encoder.encode(infiniteSeq.buffer, buffer, true);
250 }
251 infiniteSeq.clear();
252
253 buffer.flip();
254 return buffer;
255 }
256
257 /**
258 * Returns a buffer containing the specified strings as bytes, including null-termination.
259 *
260 * @param strings
261 *
262 * @return the Strings as a ByteBuffer
263 */
264 static ByteBuffer getBufferNT(final CharSequence[] strings) {
265 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
266
267 final InfiniteCharSequence infiniteSeq = getInfiniteSeq();
268 for ( int i = 0; i < strings.length; i++ ) {
269 infiniteSeq.setString(strings[i]);
270 encoder.encode(infiniteSeq.buffer, buffer, true);
271 buffer.put((byte)0);
272 }
273 infiniteSeq.clear();
274
275 buffer.flip();
276 return buffer;
277 }
278
279 /**
280 * Returns a buffer containing the lengths of the specified strings.
281 *
282 * @param strings
283 *
284 * @return the String lengths in an IntBuffer
285 */
286 static IntBuffer getLengths(final CharSequence[] strings) {
287 IntBuffer buffer = getLengths(strings.length);
288
289 for ( int i = 0; i < strings.length; i++ )
290 buffer.put(strings[i].length());
291
292 buffer.flip();
293 return buffer;
294 }
295
296 /**
297 * A mutable CharSequence with very large initial length. We can wrap this in a re-usable CharBuffer for decoding.
298 * We cannot subclass CharBuffer because of {@link CharBuffer#toString(int,int)}.
299 */
300 private static class InfiniteCharSequence implements CharSequence {
301
302 final CharBuffer buffer;
303
304 CharSequence string;
305
306 InfiniteCharSequence() {
307 buffer = CharBuffer.wrap(this);
308 }
309
310 void setString(final CharSequence string) {
311 this.string = string;
312 this.buffer.position(0);
313 this.buffer.limit(string.length());
314 }
315
316 void clear() {
317 this.string = null;
318 }
319
320 public int length() {
321 return Integer.MAX_VALUE;
322 }
323
324 public char charAt(final int index) {
325 return string.charAt(index);
326 }
327
328 public CharSequence subSequence(final int start, final int end) {
329 return string.subSequence(start, end);
330 }
331 }
332
333 private static class Buffers {
334
335 final ShortBuffer shorts;
336 final IntBuffer ints;
337 final LongBuffer longs;
338
339 final FloatBuffer floats;
340 final DoubleBuffer doubles;
341
342 Buffers() {
343 shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
344 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
345 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
346
347 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
348 doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
349 }
350
351 }
352
353 }
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 java.awt.GraphicsConfiguration;
34 import java.awt.GraphicsDevice;
35 import java.awt.Canvas;
36
37 import org.lwjgl.LWJGLException;
38
39 /**
40 *
41 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3002 $
43 * $Id: AWTCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $
44 */
45 interface AWTCanvasImplementation {
46 /**
47 * Return an opaque handle to the canvas peer information required to create a context from it.
48 */
49 PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException;
50
51 /**
52 * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
53 *
54 * @return A GraphicsConfiguration matching the given GraphicsConfiguration and PixelFormat.
55 * @throws LWJGLException if no suitable configuration could be found.
56 */
57 GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException;
58 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36
37 import java.awt.*;
38 import java.awt.event.ComponentEvent;
39 import java.awt.event.ComponentListener;
40 import java.awt.event.HierarchyEvent;
41 import java.awt.event.HierarchyListener;
42
43 /**
44 * <p/>
45 * An AWT rendering context.
46 * <p/>
47 *
48 * @author $Author: spasi $
49 * $Id: AWTGLCanvas.java 3116 2008-08-19 16:46:03Z spasi $
50 * @version $Revision: 3116 $
51 */
52 public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener {
53
54 private static final long serialVersionUID = 1L;
55
56 private final static AWTCanvasImplementation implementation;
57 private boolean update_context;
58 private Object SYNC_LOCK = new Object();
59
60 /** The requested pixel format */
61 private final PixelFormat pixel_format;
62
63 /** The drawable to share context with */
64 private final Drawable drawable;
65
66 /** The ContextAttribs to use when creating the context */
67 private final ContextAttribs attribs;
68
69 /** Context handle */
70 private PeerInfo peer_info;
71 private Context context;
72
73 /**
74 * re-entry counter for support for re-entrant
75 * redrawing in paint(). It happens when using dialog boxes.
76 */
77 private int reentry_count;
78
79 /** Tracks whether initGL() needs to be called */
80 private boolean first_run;
81
82 static {
83 Sys.initialize();
84 implementation = createImplementation();
85 }
86
87 static AWTCanvasImplementation createImplementation() {
88 switch ( LWJGLUtil.getPlatform() ) {
89 case LWJGLUtil.PLATFORM_LINUX:
90 return new LinuxCanvasImplementation();
91 case LWJGLUtil.PLATFORM_WINDOWS:
92 return new WindowsCanvasImplementation();
93 case LWJGLUtil.PLATFORM_MACOSX:
94 return new MacOSXCanvasImplementation();
95 default:
96 throw new IllegalStateException("Unsupported platform");
97 }
98 }
99
100 private void setUpdate() {
101 synchronized ( SYNC_LOCK ) {
102 update_context = true;
103 }
104 }
105
106 /** This method should only be called internally. */
107 public Context getContext() {
108 return context;
109 }
110
111 /** Constructor using the default PixelFormat. */
112 public AWTGLCanvas() throws LWJGLException {
113 this(new PixelFormat());
114 }
115
116 /**
117 * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.
118 *
119 * @param pixel_format The desired pixel format. May not be null
120 */
121 public AWTGLCanvas(PixelFormat pixel_format) throws LWJGLException {
122 this(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), pixel_format);
123 }
124
125 /**
126 * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.
127 *
128 * @param device the device to create the canvas on.
129 * @param pixel_format The desired pixel format. May not be null
130 */
131 public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
132 this(device, pixel_format, null);
133 }
134
135 /**
136 * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.
137 *
138 * @param device the device to create the canvas on.
139 * @param pixel_format The desired pixel format. May not be null
140 * @param drawable The Drawable to share context with
141 */
142 public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException {
143 this(device, pixel_format, drawable, null);
144 }
145
146 /**
147 * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.
148 *
149 * @param device the device to create the canvas on.
150 * @param pixel_format The desired pixel format. May not be null
151 * @param drawable The Drawable to share context with
152 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
153 */
154 public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLException {
155 super(implementation.findConfiguration(device, pixel_format));
156 if ( pixel_format == null )
157 throw new NullPointerException("Pixel format must be non-null");
158 addHierarchyListener(this);
159 addComponentListener(this);
160 this.drawable = drawable;
161 this.pixel_format = pixel_format;
162 this.attribs = attribs;
163 }
164
165 /* (non-Javadoc)
166 * @see java.awt.Canvas#addNotify()
167 */
168 public void addNotify() {
169 super.addNotify();
170 }
171
172 /* (non-Javadoc)
173 * @see java.awt.Component#removeNotify()
174 */
175 public void removeNotify() {
176 synchronized ( SYNC_LOCK ) {
177 destroyContext();
178 super.removeNotify();
179 }
180 }
181
182 /** Set swap interval. */
183 public void setSwapInterval(int swap_interval) {
184 synchronized ( SYNC_LOCK ) {
185 if ( context == null )
186 throw new IllegalStateException("Canvas not yet displayable");
187 Context.setSwapInterval(swap_interval);
188 }
189 }
190
191 /** Enable vsync */
192 public void setVSyncEnabled(boolean enabled) {
193 setSwapInterval(enabled ? 1 : 0);
194 }
195
196 /** Swap the canvas' buffer */
197 public void swapBuffers() throws LWJGLException {
198 synchronized ( SYNC_LOCK ) {
199 if ( context == null )
200 throw new IllegalStateException("Canvas not yet displayable");
201 Context.swapBuffers();
202 }
203 }
204
205 public void releaseContext() throws LWJGLException {
206 synchronized ( SYNC_LOCK ) {
207 if ( context == null )
208 throw new IllegalStateException("Canvas not yet displayable");
209 if ( context.isCurrent() )
210 Context.releaseCurrentContext();
211 }
212 }
213
214 /**
215 * Make the canvas' context current. It is highly recommended that the context
216 * is only made current inside the AWT thread (for example in an overridden paintGL()).
217 */
218 public void makeCurrent() throws LWJGLException {
219 synchronized ( SYNC_LOCK ) {
220 if ( context == null )
221 throw new IllegalStateException("Canvas not yet displayable");
222 context.makeCurrent();
223 }
224 }
225
226 /** Destroy the OpenGL context. This happens when the component becomes undisplayable */
227 private void destroyContext() {
228 synchronized ( SYNC_LOCK ) {
229 try {
230 if ( context != null ) {
231 context.forceDestroy();
232 context = null;
233 reentry_count = 0;
234 peer_info.destroy();
235 peer_info = null;
236 }
237 } catch (LWJGLException e) {
238 throw new RuntimeException(e);
239 }
240 }
241 }
242
243 /**
244 * Override this to do initialising of the context.
245 * It will be called once from paint(), immediately after
246 * the context is created and made current.
247 */
248 protected void initGL() {
249 }
250
251 /** Override this to do painting */
252 protected void paintGL() {
253 }
254
255 /**
256 * The default paint() operation makes the context current and calls paintGL() which should
257 * be overridden to do GL operations.
258 */
259 public final void paint(Graphics g) {
260 LWJGLException exception = null;
261 synchronized ( SYNC_LOCK ) {
262 if ( !isDisplayable() )
263 return;
264 try {
265 if ( peer_info == null ) {
266 this.peer_info = implementation.createPeerInfo(this, pixel_format);
267 }
268 peer_info.lockAndGetHandle();
269 try {
270 if ( context == null ) {
271 this.context = new Context(peer_info, attribs, drawable != null ? drawable.getContext() : null);
272 first_run = true;
273 }
274
275 if ( reentry_count == 0 )
276 context.makeCurrent();
277 reentry_count++;
278 try {
279 if ( update_context ) {
280 context.update();
281 update_context = false;
282 }
283 if ( first_run ) {
284 first_run = false;
285 initGL();
286 }
287 paintGL();
288 } finally {
289 reentry_count--;
290 if ( reentry_count == 0 )
291 Context.releaseCurrentContext();
292 }
293 } finally {
294 peer_info.unlock();
295 }
296 } catch (LWJGLException e) {
297 exception = e;
298 }
299 }
300 if ( exception != null )
301 exceptionOccurred(exception);
302 }
303
304 /**
305 * This method will be called if an unhandled LWJGLException occurs in paint().
306 * Override this method to be notified of this.
307 *
308 * @param exception The exception that occurred.
309 */
310 protected void exceptionOccurred(LWJGLException exception) {
311 LWJGLUtil.log("Unhandled exception occurred, skipping paint(): " + exception);
312 }
313
314 /** override update to avoid clearing */
315 public void update(Graphics g) {
316 paint(g);
317 }
318
319 public void componentShown(ComponentEvent e) {
320 }
321
322 public void componentHidden(ComponentEvent e) {
323 }
324
325 public void componentResized(ComponentEvent e) {
326 setUpdate();
327 }
328
329 public void componentMoved(ComponentEvent e) {
330 setUpdate();
331 }
332
333 public void setLocation(int x, int y) {
334 super.setLocation(x, y);
335 setUpdate();
336 }
337
338 public void setLocation(Point p) {
339 super.setLocation(p);
340 setUpdate();
341 }
342
343 public void setSize(Dimension d) {
344 super.setSize(d);
345 setUpdate();
346 }
347
348 public void setSize(int width, int height) {
349 super.setSize(width, height);
350 setUpdate();
351 }
352
353 public void setBounds(int x, int y, int width, int height) {
354 super.setBounds(x, y, width, height);
355 setUpdate();
356 }
357
358 public void hierarchyChanged(HierarchyEvent e) {
359 setUpdate();
360 }
361
362 }
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 java.awt.Canvas;
34 import java.nio.ByteBuffer;
35 import java.security.AccessController;
36 import java.security.PrivilegedActionException;
37 import java.security.PrivilegedExceptionAction;
38
39 import org.lwjgl.LWJGLException;
40 import org.lwjgl.LWJGLUtil;
41
42 /**
43 *
44 * @author elias_naur <elias_naur@users.sourceforge.net>
45 * @version $Revision: 3116 $
46 * $Id: AWTSurfaceLock.java 3116 2008-08-19 16:46:03Z spasi $
47 */
48 final class AWTSurfaceLock {
49
50 private final static int WAIT_DELAY_MILLIS = 100;
51
52 private final ByteBuffer lock_buffer;
53
54 private boolean firstLockSucceeded = false;
55
56 AWTSurfaceLock() {
57 lock_buffer = createHandle();
58 }
59
60 private static native ByteBuffer createHandle();
61
62 public ByteBuffer lockAndGetHandle(Canvas component) throws LWJGLException {
63 while (!privilegedLockAndInitHandle(component)) {
64 LWJGLUtil.log("Could not get drawing surface info, retrying...");
65 try {
66 Thread.sleep(WAIT_DELAY_MILLIS);
67 } catch (InterruptedException e) {
68 LWJGLUtil.log("Interrupted while retrying: " + e);
69 }
70 }
71
72 return lock_buffer;
73 }
74
75 private boolean privilegedLockAndInitHandle(final Canvas component) throws LWJGLException {
76 // Workaround for Sun JDK bug 4796548 which still exists in java for OS X
77 // We need to elevate privileges because of an AWT bug. Please see
78 // http://192.18.37.44/forums/index.php?topic=10572 for a discussion.
79 // It is only needed on first call, so we avoid it on all subsequent calls
80 // due to performance.
81 if (firstLockSucceeded)
82 return lockAndInitHandle(lock_buffer, component);
83 else
84 try {
85 final Object result = AccessController.doPrivileged(new PrivilegedExceptionAction() {
86
87 public Object run() throws LWJGLException {
88 return Boolean.valueOf(lockAndInitHandle(lock_buffer, component));
89 }
90 });
91 firstLockSucceeded = ((Boolean) result).booleanValue();
92 return firstLockSucceeded;
93 } catch (PrivilegedActionException e) {
94 throw (LWJGLException) e.getException();
95 }
96 }
97
98 private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException;
99
100 void unlock() throws LWJGLException {
101 nUnlock(lock_buffer);
102 }
103
104 private static native void nUnlock(ByteBuffer lock_buffer) throws LWJGLException;
105 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 import java.awt.Component;
38 import java.awt.Cursor;
39 import java.awt.Dimension;
40 import java.awt.GraphicsConfiguration;
41 import java.awt.GraphicsDevice;
42 import java.awt.IllegalComponentStateException;
43 import java.awt.MouseInfo;
44 import java.awt.Point;
45 import java.awt.PointerInfo;
46 import java.awt.Robot;
47 import java.awt.Toolkit;
48 import java.awt.image.BufferedImage;
49 import java.nio.IntBuffer;
50 import java.security.AccessController;
51 import java.security.PrivilegedActionException;
52 import java.security.PrivilegedExceptionAction;
53
54 import org.lwjgl.LWJGLException;
55 import org.lwjgl.LWJGLUtil;
56
57 final class AWTUtil {
58 public static boolean hasWheel() {
59 return true;
60 }
61
62 public static int getButtonCount() {
63 return MouseEventQueue.NUM_BUTTONS;
64 }
65
66 public static int getNativeCursorCapabilities() {
67 if (LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX || LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) {
68 int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors();
69 boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0;
70 int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0 | org.lwjgl.input.Cursor.CURSOR_ANIMATION;
71 return caps;
72 } else {
73 /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with
74 minimal test case):
75 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a
76 Componennt, it is reset to the default pointer cursor when the window is de-
77 activated and the re-activated. The Cursor can not be reset to the custom cursor,
78 with another setCursor.
79 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
80 mode, no mouse moved events are reported, even though mouse pressed/released and dragged
81 events are reported
82 */
83 return 0;
84 }
85 }
86
87 public static Robot createRobot(final Component component) {
88 try {
89 Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() {
90 public Object run() throws Exception {
91 return new Robot(component.getGraphicsConfiguration().getDevice());
92 }
93 });
94 return robot;
95 } catch (PrivilegedActionException e) {
96 LWJGLUtil.log("Got exception while creating robot: " + e.getCause());
97 return null;
98 }
99 }
100
101 private static int transformY(Component component, int y) {
102 return component.getHeight() - 1 - y;
103 }
104
105 /**
106 * Use reflection to access the JDK 1.5 pointer location, if possible and
107 * only if the given component is on the same screen as the cursor. Return
108 * null otherwise.
109 */
110 private static Point getPointerLocation(final Component component) {
111 try {
112 final GraphicsConfiguration config = component.getGraphicsConfiguration();
113 if (config != null) {
114 PointerInfo pointer_info = (PointerInfo)AccessController.doPrivileged(new PrivilegedExceptionAction() {
115 public Object run() throws Exception {
116 return MouseInfo.getPointerInfo();
117 }
118 });
119 GraphicsDevice device = pointer_info.getDevice();
120 if (device == config.getDevice()) {
121 return pointer_info.getLocation();
122 }
123 return null;
124 }
125 } catch (PrivilegedActionException e) {
126 LWJGLUtil.log("Failed to query pointer location: " + e.getCause());
127 }
128 return null;
129 }
130
131 /**
132 * Use the 1.5 API to get the cursor position relative to the component. Return null
133 * if it fails (JDK <= 1.4).
134 */
135 public static Point getCursorPosition(Component component) {
136 try {
137 Point pointer_location = getPointerLocation(component);
138 if (pointer_location != null) {
139 Point location = component.getLocationOnScreen();
140 pointer_location.translate(-location.x, -location.y);
141 pointer_location.move(pointer_location.x, transformY(component, pointer_location.y));
142 return pointer_location;
143 }
144 } catch (IllegalComponentStateException e) {
145 LWJGLUtil.log("Failed to set cursor position: " + e);
146 } catch (NoClassDefFoundError e) { // Not JDK 1.5
147 LWJGLUtil.log("Failed to query cursor position: " + e);
148 }
149 return null;
150 }
151
152 public static void setCursorPosition(Component component, Robot robot, int x, int y) {
153 if (robot != null) {
154 try {
155 Point location = component.getLocationOnScreen();
156 int transformed_x = location.x + x;
157 int transformed_y = location.y + transformY(component, y);
158 robot.mouseMove(transformed_x, transformed_y);
159 } catch (IllegalComponentStateException e) {
160 LWJGLUtil.log("Failed to set cursor position: " + e);
161 }
162 }
163 }
164
165 public static int getMinCursorSize() {
166 Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0);
167 return Math.max(min_size.width, min_size.height);
168 }
169
170 public static int getMaxCursorSize() {
171 Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000);
172 return Math.min(max_size.width, max_size.height);
173 }
174
175 /** Native cursor handles */
176 public static Cursor createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
177 BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
178 int[] pixels = new int[images.remaining()];
179 int old_position = images.position();
180 images.get(pixels);
181 images.position(old_position);
182 cursor_image.setRGB(0, 0, width, height, pixels, 0, width);
183 return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor");
184 }
185 }
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 java.nio.Buffer;
34 import java.nio.IntBuffer;
35 import java.util.Arrays;
36
37 class BaseReferences {
38
39 int elementArrayBuffer;
40 int arrayBuffer;
41 Buffer[] glVertexAttribPointer_buffer;
42 Buffer[] glTexCoordPointer_buffer;
43 int glClientActiveTexture;
44
45 int pixelPackBuffer;
46 int pixelUnpackBuffer;
47
48 int indirectBuffer;
49
50 BaseReferences(ContextCapabilities caps) {
51 IntBuffer temp = caps.scratch_int_buffer;
52
53 int max_vertex_attribs;
54 if (caps.OpenGL20 || caps.GL_ARB_vertex_shader) {
55 GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB, temp);
56 max_vertex_attribs = temp.get(0);
57 } else
58 max_vertex_attribs = 0;
59 glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
60
61 int max_texture_units;
62 if (caps.OpenGL20) {
63 GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS, temp);
64 max_texture_units = temp.get(0);
65 } else if (caps.OpenGL13 || caps.GL_ARB_multitexture) {
66 GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, temp);
67 max_texture_units = temp.get(0);
68 } else
69 max_texture_units = 1;
70 glTexCoordPointer_buffer = new Buffer[max_texture_units];
71 }
72
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);
79
80 this.pixelPackBuffer = 0;
81 this.pixelUnpackBuffer = 0;
82
83 this.indirectBuffer = 0;
84 }
85
86 void copy(BaseReferences references, int mask) {
87 if ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {
88 this.elementArrayBuffer = references.elementArrayBuffer;
89 this.arrayBuffer = references.arrayBuffer;
90 this.glClientActiveTexture = references.glClientActiveTexture;
91 System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
92 System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
93
94 this.indirectBuffer = references.indirectBuffer;
95 }
96
97 if ( (mask & GL11.GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
98 this.pixelPackBuffer = references.pixelPackBuffer;
99 this.pixelUnpackBuffer = references.pixelUnpackBuffer;
100 }
101 }
102 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36
37 import java.nio.ByteBuffer;
38 import java.nio.IntBuffer;
39
40 /**
41 * <p/>
42 * Context encapsulates an OpenGL context.
43 * <p/>
44 * <p/>
45 * This class is thread-safe.
46 *
47 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3117 $
49 * $Id: Context.java 3117 2008-08-19 17:47:24Z spasi $
50 */
51 final class Context {
52
53 /** The platform specific implementation of context methods */
54 private final static ContextImplementation implementation;
55
56 /** The current Context */
57 private final static ThreadLocal current_context_local = new ThreadLocal();
58
59 /** Handle to the native GL rendering context */
60 private final ByteBuffer handle;
61 private final PeerInfo peer_info;
62
63 private final IntBuffer attribList;
64 private final boolean forwardCompatible;
65
66 /** Whether the context has been destroyed */
67 private boolean destroyed;
68
69 private boolean destroy_requested;
70
71 /** The thread that has this context current, or null. */
72 private Thread thread;
73
74 static {
75 Sys.initialize();
76 implementation = createImplementation();
77 }
78
79 private static ContextImplementation createImplementation() {
80 switch ( LWJGLUtil.getPlatform() ) {
81 case LWJGLUtil.PLATFORM_LINUX:
82 return new LinuxContextImplementation();
83 case LWJGLUtil.PLATFORM_WINDOWS:
84 return new WindowsContextImplementation();
85 case LWJGLUtil.PLATFORM_MACOSX:
86 return new MacOSXContextImplementation();
87 default:
88 throw new IllegalStateException("Unsupported platform");
89 }
90 }
91
92 PeerInfo getPeerInfo() {
93 return peer_info;
94 }
95
96 static Context getCurrentContext() {
97 return (Context)current_context_local.get();
98 }
99
100 /** Create a context with the specified peer info and shared context */
101 Context(PeerInfo peer_info, ContextAttribs attribs, Context shared_context) throws LWJGLException {
102 Context context_lock = shared_context != null ? shared_context : this;
103 // If shared_context is not null, synchronize on it to make sure it is not deleted
104 // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE
105 synchronized ( context_lock ) {
106 if ( shared_context != null && shared_context.destroyed )
107 throw new IllegalArgumentException("Shared context is destroyed");
108 GLContext.loadOpenGLLibrary();
109 try {
110 this.peer_info = peer_info;
111 if ( attribs != null ) {
112 attribList = attribs.getAttribList();
113 forwardCompatible = attribs.isForwardCompatible();
114 } else {
115 attribList = null;
116 forwardCompatible = false;
117 }
118
119 this.handle = implementation.create(peer_info, attribList, shared_context != null ? shared_context.handle : null);
120 } catch (LWJGLException e) {
121 GLContext.unloadOpenGLLibrary();
122 throw e;
123 }
124 }
125 }
126
127 /** Release the current context (if any). After this call, no context is current. */
128 public static void releaseCurrentContext() throws LWJGLException {
129 Context current_context = getCurrentContext();
130 if ( current_context != null ) {
131 implementation.releaseCurrentContext();
132 GLContext.useContext(null);
133 current_context_local.set(null);
134 synchronized ( current_context ) {
135 current_context.thread = null;
136 current_context.checkDestroy();
137 }
138 }
139 }
140
141 /**
142 * Release the context from its drawable. This is necessary on some platforms,
143 * like Mac OS X, where binding the context to a drawable and binding the context
144 * for rendering are two distinct actions and where calling releaseDrawable
145 * on every releaseCurrentContext results in artifacts.
146 */
147 public synchronized void releaseDrawable() throws LWJGLException {
148 if ( destroyed )
149 throw new IllegalStateException("Context is destroyed");
150 implementation.releaseDrawable(getHandle());
151 }
152
153 /** Update the context. Should be called whenever it's drawable is moved or resized */
154 public synchronized void update() {
155 if ( destroyed )
156 throw new IllegalStateException("Context is destroyed");
157 implementation.update(getHandle());
158 }
159
160 /** Swap the buffers on the current context. Only valid for double-buffered contexts */
161 public static void swapBuffers() throws LWJGLException {
162 implementation.swapBuffers();
163 }
164
165 private boolean canAccess() {
166 return thread == null || Thread.currentThread() == thread;
167 }
168
169 private void checkAccess() {
170 if ( !canAccess() )
171 throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current");
172 }
173
174 /** Make the context current */
175 public synchronized void makeCurrent() throws LWJGLException {
176 checkAccess();
177 if ( destroyed )
178 throw new IllegalStateException("Context is destroyed");
179 thread = Thread.currentThread();
180 current_context_local.set(this);
181 implementation.makeCurrent(peer_info, handle);
182 GLContext.useContext(this, forwardCompatible);
183 }
184
185 ByteBuffer getHandle() {
186 return handle;
187 }
188
189 /** Query whether the context is current */
190 public synchronized boolean isCurrent() throws LWJGLException {
191 if ( destroyed )
192 throw new IllegalStateException("Context is destroyed");
193 return implementation.isCurrent(handle);
194 }
195
196 private void checkDestroy() {
197 if ( !destroyed && destroy_requested ) {
198 try {
199 releaseDrawable();
200 implementation.destroy(peer_info, handle);
201 destroyed = true;
202 thread = null;
203 GLContext.unloadOpenGLLibrary();
204 } catch (LWJGLException e) {
205 LWJGLUtil.log("Exception occurred while destroying context: " + e);
206 }
207 }
208 }
209
210 /**
211 * Set the buffer swap interval. This call is a best-attempt at changing
212 * the monitor swap interval, which is the minimum periodicity of color buffer swaps,
213 * measured in video frame periods, and is not guaranteed to be successful.
214 * <p/>
215 * A video frame period is the time required to display a full frame of video data.
216 */
217 public static void setSwapInterval(int value) {
218 implementation.setSwapInterval(value);
219 }
220
221 /**
222 * Destroy the context. This method behaves the same as destroy() with the extra
223 * requirement that the context must be either current to the current thread or not
224 * current at all.
225 */
226 public synchronized void forceDestroy() throws LWJGLException {
227 checkAccess();
228 destroy();
229 }
230
231 /**
232 * Request destruction of the Context. If the context is current, no context will be current after this call.
233 * The context is destroyed when no thread has it current.
234 */
235 public synchronized void destroy() throws LWJGLException {
236 if ( destroyed )
237 return;
238 destroy_requested = true;
239 boolean was_current = isCurrent();
240 int error = GL11.GL_NO_ERROR;
241 if ( was_current ) {
242 if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 )
243 error = GL11.glGetError();
244 releaseCurrentContext();
245 }
246 checkDestroy();
247 if ( was_current && error != GL11.GL_NO_ERROR )
248 throw new OpenGLException(error);
249 }
250
251 }
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.IntBuffer;
37
38 /**
39 * This class represents the context attributes passed to CreateContextAttribs of the XGL_create_context extension.
40 * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
41 * OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
42 * (read the XGL_create_context spec for details)
43 * <p/>
44 * Use of this class is optional. If an OpenGL context is created without passing an instance of this class
45 * (or XGL_create_context is not supported), the old context creation code will be used. Use of ContextAttribs is required
46 * to create an OpenGL 3.0 or newer context. Support for debug and forward compatible mobes is not guaranteed by the OpenGL
47 * implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward compatible
48 * contexts having support for deprecated functionality.
49 * <p/>
50 * If the forwardCompatible
51 * attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
52 * means that developers can start working on cleaning up their applications without an OpenGL 3.0 complaint driver.
53 *
54 * @author spasi <spasi@users.sourceforge.net>
55 */
56 public final class ContextAttribs {
57
58 private int majorVersion;
59 private int minorVersion;
60
61 private int layerPlane;
62
63 private boolean debug;
64 private boolean forwardCompatible;
65
66 private boolean profileCore;
67 private boolean profileCompatibility;
68
69 public ContextAttribs() {
70 this(1, 0);
71 }
72
73 public ContextAttribs(final int majorVersion, final int minorVersion) {
74 if ( majorVersion < 0 ||
75 3 < majorVersion ||
76 minorVersion < 0 ||
77 (majorVersion == 3 && 2 < minorVersion) ||
78 (majorVersion == 2 && 1 < minorVersion) ||
79 (majorVersion == 1 && 5 < minorVersion) )
80 throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
81
82 this.majorVersion = majorVersion;
83 this.minorVersion = minorVersion;
84
85 this.layerPlane = 0;
86
87 this.debug = false;
88 this.forwardCompatible = false;
89
90 this.profileCore = 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ? true : false;
91 this.profileCompatibility = false;
92 }
93
94 private ContextAttribs(final ContextAttribs attribs) {
95 this.majorVersion = attribs.majorVersion;
96 this.minorVersion = attribs.minorVersion;
97
98 this.layerPlane = attribs.layerPlane;
99
100 this.debug = attribs.debug;
101 this.forwardCompatible = attribs.forwardCompatible;
102
103 this.profileCore = attribs.profileCore;
104 this.profileCompatibility = attribs.profileCompatibility;
105 }
106
107 public int getMajorVersion() {
108 return majorVersion;
109 }
110
111 public int getMinorVersion() {
112 return minorVersion;
113 }
114
115 public int getLayerPlane() {
116 return layerPlane;
117 }
118
119 public boolean isDebug() {
120 return debug;
121 }
122
123 public boolean isForwardCompatible() {
124 return forwardCompatible;
125 }
126
127 public boolean isProfileCore() {
128 return profileCore;
129 }
130
131 public boolean isProfileCompatibility() {
132 return profileCompatibility;
133 }
134
135 public ContextAttribs withLayer(final int layerPlane) {
136 if ( layerPlane < 0 )
137 throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
138
139 if ( layerPlane == this.layerPlane )
140 return this;
141
142 final ContextAttribs attribs = new ContextAttribs(this);
143 attribs.layerPlane = layerPlane;
144 return attribs;
145 }
146
147 public ContextAttribs withDebug(final boolean debug) {
148 if ( debug == this.debug )
149 return this;
150
151 final ContextAttribs attribs = new ContextAttribs(this);
152 attribs.debug = debug;
153 return attribs;
154 }
155
156 public ContextAttribs withForwardCompatible(final boolean forwardCompatible) {
157 if ( forwardCompatible == this.forwardCompatible )
158 return this;
159
160 final ContextAttribs attribs = new ContextAttribs(this);
161 attribs.forwardCompatible = forwardCompatible;
162 return attribs;
163 }
164
165 public ContextAttribs withProfileCore(final boolean profileCore) {
166 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
167 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
168
169 if ( profileCore == this.profileCore )
170 return this;
171
172 final ContextAttribs attribs = new ContextAttribs(this);
173 attribs.profileCore = profileCore;
174 if ( profileCore )
175 attribs.profileCompatibility = false;
176
177 return attribs;
178 }
179
180 public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) {
181 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
182 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
183
184 if ( profileCompatibility == this.profileCompatibility )
185 return this;
186
187 final ContextAttribs attribs = new ContextAttribs(this);
188 attribs.profileCompatibility = profileCompatibility;
189 if ( profileCompatibility )
190 attribs.profileCore = false;
191
192 return attribs;
193 }
194
195 private static ContextAttribsImplementation getImplementation() {
196 switch ( LWJGLUtil.getPlatform() ) {
197 case LWJGLUtil.PLATFORM_LINUX:
198 return new LinuxContextAttribs();
199 case LWJGLUtil.PLATFORM_WINDOWS:
200 return new WindowsContextAttribs();
201 case LWJGLUtil.PLATFORM_MACOSX:
202 return new MacOSXContextAttribs();
203 default:
204 throw new IllegalStateException("Unsupported platform");
205 }
206 }
207
208 IntBuffer getAttribList() {
209 ContextAttribsImplementation implementation = getImplementation();
210
211 int attribCount = 0;
212
213 if ( !(majorVersion == 1 && minorVersion == 0) )
214 attribCount += 2;
215 if ( 0 < layerPlane )
216 attribCount++;
217
218 int flags = 0;
219 if ( debug )
220 flags |= implementation.getDebugBit();
221 if ( forwardCompatible )
222 flags |= implementation.getForwardCompatibleBit();
223 if ( 0 < flags )
224 attribCount++;
225
226 int profileMask = 0;
227 if ( profileCore )
228 profileMask |= implementation.getProfileCoreBit();
229 else if ( profileCompatibility )
230 profileMask |= implementation.getProfileCompatibilityBit();
231 if ( 0 < profileMask )
232 attribCount++;
233
234 if ( attribCount == 0 )
235 return null;
236
237 final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);
238
239 if ( !(majorVersion == 1 && minorVersion == 0) ) {
240 attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion);
241 attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion);
242 }
243 if ( 0 < layerPlane )
244 attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane);
245 if ( 0 < flags )
246 attribs.put(implementation.getFlagsAttrib()).put(flags);
247 if ( 0 < profileMask )
248 attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
249
250 attribs.put(0);
251 attribs.rewind();
252 return attribs;
253 }
254
255 public String toString() {
256 StringBuffer sb = new StringBuffer(32);
257
258 sb.append("ContextAttribs:");
259 sb.append(" Version=").append(majorVersion).append('.').append(minorVersion);
260 sb.append(" - Layer=").append(layerPlane);
261 sb.append(" - Debug=").append(debug);
262 sb.append(" - ForwardCompatible=").append(forwardCompatible);
263 sb.append(" - Profile=");
264 if ( profileCore )
265 sb.append("Core");
266 else if ( profileCompatibility )
267 sb.append("Compatibility");
268 else
269 sb.append("None");
270
271 return sb.toString();
272 }
273
274 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.opengl;
33
34 /** @author spasi <spasi@users.sourceforge.net> */
35 interface ContextAttribsImplementation {
36
37 int getMajorVersionAttrib();
38
39 int getMinorVersionAttrib();
40
41 int getLayerPlaneAttrib();
42
43 int getFlagsAttrib();
44
45 int getDebugBit();
46
47 int getForwardCompatibleBit();
48
49 int getProfileMaskAttrib();
50
51 int getProfileCoreBit();
52
53 int getProfileCompatibilityBit();
54
55 }
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 java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.LWJGLException;
37
38 /**
39 * <p/>
40 * Context implementation interface.
41 * <p/>
42 *
43 * @author elias_naur <elias_naur@users.sourceforge.net>
44 * @version $Revision: 3116 $
45 * $Id: ContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
46 */
47 interface ContextImplementation {
48 /**
49 * Create a context.
50 */
51 ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException;
52
53 /**
54 * Swap the buffers of the current context. Only valid for double-buffered contexts.
55 */
56 void swapBuffers() throws LWJGLException;
57
58 /**
59 * Release the context from its drawable, if any.
60 */
61 void releaseDrawable(ByteBuffer context_handle) throws LWJGLException;
62
63 /**
64 * Release the current context (if any). After this call, no context is current.
65 */
66 void releaseCurrentContext() throws LWJGLException;
67
68 /**
69 * Update the context. Should be called whenever it's drawable is moved or resized
70 */
71 void update(ByteBuffer context_handle);
72
73 /**
74 * Query whether the context is current
75 */
76 void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException;
77
78 /**
79 * Query whether the context is current
80 */
81 boolean isCurrent(ByteBuffer handle) throws LWJGLException;
82
83 void setSwapInterval(int value);
84
85 /**
86 * Destroys the Context.
87 */
88 void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException;
89 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the abstract class for a Display in LWJGL. LWJGL displays have some
35 * peculiar characteristics:
36 *
37 * - the display may be closeable by the user or operating system, and may be minimized
38 * by the user or operating system
39 * - only one display may ever be open at once
40 * - the operating system may or may not be able to do fullscreen or windowed displays.
41 *
42 * @author foo
43 */
44
45 import org.lwjgl.BufferUtils;
46 import org.lwjgl.LWJGLException;
47 import org.lwjgl.LWJGLUtil;
48 import org.lwjgl.Sys;
49 import org.lwjgl.input.Controllers;
50 import org.lwjgl.input.Keyboard;
51 import org.lwjgl.input.Mouse;
52
53 import java.awt.*;
54 import java.awt.event.ComponentAdapter;
55 import java.awt.event.ComponentEvent;
56 import java.awt.event.ComponentListener;
57 import java.nio.ByteBuffer;
58 import java.nio.FloatBuffer;
59 import java.security.AccessController;
60 import java.security.PrivilegedAction;
61 import java.util.Arrays;
62 import java.util.HashSet;
63
64 public final class Display {
65
66 private static final Thread shutdown_hook = new Thread() {
67 public void run() {
68 reset();
69 }
70 };
71
72 /** The display implementor */
73 private static final DisplayImplementation display_impl;
74
75 /** The initial display mode */
76 private static final DisplayMode initial_mode;
77
78 /** The parent, if any */
79 private static Canvas parent;
80
81 /** The current display mode, if created */
82 private static DisplayMode current_mode;
83
84 /** Timer for sync() */
85 private static long timeThen;
86
87 /** X coordinate of the window */
88 private static int x = -1;
89
90 /** Cached window icons, for when Display is recreated */
91 private static ByteBuffer[] cached_icons;
92
93 /**
94 * Y coordinate of the window. Y in window coordinates is from the top of the display down,
95 * unlike GL, where it is typically at the bottom of the display.
96 */
97 private static int y = -1;
98
99 /** Title of the window (never null) */
100 private static String title = "Game";
101
102 /** Fullscreen */
103 private static boolean fullscreen;
104
105 /** Swap interval */
106 private static int swap_interval;
107
108 /** A unique context object, so we can track different contexts between creates() and destroys() */
109 private static PeerInfo peer_info;
110 private static Context context;
111
112 /** The Drawable instance that tracks the current Display context */
113 private final static Drawable drawable;
114
115 private static boolean window_created = false;
116
117 private static boolean parent_resized;
118
119 /** Initial Background Color of Display */
120 private static float r = 0, g = 0, b = 0;
121
122 private static ComponentListener component_listener = new ComponentAdapter() {
123 public void componentResized(ComponentEvent e) {
124 synchronized ( GlobalLock.lock ) {
125 parent_resized = true;
126 }
127 }
128 };
129
130 static {
131 Sys.initialize();
132 display_impl = createDisplayImplementation();
133 try {
134 current_mode = initial_mode = display_impl.init();
135 LWJGLUtil.log("Initial mode: " + initial_mode);
136 } catch (LWJGLException e) {
137 throw new RuntimeException(e);
138 }
139 drawable = new Drawable() {
140 public Context getContext() {
141 synchronized ( GlobalLock.lock ) {
142 return isCreated() ? context : null;
143 }
144 }
145 };
146 }
147
148 /**
149 * Fetch the Drawable from the Display.
150 *
151 * @return the Drawable corresponding to the Display context
152 */
153 public static Drawable getDrawable() {
154 return drawable;
155 }
156
157 private static DisplayImplementation createDisplayImplementation() {
158 switch ( LWJGLUtil.getPlatform() ) {
159 case LWJGLUtil.PLATFORM_LINUX:
160 return new LinuxDisplay();
161 case LWJGLUtil.PLATFORM_WINDOWS:
162 return new WindowsDisplay();
163 case LWJGLUtil.PLATFORM_MACOSX:
164 return new MacOSXDisplay();
165 default:
166 throw new IllegalStateException("Unsupported platform");
167 }
168 }
169
170 /** Only constructed by ourselves */
171 private Display() {
172 }
173
174 /**
175 * Returns the entire list of possible fullscreen display modes as an array, in no
176 * particular order. Although best attempts to filter out invalid modes are done, any
177 * given mode is not guaranteed to be available nor is it guaranteed to be within the
178 * current monitor specs (this is especially a problem with the frequency parameter).
179 * Furthermore, it is not guaranteed that create() will detect an illegal display mode.
180 * <p/>
181 * The only certain way to check
182 * is to call create() and make sure it works.
183 * Only non-palette-indexed modes are returned (ie. bpp will be 16, 24, or 32).
184 * Only DisplayModes from this call can be used when the Display is in fullscreen
185 * mode.
186 *
187 * @return an array of all display modes the system reckons it can handle.
188 */
189 public static DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
190 synchronized ( GlobalLock.lock ) {
191 DisplayMode[] unfilteredModes = display_impl.getAvailableDisplayModes();
192
193 if ( unfilteredModes == null ) {
194 return new DisplayMode[0];
195 }
196
197 // We'll use a HashSet to filter out the duplicated modes
198 HashSet modes = new HashSet(unfilteredModes.length);
199
200 modes.addAll(Arrays.asList(unfilteredModes));
201 DisplayMode[] filteredModes = new DisplayMode[modes.size()];
202 modes.toArray(filteredModes);
203
204 LWJGLUtil.log("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
205
206 return filteredModes;
207 }
208 }
209
210 /**
211 * Return the initial desktop display mode.
212 *
213 * @return The desktop display mode
214 */
215 public static DisplayMode getDesktopDisplayMode() {
216 return initial_mode;
217 }
218
219 /**
220 * Return the current display mode, as set by setDisplayMode().
221 *
222 * @return The current display mode
223 */
224 public static DisplayMode getDisplayMode() {
225 return current_mode;
226 }
227
228 /**
229 * Set the current display mode. If no OpenGL context has been created, the given mode will apply to
230 * the context when create() is called, and no immediate mode switching will happen. If there is a
231 * context already, it will be resized according to the given mode. If the context is also a
232 * fullscreen context, the mode will also be switched immediately. The native cursor position
233 * is also reset.
234 *
235 * @param mode The new display mode to set
236 *
237 * @throws LWJGLException if the display mode could not be set
238 */
239 public static void setDisplayMode(DisplayMode mode) throws LWJGLException {
240 synchronized (GlobalLock.lock) {
241 if (mode == null)
242 throw new NullPointerException("mode must be non-null");
243 boolean was_fullscreen = isFullscreen();
244 current_mode = mode;
245 if (isCreated()) {
246 destroyWindow();
247 // If mode is not fullscreen capable, make sure we are in windowed mode
248 try {
249 if (was_fullscreen && !isFullscreen())
250 display_impl.resetDisplayMode();
251 else if (isFullscreen())
252 switchDisplayMode();
253 createWindow();
254 makeCurrentAndSetSwapInterval();
255 } catch (LWJGLException e) {
256 destroyContext();
257 destroyPeerInfo();
258 display_impl.resetDisplayMode();
259 throw e;
260 }
261 }
262 }
263 }
264
265 private static DisplayMode getEffectiveMode() {
266 return !isFullscreen() && parent != null ? new DisplayMode(parent.getWidth(), parent.getHeight()) : current_mode;
267 }
268
269 private static int getWindowX() {
270 if (!isFullscreen() && parent == null) {
271 // if no display location set, center window
272 if (x == -1) {
273 return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2);
274 } else {
275 return x;
276 }
277 } else {
278 return 0;
279 }
280 }
281
282 private static int getWindowY() {
283 if (!isFullscreen() && parent == null) {
284 // if no display location set, center window
285 if ( y == -1 ) {
286 return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2);
287 } else {
288 return y;
289 }
290 } else {
291 return 0;
292 }
293 }
294
295 /**
296 * Create the native window peer from the given mode and fullscreen flag.
297 * A native context must exist, and it will be attached to the window.
298 */
299 private static void createWindow() throws LWJGLException {
300 if ( window_created ) {
301 return;
302 }
303 Canvas tmp_parent = isFullscreen() ? null : parent;
304 if ( tmp_parent != null && !tmp_parent.isDisplayable() ) // Only a best effort check, since the parent can turn undisplayable hereafter
305 throw new LWJGLException("Parent.isDisplayable() must be true");
306 if ( tmp_parent != null ) {
307 tmp_parent.addComponentListener(component_listener);
308 }
309 DisplayMode mode = getEffectiveMode();
310 display_impl.createWindow(mode, tmp_parent, getWindowX(), getWindowY());
311 window_created = true;
312
313 setTitle(title);
314 initControls();
315
316 // set cached window icon if exists
317 if ( cached_icons != null ) {
318 setIcon(cached_icons);
319 } else {
320 setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon32x32, LWJGLUtil.LWJGLIcon16x16 });
321 }
322 }
323
324 private static void releaseDrawable() {
325 try {
326 if ( context != null && context.isCurrent() ) {
327 Context.releaseCurrentContext();
328 context.releaseDrawable();
329 }
330 } catch (LWJGLException e) {
331 LWJGLUtil.log("Exception occurred while trying to release context: " + e);
332 }
333 }
334
335 private static void destroyWindow() {
336 if ( !window_created ) {
337 return;
338 }
339 if ( parent != null ) {
340 parent.removeComponentListener(component_listener);
341 }
342 releaseDrawable();
343
344 // Automatically destroy keyboard & mouse
345 if ( Mouse.isCreated() ) {
346 Mouse.destroy();
347 }
348 if ( Keyboard.isCreated() ) {
349 Keyboard.destroy();
350 }
351 display_impl.destroyWindow();
352 window_created = false;
353 }
354
355 private static void switchDisplayMode() throws LWJGLException {
356 if ( !current_mode.isFullscreenCapable() ) {
357 throw new IllegalStateException("Only modes acquired from getAvailableDisplayModes() can be used for fullscreen display");
358 }
359 display_impl.switchDisplayMode(current_mode);
360 }
361
362 /**
363 * Set the display configuration to the specified gamma, brightness and contrast.
364 * The configuration changes will be reset when destroy() is called.
365 *
366 * @param gamma The gamma value
367 * @param brightness The brightness value between -1.0 and 1.0, inclusive
368 * @param contrast The contrast, larger than 0.0.
369 */
370 public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws LWJGLException {
371 synchronized ( GlobalLock.lock ) {
372 if ( !isCreated() ) {
373 throw new LWJGLException("Display not yet created.");
374 }
375 if ( brightness < -1.0f || brightness > 1.0f )
376 throw new IllegalArgumentException("Invalid brightness value");
377 if ( contrast < 0.0f )
378 throw new IllegalArgumentException("Invalid contrast value");
379 int rampSize = display_impl.getGammaRampLength();
380 if ( rampSize == 0 ) {
381 throw new LWJGLException("Display configuration not supported");
382 }
383 FloatBuffer gammaRamp = BufferUtils.createFloatBuffer(rampSize);
384 for ( int i = 0; i < rampSize; i++ ) {
385 float intensity = (float)i / (rampSize - 1);
386 // apply gamma
387 float rampEntry = (float)java.lang.Math.pow(intensity, gamma);
388 // apply brightness
389 rampEntry += brightness;
390 // apply contrast
391 rampEntry = (rampEntry - 0.5f) * contrast + 0.5f;
392 // Clamp entry to [0, 1]
393 if ( rampEntry > 1.0f )
394 rampEntry = 1.0f;
395 else if ( rampEntry < 0.0f )
396 rampEntry = 0.0f;
397 gammaRamp.put(i, rampEntry);
398 }
399 display_impl.setGammaRamp(gammaRamp);
400 LWJGLUtil.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
401 }
402 }
403
404 private static long timeLate;
405
406 /**
407 * Best sync method that works reliably.
408 *
409 * @param fps The desired frame rate, in frames per second
410 */
411 public static void sync(int fps) {
412 long timeNow;
413 long gapTo;
414 long savedTimeLate;
415 synchronized ( GlobalLock.lock ) {
416 gapTo = Sys.getTimerResolution() / fps + timeThen;
417 timeNow = Sys.getTime();
418 savedTimeLate = timeLate;
419 }
420
421 while ( gapTo > timeNow + savedTimeLate ) {
422 try {
423 Thread.sleep(1);
424 } catch (InterruptedException e) {
425 }
426 timeNow = Sys.getTime();
427 }
428
429 synchronized ( GlobalLock.lock ) {
430 if ( gapTo < timeNow )
431 timeLate = timeNow - gapTo;
432 else
433 timeLate = 0;
434
435 timeThen = timeNow;
436 }
437 }
438
439 /** @return the title of the window */
440 public static String getTitle() {
441 synchronized ( GlobalLock.lock ) {
442 return title;
443 }
444 }
445
446 /** Return the last parent set with setParent(). */
447 public static Canvas getParent() {
448 synchronized ( GlobalLock.lock ) {
449 return parent;
450 }
451 }
452
453 /**
454 * Set the parent of the Display. If parent is null, the Display will appear as a top level window.
455 * If parent is not null, the Display is made a child of the parent. A parent's isDisplayable() must be true when
456 * setParent() is called and remain true until setParent() is called again with
457 * null or a different parent. This generally means that the parent component must remain added to it's parent container.<p>
458 * It is not advisable to call this method from an AWT thread, since the context will be made current on the thread
459 * and it is difficult to predict which AWT thread will process any given AWT event.<p>
460 * While the Display is in fullscreen mode, the current parent will be ignored. Additionally, when a non null parent is specified,
461 * the Dispaly will inherit the size of the parent, disregarding the currently set display mode.<p>
462 */
463 public static void setParent(Canvas parent) throws LWJGLException {
464 synchronized ( GlobalLock.lock ) {
465 if (Display.parent != parent) {
466 Display.parent = parent;
467 if ( !isCreated() )
468 return;
469 destroyWindow();
470 try {
471 if (isFullscreen()) {
472 switchDisplayMode();
473 } else {
474 display_impl.resetDisplayMode();
475 }
476 createWindow();
477 makeCurrentAndSetSwapInterval();
478 } catch (LWJGLException e) {
479 destroyContext();
480 destroyPeerInfo();
481 display_impl.resetDisplayMode();
482 throw e;
483 }
484 }
485 }
486 }
487
488 /**
489 * Set the fullscreen mode of the context. If no context has been created through create(),
490 * the mode will apply when create() is called. If fullscreen is true, the context will become
491 * a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If
492 * fullscreen is false, the context will become a windowed context with the dimensions given in the
493 * mode returned by getDisplayMode(). The native cursor position is also reset.
494 *
495 * @param fullscreen Specify the fullscreen mode of the context.
496 *
497 * @throws LWJGLException If fullscreen is true, and the current DisplayMode instance is not
498 * from getAvailableDisplayModes() or if the mode switch fails.
499 */
500 public static void setFullscreen(boolean fullscreen) throws LWJGLException {
501 setDisplayModeAndFullscreenInternal(fullscreen, current_mode);
502 }
503
504 /**
505 * Set the mode of the context. If no context has been created through create(),
506 * the mode will apply when create() is called. If mode.isFullscreenCapable() is true, the context will become
507 * a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If
508 * mode.isFullscreenCapable() is false, the context will become a windowed context with the dimensions given in the
509 * mode returned by getDisplayMode(). The native cursor position is also reset.
510 *
511 * @param mode The new display mode to set. Must be non-null.
512 *
513 * @throws LWJGLException If the mode switch fails.
514 */
515 public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException {
516 setDisplayModeAndFullscreenInternal(mode.isFullscreenCapable(), mode);
517 }
518
519 private static void setDisplayModeAndFullscreenInternal(boolean fullscreen, DisplayMode mode) throws LWJGLException {
520 synchronized ( GlobalLock.lock ) {
521 if (mode == null)
522 throw new NullPointerException("mode must be non-null");
523 DisplayMode old_mode = current_mode;
524 current_mode = mode;
525 boolean was_fullscreen = isFullscreen();
526 Display.fullscreen = fullscreen;
527 if (was_fullscreen != isFullscreen() || !mode.equals(old_mode)) {
528 if (!isCreated())
529 return;
530 destroyWindow();
531 try {
532 if (isFullscreen()) {
533 switchDisplayMode();
534 } else {
535 display_impl.resetDisplayMode();
536 }
537 createWindow();
538 makeCurrentAndSetSwapInterval();
539 } catch (LWJGLException e) {
540 destroyContext();
541 destroyPeerInfo();
542 display_impl.resetDisplayMode();
543 throw e;
544 }
545 }
546 }
547 }
548
549 /** @return whether the Display is in fullscreen mode */
550 public static boolean isFullscreen() {
551 synchronized (GlobalLock.lock) {
552 return fullscreen && current_mode.isFullscreenCapable();
553 }
554 }
555
556 /**
557 * Set the title of the window. This may be ignored by the underlying OS.
558 *
559 * @param newTitle The new window title
560 */
561 public static void setTitle(String newTitle) {
562 synchronized ( GlobalLock.lock ) {
563 if ( newTitle == null ) {
564 newTitle = "";
565 }
566 title = newTitle;
567 if ( isCreated() )
568 display_impl.setTitle(title);
569 }
570 }
571
572 /** @return true if the user or operating system has asked the window to close */
573 public static boolean isCloseRequested() {
574 synchronized ( GlobalLock.lock ) {
575 if ( !isCreated() )
576 throw new IllegalStateException("Cannot determine close requested state of uncreated window");
577 return display_impl.isCloseRequested();
578 }
579 }
580
581 /** @return true if the window is visible, false if not */
582 public static boolean isVisible() {
583 synchronized ( GlobalLock.lock ) {
584 if ( !isCreated() )
585 throw new IllegalStateException("Cannot determine minimized state of uncreated window");
586 return display_impl.isVisible();
587 }
588 }
589
590 /** @return true if window is active, that is, the foreground display of the operating system. */
591 public static boolean isActive() {
592 synchronized ( GlobalLock.lock ) {
593 if ( !isCreated() )
594 throw new IllegalStateException("Cannot determine focused state of uncreated window");
595 return display_impl.isActive();
596 }
597 }
598
599 /**
600 * Determine if the window's contents have been damaged by external events.
601 * If you are writing a straightforward game rendering loop and simply paint
602 * every frame regardless, you can ignore this flag altogether. If you are
603 * trying to be kind to other processes you can check this flag and only
604 * redraw when it returns true. The flag is cleared when update() or isDirty() is called.
605 *
606 * @return true if the window has been damaged by external changes
607 * and needs to repaint itself
608 */
609 public static boolean isDirty() {
610 synchronized ( GlobalLock.lock ) {
611 if ( !isCreated() )
612 throw new IllegalStateException("Cannot determine dirty state of uncreated window");
613 return display_impl.isDirty();
614 }
615 }
616
617 /**
618 * Process operating system events. Call this to update the Display's state and to receive new
619 * input device events. This method is called from update(), so it is not necessary to call
620 * this method if update() is called periodically.
621 */
622 public static void processMessages() {
623 synchronized ( GlobalLock.lock ) {
624 if ( !isCreated() )
625 throw new IllegalStateException("Display not created");
626
627 display_impl.update();
628 }
629 pollDevices();
630 }
631
632 /**
633 * Swap the display buffers. This method is called from update(), and should normally not be called by
634 * the application.
635 *
636 * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError()
637 */
638 public static void swapBuffers() throws LWJGLException {
639 synchronized ( GlobalLock.lock ) {
640 if ( !isCreated() )
641 throw new IllegalStateException("Display not created");
642
643 if ( LWJGLUtil.DEBUG )
644 Util.checkGLError();
645 Context.swapBuffers();
646 }
647 }
648
649 /**
650 * Update the window. If the window is visible clears
651 * the dirty flag and calls swapBuffers() and finally
652 * polls the input devices.
653 *
654 */
655 public static void update() {
656 update(true);
657 }
658
659 /**
660 * Update the window. If the window is visible clears
661 * the dirty flag and calls swapBuffers() and finally
662 * polls the input devices if processMessages is true.
663 *
664 * @param processMessages Poll input devices if true
665 */
666 public static void update(boolean processMessages) {
667 synchronized ( GlobalLock.lock ) {
668 if ( !isCreated() )
669 throw new IllegalStateException("Display not created");
670
671 // We paint only when the window is visible or dirty
672 if ( display_impl.isVisible() || display_impl.isDirty() ) {
673 try {
674 swapBuffers();
675 } catch (LWJGLException e) {
676 throw new RuntimeException(e);
677 }
678 }
679
680 if ( parent_resized ) {
681 reshape();
682 parent_resized = false;
683 }
684
685 if ( processMessages )
686 processMessages();
687 }
688 }
689
690 static void pollDevices() {
691 // Poll the input devices while we're here
692 if ( Mouse.isCreated() ) {
693 Mouse.poll();
694 Mouse.updateCursor();
695 }
696
697 if ( Keyboard.isCreated() ) {
698 Keyboard.poll();
699 }
700
701 if ( Controllers.isCreated() ) {
702 Controllers.poll();
703 }
704 }
705
706 /**
707 * Release the Display context.
708 *
709 * @throws LWJGLException If the context could not be released
710 */
711 public static void releaseContext() throws LWJGLException {
712 synchronized ( GlobalLock.lock ) {
713 if ( !isCreated() )
714 throw new IllegalStateException("Display is not created");
715 if ( context.isCurrent() )
716 Context.releaseCurrentContext();
717 }
718 }
719
720 /**
721 * Make the Display the current rendering context for GL calls.
722 *
723 * @throws LWJGLException If the context could not be made current
724 */
725 public static void makeCurrent() throws LWJGLException {
726 synchronized ( GlobalLock.lock ) {
727 if ( !isCreated() )
728 throw new IllegalStateException("Display is not created");
729 context.makeCurrent();
730 }
731 }
732
733 private static void removeShutdownHook() {
734 AccessController.doPrivileged(new PrivilegedAction() {
735 public Object run() {
736 Runtime.getRuntime().removeShutdownHook(shutdown_hook);
737 return null;
738 }
739 });
740 }
741
742 private static void registerShutdownHook() {
743 AccessController.doPrivileged(new PrivilegedAction() {
744 public Object run() {
745 Runtime.getRuntime().addShutdownHook(shutdown_hook);
746 return null;
747 }
748 });
749 }
750
751 /**
752 * Create the OpenGL context. If isFullscreen() is true or if windowed
753 * context are not supported on the platform, the display mode will be switched to the mode returned by
754 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
755 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
756 * created with the given parameters, a LWJGLException will be thrown.
757 * <p/>
758 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
759 *
760 * @throws LWJGLException
761 */
762 public static void create() throws LWJGLException {
763 synchronized ( GlobalLock.lock ) {
764 create(new PixelFormat());
765 }
766 }
767
768 /**
769 * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed
770 * context are not supported on the platform, the display mode will be switched to the mode returned by
771 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
772 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
773 * created with the given parameters, a LWJGLException will be thrown.
774 * <p/>
775 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
776 *
777 * @param pixel_format Describes the minimum specifications the context must fulfill.
778 *
779 * @throws LWJGLException
780 */
781 public static void create(PixelFormat pixel_format) throws LWJGLException {
782 synchronized ( GlobalLock.lock ) {
783 create(pixel_format, null, null);
784 }
785 }
786
787 /**
788 * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed
789 * context are not supported on the platform, the display mode will be switched to the mode returned by
790 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
791 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
792 * created with the given parameters, a LWJGLException will be thrown.
793 * <p/>
794 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
795 *
796 * @param pixel_format Describes the minimum specifications the context must fulfill.
797 * @param shared_drawable The Drawable to share context with. (optional, may be null)
798 *
799 * @throws LWJGLException
800 */
801 public static void create(PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException {
802 synchronized ( GlobalLock.lock ) {
803 create(pixel_format, shared_drawable, null);
804 }
805 }
806
807 /**
808 * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed
809 * context are not supported on the platform, the display mode will be switched to the mode returned by
810 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
811 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
812 * created with the given parameters, a LWJGLException will be thrown.
813 * <p/>
814 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
815 *
816 * @param pixel_format Describes the minimum specifications the context must fulfill.
817 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
818 *
819 * @throws LWJGLException
820 */
821 public static void create(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
822 synchronized ( GlobalLock.lock ) {
823 create(pixel_format, null, attribs);
824 }
825 }
826
827 /**
828 * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed
829 * context are not supported on the platform, the display mode will be switched to the mode returned by
830 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
831 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
832 * created with the given parameters, a LWJGLException will be thrown.
833 * <p/>
834 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
835 *
836 * @param pixel_format Describes the minimum specifications the context must fulfill.
837 * @param shared_drawable The Drawable to share context with. (optional, may be null)
838 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
839 *
840 * @throws LWJGLException
841 */
842 public static void create(PixelFormat pixel_format, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException {
843 synchronized ( GlobalLock.lock ) {
844 if ( isCreated() )
845 throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
846 if ( pixel_format == null )
847 throw new NullPointerException("pixel_format cannot be null");
848 removeShutdownHook();
849 registerShutdownHook();
850 if (isFullscreen())
851 switchDisplayMode();
852 try {
853 peer_info = display_impl.createPeerInfo(pixel_format);
854 try {
855 createWindow();
856 try {
857 context = new Context(peer_info, attribs, shared_drawable != null ? shared_drawable.getContext() : null);
858 try {
859 makeCurrentAndSetSwapInterval();
860 initContext();
861 } catch (LWJGLException e) {
862 destroyContext();
863 throw e;
864 }
865 } catch (LWJGLException e) {
866 destroyWindow();
867 throw e;
868 }
869 } catch (LWJGLException e) {
870 destroyPeerInfo();
871 throw e;
872 }
873 } catch (LWJGLException e) {
874 display_impl.resetDisplayMode();
875 throw e;
876 }
877 }
878 }
879
880 /**
881 * Set the initial color of the Display. This method is called before the Display is created and will set the
882 * background color to the one specified in this method.
883 *
884 * @param red - color value between 0 - 1
885 * @param green - color value between 0 - 1
886 * @param blue - color value between 0 - 1
887 */
888 public static void setInitialBackground(float red, float green, float blue) {
889 r = red;
890 g = green;
891 b = blue;
892 }
893
894 private static void makeCurrentAndSetSwapInterval() throws LWJGLException {
895 makeCurrent();
896 try {
897 Util.checkGLError();
898 } catch (OpenGLException e) {
899 LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage());
900 }
901 setSwapInterval(swap_interval);
902 }
903
904 private static void initContext() {
905 // set background clear color
906 GL11.glClearColor(r, g, b, 1.0f);
907 // Clear window to avoid the desktop "showing through"
908 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
909 update();
910 }
911
912 static DisplayImplementation getImplementation() {
913 return display_impl;
914 }
915
916 /** Gets a boolean property as a privileged action. */
917 static boolean getPrivilegedBoolean(final String property_name) {
918 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
919 public Object run() {
920 return new Boolean(Boolean.getBoolean(property_name));
921 }
922 });
923 return value.booleanValue();
924 }
925
926 private static void initControls() {
927 // Automatically create mouse, keyboard and controller
928 if ( !getPrivilegedBoolean("org.lwjgl.opengl.Display.noinput") ) {
929 if ( !Mouse.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nomouse") ) {
930 try {
931 Mouse.create();
932 } catch (LWJGLException e) {
933 if ( LWJGLUtil.DEBUG ) {
934 e.printStackTrace(System.err);
935 } else {
936 LWJGLUtil.log("Failed to create Mouse: " + e);
937 }
938 }
939 }
940 if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) {
941 try {
942 Keyboard.create();
943 } catch (LWJGLException e) {
944 if ( LWJGLUtil.DEBUG ) {
945 e.printStackTrace(System.err);
946 } else {
947 LWJGLUtil.log("Failed to create Keyboard: " + e);
948 }
949 }
950 }
951 }
952 }
953
954 /**
955 * Destroy the Display. After this call, there will be no current GL rendering context,
956 * regardless of whether the Display was the current rendering context.
957 */
958 public static void destroy() {
959 synchronized ( GlobalLock.lock ) {
960 if ( !isCreated() ) {
961 return;
962 }
963
964 releaseDrawable();
965 destroyContext();
966 destroyWindow();
967 destroyPeerInfo();
968 x = y = -1;
969 cached_icons = null;
970 reset();
971 removeShutdownHook();
972 }
973 }
974
975 private static void destroyPeerInfo() {
976 peer_info.destroy();
977 peer_info = null;
978 }
979
980 private static void destroyContext() {
981 try {
982 context.forceDestroy();
983 } catch (LWJGLException e) {
984 throw new RuntimeException(e);
985 } finally {
986 context = null;
987 }
988 }
989
990 /*
991 * Reset display mode if fullscreen. This method is also called from the shutdown hook added
992 * in the static constructor
993 */
994 private static void reset() {
995 display_impl.resetDisplayMode();
996 current_mode = initial_mode;
997 }
998
999 /** @return true if the window's native peer has been created */
1000 public static boolean isCreated() {
1001 synchronized ( GlobalLock.lock ) {
1002 return window_created;
1003 }
1004 }
1005
1006 /**
1007 * Set the buffer swap interval. This call is a best-attempt at changing
1008 * the monitor swap interval, which is the minimum periodicity of color buffer swaps,
1009 * measured in video frame periods, and is not guaranteed to be successful.
1010 * <p/>
1011 * A video frame period is the time required to display a full frame of video data.
1012 *
1013 * @param value The swap interval in frames, 0 to disable
1014 */
1015 public static void setSwapInterval(int value) {
1016 synchronized ( GlobalLock.lock ) {
1017 swap_interval = value;
1018 if ( isCreated() )
1019 Context.setSwapInterval(swap_interval);
1020 }
1021 }
1022
1023 /**
1024 * Enable or disable vertical monitor synchronization. This call is a best-attempt at changing
1025 * the vertical refresh synchronization of the monitor, and is not guaranteed to be successful.
1026 *
1027 * @param sync true to synchronize; false to ignore synchronization
1028 */
1029 public static void setVSyncEnabled(boolean sync) {
1030 synchronized ( GlobalLock.lock ) {
1031 setSwapInterval(sync ? 1 : 0);
1032 }
1033 }
1034
1035 /**
1036 * Set the window's location. This is a no-op on fullscreen windows or when getParent() != null.
1037 * The window is clamped to remain entirely on the screen. If you attempt
1038 * to position the window such that it would extend off the screen, the window
1039 * is simply placed as close to the edge as possible.
1040 * <br><b>note</b>If no location has been specified (or x == y == -1) the window will be centered
1041 *
1042 * @param new_x The new window location on the x axis
1043 * @param new_y The new window location on the y axis
1044 */
1045 public static void setLocation(int new_x, int new_y) {
1046 synchronized ( GlobalLock.lock ) {
1047 // cache position
1048 x = new_x;
1049 y = new_y;
1050
1051 // offset if already created
1052 if (isCreated() && !isFullscreen()) {
1053 reshape();
1054 }
1055 }
1056 }
1057
1058 private static void reshape() {
1059 DisplayMode mode = getEffectiveMode();
1060 display_impl.reshape(getWindowX(), getWindowY(), mode.getWidth(), mode.getHeight());
1061 }
1062
1063 /**
1064 * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2",
1065 * "Radeon9700". If the adapter cannot be determined, this function returns null.
1066 *
1067 * @return a String
1068 */
1069 public static String getAdapter() {
1070 synchronized ( GlobalLock.lock ) {
1071 return display_impl.getAdapter();
1072 }
1073 }
1074
1075 /**
1076 * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined,
1077 * this function returns null.
1078 *
1079 * @return a String
1080 */
1081 public static String getVersion() {
1082 synchronized ( GlobalLock.lock ) {
1083 return display_impl.getVersion();
1084 }
1085 }
1086
1087 /**
1088 * Sets one or more icons for the Display.
1089 * <ul>
1090 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
1091 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
1092 * <li>Mac OS X should be supplied one 128x128 icon</li>
1093 * </ul>
1094 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
1095 * <p/>
1096 * <b>NOTE:</b> The display will make a deep copy of the supplied byte buffer array, for the purpose
1097 * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to
1098 * set the icon once per instance.
1099 *
1100 * @param icons Array of icons in RGBA mode. Pass the icons in order of preference.
1101 *
1102 * @return number of icons used, or 0 if display hasn't been created
1103 */
1104 public static int setIcon(ByteBuffer[] icons) {
1105 synchronized ( GlobalLock.lock ) {
1106 // make deep copy so we dont rely on the supplied buffers later on
1107 // don't recache!
1108 if ( cached_icons != icons ) {
1109 cached_icons = new ByteBuffer[icons.length];
1110 for ( int i = 0; i < icons.length; i++ ) {
1111 cached_icons[i] = BufferUtils.createByteBuffer(icons[i].capacity());
1112 int old_position = icons[i].position();
1113 cached_icons[i].put(icons[i]);
1114 icons[i].position(old_position);
1115 cached_icons[i].flip();
1116 }
1117 }
1118
1119 if ( Display.isCreated() && parent == null ) {
1120 return display_impl.setIcon(cached_icons);
1121 } else {
1122 return 0;
1123 }
1124 }
1125 }
1126 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the Display implementation interface. Display delegates
35 * to implementors of this interface. There is one DisplayImplementation
36 * for each supported platform.
37 * @author elias_naur
38 */
39
40 import java.nio.ByteBuffer;
41 import java.nio.FloatBuffer;
42 import java.nio.IntBuffer;
43 import java.awt.Canvas;
44
45 import org.lwjgl.LWJGLException;
46
47 interface DisplayImplementation extends InputImplementation {
48
49 void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException;
50
51 void destroyWindow();
52
53 void switchDisplayMode(DisplayMode mode) throws LWJGLException;
54
55 /**
56 * Reset the display mode to whatever it was when LWJGL was initialized.
57 * Fails silently.
58 */
59 void resetDisplayMode();
60
61 /**
62 * Return the length of the gamma ramp arrays. Returns 0 if gamma settings are
63 * unsupported.
64 *
65 * @return the length of each gamma ramp array, or 0 if gamma settings are unsupported.
66 */
67 int getGammaRampLength();
68
69 /**
70 * Method to set the gamma ramp.
71 */
72 void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
73
74 /**
75 * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2",
76 * "Radeon9700". If the adapter cannot be determined, this function returns null.
77 * @return a String
78 */
79 String getAdapter();
80
81 /**
82 * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined,
83 * this function returns null.
84 * @return a String
85 */
86 String getVersion();
87
88 /**
89 * Initialize and return the current display mode.
90 */
91 DisplayMode init() throws LWJGLException;
92
93 /**
94 * Implementation of setTitle(). This will read the window's title member
95 * and stash it in the native title of the window.
96 */
97 void setTitle(String title);
98
99 boolean isCloseRequested();
100
101 boolean isVisible();
102 boolean isActive();
103
104 boolean isDirty();
105
106 /**
107 * Create the native PeerInfo.
108 * @throws LWJGLException
109 */
110 PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException;
111
112 // void destroyPeerInfo();
113
114 /**
115 * Updates the windows internal state. This must be called at least once per video frame
116 * to handle window close requests, moves, paints, etc.
117 */
118 void update();
119
120 void reshape(int x, int y, int width, int height);
121
122 /**
123 * Method for getting displaymodes
124 */
125 DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
126
127 /* Pbuffer */
128 int getPbufferCapabilities();
129
130 /**
131 * Method to test for buffer integrity
132 */
133 boolean isBufferLost(PeerInfo handle);
134
135 /**
136 * Method to create a Pbuffer
137 */
138 PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
139 IntBuffer pixelFormatCaps,
140 IntBuffer pBufferAttribs) throws LWJGLException;
141
142 void setPbufferAttrib(PeerInfo handle, int attrib, int value);
143
144 void bindTexImageToPbuffer(PeerInfo handle, int buffer);
145
146 void releaseTexImageFromPbuffer(PeerInfo handle, int buffer);
147
148 /**
149 * Sets one or more icons for the Display.
150 * <ul>
151 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
152 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
153 * <li>Mac OS X should be supplied one 128x128 icon</li>
154 * </ul>
155 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
156 *
157 * @param icons Array of icons in RGBA mode
158 * @return number of icons used.
159 */
160 int setIcon(ByteBuffer[] icons);
161 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 *
35 * This class encapsulates the properties for a given display mode.
36 * This class is not instantiable, and is aquired from the <code>Display.
37 * getAvailableDisplayModes()</code> method.
38 *
39 * @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 $
42 */
43
44 public final class DisplayMode {
45
46 /** properties of the display mode */
47 private final int width, height, bpp, freq;
48 /** If true, this instance can be used for fullscreen modes */
49 private final boolean fullscreen;
50
51 /**
52 * Construct a display mode. DisplayModes constructed through the
53 * public constructor can only be used to specify the dimensions of
54 * the Display in windowed mode. To get the available DisplayModes for
55 * fullscreen modes, use Display.getAvailableDisplayModes().
56 *
57 * @param width The Display width.
58 * @param height The Display height.
59 * @see Display
60 */
61 public DisplayMode(int width, int height) {
62 this(width, height, 0, 0, false);
63 }
64
65 DisplayMode(int width, int height, int bpp, int freq) {
66 this(width, height, bpp, freq, true);
67 }
68
69 private DisplayMode(int width, int height, int bpp, int freq, boolean fullscreen) {
70 this.width = width;
71 this.height = height;
72 this.bpp = bpp;
73 this.freq = freq;
74 this.fullscreen = fullscreen;
75 }
76
77 /** True iff this instance can be used for fullscreen modes */
78 public boolean isFullscreenCapable() {
79 return fullscreen;
80 }
81
82 public int getWidth() {
83 return width;
84 }
85
86 public int getHeight() {
87 return height;
88 }
89
90 public int getBitsPerPixel() {
91 return bpp;
92 }
93
94 public int getFrequency() {
95 return freq;
96 }
97
98 /**
99 * Tests for <code>DisplayMode</code> equality
100 *
101 * @see java.lang.Object#equals(Object)
102 */
103 public boolean equals(Object obj) {
104 if (obj == null || !(obj instanceof DisplayMode)) {
105 return false;
106 }
107
108 DisplayMode dm = (DisplayMode) obj;
109 return dm.width == width
110 && dm.height == height
111 && dm.bpp == bpp
112 && dm.freq == freq;
113 }
114
115 /**
116 * Retrieves the hashcode for this object
117 *
118 * @see java.lang.Object#hashCode()
119 */
120 public int hashCode() {
121 return width ^ height ^ freq ^ bpp;
122 }
123
124 /**
125 * Retrieves a String representation of this <code>DisplayMode</code>
126 *
127 * @see java.lang.Object#toString()
128 */
129 public String toString() {
130 StringBuffer sb = new StringBuffer(32);
131 sb.append(width);
132 sb.append(" x ");
133 sb.append(height);
134 sb.append(" x ");
135 sb.append(bpp);
136 sb.append(" @");
137 sb.append(freq);
138 sb.append("Hz");
139 return sb.toString();
140 }
141 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * The Drawable interface describes an OpenGL drawable with an associated
35 * Context.
36 *
37 * @author elias_naur
38 */
39
40 public interface Drawable {
41 Context getContext();
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 package org.lwjgl.opengl;
32
33 /**
34 * A java implementation of a LWJGL compatible event queue.
35 * @author elias_naur
36 */
37
38 import java.nio.ByteBuffer;
39
40 class EventQueue {
41 private static final int QUEUE_SIZE = 200;
42
43 private final int event_size;
44
45 private final ByteBuffer queue;
46
47 protected EventQueue(int event_size) {
48 this.event_size = event_size;
49 this.queue = ByteBuffer.allocate(QUEUE_SIZE*event_size);
50 }
51
52 protected synchronized void clearEvents() {
53 queue.clear();
54 }
55
56 /**
57 * Copy available events into the specified buffer.
58 */
59 public synchronized void copyEvents(ByteBuffer dest) {
60 queue.flip();
61 int old_limit = queue.limit();
62 if (dest.remaining() < queue.remaining())
63 queue.limit(dest.remaining() + queue.position());
64 dest.put(queue);
65 queue.limit(old_limit);
66 queue.compact();
67 }
68
69 /**
70 * Put an event into the queue.
71 * @return true if the event fitted into the queue, false otherwise
72 */
73 public synchronized boolean putEvent(ByteBuffer event) {
74 if (event.remaining() != event_size)
75 throw new IllegalArgumentException("Internal error: event size " + event_size + " does not equal the given event size " + event.remaining());
76 if (queue.remaining() >= event.remaining()) {
77 queue.put(event);
78 return true;
79 } else
80 return false;
81 }
82 }
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 java.nio.Buffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.BufferUtils;
37
38 /**
39 * A class to check buffer boundaries in GL methods. Many GL
40 * methods read data from the GL into a native Buffer at its current position. If there is unsufficient space in the buffer when
41 * the call is made then a buffer overflow would otherwise occur and cause unexpected behaviour, a crash, or worse, a security
42 * risk. Therefore in those methods where GL reads data back into a buffer, we will call a bounds check method from this class
43 * to ensure that there is sufficient space in the buffer.
44 * <p/>
45 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
46 *
47 * @author cix_foo <cix_foo@users.sourceforge.net>
48 * @version $Revision: 3279 $
49 * $Id: GLChecks.java 3279 2010-03-11 21:06:49Z spasi $
50 */
51 class GLChecks {
52
53 /** Static methods only! */
54 private GLChecks() {
55 }
56
57 static References getReferences(ContextCapabilities caps) {
58 return StateTracker.getReferencesStack(caps).getReferences();
59 }
60
61 static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
62 IntBuffer scratch_buffer = caps.scratch_int_buffer;
63 GL15.glGetBufferParameter(buffer_enum, GL15.GL_BUFFER_SIZE, scratch_buffer);
64 return scratch_buffer.get(0);
65 }
66
67 static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) {
68 IntBuffer scratch_buffer = caps.scratch_int_buffer;
69 ARBBufferObject.glGetBufferParameterARB(buffer_enum, ARBBufferObject.GL_BUFFER_SIZE_ARB, scratch_buffer);
70 return scratch_buffer.get(0);
71 }
72
73 static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) {
74 IntBuffer scratch_buffer = caps.scratch_int_buffer;
75 ATIVertexArrayObject.glGetObjectBufferATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI, scratch_buffer);
76 return scratch_buffer.get(0);
77 }
78
79 static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) {
80 IntBuffer scratch_buffer = caps.scratch_int_buffer;
81 EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE, scratch_buffer);
82 return scratch_buffer.get(0);
83 }
84
85 private static boolean checkBufferObject(ContextCapabilities caps, int buffer_enum, boolean state) {
86 IntBuffer scratch_buffer = caps.scratch_int_buffer;
87 GL11.glGetInteger(buffer_enum, scratch_buffer);
88 boolean is_enabled = scratch_buffer.get(0) != 0;
89 return state == is_enabled;
90 }
91
92 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
93 static void ensureArrayVBOdisabled(ContextCapabilities caps) {
94 if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0)
95 throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
96 }
97
98 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
99 static void ensureArrayVBOenabled(ContextCapabilities caps) {
100 if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0)
101 throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
102 }
103
104 /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
105 static void ensureElementVBOdisabled(ContextCapabilities caps) {
106 if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0)
107 throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
108 }
109
110 /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
111 static void ensureElementVBOenabled(ContextCapabilities caps) {
112 if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0)
113 throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
114 }
115
116 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
117 static void ensureIndirectBOdisabled(ContextCapabilities caps) {
118 if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
119 throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled");
120 }
121
122 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
123 static void ensureIndirectBOenabled(ContextCapabilities caps) {
124 if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
125 throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled");
126 }
127
128 /** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
129 static void ensurePackPBOdisabled(ContextCapabilities caps) {
130 if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
131 throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
132 }
133
134 /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
135 static void ensurePackPBOenabled(ContextCapabilities caps) {
136 if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 )
137 throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
138 }
139
140 /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
141 static void ensureUnpackPBOdisabled(ContextCapabilities caps) {
142 if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 )
143 throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
144 }
145
146 /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
147 static void ensureUnpackPBOenabled(ContextCapabilities caps) {
148 if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 )
149 throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
150 }
151
152 /**
153 * Calculate the storage required for an image in elements
154 *
155 * @param format The format of the image (example: GL_RGBA)
156 * @param type The type of the image elements (example: GL_UNSIGNED_BYTE)
157 * @param width The width of the image
158 * @param height The height of the image (1 for 1D images)
159 * @param depth The depth of the image (1 for 2D images)
160 *
161 * @return the size, in elements, of the image
162 */
163 static int calculateImageStorage(Buffer buffer, int format, int type, int width, int height, int depth) {
164 return calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer);
165 }
166
167 static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width) {
168 return calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer);
169 }
170
171 static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height) {
172 return calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer);
173 }
174
175 static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth) {
176 return calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer);
177 }
178
179 /**
180 * Calculate the storage required for an image in bytes.
181 *
182 * @param format The format of the image (example: GL_RGBA)
183 * @param type The type of the image elements (example: GL_UNSIGNED_BYTE)
184 * @param width The width of the image
185 * @param height The height of the image (1 for 1D images)
186 * @param depth The depth of the image (1 for 2D images)
187 *
188 * @return the size, in bytes, of the image
189 */
190 private static int calculateImageStorage(int format, int type, int width, int height, int depth) {
191 return calculateBytesPerPixel(format, type) * width * height * depth;
192 }
193
194 private static int calculateTexImage1DStorage(int format, int type, int width) {
195 return calculateBytesPerPixel(format, type) * width;
196 }
197
198 private static int calculateTexImage2DStorage(int format, int type, int width, int height) {
199 return calculateTexImage1DStorage(format, type, width) * height;
200 }
201
202 private static int calculateTexImage3DStorage(int format, int type, int width, int height, int depth) {
203 return calculateTexImage2DStorage(format, type, width, height) * depth;
204 }
205
206 private static int calculateBytesPerPixel(int format, int type) {
207 int bpe;
208 switch ( type ) {
209 case GL11.GL_UNSIGNED_BYTE:
210 case GL11.GL_BYTE:
211 bpe = 1;
212 break;
213 case GL11.GL_UNSIGNED_SHORT:
214 case GL11.GL_SHORT:
215 bpe = 2;
216 break;
217 case GL11.GL_UNSIGNED_INT:
218 case GL11.GL_INT:
219 case GL11.GL_FLOAT:
220 bpe = 4;
221 break;
222 default :
223 // TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8
224 return 0;
225 // throw new IllegalArgumentException("Unknown type " + type);
226 }
227 int epp;
228 switch ( format ) {
229 case GL11.GL_LUMINANCE:
230 case GL11.GL_ALPHA:
231 epp = 1;
232 break;
233
234 case GL11.GL_LUMINANCE_ALPHA:
235 epp = 2;
236 break;
237 case GL11.GL_RGB:
238 case EXTBgra.GL_BGR_EXT:
239 epp = 3;
240 break;
241 case GL11.GL_RGBA:
242 case EXTAbgr.GL_ABGR_EXT:
243 case EXTBgra.GL_BGRA_EXT:
244 epp = 4;
245 break;
246 default :
247 // TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT)
248 return 0;
249 /* // Assume 4 elements per pixel
250 epp = 4;*/
251 }
252
253 return bpe * epp;
254 }
255 }
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.LWJGLException;
35 import org.lwjgl.LWJGLUtil;
36 import org.lwjgl.Sys;
37
38 import java.lang.reflect.Method;
39 import java.nio.IntBuffer;
40 import java.security.AccessController;
41 import java.security.PrivilegedAction;
42 import java.security.PrivilegedExceptionAction;
43 import java.util.*;
44
45 /**
46 * <p/>
47 * Manages GL contexts. Before any rendering is done by a LWJGL system, a call should be made to GLContext.useContext() with a
48 * context. This will ensure that GLContext has an accurate reflection of the current context's capabilities and function
49 * pointers.
50 * <p/>
51 * This class is thread-safe in the sense that multiple threads can safely call all public methods. The class is also
52 * thread-aware in the sense that it tracks a per-thread current context (including capabilities and function pointers).
53 * That way, multiple threads can have multiple contexts current and render to them concurrently.
54 *
55 * @author elias_naur <elias_naur@users.sourceforge.net>
56 * @version $Revision: 3279 $
57 * $Id: GLContext.java 3279 2010-03-11 21:06:49Z spasi $
58 */
59 public final class GLContext {
60
61 /** Maps threads to their current context's ContextCapabilities, if any */
62 private final static ThreadLocal current_capabilities = new ThreadLocal();
63
64 /**
65 * The getCapabilities() method is a potential hot spot in any LWJGL application, since
66 * it is needed for context capability discovery (e.g. is OpenGL 2.0 supported?), and
67 * for the function pointers of gl functions. However, the 'current_capabilities' ThreadLocal
68 * is (relatively) expensive to look up, and since most OpenGL applications use are single threaded
69 * rendering, the following two is an optimization for this case.
70 * <p/>
71 * ThreadLocals can be thought of as a mapping between threads and values, so the idea
72 * is to use a lock-less cache of mappings between threads and the current ContextCapabilities. The cache
73 * could be any size, but in our case, we want a single sized cache for optimal performance
74 * in the single threaded case.
75 * <p/>
76 * 'fast_path_cache' is the most recent ContextCapabilities (potentially null) and its owner. By
77 * recent I mean the last thread setting the value in setCapabilities(). When getCapabilities()
78 * is called, a check to see if the current is the owner of the ContextCapabilities instance in
79 * fast_path_cache. If so, the instance is returned, if not, some thread has since taken ownership
80 * of the cache entry and the slower current_capabilities ThreadLocal is queried instead.
81 * <p/>
82 * No locks are needed in get/setCapabilities, because even though fast_path_cache can be accessed
83 * from multiple threads at once, we are guaranteed by the JVM spec that its value is always valid.
84 * Furthermore, if the ownership test in getCapabilities() succeeds, the cache entry can only contain
85 * the correct ContextCapabilites (that is, the one from getThreadLocalCapabilites()),
86 * since no other thread can set the owner to anyone else than itself.
87 */
88 private static CapabilitiesCacheEntry fast_path_cache = new CapabilitiesCacheEntry();
89
90 /**
91 * Simple lock-free cache of CapabilitesEntryCache to avoid allocating more than one
92 * cache entry per thread
93 */
94 private final static ThreadLocal thread_cache_entries = new ThreadLocal();
95
96 /**
97 * The weak mapping from context Object instances to ContextCapabilities. Used
98 * to avoid recreating a ContextCapabilities every time a context is made current.
99 */
100 private final static Map capability_cache = new WeakHashMap();
101
102 /** Reference count of the native opengl implementation library */
103 private static int gl_ref_count;
104 private static boolean did_auto_load;
105
106 static {
107 Sys.initialize();
108 }
109
110 /**
111 * Get the current capabilities instance. It contains the flags used
112 * to test for support of a particular extension.
113 *
114 * @return The current capabilities instance.
115 */
116 public static ContextCapabilities getCapabilities() {
117 CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
118 // Check owner of cache entry
119 if ( recent_cache_entry.owner == Thread.currentThread() ) {
120 /* The owner ship test succeeded, so the cache must contain the current ContextCapabilities instance
121 * assert recent_cache_entry.capabilities == getThreadLocalCapabilities();
122 */
123 return recent_cache_entry.capabilities;
124 } else // Some other thread has written to the cache since, and we fall back to the slower path
125 return getThreadLocalCapabilities();
126 }
127
128 private static ContextCapabilities getThreadLocalCapabilities() {
129 return ((ContextCapabilities)current_capabilities.get());
130 }
131
132 /**
133 * Set the current capabilities instance. It contains the flags used
134 * to test for support of a particular extension.
135 *
136 * @return The current capabilities instance.
137 */
138 static void setCapabilities(ContextCapabilities capabilities) {
139 current_capabilities.set(capabilities);
140
141 CapabilitiesCacheEntry thread_cache_entry = (CapabilitiesCacheEntry)thread_cache_entries.get();
142 if ( thread_cache_entry == null ) {
143 thread_cache_entry = new CapabilitiesCacheEntry();
144 thread_cache_entries.set(thread_cache_entry);
145 }
146 thread_cache_entry.owner = Thread.currentThread();
147 thread_cache_entry.capabilities = capabilities;
148
149 fast_path_cache = thread_cache_entry;
150 }
151
152 /**
153 * Helper method to get a pointer to a named function in the OpenGL library
154 * with a name dependent on the current platform
155 */
156 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 return System.getProperty("os.name");
160 }
161 });
162 for ( int i = 0; i < os_prefixes.length; i++ )
163 if ( os_name.startsWith(os_prefixes[i]) ) {
164 String platform_function_name = function.replaceFirst(function_prefix, os_function_prefixes[i]);
165 long address = getFunctionAddress(platform_function_name);
166 return address;
167 }
168 return 0;
169 }
170
171 /** Helper method to get a pointer to a named function in the OpenGL library */
172 static native long getFunctionAddress(String name);
173
174 /**
175 * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
176 *
177 * @param supported_extensions the Set to fill with the available extension names
178 *
179 * @return the context profile mask, will be 0 for any version < 3.2
180 */
181 static int getSupportedExtensions(final Set supported_extensions) {
182 // Detect OpenGL version first
183
184 final String version = GL11.glGetString(GL11.GL_VERSION);
185 if ( version == null )
186 throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context.");
187
188 final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
189 final String major_string = version_tokenizer.nextToken();
190 final String minor_string = version_tokenizer.nextToken();
191
192 int majorVersion = 0;
193 int minorVersion = 0;
194 try {
195 majorVersion = Integer.parseInt(major_string);
196 minorVersion = Integer.parseInt(minor_string);
197 } catch (NumberFormatException e) {
198 LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
199 }
200
201 // ----------------------[ 4.X ]----------------------
202 if ( 4 <= majorVersion )
203 supported_extensions.add("OpenGL40");
204
205 // ----------------------[ 3.X ]----------------------
206 if ( 3 < majorVersion || (3 == majorVersion && 3 <= minorVersion) )
207 supported_extensions.add("OpenGL33");
208 if ( 3 < majorVersion || (3 == majorVersion && 2 <= minorVersion) )
209 supported_extensions.add("OpenGL32");
210 if ( 3 < majorVersion || (3 == majorVersion && 1 <= minorVersion) )
211 supported_extensions.add("OpenGL31");
212 if ( 3 <= majorVersion )
213 supported_extensions.add("OpenGL30");
214
215 // ----------------------[ 2.X ]----------------------
216 if ( 2 < majorVersion || (2 == majorVersion && 1 <= minorVersion) )
217 supported_extensions.add("OpenGL21");
218 if ( 2 <= majorVersion )
219 supported_extensions.add("OpenGL20");
220
221 // ----------------------[ 1.X ]----------------------
222 if ( 1 < majorVersion || 5 <= minorVersion )
223 supported_extensions.add("OpenGL15");
224 if ( 1 < majorVersion || 4 <= minorVersion )
225 supported_extensions.add("OpenGL14");
226 if ( 1 < majorVersion || 3 <= minorVersion )
227 supported_extensions.add("OpenGL13");
228 if ( 1 < majorVersion || 2 <= minorVersion )
229 supported_extensions.add("OpenGL12");
230 if ( 1 < majorVersion || 1 <= minorVersion )
231 supported_extensions.add("OpenGL11");
232
233 int profileMask = 0;
234
235 if ( majorVersion < 3 ) {
236 // Parse EXTENSIONS string
237 final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);
238 if ( extensions_string == null )
239 throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?");
240
241 final StringTokenizer tokenizer = new StringTokenizer(extensions_string);
242 while ( tokenizer.hasMoreTokens() )
243 supported_extensions.add(tokenizer.nextToken());
244 } else {
245 // Use forward compatible indexed EXTENSIONS
246 final IntBuffer buffer = BufferUtils.createIntBuffer(16);
247 GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS, buffer);
248 final int extensionCount = buffer.get(0);
249
250 for ( int i = 0; i < extensionCount; i++ )
251 supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i));
252
253 // Get the context profile mask for versions >= 3.2
254 if ( 3 < majorVersion || 2 <= minorVersion ) {
255 Util.checkGLError(); // Make sure we have no errors up to this point
256
257 GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK, buffer);
258
259 try {
260 // Retrieving GL_CONTEXT_PROFILE_MASK may generate an INVALID_OPERATION error on certain implementations, ignore.
261 // Happens on pre10.1 ATI drivers, when ContextAttribs.withProfileCompatibility is not used
262 Util.checkGLError();
263 profileMask = buffer.get(0);
264 } catch (OpenGLException e) {
265 LWJGLUtil.log("Failed to retrieve CONTEXT_PROFILE_MASK");
266 }
267 }
268 }
269
270 return profileMask;
271 }
272
273 /**
274 * Helper method to ContextCapabilities. It will try to initialize the native stubs,
275 * and remove the given extension name from the extension set if the initialization fails.
276 */
277 static void initNativeStubs(final Class extension_class, Set supported_extensions, String ext_name) {
278 resetNativeStubs(extension_class);
279 if ( supported_extensions.contains(ext_name) ) {
280 try {
281 AccessController.doPrivileged(new PrivilegedExceptionAction() {
282 public Object run() throws Exception {
283 Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs", null);
284 init_stubs_method.invoke(null, null);
285 return null;
286 }
287 });
288 } catch (Exception e) {
289 LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e);
290 supported_extensions.remove(ext_name);
291 }
292 }
293 }
294
295 /**
296 * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to
297 * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and
298 * function pointers. Use useContext(null) when no context is active. <p>If the context is the same as last time, then this is
299 * a no-op. <p>If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set
300 * of caps and function pointers will be used. <p>The reference to the context is held in a weak reference; therefore if no
301 * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the
302 * future, freeing up a little RAM.
303 *
304 * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are
305 * unloaded.
306 *
307 * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded
308 */
309 public static synchronized void useContext(Object context) throws LWJGLException {
310 useContext(context, false);
311 }
312
313 /**
314 * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to
315 * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and
316 * function pointers. Use useContext(null) when no context is active. <p>If the context is the same as last time, then this is
317 * a no-op. <p>If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set
318 * of caps and function pointers will be used. <p>The reference to the context is held in a weak reference; therefore if no
319 * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the
320 * future, freeing up a little RAM.
321 * <p>If forwardCompatible is true, function pointers of deprecated GL11-GL21 functionality will not be loaded. Calling a deprecated
322 * function using the specified context will result in an <code>IllegalStateException</code>.
323 *
324 * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are
325 * unloaded.
326 * @param forwardCompatible If the context is a forward compatible context (does not expose deprecated functionality, see XGL_ARB_create_context)
327 *
328 * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded
329 */
330 public static synchronized void useContext(Object context, boolean forwardCompatible) throws LWJGLException {
331 if ( context == null ) {
332 ContextCapabilities.unloadAllStubs();
333 setCapabilities(null);
334 if ( did_auto_load )
335 unloadOpenGLLibrary();
336 return;
337 }
338 if ( gl_ref_count == 0 ) {
339 loadOpenGLLibrary();
340 did_auto_load = true;
341 }
342 try {
343 ContextCapabilities capabilities = (ContextCapabilities)capability_cache.get(context);
344 if ( capabilities == null ) {
345 /*
346 * The capabilities object registers itself as current. This behaviour is caused
347 * by a chicken-and-egg situation where the constructor needs to call GL functions
348 * as part of its capability discovery, but GL functions cannot be called before
349 * a capabilities object has been set.
350 */
351 new ContextCapabilities(forwardCompatible);
352 capability_cache.put(context, getCapabilities());
353 } else
354 setCapabilities(capabilities);
355 } catch (LWJGLException e) {
356 if ( did_auto_load )
357 unloadOpenGLLibrary();
358 throw e;
359 }
360 }
361
362 /** If the OpenGL reference count is 0, the library is loaded. The reference count is then incremented. */
363 public static synchronized void loadOpenGLLibrary() throws LWJGLException {
364 if ( gl_ref_count == 0 )
365 nLoadOpenGLLibrary();
366 gl_ref_count++;
367 }
368
369 private static native void nLoadOpenGLLibrary() throws LWJGLException;
370
371 /** The OpenGL library reference count is decremented, and if it reaches 0, the library is unloaded. */
372 public static synchronized void unloadOpenGLLibrary() {
373 gl_ref_count--;
374 /*
375 * Unload the native OpenGL library unless we're on linux, since
376 * some drivers (NVIDIA proprietary) crash on exit when unloading the library.
377 */
378 if ( gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX )
379 nUnloadOpenGLLibrary();
380 }
381
382 private static native void nUnloadOpenGLLibrary();
383
384 /** Native method to clear native stub bindings */
385 static native void resetNativeStubs(Class clazz);
386
387 private final static class CapabilitiesCacheEntry {
388
389 Thread owner;
390 ContextCapabilities capabilities;
391 }
392 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author spasi <spasi@users.sourceforge.net>
35 */
36 public final class GLSync implements PointerWrapper {
37
38 private final long sync;
39
40 GLSync(final long sync) {
41 this.sync = sync;
42 }
43
44 public long getPointer() {
45 return sync;
46 }
47
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.opengl;
32
33 /**
34 * <p/>
35 * GLU constants.
36 *
37 * @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 */
41 public interface GLUConstants {
42
43 /* Errors: (return value 0 = no error) */
44 int GLU_INVALID_ENUM = 100900;
45 int GLU_INVALID_VALUE = 100901;
46 int GLU_OUT_OF_MEMORY = 100902;
47 int GLU_INCOMPATIBLE_GL_VERSION = 100903;
48
49 /* StringName */
50 int GLU_VERSION = 100800;
51 int GLU_EXTENSIONS = 100801;
52
53 /* Boolean */
54 int GLU_TRUE = GL11.GL_TRUE;
55 int GLU_FALSE = GL11.GL_FALSE;
56
57 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This class contains the global lock that LWJGL will use to
35 * synchronize access to Display.
36 */
37 final class GlobalLock {
38 final static Object lock = new Object();
39 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the input implementation interface. Mouse and Keyboard delegates
35 * to implementors of this interface. There is one InputImplementation
36 * for each supported platform.
37 * @author elias_naur
38 */
39
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42
43 import org.lwjgl.LWJGLException;
44
45 public interface InputImplementation {
46 /*
47 * Mouse methods
48 */
49 /** Query of wheel support */
50 boolean hasWheel();
51
52 /** Query of button count */
53 int getButtonCount();
54
55 /**
56 * Method to create the mouse.
57 */
58 void createMouse() throws LWJGLException;
59
60 /**
61 * Method the destroy the mouse
62 */
63 void destroyMouse();
64
65 /**
66 * Method to poll the mouse
67 */
68 void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
69
70 /**
71 * Method to read the keyboard buffer
72 */
73 void readMouse(ByteBuffer buffer);
74
75 void grabMouse(boolean grab);
76
77 /**
78 * Function to determine native cursor support
79 */
80 int getNativeCursorCapabilities();
81
82 /** Method to set the native cursor position */
83 void setCursorPosition(int x, int y);
84
85 /** Method to set the native cursor */
86 void setNativeCursor(Object handle) throws LWJGLException;
87
88 /** Method returning the minimum cursor size */
89 int getMinCursorSize();
90
91 /** Method returning the maximum cursor size */
92 int getMaxCursorSize();
93
94 /*
95 * Keyboard methods
96 */
97
98 /**
99 * Method to create the keyboard
100 */
101 void createKeyboard() throws LWJGLException;
102
103 /**
104 * Method to destroy the keyboard
105 */
106 void destroyKeyboard();
107
108 /**
109 * Method to poll the keyboard.
110 *
111 * @param keyDownBuffer the address of a 256-byte buffer to place
112 * key states in.
113 */
114 void pollKeyboard(ByteBuffer keyDownBuffer);
115
116 /**
117 * Method to read the keyboard buffer
118 */
119 void readKeyboard(ByteBuffer buffer);
120
121 // int isStateKeySet(int key);
122
123 /** Native cursor handles */
124 Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException;
125
126 void destroyCursor(Object cursor_handle);
127
128 int getWidth();
129
130 int getHeight();
131
132 boolean isInsideWindow();
133 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An AWT implementation of a LWJGL compatible Keyboard event queue.
35 * @author elias_naur
36 */
37
38 import java.awt.event.KeyEvent;
39 import java.awt.event.KeyListener;
40 import java.awt.Component;
41 import java.nio.ByteBuffer;
42
43 import org.lwjgl.input.Keyboard;
44
45 final class KeyboardEventQueue extends EventQueue implements KeyListener {
46 private static final int[] KEY_MAP = new int[0xffff];
47
48 private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
49
50 /** Event scratch array */
51 private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
52
53 private final Component component;
54
55 private boolean has_deferred_event;
56 private long deferred_nanos;
57 private int deferred_key_code;
58 private int deferred_key_location;
59 private byte deferred_key_state;
60 private int deferred_character;
61
62 static {
63 KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0;
64 KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1;
65 KEY_MAP[KeyEvent.VK_2] = Keyboard.KEY_2;
66 KEY_MAP[KeyEvent.VK_3] = Keyboard.KEY_3;
67 KEY_MAP[KeyEvent.VK_4] = Keyboard.KEY_4;
68 KEY_MAP[KeyEvent.VK_5] = Keyboard.KEY_5;
69 KEY_MAP[KeyEvent.VK_6] = Keyboard.KEY_6;
70 KEY_MAP[KeyEvent.VK_7] = Keyboard.KEY_7;
71 KEY_MAP[KeyEvent.VK_8] = Keyboard.KEY_8;
72 KEY_MAP[KeyEvent.VK_9] = Keyboard.KEY_9;
73 KEY_MAP[KeyEvent.VK_A] = Keyboard.KEY_A;
74 // KEY_MAP[KeyEvent.VK_ACCEPT] = Keyboard.KEY_ACCEPT;
75 KEY_MAP[KeyEvent.VK_ADD] = Keyboard.KEY_ADD;
76 // KEY_MAP[KeyEvent.VK_AGAIN] = Keyboard.KEY_AGAIN;
77 // KEY_MAP[KeyEvent.VK_ALL_CANDIDATES] = Keyboard.KEY_ALL_CANDIDATES;
78 // KEY_MAP[KeyEvent.VK_ALPHANUMERIC] = Keyboard.KEY_ALPHANUMERIC;
79 // KEY_MAP[KeyEvent.VK_ALT] = Keyboard.KEY_LMENU; manually mapped
80 KEY_MAP[KeyEvent.VK_ALT_GRAPH] = Keyboard.KEY_RMENU;
81 // KEY_MAP[KeyEvent.VK_AMPERSAND] = Keyboard.KEY_AMPERSAND;
82 // KEY_MAP[KeyEvent.VK_ASTERISK] = Keyboard.KEY_ASTERISK;
83 KEY_MAP[KeyEvent.VK_AT] = Keyboard.KEY_AT;
84 KEY_MAP[KeyEvent.VK_B] = Keyboard.KEY_B;
85 // KEY_MAP[KeyEvent.VK_BACK_QUOTE] = Keyboard.KEY_BACK_QUOTE;
86 KEY_MAP[KeyEvent.VK_BACK_SLASH] = Keyboard.KEY_BACKSLASH;
87 KEY_MAP[KeyEvent.VK_BACK_SPACE] = Keyboard.KEY_BACK;
88 // KEY_MAP[KeyEvent.VK_BRACELEFT] = Keyboard.KEY_BRACELEFT;
89 // KEY_MAP[KeyEvent.VK_BRACERIGHT] = Keyboard.KEY_BRACERIGHT;
90 KEY_MAP[KeyEvent.VK_C] = Keyboard.KEY_C;
91 // KEY_MAP[KeyEvent.VK_CANCEL] = Keyboard.KEY_CANCEL;
92 KEY_MAP[KeyEvent.VK_CAPS_LOCK] = Keyboard.KEY_CAPITAL;
93 KEY_MAP[KeyEvent.VK_CIRCUMFLEX] = Keyboard.KEY_CIRCUMFLEX;
94 // KEY_MAP[KeyEvent.VK_CLEAR] = Keyboard.KEY_CLEAR;
95 KEY_MAP[KeyEvent.VK_CLOSE_BRACKET] = Keyboard.KEY_RBRACKET;
96 // KEY_MAP[KeyEvent.VK_CODE_INPUT] = Keyboard.KEY_CODE_INPUT;
97 KEY_MAP[KeyEvent.VK_COLON] = Keyboard.KEY_COLON;
98 KEY_MAP[KeyEvent.VK_COMMA] = Keyboard.KEY_COMMA;
99 // KEY_MAP[KeyEvent.VK_COMPOSE] = Keyboard.KEY_COMPOSE;
100 // KEY_MAP[KeyEvent.VK_CONTROL] = Keyboard.KEY_LCONTROL; manually mapped
101 KEY_MAP[KeyEvent.VK_CONVERT] = Keyboard.KEY_CONVERT;
102 // KEY_MAP[KeyEvent.VK_COPY] = Keyboard.KEY_COPY;
103 // KEY_MAP[KeyEvent.VK_CUT] = Keyboard.KEY_CUT;
104 KEY_MAP[KeyEvent.VK_D] = Keyboard.KEY_D;
105 // KEY_MAP[KeyEvent.VK_DEAD_ABOVEDOT] = Keyboard.KEY_DEAD_ABOVEDOT;
106 // KEY_MAP[KeyEvent.VK_DEAD_ABOVERING] = Keyboard.KEY_DEAD_ABOVERING;
107 // KEY_MAP[KeyEvent.VK_DEAD_ACUTE] = Keyboard.KEY_DEAD_ACUTE;
108 // KEY_MAP[KeyEvent.VK_DEAD_BREVE] = Keyboard.KEY_DEAD_BREVE;
109 // KEY_MAP[KeyEvent.VK_DEAD_CARON] = Keyboard.KEY_DEAD_CARON;
110 // KEY_MAP[KeyEvent.VK_DEAD_CEDILLA] = Keyboard.KEY_DEAD_CEDILLA;
111 // KEY_MAP[KeyEvent.VK_DEAD_CIRCUMFLEX] = Keyboard.KEY_DEAD_CIRCUMFLEX;
112 // KEY_MAP[KeyEvent.VK_DEAD_DIAERESIS] = Keyboard.KEY_DEAD_DIAERESIS;
113 // KEY_MAP[KeyEvent.VK_DEAD_DOUBLEACUTE] = Keyboard.KEY_DEAD_DOUBLEACUTE;
114 // KEY_MAP[KeyEvent.VK_DEAD_GRAVE] = Keyboard.KEY_DEAD_GRAVE;
115 // KEY_MAP[KeyEvent.VK_DEAD_IOTA] = Keyboard.KEY_DEAD_IOTA;
116 // KEY_MAP[KeyEvent.VK_DEAD_MACRON] = Keyboard.KEY_DEAD_MACRON;
117 // KEY_MAP[KeyEvent.VK_DEAD_OGONEK] = Keyboard.KEY_DEAD_OGONEK;
118 // KEY_MAP[KeyEvent.VK_DEAD_SEMIVOICED_SOUND] = Keyboard.KEY_DEAD_SEMIVOICED_SOUND;
119 // KEY_MAP[KeyEvent.VK_DEAD_TILDE] = Keyboard.KEY_DEAD_TILDE;
120 // KEY_MAP[KeyEvent.VK_DEAD_VOICED_SOUND] = Keyboard.KEY_DEAD_VOICED_SOUND;
121 KEY_MAP[KeyEvent.VK_DECIMAL] = Keyboard.KEY_DECIMAL;
122 KEY_MAP[KeyEvent.VK_DELETE] = Keyboard.KEY_DELETE;
123 KEY_MAP[KeyEvent.VK_DIVIDE] = Keyboard.KEY_DIVIDE;
124 // KEY_MAP[KeyEvent.VK_DOLLAR] = Keyboard.KEY_DOLLAR;
125 KEY_MAP[KeyEvent.VK_DOWN] = Keyboard.KEY_DOWN;
126 KEY_MAP[KeyEvent.VK_E] = Keyboard.KEY_E;
127 KEY_MAP[KeyEvent.VK_END] = Keyboard.KEY_END;
128 KEY_MAP[KeyEvent.VK_ENTER] = Keyboard.KEY_RETURN;
129 KEY_MAP[KeyEvent.VK_EQUALS] = Keyboard.KEY_EQUALS;
130 KEY_MAP[KeyEvent.VK_ESCAPE] = Keyboard.KEY_ESCAPE;
131 // KEY_MAP[KeyEvent.VK_EURO_SIGN] = Keyboard.KEY_EURO_SIGN;
132 // KEY_MAP[KeyEvent.VK_EXCLAMATION_MARK] = Keyboard.KEY_EXCLAMATION_MARK;
133 KEY_MAP[KeyEvent.VK_F] = Keyboard.KEY_F;
134 KEY_MAP[KeyEvent.VK_F1] = Keyboard.KEY_F1;
135 KEY_MAP[KeyEvent.VK_F10] = Keyboard.KEY_F10;
136 KEY_MAP[KeyEvent.VK_F11] = Keyboard.KEY_F11;
137 KEY_MAP[KeyEvent.VK_F12] = Keyboard.KEY_F12;
138 KEY_MAP[KeyEvent.VK_F13] = Keyboard.KEY_F13;
139 KEY_MAP[KeyEvent.VK_F14] = Keyboard.KEY_F14;
140 KEY_MAP[KeyEvent.VK_F15] = Keyboard.KEY_F15;
141 // KEY_MAP[KeyEvent.VK_F16] = Keyboard.KEY_F16;
142 // KEY_MAP[KeyEvent.VK_F17] = Keyboard.KEY_F17;
143 // KEY_MAP[KeyEvent.VK_F18] = Keyboard.KEY_F18;
144 // KEY_MAP[KeyEvent.VK_F19] = Keyboard.KEY_F19;
145 KEY_MAP[KeyEvent.VK_F2] = Keyboard.KEY_F2;
146 // KEY_MAP[KeyEvent.VK_F20] = Keyboard.KEY_F20;
147 // KEY_MAP[KeyEvent.VK_F21] = Keyboard.KEY_F21;
148 // KEY_MAP[KeyEvent.VK_F22] = Keyboard.KEY_F22;
149 // KEY_MAP[KeyEvent.VK_F23] = Keyboard.KEY_F23;
150 // KEY_MAP[KeyEvent.VK_F24] = Keyboard.KEY_F24;
151 KEY_MAP[KeyEvent.VK_F3] = Keyboard.KEY_F3;
152 KEY_MAP[KeyEvent.VK_F4] = Keyboard.KEY_F4;
153 KEY_MAP[KeyEvent.VK_F5] = Keyboard.KEY_F5;
154 KEY_MAP[KeyEvent.VK_F6] = Keyboard.KEY_F6;
155 KEY_MAP[KeyEvent.VK_F7] = Keyboard.KEY_F7;
156 KEY_MAP[KeyEvent.VK_F8] = Keyboard.KEY_F8;
157 KEY_MAP[KeyEvent.VK_F9] = Keyboard.KEY_F9;
158 // KEY_MAP[KeyEvent.VK_FINAL] = Keyboard.KEY_FINAL;
159 // KEY_MAP[KeyEvent.VK_FIND] = Keyboard.KEY_FIND;
160 // KEY_MAP[KeyEvent.VK_FULL_WIDTH] = Keyboard.KEY_FULL_WIDTH;
161 KEY_MAP[KeyEvent.VK_G] = Keyboard.KEY_G;
162 // KEY_MAP[KeyEvent.VK_GREATER] = Keyboard.KEY_GREATER;
163 KEY_MAP[KeyEvent.VK_H] = Keyboard.KEY_H;
164 // KEY_MAP[KeyEvent.VK_HALF_WIDTH] = Keyboard.KEY_HALF_WIDTH;
165 // KEY_MAP[KeyEvent.VK_HELP] = Keyboard.KEY_HELP;
166 // KEY_MAP[KeyEvent.VK_HIRAGANA] = Keyboard.KEY_HIRAGANA;
167 KEY_MAP[KeyEvent.VK_HOME] = Keyboard.KEY_HOME;
168 KEY_MAP[KeyEvent.VK_I] = Keyboard.KEY_I;
169 // KEY_MAP[KeyEvent.VK_INPUT_METHOD_ON_OFF] = Keyboard.KEY_INPUT_METHOD_ON_OFF;
170 KEY_MAP[KeyEvent.VK_INSERT] = Keyboard.KEY_INSERT;
171 // KEY_MAP[KeyEvent.VK_INVERTED_EXCLAMATION_MARK] = Keyboard.KEY_INVERTED_EXCLAMATION_MARK;
172 KEY_MAP[KeyEvent.VK_J] = Keyboard.KEY_J;
173 // KEY_MAP[KeyEvent.VK_JAPANESE_HIRAGANA] = Keyboard.KEY_JAPANESE_HIRAGANA;
174 // KEY_MAP[KeyEvent.VK_JAPANESE_KATAKANA] = Keyboard.KEY_JAPANESE_KATAKANA;
175 // KEY_MAP[KeyEvent.VK_JAPANESE_ROMAN] = Keyboard.KEY_JAPANESE_ROMAN;
176 KEY_MAP[KeyEvent.VK_K] = Keyboard.KEY_K;
177 KEY_MAP[KeyEvent.VK_KANA] = Keyboard.KEY_KANA;
178 // KEY_MAP[KeyEvent.VK_KANA_LOCK] = Keyboard.KEY_KANA_LOCK;
179 KEY_MAP[KeyEvent.VK_KANJI] = Keyboard.KEY_KANJI;
180 // KEY_MAP[KeyEvent.VK_KATAKANA] = Keyboard.KEY_KATAKANA;
181 // KEY_MAP[KeyEvent.VK_KP_DOWN] = Keyboard.KEY_KP_DOWN;
182 // KEY_MAP[KeyEvent.VK_KP_LEFT] = Keyboard.KEY_KP_LEFT;
183 // KEY_MAP[KeyEvent.VK_KP_RIGHT] = Keyboard.KEY_KP_RIGHT;
184 // KEY_MAP[KeyEvent.VK_KP_UP] = Keyboard.KEY_KP_UP;
185 KEY_MAP[KeyEvent.VK_L] = Keyboard.KEY_L;
186 KEY_MAP[KeyEvent.VK_LEFT] = Keyboard.KEY_LEFT;
187 // KEY_MAP[KeyEvent.VK_LEFT_PARENTHESIS] = Keyboard.KEY_LEFT_PARENTHESIS;
188 // KEY_MAP[KeyEvent.VK_LESS] = Keyboard.KEY_LESS;
189 KEY_MAP[KeyEvent.VK_M] = Keyboard.KEY_M;
190 // KEY_MAP[KeyEvent.VK_META] = Keyboard.KEY_LMENU; manually mapped
191 KEY_MAP[KeyEvent.VK_MINUS] = Keyboard.KEY_MINUS;
192 // KEY_MAP[KeyEvent.VK_MODECHANGE] = Keyboard.KEY_MODECHANGE;
193 KEY_MAP[KeyEvent.VK_MULTIPLY] = Keyboard.KEY_MULTIPLY;
194 KEY_MAP[KeyEvent.VK_N] = Keyboard.KEY_N;
195 // KEY_MAP[KeyEvent.VK_NONCONVERT] = Keyboard.KEY_NONCONVERT;
196 KEY_MAP[KeyEvent.VK_NUM_LOCK] = Keyboard.KEY_NUMLOCK;
197 // KEY_MAP[KeyEvent.VK_NUMBER_SIGN] = Keyboard.KEY_NUMBER_SIGN;
198 KEY_MAP[KeyEvent.VK_NUMPAD0] = Keyboard.KEY_NUMPAD0;
199 KEY_MAP[KeyEvent.VK_NUMPAD1] = Keyboard.KEY_NUMPAD1;
200 KEY_MAP[KeyEvent.VK_NUMPAD2] = Keyboard.KEY_NUMPAD2;
201 KEY_MAP[KeyEvent.VK_NUMPAD3] = Keyboard.KEY_NUMPAD3;
202 KEY_MAP[KeyEvent.VK_NUMPAD4] = Keyboard.KEY_NUMPAD4;
203 KEY_MAP[KeyEvent.VK_NUMPAD5] = Keyboard.KEY_NUMPAD5;
204 KEY_MAP[KeyEvent.VK_NUMPAD6] = Keyboard.KEY_NUMPAD6;
205 KEY_MAP[KeyEvent.VK_NUMPAD7] = Keyboard.KEY_NUMPAD7;
206 KEY_MAP[KeyEvent.VK_NUMPAD8] = Keyboard.KEY_NUMPAD8;
207 KEY_MAP[KeyEvent.VK_NUMPAD9] = Keyboard.KEY_NUMPAD9;
208 KEY_MAP[KeyEvent.VK_O] = Keyboard.KEY_O;
209 KEY_MAP[KeyEvent.VK_OPEN_BRACKET] = Keyboard.KEY_LBRACKET;
210 KEY_MAP[KeyEvent.VK_P] = Keyboard.KEY_P;
211 KEY_MAP[KeyEvent.VK_PAGE_DOWN] = Keyboard.KEY_NEXT;
212 KEY_MAP[KeyEvent.VK_PAGE_UP] = Keyboard.KEY_PRIOR;
213 // KEY_MAP[KeyEvent.VK_PASTE] = Keyboard.KEY_PASTE;
214 KEY_MAP[KeyEvent.VK_PAUSE] = Keyboard.KEY_PAUSE;
215 KEY_MAP[KeyEvent.VK_PERIOD] = Keyboard.KEY_PERIOD;
216 // KEY_MAP[KeyEvent.VK_PLUS] = Keyboard.KEY_PLUS;
217 // KEY_MAP[KeyEvent.VK_PREVIOUS_CANDIDATE] = Keyboard.KEY_PREVIOUS_CANDIDATE;
218 // KEY_MAP[KeyEvent.VK_PRINTSCREEN] = Keyboard.KEY_PRINTSCREEN;
219 // KEY_MAP[KeyEvent.VK_PROPS] = Keyboard.KEY_PROPS;
220 KEY_MAP[KeyEvent.VK_Q] = Keyboard.KEY_Q;
221 // KEY_MAP[KeyEvent.VK_QUOTE] = Keyboard.KEY_QUOTE;
222 // KEY_MAP[KeyEvent.VK_QUOTEDBL] = Keyboard.KEY_QUOTEDBL;
223 KEY_MAP[KeyEvent.VK_R] = Keyboard.KEY_R;
224 KEY_MAP[KeyEvent.VK_RIGHT] = Keyboard.KEY_RIGHT;
225 // KEY_MAP[KeyEvent.VK_RIGHT_PARENTHESIS] = Keyboard.KEY_RIGHT_PARENTHESIS;
226 // KEY_MAP[KeyEvent.VK_ROMAN_CHARACTERS] = Keyboard.KEY_ROMAN_CHARACTERS;
227 KEY_MAP[KeyEvent.VK_S] = Keyboard.KEY_S;
228 KEY_MAP[KeyEvent.VK_SCROLL_LOCK] = Keyboard.KEY_SCROLL;
229 KEY_MAP[KeyEvent.VK_SEMICOLON] = Keyboard.KEY_SEMICOLON;
230 KEY_MAP[KeyEvent.VK_SEPARATOR] = Keyboard.KEY_DECIMAL;
231 // KEY_MAP[KeyEvent.VK_SHIFT] = Keyboard.KEY_LSHIFT; manually mapped
232 KEY_MAP[KeyEvent.VK_SLASH] = Keyboard.KEY_SLASH;
233 KEY_MAP[KeyEvent.VK_SPACE] = Keyboard.KEY_SPACE;
234 KEY_MAP[KeyEvent.VK_STOP] = Keyboard.KEY_STOP;
235 KEY_MAP[KeyEvent.VK_SUBTRACT] = Keyboard.KEY_SUBTRACT;
236 KEY_MAP[KeyEvent.VK_T] = Keyboard.KEY_T;
237 KEY_MAP[KeyEvent.VK_TAB] = Keyboard.KEY_TAB;
238 KEY_MAP[KeyEvent.VK_U] = Keyboard.KEY_U;
239 // KEY_MAP[KeyEvent.VK_UNDERSCORE] = Keyboard.KEY_UNDERSCORE;
240 // KEY_MAP[KeyEvent.VK_UNDO] = Keyboard.KEY_UNDO;
241 KEY_MAP[KeyEvent.VK_UP] = Keyboard.KEY_UP;
242 KEY_MAP[KeyEvent.VK_V] = Keyboard.KEY_V;
243 KEY_MAP[KeyEvent.VK_W] = Keyboard.KEY_W;
244 KEY_MAP[KeyEvent.VK_X] = Keyboard.KEY_X;
245 KEY_MAP[KeyEvent.VK_Y] = Keyboard.KEY_Y;
246 KEY_MAP[KeyEvent.VK_Z] = Keyboard.KEY_Z;
247 }
248
249 KeyboardEventQueue(Component component) {
250 super(Keyboard.EVENT_SIZE);
251 this.component = component;
252 }
253
254 public void register() {
255 component.addKeyListener(this);
256 }
257
258 public void unregister() {
259 /*
260 * This line is commented out to work around AWT bug 4867453:
261 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453
262 */
263 //component.removeKeyListener(this);
264 }
265
266 private void putKeyboardEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
267 event.clear();
268 event.putInt(key_code).put(state).putInt(character).putLong(nanos).put(repeat ? (byte)1 : (byte)0);
269 event.flip();
270 putEvent(event);
271 }
272
273 public synchronized void poll(ByteBuffer key_down_buffer) {
274 flushDeferredEvent();
275 int old_position = key_down_buffer.position();
276 key_down_buffer.put(key_states);
277 key_down_buffer.position(old_position);
278 }
279
280 public synchronized void copyEvents(ByteBuffer dest) {
281 flushDeferredEvent();
282 super.copyEvents(dest);
283 }
284
285 private synchronized void handleKey(int key_code, int key_location, byte state, int character, long nanos) {
286 if (character == KeyEvent.CHAR_UNDEFINED)
287 character = Keyboard.CHAR_NONE;
288 if (state == 1) {
289 boolean repeat = false;
290 if (has_deferred_event) {
291 if ((nanos == deferred_nanos && deferred_key_code == key_code &&
292 deferred_key_location == key_location)) {
293 has_deferred_event = false;
294 repeat = true; // Repeat event
295 } else
296 flushDeferredEvent();
297 }
298 putKeyEvent(key_code, key_location, state, character, nanos, repeat);
299 } else {
300 flushDeferredEvent();
301 has_deferred_event = true;
302 deferred_nanos = nanos;
303 deferred_key_code = key_code;
304 deferred_key_location = key_location;
305 deferred_key_state = state;
306 deferred_character = character;
307 }
308 }
309
310 private void flushDeferredEvent() {
311 if (has_deferred_event) {
312 putKeyEvent(deferred_key_code, deferred_key_location, deferred_key_state, deferred_character, deferred_nanos, false);
313 has_deferred_event = false;
314 }
315 }
316
317 private void putKeyEvent(int key_code, int key_location, byte state, int character, long nanos, boolean repeat) {
318 int key_code_mapped = getMappedKeyCode(key_code, key_location);
319 /* Ignore repeating presses */
320 if ( key_states[key_code_mapped] == state )
321 repeat = true;
322 key_states[key_code_mapped] = state;
323 int key_int_char = character & 0xffff;
324 putKeyboardEvent(key_code_mapped, state, key_int_char, nanos, repeat);
325 }
326
327 private int getMappedKeyCode(int key_code, int position) {
328 // manually map positioned keys
329 switch (key_code) {
330 case KeyEvent.VK_ALT: // fall through
331 if (position == KeyEvent.KEY_LOCATION_RIGHT)
332 return Keyboard.KEY_RMENU;
333 else
334 return Keyboard.KEY_LMENU;
335 case KeyEvent.VK_META:
336 if (position == KeyEvent.KEY_LOCATION_RIGHT)
337 return Keyboard.KEY_RMETA;
338 else
339 return Keyboard.KEY_LMETA;
340 case KeyEvent.VK_SHIFT:
341 if (position == KeyEvent.KEY_LOCATION_RIGHT)
342 return Keyboard.KEY_RSHIFT;
343 else
344 return Keyboard.KEY_LSHIFT;
345 case KeyEvent.VK_CONTROL:
346 if (position == KeyEvent.KEY_LOCATION_RIGHT)
347 return Keyboard.KEY_RCONTROL;
348 else
349 return Keyboard.KEY_LCONTROL;
350 default:
351 return KEY_MAP[key_code];
352 }
353 }
354
355 public void keyPressed(KeyEvent e) {
356 handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)1, e.getKeyChar(), e.getWhen()*1000000);
357 }
358
359 public void keyReleased(KeyEvent e) {
360 handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)0, Keyboard.CHAR_NONE, e.getWhen()*1000000);
361 }
362
363 public void keyTyped(KeyEvent e) {
364 }
365 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36 import org.lwjgl.LWJGLUtil;
37 import java.awt.Canvas;
38
39 /**
40 *
41 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: LinuxAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
44 */
45 final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
46 private final Canvas component;
47 private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
48 private int screen = -1;
49
50 LinuxAWTGLCanvasPeerInfo(Canvas component) {
51 this.component = component;
52 }
53
54 protected void doLockAndInitHandle() throws LWJGLException {
55 ByteBuffer surface_handle = awt_surface.lockAndGetHandle(component);
56 if (screen == -1) {
57 try {
58 screen = getScreenFromSurfaceInfo(surface_handle);
59 } catch (LWJGLException e) {
60 LWJGLUtil.log("Got exception while trying to determine screen: " + e);
61 screen = 0;
62 }
63 }
64 nInitHandle(screen, surface_handle, getHandle());
65 }
66 private static native int getScreenFromSurfaceInfo(ByteBuffer surface_handle) throws LWJGLException;
67 private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
68
69 protected void doUnlock() throws LWJGLException {
70 awt_surface.unlock();
71 }
72 }
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 java.awt.GraphicsConfiguration;
34 import java.awt.GraphicsDevice;
35 import java.awt.Canvas;
36 import java.lang.reflect.Method;
37 import java.security.AccessController;
38 import java.security.PrivilegedExceptionAction;
39
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.LWJGLUtil;
42
43 /**
44 *
45 * @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 $
48 */
49 final class LinuxCanvasImplementation implements AWTCanvasImplementation {
50 static int getScreenFromDevice(final GraphicsDevice device) throws LWJGLException {
51 try {
52 Method getScreen_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
53 public Object run() throws Exception {
54 return device.getClass().getMethod("getScreen", null);
55 }
56 });
57 Integer screen = (Integer)getScreen_method.invoke(device, null);
58 return screen.intValue();
59 } catch (Exception e) {
60 throw new LWJGLException(e);
61 }
62 }
63
64 private static int getVisualIDFromConfiguration(final GraphicsConfiguration configuration) throws LWJGLException {
65 try {
66 Method getVisual_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
67 public Object run() throws Exception {
68 return configuration.getClass().getMethod("getVisual", null);
69 }
70 });
71 Integer visual = (Integer)getVisual_method.invoke(configuration, null);
72 return visual.intValue();
73 } catch (Exception e) {
74 throw new LWJGLException(e);
75 }
76 }
77
78 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
79 return new LinuxAWTGLCanvasPeerInfo(component);
80 }
81
82 /**
83 * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
84 *
85 * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
86 */
87 public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
88 try {
89 int screen = getScreenFromDevice(device);
90 int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format);
91 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];
96 }
97 } catch (LWJGLException e) {
98 LWJGLUtil.log("Got exception while trying to determine configuration: " + e);
99 }
100 return null; // In case we failed to locate the visual, or if we're not on a SUN JDK
101 }
102
103 private static int findVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException {
104 try {
105 LinuxDisplay.lockAWT();
106 try {
107 GLContext.loadOpenGLLibrary();
108 try {
109 LinuxDisplay.incDisplay();
110 return nFindVisualIDFromFormat(LinuxDisplay.getDisplay(), screen, pixel_format);
111 } finally {
112 LinuxDisplay.decDisplay();
113 }
114 } finally {
115 GLContext.unloadOpenGLLibrary();
116 }
117 } finally {
118 LinuxDisplay.unlockAWT();
119 }
120 }
121 private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException;
122 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An implementation of ContextAttribs using GLX_create_context.
35 * <p/><p/>
36 * ---- WIP - GLX_create_context has not been defined yet ----
37 *
38 * @author spasi <spasi@users.sourceforge.net>
39 */
40 final class LinuxContextAttribs implements ContextAttribsImplementation {
41
42 private static final int GLX_CONTEXT_MAJOR_VERSION_ARB = 0x2091;
43 private static final int GLX_CONTEXT_MINOR_VERSION_ARB = 0x2092;
44 private static final int GLX_CONTEXT_LAYER_PLANE_ARB = 0x2093;
45 private static final int GLX_CONTEXT_FLAGS_ARB = 0x2094;
46 private static final int GLX_CONTEXT_PROFILE_MASK_ARB = 0x9126;
47
48 private static final int GLX_CONTEXT_DEBUG_BIT_ARB = 0x0001;
49 private static final int GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
50
51 private static final int GLX_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
52 private static final int GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
53
54 LinuxContextAttribs() {
55 }
56
57 public int getMajorVersionAttrib() {
58 return GLX_CONTEXT_MAJOR_VERSION_ARB;
59 }
60
61 public int getMinorVersionAttrib() {
62 return GLX_CONTEXT_MINOR_VERSION_ARB;
63 }
64
65 public int getLayerPlaneAttrib() {
66 return GLX_CONTEXT_LAYER_PLANE_ARB;
67 }
68
69 public int getFlagsAttrib() {
70 return GLX_CONTEXT_FLAGS_ARB;
71 }
72
73 public int getDebugBit() {
74 return GLX_CONTEXT_DEBUG_BIT_ARB;
75 }
76
77 public int getForwardCompatibleBit() {
78 return GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
79 }
80
81 public int getProfileMaskAttrib() {
82 return GLX_CONTEXT_PROFILE_MASK_ARB;
83 }
84
85 public int getProfileCoreBit() {
86 return GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
87 }
88
89 public int getProfileCompatibilityBit() {
90 return GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
91 }
92
93 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.LWJGLException;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 /**
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class LinuxContextImplementation implements ContextImplementation {
44
45 public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
46 LinuxDisplay.lockAWT();
47 try {
48 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
49 try {
50 return nCreate(peer_handle, attribs, shared_context_handle);
51 } finally {
52 peer_info.unlock();
53 }
54 } finally {
55 LinuxDisplay.unlockAWT();
56 }
57 }
58
59 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException;
60
61 public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException {
62 }
63
64 public void swapBuffers() throws LWJGLException {
65 Context current_context = Context.getCurrentContext();
66 if ( current_context == null )
67 throw new IllegalStateException("No context is current");
68 synchronized ( current_context ) {
69 PeerInfo current_peer_info = current_context.getPeerInfo();
70 LinuxDisplay.lockAWT();
71 try {
72 ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
73 try {
74 nSwapBuffers(peer_handle);
75 } finally {
76 current_peer_info.unlock();
77 }
78 } finally {
79 LinuxDisplay.unlockAWT();
80 }
81 }
82 }
83
84 private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
85
86 public void releaseCurrentContext() throws LWJGLException {
87 Context current_context = Context.getCurrentContext();
88 if ( current_context == null )
89 throw new IllegalStateException("No context is current");
90 synchronized ( current_context ) {
91 PeerInfo current_peer_info = current_context.getPeerInfo();
92 LinuxDisplay.lockAWT();
93 try {
94 ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
95 try {
96 nReleaseCurrentContext(peer_handle);
97 } finally {
98 current_peer_info.unlock();
99 }
100 } finally {
101 LinuxDisplay.unlockAWT();
102 }
103 }
104 }
105
106 private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException;
107
108 public void update(ByteBuffer context_handle) {
109 }
110
111 public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
112 LinuxDisplay.lockAWT();
113 try {
114 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
115 try {
116 nMakeCurrent(peer_handle, handle);
117 } finally {
118 peer_info.unlock();
119 }
120 } finally {
121 LinuxDisplay.unlockAWT();
122 }
123 }
124
125 private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
126
127 public boolean isCurrent(ByteBuffer handle) throws LWJGLException {
128 LinuxDisplay.lockAWT();
129 try {
130 boolean result = nIsCurrent(handle);
131 return result;
132 } finally {
133 LinuxDisplay.unlockAWT();
134 }
135 }
136
137 private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
138
139 public void setSwapInterval(int value) {
140 Context current_context = Context.getCurrentContext();
141 if ( current_context == null )
142 throw new IllegalStateException("No context is current");
143 synchronized ( current_context ) {
144 LinuxDisplay.lockAWT();
145 nSetSwapInterval(current_context.getHandle(), value);
146 LinuxDisplay.unlockAWT();
147 }
148 }
149
150 private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
151
152 public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
153 LinuxDisplay.lockAWT();
154 try {
155 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
156 try {
157 nDestroy(peer_handle, handle);
158 } finally {
159 peer_info.unlock();
160 }
161 } finally {
162 LinuxDisplay.unlockAWT();
163 }
164 }
165
166 private static native void nDestroy(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
167 }
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 /**
34 * This is the Display implementation interface. Display delegates
35 * to implementors of this interface. There is one DisplayImplementation
36 * for each supported platform.
37 * @author elias_naur
38 */
39
40 import java.awt.Canvas;
41 import java.nio.ByteBuffer;
42 import java.nio.FloatBuffer;
43 import java.nio.IntBuffer;
44
45 import org.lwjgl.BufferUtils;
46 import org.lwjgl.LWJGLException;
47 import org.lwjgl.LWJGLUtil;
48 import org.lwjgl.opengl.XRandR.Screen;
49
50 final class LinuxDisplay implements DisplayImplementation {
51 /* X11 constants */
52 public final static int CurrentTime = 0;
53 public final static int GrabSuccess = 0;
54 public final static int AutoRepeatModeOff = 0;
55 public final static int AutoRepeatModeOn = 1;
56 public final static int AutoRepeatModeDefault = 2;
57 public final static int None = 0;
58
59 private final static int KeyPressMask = 1 << 0;
60 private final static int KeyReleaseMask = 1 << 1;
61 private final static int ButtonPressMask = 1 << 2;
62 private final static int ButtonReleaseMask = 1 << 3;
63
64 private final static int NotifyAncestor = 0;
65 private final static int NotifyNonlinear = 3;
66 private final static int NotifyPointer = 5;
67 private final static int NotifyPointerRoot = 6;
68 private final static int NotifyDetailNone = 7;
69
70 private final static int SetModeInsert = 0;
71 private final static int SaveSetRoot = 1;
72 private final static int SaveSetUnmap = 1;
73
74 /** Window mode enum */
75 private static final int FULLSCREEN_LEGACY = 1;
76 private static final int FULLSCREEN_NETWM = 2;
77 private static final int WINDOWED = 3;
78
79 /** Current window mode */
80 private static int current_window_mode = WINDOWED;
81
82 /** Display mode switching API */
83 private static final int XRANDR = 10;
84 private static final int XF86VIDMODE = 11;
85 private static final int NONE = 12;
86
87 /** Current X11 Display pointer */
88 private static long display;
89 private static long current_window;
90 private static long saved_error_handler;
91
92 private static int display_connection_usage_count = 0;
93
94 /** Event buffer */
95 private final LinuxEvent event_buffer = new LinuxEvent();
96 private final LinuxEvent tmp_event_buffer = new LinuxEvent();
97
98 /** Current mode swithcing API */
99 private int current_displaymode_extension = NONE;
100
101 /** Atom used for the pointer warp messages */
102 private long delete_atom;
103
104 private PeerInfo peer_info;
105
106 /** Saved gamma used to restore display settings */
107 private ByteBuffer saved_gamma;
108 private ByteBuffer current_gamma;
109
110 /** Saved mode to restore with */
111 private DisplayMode saved_mode;
112 private DisplayMode current_mode;
113
114 private Screen[] savedXrandrConfig;
115
116 private boolean keyboard_grabbed;
117 private boolean pointer_grabbed;
118 private boolean input_released;
119 private boolean grab;
120 private boolean focused;
121 private boolean minimized;
122 private boolean dirty;
123 private boolean close_requested;
124 private long current_cursor;
125 private long blank_cursor;
126 private Canvas parent;
127 private long parent_window;
128 private boolean xembedded;
129 private boolean parent_focus;
130
131 private LinuxKeyboard keyboard;
132 private LinuxMouse mouse;
133
134 private static ByteBuffer getCurrentGammaRamp() throws LWJGLException {
135 lockAWT();
136 try {
137 incDisplay();
138 try {
139 if (isXF86VidModeSupported())
140 return nGetCurrentGammaRamp(getDisplay(), getDefaultScreen());
141 else
142 return null;
143 } finally {
144 decDisplay();
145 }
146 } finally {
147 unlockAWT();
148 }
149 }
150 private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException;
151
152 private static int getBestDisplayModeExtension() {
153 int result;
154 if (isXrandrSupported()) {
155 LWJGLUtil.log("Using Xrandr for display mode switching");
156 result = XRANDR;
157 } else if (isXF86VidModeSupported()) {
158 LWJGLUtil.log("Using XF86VidMode for display mode switching");
159 result = XF86VIDMODE;
160 } else {
161 LWJGLUtil.log("No display mode extensions available");
162 result = NONE;
163 }
164 return result;
165 }
166
167 private static boolean isXrandrSupported() {
168 if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR"))
169 return false;
170 lockAWT();
171 try {
172 incDisplay();
173 try {
174 return nIsXrandrSupported(getDisplay());
175 } finally {
176 decDisplay();
177 }
178 } catch (LWJGLException e) {
179 LWJGLUtil.log("Got exception while querying Xrandr support: " + e);
180 return false;
181 } finally {
182 unlockAWT();
183 }
184 }
185 private static native boolean nIsXrandrSupported(long display) throws LWJGLException;
186
187 private static boolean isXF86VidModeSupported() {
188 lockAWT();
189 try {
190 incDisplay();
191 try {
192 return nIsXF86VidModeSupported(getDisplay());
193 } finally {
194 decDisplay();
195 }
196 } catch (LWJGLException e) {
197 LWJGLUtil.log("Got exception while querying XF86VM support: " + e);
198 return false;
199 } finally {
200 unlockAWT();
201 }
202 }
203 private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException;
204
205 private static boolean isNetWMFullscreenSupported() throws LWJGLException {
206 if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM"))
207 return false;
208 lockAWT();
209 try {
210 incDisplay();
211 try {
212 return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen());
213 } finally {
214 decDisplay();
215 }
216 } catch (LWJGLException e) {
217 LWJGLUtil.log("Got exception while querying NetWM support: " + e);
218 return false;
219 } finally {
220 unlockAWT();
221 }
222 }
223 private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException;
224
225 /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
226 * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to
227 * do just that.
228 */
229 static void lockAWT() {
230 try {
231 nLockAWT();
232 } catch (LWJGLException e) {
233 LWJGLUtil.log("Caught exception while locking AWT: " + e);
234 }
235 }
236 private static native void nLockAWT() throws LWJGLException;
237
238 static void unlockAWT() {
239 try {
240 nUnlockAWT();
241 } catch (LWJGLException e) {
242 LWJGLUtil.log("Caught exception while unlocking AWT: " + e);
243 }
244 }
245 private static native void nUnlockAWT() throws LWJGLException;
246
247 /**
248 * increment and decrement display usage.
249 */
250 static void incDisplay() throws LWJGLException {
251 if (display_connection_usage_count == 0) {
252 GLContext.loadOpenGLLibrary();
253 saved_error_handler = setErrorHandler();
254 display = openDisplay();
255 // synchronize(display, true);
256 }
257 display_connection_usage_count++;
258 }
259 private static native int callErrorHandler(long handler, long display, long error_ptr);
260 private static native long setErrorHandler();
261 private static native long resetErrorHandler(long handler);
262 private static native void synchronize(long display, boolean synchronize);
263
264 private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException {
265 if (display == getDisplay()) {
266 String error_msg = getErrorText(display, error_code);
267 throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code);
268 } else if (saved_error_handler != 0)
269 return callErrorHandler(saved_error_handler, display, event_ptr);
270 return 0;
271 }
272 private static native String getErrorText(long display, long error_code);
273
274 static void decDisplay() {
275 /*
276 * Some drivers (at least some versions of the radeon dri driver)
277 * don't like it when the display is closed and later re-opened,
278 * so we'll just let the singleton display connection leak.
279 */
280 /* display_connection_usage_count--;
281 if (display_connection_usage_count < 0)
282 throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count);
283 if (display_connection_usage_count == 0) {
284 closeDisplay(display);
285 resetErrorHandler(saved_error_handler);
286 display = 0;
287 GLContext.unloadOpenGLLibrary();
288 }*/
289 }
290
291 static native long openDisplay() throws LWJGLException;
292 static native void closeDisplay(long display);
293
294 private int getWindowMode(boolean fullscreen) throws LWJGLException {
295 if (fullscreen) {
296 if (current_displaymode_extension == XRANDR && isNetWMFullscreenSupported()) {
297 LWJGLUtil.log("Using NetWM for fullscreen window");
298 return FULLSCREEN_NETWM;
299 } else {
300 LWJGLUtil.log("Using legacy mode for fullscreen window");
301 return FULLSCREEN_LEGACY;
302 }
303 } else
304 return WINDOWED;
305 }
306
307 static long getDisplay() {
308 if (display_connection_usage_count <= 0)
309 throw new InternalError("display_connection_usage_count = " + display_connection_usage_count);
310 return display;
311 }
312
313 static int getDefaultScreen() {
314 return nGetDefaultScreen(getDisplay());
315 }
316 static native int nGetDefaultScreen(long display);
317
318 static long getWindow() {
319 return current_window;
320 }
321
322 private void ungrabKeyboard() {
323 if (keyboard_grabbed) {
324 nUngrabKeyboard(getDisplay());
325 keyboard_grabbed = false;
326 }
327 }
328 static native int nUngrabKeyboard(long display);
329
330 private void grabKeyboard() {
331 if (!keyboard_grabbed) {
332 int res = nGrabKeyboard(getDisplay(), getWindow());
333 if (res == GrabSuccess)
334 keyboard_grabbed = true;
335 }
336 }
337 static native int nGrabKeyboard(long display, long window);
338
339 private void grabPointer() {
340 if (!pointer_grabbed) {
341 int result = nGrabPointer(getDisplay(), getWindow(), None);
342 if (result == GrabSuccess) {
343 pointer_grabbed = true;
344 // make sure we have a centered window
345 if (isLegacyFullscreen()) {
346 nSetViewPort(getDisplay(), getWindow(), getDefaultScreen());
347 }
348 }
349 }
350 }
351 static native int nGrabPointer(long display, long window, long cursor);
352 private static native void nSetViewPort(long display, long window, int screen);
353
354 private void ungrabPointer() {
355 if (pointer_grabbed) {
356 pointer_grabbed = false;
357 nUngrabPointer(getDisplay());
358 }
359 }
360 static native int nUngrabPointer(long display);
361
362 private boolean isFullscreen() {
363 return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM;
364 }
365
366 private boolean shouldGrab() {
367 return !input_released && grab && mouse != null;
368 }
369
370 private void updatePointerGrab() {
371 if (isFullscreen() || shouldGrab()) {
372 grabPointer();
373 } else {
374 ungrabPointer();
375 }
376 updateCursor();
377 }
378
379 private void updateCursor() {
380 long cursor;
381 if (shouldGrab()) {
382 cursor = blank_cursor;
383 } else {
384 cursor = current_cursor;
385 }
386 nDefineCursor(getDisplay(), getWindow(), cursor);
387 }
388 private static native void nDefineCursor(long display, long window, long cursor_handle);
389
390 private boolean isLegacyFullscreen() {
391 return current_window_mode == FULLSCREEN_LEGACY;
392 }
393
394 private void updateKeyboardGrab() {
395 if (isLegacyFullscreen())
396 grabKeyboard();
397 else
398 ungrabKeyboard();
399 }
400
401 public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
402 lockAWT();
403 try {
404 incDisplay();
405 try {
406 ByteBuffer handle = peer_info.lockAndGetHandle();
407 try {
408 current_window_mode = getWindowMode(Display.isFullscreen());
409 boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED;
410 this.parent = parent;
411 parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
412 current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window);
413 mapRaised(getDisplay(), current_window);
414 xembedded = parent != null && isAncestorXEmbedded(parent_window);
415 blank_cursor = createBlankCursor();
416 current_cursor = None;
417 focused = false;
418 input_released = false;
419 pointer_grabbed = false;
420 keyboard_grabbed = false;
421 close_requested = false;
422 grab = false;
423 minimized = false;
424 dirty = true;
425 } finally {
426 peer_info.unlock();
427 }
428 } catch (LWJGLException e) {
429 decDisplay();
430 throw e;
431 }
432 } finally {
433 unlockAWT();
434 }
435 }
436 private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle) throws LWJGLException;
437 private static native long getRootWindow(long display, int screen);
438 private static native boolean hasProperty(long display, long window, long property);
439 private static native long getParentWindow(long display, long window) throws LWJGLException;
440 private static native void mapRaised(long display, long window);
441 private static native void reparentWindow(long display, long window, long parent, int x, int y);
442
443 private boolean isAncestorXEmbedded(long window) throws LWJGLException {
444 long xembed_atom = internAtom("_XEMBED_INFO", true);
445 if (xembed_atom != None) {
446 long w = window;
447 while (w != None) {
448 if (hasProperty(getDisplay(), w, xembed_atom))
449 return true;
450 w = getParentWindow(getDisplay(), w);
451 }
452 }
453 return false;
454 }
455
456 private static long getHandle(Canvas parent) throws LWJGLException {
457 AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
458 LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null);
459 ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
460 try {
461 return parent_peer_info.getDrawable();
462 } finally {
463 parent_peer_info.unlock();
464 }
465 }
466
467 private void updateInputGrab() {
468 updatePointerGrab();
469 updateKeyboardGrab();
470 }
471
472 public void destroyWindow() {
473 lockAWT();
474 try {
475 try {
476 setNativeCursor(null);
477 } catch (LWJGLException e) {
478 LWJGLUtil.log("Failed to reset cursor: " + e.getMessage());
479 }
480 nDestroyCursor(getDisplay(), blank_cursor);
481 blank_cursor = None;
482 ungrabKeyboard();
483 nDestroyWindow(getDisplay(), getWindow());
484 decDisplay();
485 } finally {
486 unlockAWT();
487 }
488 }
489 static native void nDestroyWindow(long display, long window);
490
491 public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
492 lockAWT();
493 try {
494 switchDisplayModeOnTmpDisplay(mode);
495 current_mode = mode;
496 } finally {
497 unlockAWT();
498 }
499 }
500
501 private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
502 incDisplay();
503 try {
504 nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
505 } finally {
506 decDisplay();
507 }
508 }
509 private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
510
511 private static long internAtom(String atom_name, boolean only_if_exists) throws LWJGLException {
512 incDisplay();
513 try {
514 return nInternAtom(getDisplay(), atom_name, only_if_exists);
515 } finally {
516 decDisplay();
517 }
518 }
519 static native long nInternAtom(long display, String atom_name, boolean only_if_exists);
520
521 public void resetDisplayMode() {
522 lockAWT();
523 try {
524 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
525 {
526 XRandR.setConfiguration( savedXrandrConfig );
527 }
528 else
529 {
530 switchDisplayMode(saved_mode);
531 }
532 if (isXF86VidModeSupported())
533 doSetGamma(saved_gamma);
534 } catch (LWJGLException e) {
535 LWJGLUtil.log("Caught exception while resetting mode: " + e);
536 } finally {
537 unlockAWT();
538 }
539 }
540
541 public int getGammaRampLength() {
542 if (!isXF86VidModeSupported())
543 return 0;
544 lockAWT();
545 try {
546 try {
547 incDisplay();
548 try {
549 return nGetGammaRampLength(getDisplay(), getDefaultScreen());
550 } catch (LWJGLException e) {
551 LWJGLUtil.log("Got exception while querying gamma length: " + e);
552 return 0;
553 } finally {
554 decDisplay();
555 }
556 } catch (LWJGLException e) {
557 LWJGLUtil.log("Failed to get gamma ramp length: " + e);
558 return 0;
559 }
560 } finally {
561 unlockAWT();
562 }
563 }
564 private static native int nGetGammaRampLength(long display, int screen) throws LWJGLException;
565
566 public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException {
567 if (!isXF86VidModeSupported())
568 throw new LWJGLException("No gamma ramp support (Missing XF86VM extension)");
569 doSetGamma(convertToNativeRamp(gammaRamp));
570 }
571
572 private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException {
573 lockAWT();
574 try {
575 setGammaRampOnTmpDisplay(native_gamma);
576 current_gamma = native_gamma;
577 } finally {
578 unlockAWT();
579 }
580 }
581
582 private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
583 incDisplay();
584 try {
585 nSetGammaRamp(getDisplay(), getDefaultScreen(), native_gamma);
586 } finally {
587 decDisplay();
588 }
589 }
590 private static native void nSetGammaRamp(long display, int screen, ByteBuffer gammaRamp) throws LWJGLException;
591
592 private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException {
593 return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining());
594 }
595 private static native ByteBuffer nConvertToNativeRamp(FloatBuffer ramp, int offset, int length) throws LWJGLException;
596
597 public String getAdapter() {
598 return null;
599 }
600
601 public String getVersion() {
602 return null;
603 }
604
605 public DisplayMode init() throws LWJGLException {
606 lockAWT();
607 try {
608 delete_atom = internAtom("WM_DELETE_WINDOW", false);
609 current_displaymode_extension = getBestDisplayModeExtension();
610 if (current_displaymode_extension == NONE)
611 throw new LWJGLException("No display mode extension is available");
612 DisplayMode[] modes = getAvailableDisplayModes();
613 if (modes == null || modes.length == 0)
614 throw new LWJGLException("No modes available");
615 switch (current_displaymode_extension) {
616 case XRANDR:
617 savedXrandrConfig = XRandR.getConfiguration();
618 saved_mode = getCurrentXRandrMode();
619 break;
620 case XF86VIDMODE:
621 saved_mode = modes[0];
622 break;
623 default:
624 throw new LWJGLException("Unknown display mode extension: " + current_displaymode_extension);
625 }
626 current_mode = saved_mode;
627 saved_gamma = getCurrentGammaRamp();
628 current_gamma = saved_gamma;
629 return saved_mode;
630 } finally {
631 unlockAWT();
632 }
633 }
634
635 private static DisplayMode getCurrentXRandrMode() throws LWJGLException {
636 lockAWT();
637 try {
638 incDisplay();
639 try {
640 return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen());
641 } finally {
642 decDisplay();
643 }
644 } finally {
645 unlockAWT();
646 }
647 }
648
649 /** Assumes extension == XRANDR */
650 private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException;
651
652 public void setTitle(String title) {
653 lockAWT();
654 try {
655 nSetTitle(getDisplay(), getWindow(), title);
656 } finally {
657 unlockAWT();
658 }
659 }
660 private static native void nSetTitle(long display, long window, String title);
661
662 public boolean isCloseRequested() {
663 boolean result = close_requested;
664 close_requested = false;
665 return result;
666 }
667
668 public boolean isVisible() {
669 return !minimized;
670 }
671
672 public boolean isActive() {
673 return focused || isLegacyFullscreen();
674 }
675
676 public boolean isDirty() {
677 boolean result = dirty;
678 dirty = false;
679 return result;
680 }
681
682 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
683 peer_info = new LinuxDisplayPeerInfo(pixel_format);
684 return peer_info;
685 }
686
687 static native void setInputFocus(long display, long window, long time);
688
689 private void relayEventToParent(LinuxEvent event_buffer, int event_mask) {
690 tmp_event_buffer.copyFrom(event_buffer);
691 tmp_event_buffer.setWindow(parent_window);
692 tmp_event_buffer.sendEvent(getDisplay(), parent_window, true, event_mask);
693 }
694
695 private void relayEventToParent(LinuxEvent event_buffer) {
696 if (parent == null)
697 return;
698 switch (event_buffer.getType()) {
699 case LinuxEvent.KeyPress:
700 relayEventToParent(event_buffer, KeyPressMask);
701 break;
702 case LinuxEvent.KeyRelease:
703 relayEventToParent(event_buffer, KeyPressMask);
704 break;
705 case LinuxEvent.ButtonPress:
706 relayEventToParent(event_buffer, KeyPressMask);
707 break;
708 case LinuxEvent.ButtonRelease:
709 relayEventToParent(event_buffer, KeyPressMask);
710 break;
711 default:
712 break;
713 }
714 }
715
716 private void processEvents() {
717 while (LinuxEvent.getPending(getDisplay()) > 0) {
718 event_buffer.nextEvent(getDisplay());
719 long event_window = event_buffer.getWindow();
720 relayEventToParent(event_buffer);
721 if (event_window != getWindow() || event_buffer.filterEvent(event_window) ||
722 (mouse != null && mouse.filterEvent(grab, shouldWarpPointer(), event_buffer)) ||
723 (keyboard != null && keyboard.filterEvent(event_buffer)))
724 continue;
725 switch (event_buffer.getType()) {
726 case LinuxEvent.FocusIn:
727 setFocused(true, event_buffer.getFocusDetail());
728 break;
729 case LinuxEvent.FocusOut:
730 setFocused(false, event_buffer.getFocusDetail());
731 break;
732 case LinuxEvent.ClientMessage:
733 if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom))
734 close_requested = true;
735 break;
736 case LinuxEvent.MapNotify:
737 dirty = true;
738 minimized = false;
739 break;
740 case LinuxEvent.UnmapNotify:
741 dirty = true;
742 minimized = true;
743 break;
744 case LinuxEvent.Expose:
745 dirty = true;
746 break;
747 default:
748 break;
749 }
750 }
751 }
752
753 public void update() {
754 lockAWT();
755 try {
756 processEvents();
757 checkInput();
758 } finally {
759 unlockAWT();
760 }
761 }
762
763 public void reshape(int x, int y, int width, int height) {
764 lockAWT();
765 try {
766 nReshape(getDisplay(), getWindow(), x, y, width, height);
767 } finally {
768 unlockAWT();
769 }
770 }
771 private static native void nReshape(long display, long window, int x, int y, int width, int height);
772
773 public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
774 lockAWT();
775 try {
776 incDisplay();
777 try {
778 DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
779 return modes;
780 } finally {
781 decDisplay();
782 }
783 } finally {
784 unlockAWT();
785 }
786 }
787 private static native DisplayMode[] nGetAvailableDisplayModes(long display, int screen, int extension) throws LWJGLException;
788
789 /* Mouse */
790 public boolean hasWheel() {
791 return true;
792 }
793
794 public int getButtonCount() {
795 return mouse.getButtonCount();
796 }
797
798 public void createMouse() throws LWJGLException {
799 lockAWT();
800 try {
801 mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow());
802 } finally {
803 unlockAWT();
804 }
805 }
806
807 public void destroyMouse() {
808 mouse = null;
809 updateInputGrab();
810 }
811
812 public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
813 lockAWT();
814 try {
815 mouse.poll(grab, coord_buffer, buttons);
816 } finally {
817 unlockAWT();
818 }
819 }
820
821 public void readMouse(ByteBuffer buffer) {
822 lockAWT();
823 try {
824 mouse.read(buffer);
825 } finally {
826 unlockAWT();
827 }
828 }
829
830 public void setCursorPosition(int x, int y) {
831 lockAWT();
832 try {
833 mouse.setCursorPosition(x, y);
834 } finally {
835 unlockAWT();
836 }
837 }
838
839 private void checkInput() {
840 if (parent == null) return;
841
842 if (parent_focus != parent.hasFocus()) {
843 parent_focus = parent.hasFocus();
844
845 if (parent_focus) {
846 setInputFocusUnsafe(current_window);
847 }
848 else if (xembedded) {
849 setInputFocusUnsafe(0);
850 }
851 }
852 else if (parent_focus && !focused) {
853 setInputFocusUnsafe(current_window);
854 }
855 }
856
857 private void setFocused(boolean got_focus, int focus_detail) {
858 if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot)
859 return;
860 focused = got_focus;
861
862 if (focused) {
863 acquireInput();
864 }
865 else {
866 releaseInput();
867 }
868 }
869 static native long nGetInputFocus(long display);
870
871 private void setInputFocusUnsafe(long window) {
872 try {
873 setInputFocus(getDisplay(), window, CurrentTime);
874 sync(getDisplay(), false);
875 } catch (LWJGLException e) {
876 // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore
877 LWJGLUtil.log("Got exception while trying to focus: " + e);
878 }
879 }
880 private static native void sync(long display, boolean throw_away_events) throws LWJGLException;
881
882 private void releaseInput() {
883 if (isLegacyFullscreen() || input_released)
884 return;
885 input_released = true;
886 updateInputGrab();
887 if (current_window_mode == FULLSCREEN_NETWM) {
888 nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen());
889 try {
890 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
891 {
892 XRandR.setConfiguration( savedXrandrConfig );
893 }
894 else
895 {
896 switchDisplayModeOnTmpDisplay(saved_mode);
897 }
898 setGammaRampOnTmpDisplay(saved_gamma);
899 } catch (LWJGLException e) {
900 LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage());
901 }
902 }
903 }
904 private static native void nIconifyWindow(long display, long window, int screen);
905
906 private void acquireInput() {
907 if (isLegacyFullscreen() || !input_released)
908 return;
909 input_released = false;
910 updateInputGrab();
911 if (current_window_mode == FULLSCREEN_NETWM) {
912 try {
913 switchDisplayModeOnTmpDisplay(current_mode);
914 setGammaRampOnTmpDisplay(current_gamma);
915 } catch (LWJGLException e) {
916 LWJGLUtil.log("Failed to restore mode: " + e.getMessage());
917 }
918 }
919 }
920
921 public void grabMouse(boolean new_grab) {
922 lockAWT();
923 try {
924 if (new_grab != grab) {
925 grab = new_grab;
926 updateInputGrab();
927 mouse.changeGrabbed(grab, shouldWarpPointer());
928 }
929 } finally {
930 unlockAWT();
931 }
932 }
933
934 private boolean shouldWarpPointer() {
935 return pointer_grabbed && shouldGrab();
936 }
937
938 public int getNativeCursorCapabilities() {
939 lockAWT();
940 try {
941 incDisplay();
942 try {
943 return nGetNativeCursorCapabilities(getDisplay());
944 } finally {
945 decDisplay();
946 }
947 } catch (LWJGLException e) {
948 throw new RuntimeException(e);
949 } finally {
950 unlockAWT();
951 }
952 }
953 private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
954
955 public void setNativeCursor(Object handle) throws LWJGLException {
956 current_cursor = getCursorHandle(handle);
957 lockAWT();
958 try {
959 updateCursor();
960 } finally {
961 unlockAWT();
962 }
963 }
964
965 public int getMinCursorSize() {
966 lockAWT();
967 try {
968 incDisplay();
969 try {
970 return nGetMinCursorSize(getDisplay(), getWindow());
971 } finally {
972 decDisplay();
973 }
974 } catch (LWJGLException e) {
975 LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e);
976 return 0;
977 } finally {
978 unlockAWT();
979 }
980 }
981 private static native int nGetMinCursorSize(long display, long window);
982
983 public int getMaxCursorSize() {
984 lockAWT();
985 try {
986 incDisplay();
987 try {
988 return nGetMaxCursorSize(getDisplay(), getWindow());
989 } finally {
990 decDisplay();
991 }
992 } catch (LWJGLException e) {
993 LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e);
994 return 0;
995 } finally {
996 unlockAWT();
997 }
998 }
999 private static native int nGetMaxCursorSize(long display, long window);
1000
1001 /* Keyboard */
1002 public void createKeyboard() throws LWJGLException {
1003 lockAWT();
1004 try {
1005 keyboard = new LinuxKeyboard(getDisplay(), getWindow());
1006 } finally {
1007 unlockAWT();
1008 }
1009 }
1010
1011 public void destroyKeyboard() {
1012 lockAWT();
1013 try {
1014 keyboard.destroy(getDisplay());
1015 keyboard = null;
1016 } finally {
1017 unlockAWT();
1018 }
1019 }
1020
1021 public void pollKeyboard(ByteBuffer keyDownBuffer) {
1022 lockAWT();
1023 try {
1024 keyboard.poll(keyDownBuffer);
1025 } finally {
1026 unlockAWT();
1027 }
1028 }
1029
1030 public void readKeyboard(ByteBuffer buffer) {
1031 lockAWT();
1032 try {
1033 keyboard.read(buffer);
1034 } finally {
1035 unlockAWT();
1036 }
1037 }
1038
1039 private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
1040
1041 private static long createBlankCursor() {
1042 return nCreateBlankCursor(getDisplay(), getWindow());
1043 }
1044 static native long nCreateBlankCursor(long display, long window);
1045
1046 public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
1047 lockAWT();
1048 try {
1049 incDisplay();
1050 try {
1051 long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
1052 return new Long(cursor);
1053 } catch (LWJGLException e) {
1054 decDisplay();
1055 throw e;
1056 }
1057 } finally {
1058 unlockAWT();
1059 }
1060 }
1061
1062 private static long getCursorHandle(Object cursor_handle) {
1063 return cursor_handle != null ? ((Long)cursor_handle).longValue() : None;
1064 }
1065
1066 public void destroyCursor(Object cursorHandle) {
1067 lockAWT();
1068 try {
1069 nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle));
1070 decDisplay();
1071 } finally {
1072 unlockAWT();
1073 }
1074 }
1075 static native void nDestroyCursor(long display, long cursorHandle);
1076
1077 public int getPbufferCapabilities() {
1078 lockAWT();
1079 try {
1080 incDisplay();
1081 try {
1082 return nGetPbufferCapabilities(getDisplay(), getDefaultScreen());
1083 } finally {
1084 decDisplay();
1085 }
1086 } catch (LWJGLException e) {
1087 LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e);
1088 return 0;
1089 } finally {
1090 unlockAWT();
1091 }
1092 }
1093 private static native int nGetPbufferCapabilities(long display, int screen);
1094
1095 public boolean isBufferLost(PeerInfo handle) {
1096 return false;
1097 }
1098
1099 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
1100 IntBuffer pixelFormatCaps,
1101 IntBuffer pBufferAttribs) throws LWJGLException {
1102 return new LinuxPbufferPeerInfo(width, height, pixel_format);
1103 }
1104
1105 public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
1106 throw new UnsupportedOperationException();
1107 }
1108
1109 public void bindTexImageToPbuffer(PeerInfo handle, int buffer) {
1110 throw new UnsupportedOperationException();
1111 }
1112
1113 public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
1114 throw new UnsupportedOperationException();
1115 }
1116
1117 private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
1118 ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity());
1119 int x;
1120 int y;
1121 byte r,g,b;
1122
1123 int depth = 4;
1124
1125 for (y = 0; y < height; y++) {
1126 for (x = 0; x < width; x++) {
1127 r = icon.get((x*4)+(y*width*4));
1128 g = icon.get((x*4)+(y*width*4)+1);
1129 b = icon.get((x*4)+(y*width*4)+2);
1130
1131 icon_rgb.put((x*depth)+(y*width*depth), b); // blue
1132 icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
1133 icon_rgb.put((x*depth)+(y*width*depth)+2, r);
1134 }
1135 }
1136 return icon_rgb;
1137 }
1138
1139 private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) {
1140 ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8);
1141 int x;
1142 int y;
1143 byte a;
1144
1145 int depth = 4;
1146
1147 for (y = 0; y < height; y++) {
1148 for (x = 0; x < width; x++) {
1149 a = icon.get((x*4)+(y*width*4)+3);
1150
1151 int mask_index = x + y*width;
1152 int mask_byte_index = mask_index/8;
1153 int mask_bit_index = mask_index%8;
1154 byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0;
1155 byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff);
1156 icon_mask.put(mask_byte_index, new_byte);
1157 }
1158 }
1159 return icon_mask;
1160 }
1161
1162 /**
1163 * Sets one or more icons for the Display.
1164 * <ul>
1165 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
1166 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
1167 * <li>Mac OS X should be supplied one 128x128 icon</li>
1168 * </ul>
1169 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions necessary for the specific platform.
1170 *
1171 * @param icons Array of icons in RGBA mode
1172 * @return number of icons used.
1173 */
1174 public int setIcon(ByteBuffer[] icons) {
1175 lockAWT();
1176 try {
1177 incDisplay();
1178 try {
1179 for (int i=0;i<icons.length;i++) {
1180 int size = icons[i].limit() / 4;
1181 int dimension = (int)Math.sqrt(size);
1182 if (dimension > 0) {
1183 ByteBuffer icon_rgb = convertIcon(icons[i], dimension, dimension);
1184 ByteBuffer icon_mask = convertIconMask(icons[i], dimension, dimension);
1185 nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
1186 return 1;
1187 }
1188 }
1189 return 0;
1190 } finally {
1191 decDisplay();
1192 }
1193 } catch (LWJGLException e) {
1194 LWJGLUtil.log("Failed to set display icon: " + e);
1195 return 0;
1196 } finally {
1197 unlockAWT();
1198 }
1199 }
1200
1201 private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height);
1202
1203 public int getWidth() {
1204 return Display.getDisplayMode().getWidth();
1205 }
1206
1207 public int getHeight() {
1208 return Display.getDisplayMode().getHeight();
1209 }
1210
1211 public boolean isInsideWindow() {
1212 return true;
1213 }
1214 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
44 LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
45 LinuxDisplay.lockAWT();
46 try {
47 GLContext.loadOpenGLLibrary();
48 try {
49 LinuxDisplay.incDisplay();
50 try {
51 initDefaultPeerInfo(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), pixel_format);
52 } catch (LWJGLException e) {
53 LinuxDisplay.decDisplay();
54 throw e;
55 }
56 } catch (LWJGLException e) {
57 GLContext.unloadOpenGLLibrary();
58 throw e;
59 }
60 } finally {
61 LinuxDisplay.unlockAWT();
62 }
63 }
64 private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
65
66 protected void doLockAndInitHandle() throws LWJGLException {
67 LinuxDisplay.lockAWT();
68 try {
69 initDrawable(LinuxDisplay.getWindow(), getHandle());
70 } finally {
71 LinuxDisplay.unlockAWT();
72 }
73 }
74 private static native void initDrawable(long window, ByteBuffer peer_info_handle);
75
76 protected void doUnlock() throws LWJGLException {
77 // NO-OP
78 }
79
80 public void destroy() {
81 super.destroy();
82 LinuxDisplay.lockAWT();
83 LinuxDisplay.decDisplay();
84 GLContext.unloadOpenGLLibrary();
85 LinuxDisplay.unlockAWT();
86 }
87 }
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 java.nio.ByteBuffer;
34
35 /**
36 * Wrapper class for X11 events.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2286 $
40 * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $
41 */
42 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;
54
55 private final ByteBuffer event_buffer;
56
57 LinuxEvent() {
58 this.event_buffer = createEventBuffer();
59 }
60 private static native ByteBuffer createEventBuffer();
61
62 public void copyFrom(LinuxEvent event) {
63 int pos = event_buffer.position();
64 int event_pos = event.event_buffer.position();
65 event_buffer.put(event.event_buffer);
66 event_buffer.position(pos);
67 event.event_buffer.position(event_pos);
68 }
69
70 public static native int getPending(long display);
71
72 public void sendEvent(long display, long window, boolean propagate, long event_mask) {
73 nSendEvent(event_buffer, display, window, propagate, event_mask);
74 }
75 private static native void nSendEvent(ByteBuffer event_buffer, long display, long window, boolean propagate, long event_mask);
76
77 public boolean filterEvent(long window) {
78 return nFilterEvent(event_buffer, window);
79 }
80 private static native boolean nFilterEvent(ByteBuffer event_buffer, long window);
81
82 public void nextEvent(long display) {
83 nNextEvent(display, event_buffer);
84 }
85 private static native void nNextEvent(long display, ByteBuffer event_buffer);
86
87 public int getType() {
88 return nGetType(event_buffer);
89 }
90 private static native int nGetType(ByteBuffer event_buffer);
91
92 public long getWindow() {
93 return nGetWindow(event_buffer);
94 }
95 private static native long nGetWindow(ByteBuffer event_buffer);
96
97 public void setWindow(long window) {
98 nSetWindow(event_buffer, window);
99 }
100 private static native void nSetWindow(ByteBuffer event_buffer, long window);
101
102 /* Focus methods */
103
104 public int getFocusMode() {
105 return nGetFocusMode(event_buffer);
106 }
107 private static native int nGetFocusMode(ByteBuffer event_buffer);
108
109 public int getFocusDetail() {
110 return nGetFocusDetail(event_buffer);
111 }
112 private static native int nGetFocusDetail(ByteBuffer event_buffer);
113
114 /* ClientMessage methods */
115
116 public long getClientMessageType() {
117 return nGetClientMessageType(event_buffer);
118 }
119 private static native long nGetClientMessageType(ByteBuffer event_buffer);
120
121 public int getClientData(int index) {
122 return nGetClientData(event_buffer, index);
123 }
124 private static native int nGetClientData(ByteBuffer event_buffer, int index);
125
126 public int getClientFormat() {
127 return nGetClientFormat(event_buffer);
128 }
129 private static native int nGetClientFormat(ByteBuffer event_buffer);
130
131 /* Button methods */
132
133 public long getButtonTime() {
134 return nGetButtonTime(event_buffer);
135 }
136 private static native long nGetButtonTime(ByteBuffer event_buffer);
137
138 public int getButtonState() {
139 return nGetButtonState(event_buffer);
140 }
141 private static native int nGetButtonState(ByteBuffer event_buffer);
142
143 public int getButtonType() {
144 return nGetButtonType(event_buffer);
145 }
146 private static native int nGetButtonType(ByteBuffer event_buffer);
147
148 public int getButtonButton() {
149 return nGetButtonButton(event_buffer);
150 }
151 private static native int nGetButtonButton(ByteBuffer event_buffer);
152
153 public long getButtonRoot() {
154 return nGetButtonRoot(event_buffer);
155 }
156 private static native long nGetButtonRoot(ByteBuffer event_buffer);
157
158 public int getButtonXRoot() {
159 return nGetButtonXRoot(event_buffer);
160 }
161 private static native int nGetButtonXRoot(ByteBuffer event_buffer);
162
163 public int getButtonYRoot() {
164 return nGetButtonYRoot(event_buffer);
165 }
166 private static native int nGetButtonYRoot(ByteBuffer event_buffer);
167
168 public int getButtonX() {
169 return nGetButtonX(event_buffer);
170 }
171 private static native int nGetButtonX(ByteBuffer event_buffer);
172
173 public int getButtonY() {
174 return nGetButtonY(event_buffer);
175 }
176 private static native int nGetButtonY(ByteBuffer event_buffer);
177
178 /* Key methods */
179
180 public long getKeyAddress() {
181 return nGetKeyAddress(event_buffer);
182 }
183 private static native long nGetKeyAddress(ByteBuffer event_buffer);
184
185 public long getKeyTime() {
186 return nGetKeyTime(event_buffer);
187 }
188 private static native int nGetKeyTime(ByteBuffer event_buffer);
189
190 public int getKeyType() {
191 return nGetKeyType(event_buffer);
192 }
193 private static native int nGetKeyType(ByteBuffer event_buffer);
194
195 public int getKeyKeyCode() {
196 return nGetKeyKeyCode(event_buffer);
197 }
198 private static native int nGetKeyKeyCode(ByteBuffer event_buffer);
199
200 public int getKeyState() {
201 return nGetKeyState(event_buffer);
202 }
203 private static native int nGetKeyState(ByteBuffer event_buffer);
204 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 import java.nio.ByteBuffer;
38 import java.nio.CharBuffer;
39 import java.nio.charset.Charset;
40 import java.nio.charset.CharsetDecoder;
41
42 import org.lwjgl.BufferUtils;
43 import org.lwjgl.LWJGLUtil;
44 import org.lwjgl.input.Keyboard;
45
46 final class LinuxKeyboard {
47 private static final int LockMapIndex = 1;
48 private static final long NoSymbol = 0;
49 private static final long ShiftMask = 1 << 0;
50 private static final long LockMask = 1 << 1;
51 private static final int XLookupChars = 2;
52 private static final int XLookupBoth = 4;
53
54 private static final int KEYBOARD_BUFFER_SIZE = 50;
55
56 private final long xim;
57 private final long xic;
58
59 private final int numlock_mask;
60 private final int modeswitch_mask;
61 private final int caps_lock_mask;
62 private final int shift_lock_mask;
63
64 private final ByteBuffer compose_status;
65
66 private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
67 private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE);
68
69 private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
70 private final int[] temp_translation_buffer = new int[KEYBOARD_BUFFER_SIZE];
71 private final ByteBuffer native_translation_buffer = BufferUtils.createByteBuffer(KEYBOARD_BUFFER_SIZE);
72 private final CharsetDecoder utf8_decoder = Charset.forName("UTF-8").newDecoder();
73 private final CharBuffer char_buffer = CharBuffer.allocate(KEYBOARD_BUFFER_SIZE);
74
75 // Deferred key released event, to detect key repeat
76 private boolean has_deferred_event;
77 private int deferred_keycode;
78 private int deferred_event_keycode;
79 private long deferred_nanos;
80 private byte deferred_key_state;
81
82 LinuxKeyboard(long display, long window) {
83 long modifier_map = getModifierMapping(display);
84 int tmp_numlock_mask = 0;
85 int tmp_modeswitch_mask = 0;
86 int tmp_caps_lock_mask = 0;
87 int tmp_shift_lock_mask = 0;
88 if (modifier_map != 0) {
89 int max_keypermod = getMaxKeyPerMod(modifier_map);
90 // Find modifier masks
91 int i, j;
92 for (i = 0; i < 8; i++) {
93 for (j = 0; j < max_keypermod; j++) {
94 int key_code = lookupModifierMap(modifier_map, i*max_keypermod + j);
95 int key_sym = (int)keycodeToKeySym(display, key_code);
96 int mask = 1 << i;
97 switch (key_sym) {
98 case LinuxKeycodes.XK_Num_Lock:
99 tmp_numlock_mask |= mask;
100 break;
101 case LinuxKeycodes.XK_Mode_switch:
102 tmp_modeswitch_mask |= mask;
103 break;
104 case LinuxKeycodes.XK_Caps_Lock:
105 if (i == LockMapIndex) {
106 tmp_caps_lock_mask = mask;
107 tmp_shift_lock_mask = 0;
108 }
109 break;
110 case LinuxKeycodes.XK_Shift_Lock:
111 if (i == LockMapIndex && tmp_caps_lock_mask == 0)
112 tmp_shift_lock_mask = mask;
113 break;
114 default:
115 break;
116 }
117 }
118 }
119 freeModifierMapping(modifier_map);
120 }
121 numlock_mask = tmp_numlock_mask;
122 modeswitch_mask = tmp_modeswitch_mask;
123 caps_lock_mask = tmp_caps_lock_mask;
124 shift_lock_mask = tmp_shift_lock_mask;
125 setDetectableKeyRepeat(display, true);
126 xim = openIM(display);
127 if (xim != 0) {
128 xic = createIC(xim, window);
129 if (xic != 0) {
130 setupIMEventMask(display, window, xic);
131 } else {
132 destroy(display);
133 }
134 } else {
135 xic = 0;
136 }
137 compose_status = allocateComposeStatus();
138 }
139 private static native long getModifierMapping(long display);
140 private static native void freeModifierMapping(long modifier_map);
141 private static native int getMaxKeyPerMod(long modifier_map);
142 private static native int lookupModifierMap(long modifier_map, int index);
143 private static native long keycodeToKeySym(long display, int key_code);
144
145 private static native long openIM(long display);
146 private static native long createIC(long xim, long window);
147 private static native void setupIMEventMask(long display, long window, long xic);
148 private static native ByteBuffer allocateComposeStatus();
149
150 private static void setDetectableKeyRepeat(long display, boolean enabled) {
151 boolean success = nSetDetectableKeyRepeat(display, enabled);
152 if (!success)
153 LWJGLUtil.log("Failed to set detectable key repeat to " + enabled);
154 }
155 private static native boolean nSetDetectableKeyRepeat(long display, boolean enabled);
156
157 public void destroy(long display) {
158 if (xic != 0)
159 destroyIC(xic);
160 if (xim != 0)
161 closeIM(xim);
162 setDetectableKeyRepeat(display, false);
163 }
164 private static native void destroyIC(long xic);
165 private static native void closeIM(long xim);
166
167 public void read(ByteBuffer buffer) {
168 flushDeferredEvent();
169 event_queue.copyEvents(buffer);
170 }
171
172 public void poll(ByteBuffer keyDownBuffer) {
173 flushDeferredEvent();
174 int old_position = keyDownBuffer.position();
175 keyDownBuffer.put(key_down_buffer);
176 keyDownBuffer.position(old_position);
177 }
178
179 private void putKeyboardEvent(int keycode, byte state, int ch, long nanos, boolean repeat) {
180 tmp_event.clear();
181 tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos).put(repeat ? (byte)1 : (byte)0);
182 tmp_event.flip();
183 event_queue.putEvent(tmp_event);
184 }
185
186 private int lookupStringISO88591(long event_ptr, int[] translation_buffer) {
187 int i;
188
189 int num_chars = lookupString(event_ptr, native_translation_buffer, compose_status);
190 for (i = 0; i < num_chars; i++) {
191 translation_buffer[i] = ((int)native_translation_buffer.get(i)) & 0xff;
192 }
193 return num_chars;
194 }
195 private static native int lookupString(long event_ptr, ByteBuffer buffer, ByteBuffer compose_status);
196
197 private int lookupStringUnicode(long event_ptr, int[] translation_buffer) {
198 int status = utf8LookupString(xic, event_ptr, native_translation_buffer, native_translation_buffer.position(), native_translation_buffer.remaining());
199 if (status != XLookupChars && status != XLookupBoth)
200 return 0;
201 native_translation_buffer.flip();
202 utf8_decoder.decode(native_translation_buffer, char_buffer, true);
203 native_translation_buffer.compact();
204 char_buffer.flip();
205 int i = 0;
206 while (char_buffer.hasRemaining() && i < translation_buffer.length) {
207 translation_buffer[i++] = char_buffer.get();
208 }
209 char_buffer.compact();
210 return i;
211 }
212 private static native int utf8LookupString(long xic, long event_ptr, ByteBuffer buffer, int pos, int size);
213
214 private int lookupString(long event_ptr, int[] translation_buffer) {
215 if (xic != 0) {
216 return lookupStringUnicode(event_ptr, translation_buffer);
217 } else
218 return lookupStringISO88591(event_ptr, translation_buffer);
219 }
220
221 private void translateEvent(long event_ptr, int keycode, byte key_state, long nanos, boolean repeat) {
222 int num_chars, i;
223 int ch;
224
225 num_chars = lookupString(event_ptr, temp_translation_buffer);
226 if (num_chars > 0) {
227 ch = temp_translation_buffer[0];
228 putKeyboardEvent(keycode, key_state, ch, nanos, repeat);
229 for (i = 1; i < num_chars; i++) {
230 ch = temp_translation_buffer[i];
231 putKeyboardEvent(0, (byte)0, ch, nanos, repeat);
232 }
233 } else {
234 putKeyboardEvent(keycode, key_state, 0, nanos, repeat);
235 }
236 }
237
238 private static boolean isKeypadKeysym(long keysym) {
239 return (0xFF80 <= keysym && keysym <= 0xFFBD) ||
240 (0x11000000 <= keysym && keysym <= 0x1100FFFF);
241 }
242
243 private static boolean isNoSymbolOrVendorSpecific(long keysym) {
244 return keysym == NoSymbol || (keysym & (1 << 28)) != 0;
245 }
246
247 private static long getKeySym(long event_ptr, int group, int index) {
248 long keysym = lookupKeysym(event_ptr, group*2 + index);
249 if (isNoSymbolOrVendorSpecific(keysym) && index == 1) {
250 keysym = lookupKeysym(event_ptr, group*2 + 0);
251 }
252 if (isNoSymbolOrVendorSpecific(keysym) && group == 1)
253 keysym = getKeySym(event_ptr, 0, index);
254 return keysym;
255 }
256 private static native long lookupKeysym(long event_ptr, int index);
257 private static native long toUpper(long keysym);
258
259 private long mapEventToKeySym(long event_ptr, int event_state) {
260 int group;
261 long keysym;
262 if ((event_state & modeswitch_mask) != 0)
263 group = 1;
264 else
265 group = 0;
266 if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) {
267 if ((event_state & (ShiftMask | shift_lock_mask)) != 0) {
268 return getKeySym(event_ptr, group, 0);
269 } else {
270 return keysym;
271 }
272 } else if ((event_state & (ShiftMask | LockMask)) == 0) {
273 return getKeySym(event_ptr, group, 0);
274 } else if ((event_state & ShiftMask) == 0) {
275 keysym = getKeySym(event_ptr, group, 0);
276 if ((event_state & caps_lock_mask) != 0)
277 keysym = toUpper(keysym);
278 return keysym;
279 } else {
280 keysym = getKeySym(event_ptr, group, 1);
281 if ((event_state & caps_lock_mask) != 0)
282 keysym = toUpper(keysym);
283 return keysym;
284 }
285 }
286
287 private int getKeycode(long event_ptr, int event_state) {
288 long keysym = mapEventToKeySym(event_ptr, event_state);
289 int keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
290 if (keycode == Keyboard.KEY_NONE) {
291 // Try unshifted keysym mapping
292 keysym = lookupKeysym(event_ptr, 0);
293 keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
294 }
295 return keycode;
296 }
297
298 private byte getKeyState(int event_type) {
299 switch (event_type) {
300 case LinuxEvent.KeyPress:
301 return 1;
302 case LinuxEvent.KeyRelease:
303 return 0;
304 default:
305 throw new IllegalArgumentException("Unknown event_type: " + event_type);
306 }
307 }
308
309 private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
310 int keycode = getKeycode(event_ptr, event_state);
311 byte key_state = getKeyState(event_type);
312 boolean repeat = key_state == key_down_buffer[keycode];
313 key_down_buffer[keycode] = key_state;
314 long nanos = millis*1000000;
315 if (event_type == LinuxEvent.KeyPress) {
316 if (has_deferred_event) {
317 if (nanos == deferred_nanos && event_keycode == deferred_event_keycode) {
318 has_deferred_event = false;
319 repeat = true; // Repeated event
320 } else
321 flushDeferredEvent();
322 }
323 translateEvent(event_ptr, keycode, key_state, nanos, repeat);
324 } else {
325 flushDeferredEvent();
326 has_deferred_event = true;
327 deferred_keycode = keycode;
328 deferred_event_keycode = event_keycode;
329 deferred_nanos = nanos;
330 deferred_key_state = key_state;
331 }
332 }
333
334 private void flushDeferredEvent() {
335 if (has_deferred_event) {
336 putKeyboardEvent(deferred_keycode, deferred_key_state, 0, deferred_nanos, false);
337 has_deferred_event = false;
338 }
339 }
340
341 public boolean filterEvent(LinuxEvent event) {
342 switch (event.getType()) {
343 case LinuxEvent.KeyPress: /* Fall through */
344 case LinuxEvent.KeyRelease:
345 handleKeyEvent(event.getKeyAddress(), event.getKeyTime(), event.getKeyType(), event.getKeyKeyCode(), event.getKeyState());
346 return true;
347 default:
348 break;
349 }
350 return false;
351 }
352 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 import org.lwjgl.input.Keyboard;
38
39 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;
86
87
88 /* Misc functions */
89
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;
104
105 /* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
106
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;
145
146
147
148 /*
149 * Auxilliary functions; note the duplicate definitions for left and right
150 * function keys; Sun keyboards and a few other manufactures have such
151 * function key groups on the left and/or right sides of the keyboard.
152 * We've not found a keyboard with more than 35 function keys total.
153 */
154
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;
215
216 /* Modifiers */
217
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;
434
435 public static int mapKeySymToLWJGLKeyCode(long keysym) {
436 switch ((int)keysym) {
437 case XK_BackSpace:
438 return Keyboard.KEY_BACK;
439 case XK_ISO_Left_Tab:
440 case XK_Tab:
441 return Keyboard.KEY_TAB;
442 case XK_Return:
443 return Keyboard.KEY_RETURN;
444 case XK_Pause:
445 return Keyboard.KEY_PAUSE;
446 case XK_Scroll_Lock:
447 return Keyboard.KEY_SCROLL;
448 case XK_Sys_Req:
449 return Keyboard.KEY_SYSRQ;
450 case XK_Escape:
451 return Keyboard.KEY_ESCAPE;
452 case XK_Delete:
453 return Keyboard.KEY_DELETE;
454
455 /* Japanese keyboard support */
456
457 case XK_Kanji:
458 return Keyboard.KEY_KANJI;
459
460 /* Cursor control & motion */
461
462 case XK_Home:
463 return Keyboard.KEY_HOME;
464 case XK_Left:
465 return Keyboard.KEY_LEFT;
466 case XK_Up:
467 return Keyboard.KEY_UP;
468 case XK_Right:
469 return Keyboard.KEY_RIGHT;
470 case XK_Down:
471 return Keyboard.KEY_DOWN;
472 case XK_Page_Up:
473 return Keyboard.KEY_PRIOR;
474 case XK_Page_Down:
475 return Keyboard.KEY_NEXT;
476 case XK_End:
477 return Keyboard.KEY_END;
478
479
480 /* Misc Functions */
481
482 case XK_Break:
483 return Keyboard.KEY_PAUSE;
484 case XK_Insert:
485 return Keyboard.KEY_INSERT;
486 case XK_Num_Lock:
487 return Keyboard.KEY_NUMLOCK;
488
489 /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */
490
491 case XK_KP_Space:
492 return Keyboard.KEY_SPACE;
493 case XK_KP_Tab:
494 return Keyboard.KEY_TAB;
495 case XK_KP_Enter:
496 return Keyboard.KEY_NUMPADENTER;
497 case XK_KP_F1:
498 return Keyboard.KEY_F1;
499 case XK_KP_F2:
500 return Keyboard.KEY_F2;
501 case XK_KP_F3:
502 return Keyboard.KEY_F3;
503 case XK_KP_F4:
504 return Keyboard.KEY_F4;
505 case XK_KP_Home:
506 return Keyboard.KEY_HOME;
507 case XK_KP_Left:
508 return Keyboard.KEY_LEFT;
509 case XK_KP_Up:
510 return Keyboard.KEY_UP;
511 case XK_KP_Right:
512 return Keyboard.KEY_RIGHT;
513 case XK_KP_Down:
514 return Keyboard.KEY_DOWN;
515 case XK_KP_Page_Up:
516 return Keyboard.KEY_PRIOR;
517 case XK_KP_Page_Down:
518 return Keyboard.KEY_NEXT;
519 case XK_KP_End:
520 return Keyboard.KEY_END;
521 case XK_KP_Insert:
522 return Keyboard.KEY_INSERT;
523 case XK_KP_Delete:
524 return Keyboard.KEY_DELETE;
525 case XK_KP_Equal:
526 return Keyboard.KEY_NUMPADEQUALS;
527 case XK_KP_Multiply:
528 return Keyboard.KEY_MULTIPLY;
529 case XK_KP_Add:
530 return Keyboard.KEY_ADD;
531 case XK_KP_Subtract:
532 return Keyboard.KEY_SUBTRACT;
533 case XK_KP_Decimal:
534 return Keyboard.KEY_DECIMAL;
535 case XK_KP_Divide:
536 return Keyboard.KEY_DIVIDE;
537
538 case XK_KP_0:
539 return Keyboard.KEY_NUMPAD0;
540 case XK_KP_1:
541 return Keyboard.KEY_NUMPAD1;
542 case XK_KP_2:
543 return Keyboard.KEY_NUMPAD2;
544 case XK_KP_3:
545 return Keyboard.KEY_NUMPAD3;
546 case XK_KP_4:
547 return Keyboard.KEY_NUMPAD4;
548 case XK_KP_5:
549 return Keyboard.KEY_NUMPAD5;
550 case XK_KP_6:
551 return Keyboard.KEY_NUMPAD6;
552 case XK_KP_7:
553 return Keyboard.KEY_NUMPAD7;
554 case XK_KP_8:
555 return Keyboard.KEY_NUMPAD8;
556 case XK_KP_9:
557 return Keyboard.KEY_NUMPAD9;
558
559 /*
560 * Auxilliary Functions; note the duplicate definitions for left and right
561 * function keys; Sun keyboards and a few other manufactures have such
562 * function key groups on the left and/or right sides of the keyboard.
563 * We've not found a keyboard with more than 35 function keys total.
564 */
565
566 case XK_F1:
567 return Keyboard.KEY_F1;
568 case XK_F2:
569 return Keyboard.KEY_F2;
570 case XK_F3:
571 return Keyboard.KEY_F3;
572 case XK_F4:
573 return Keyboard.KEY_F4;
574 case XK_F5:
575 return Keyboard.KEY_F5;
576 case XK_F6:
577 return Keyboard.KEY_F6;
578 case XK_F7:
579 return Keyboard.KEY_F7;
580 case XK_F8:
581 return Keyboard.KEY_F8;
582 case XK_F9:
583 return Keyboard.KEY_F9;
584 case XK_F10:
585 return Keyboard.KEY_F10;
586 case XK_F11:
587 return Keyboard.KEY_F11;
588 case XK_F12:
589 return Keyboard.KEY_F12;
590 case XK_F13:
591 return Keyboard.KEY_F13;
592 case XK_F14:
593 return Keyboard.KEY_F14;
594 case XK_F15:
595 return Keyboard.KEY_F15;
596
597 /* Modifiers */
598
599 case XK_Shift_L:
600 return Keyboard.KEY_LSHIFT;
601 case XK_Shift_R:
602 return Keyboard.KEY_RSHIFT;
603 case XK_Control_L:
604 return Keyboard.KEY_LCONTROL;
605 case XK_Control_R:
606 return Keyboard.KEY_RCONTROL;
607 case XK_Caps_Lock:
608 return Keyboard.KEY_CAPITAL;
609
610 case XK_Meta_L:
611 return Keyboard.KEY_LMENU;
612 case XK_ISO_Level3_Shift:
613 case XK_Meta_R:
614 return Keyboard.KEY_RMENU;
615 case XK_Alt_L:
616 return Keyboard.KEY_LMENU;
617 case XK_Alt_R:
618 return Keyboard.KEY_RMENU;
619
620 case XK_dead_grave:
621 return Keyboard.KEY_GRAVE;
622 case XK_dead_circumflex:
623 return Keyboard.KEY_CIRCUMFLEX;
624
625 /*
626 * Latin 1
627 * Byte 3 = 0
628 */
629 case XK_space:
630 return Keyboard.KEY_SPACE;
631 case XK_apostrophe:
632 return Keyboard.KEY_APOSTROPHE;
633 case XK_comma:
634 return Keyboard.KEY_COMMA;
635 case XK_minus:
636 return Keyboard.KEY_MINUS;
637 case XK_period:
638 return Keyboard.KEY_PERIOD;
639 case XK_slash:
640 return Keyboard.KEY_SLASH;
641 case XK_0:
642 return Keyboard.KEY_0;
643 case XK_1:
644 return Keyboard.KEY_1;
645 case XK_2:
646 return Keyboard.KEY_2;
647 case XK_3:
648 return Keyboard.KEY_3;
649 case XK_4:
650 return Keyboard.KEY_4;
651 case XK_5:
652 return Keyboard.KEY_5;
653 case XK_6:
654 return Keyboard.KEY_6;
655 case XK_7:
656 return Keyboard.KEY_7;
657 case XK_8:
658 return Keyboard.KEY_8;
659 case XK_9:
660 return Keyboard.KEY_9;
661 case XK_colon:
662 return Keyboard.KEY_COLON;
663 case XK_semicolon:
664 return Keyboard.KEY_SEMICOLON;
665 case XK_equal:
666 return Keyboard.KEY_EQUALS;
667 case XK_at:
668 return Keyboard.KEY_AT;
669 case XK_bracketleft:
670 return Keyboard.KEY_LBRACKET;
671 case XK_bracketright:
672 return Keyboard.KEY_RBRACKET;
673 case XK_asciicircum:
674 return Keyboard.KEY_CIRCUMFLEX;
675 case XK_underscore:
676 return Keyboard.KEY_UNDERLINE;
677 case XK_grave:
678 return Keyboard.KEY_GRAVE;
679 case XK_a:
680 case XK_A:
681 return Keyboard.KEY_A;
682 case XK_b:
683 case XK_B:
684 return Keyboard.KEY_B;
685 case XK_c:
686 case XK_C:
687 return Keyboard.KEY_C;
688 case XK_d:
689 case XK_D:
690 return Keyboard.KEY_D;
691 case XK_e:
692 case XK_E:
693 return Keyboard.KEY_E;
694 case XK_f:
695 case XK_F:
696 return Keyboard.KEY_F;
697 case XK_g:
698 case XK_G:
699 return Keyboard.KEY_G;
700 case XK_h:
701 case XK_H:
702 return Keyboard.KEY_H;
703 case XK_i:
704 case XK_I:
705 return Keyboard.KEY_I;
706 case XK_j:
707 case XK_J:
708 return Keyboard.KEY_J;
709 case XK_k:
710 case XK_K:
711 return Keyboard.KEY_K;
712 case XK_l:
713 case XK_L:
714 return Keyboard.KEY_L;
715 case XK_m:
716 case XK_M:
717 return Keyboard.KEY_M;
718 case XK_n:
719 case XK_N:
720 return Keyboard.KEY_N;
721 case XK_o:
722 case XK_O:
723 return Keyboard.KEY_O;
724 case XK_p:
725 case XK_P:
726 return Keyboard.KEY_P;
727 case XK_q:
728 case XK_Q:
729 return Keyboard.KEY_Q;
730 case XK_r:
731 case XK_R:
732 return Keyboard.KEY_R;
733 case XK_s:
734 case XK_S:
735 return Keyboard.KEY_S;
736 case XK_t:
737 case XK_T:
738 return Keyboard.KEY_T;
739 case XK_u:
740 case XK_U:
741 return Keyboard.KEY_U;
742 case XK_v:
743 case XK_V:
744 return Keyboard.KEY_V;
745 case XK_w:
746 case XK_W:
747 return Keyboard.KEY_W;
748 case XK_x:
749 case XK_X:
750 return Keyboard.KEY_X;
751 case XK_y:
752 case XK_Y:
753 return Keyboard.KEY_Y;
754 case XK_z:
755 case XK_Z:
756 return Keyboard.KEY_Z;
757 default:
758 return Keyboard.KEY_NONE;
759 }
760 }
761
762 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 import java.nio.ByteBuffer;
38 import java.nio.IntBuffer;
39
40 import org.lwjgl.BufferUtils;
41 import org.lwjgl.LWJGLException;
42 import org.lwjgl.input.Mouse;
43
44 final class LinuxMouse {
45 private static final int NUM_BUTTONS = 3;
46 private static final int POINTER_WARP_BORDER = 10;
47 // scale the mouse wheel according to DirectInput
48 private static final int WHEEL_SCALE = 120;
49
50 /* 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;
59
60 private final long display;
61 private final long window;
62 private final long input_window;
63 private final long warp_atom;
64 private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4);
65 private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE);
66
67 private int last_x;
68 private int last_y;
69 private int accum_dx;
70 private int accum_dy;
71 private int accum_dz;
72 private byte[] buttons = new byte[NUM_BUTTONS];
73 private EventQueue event_queue;
74 private long last_event_nanos;
75
76 LinuxMouse(long display, long window, long input_window) throws LWJGLException {
77 this.display = display;
78 this.window = window;
79 this.input_window = input_window;
80 this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
81 reset(false, false);
82 }
83
84 private void reset(boolean grab, boolean warp_pointer) {
85 event_queue = new EventQueue(event_buffer.capacity());
86 accum_dx = accum_dy = 0;
87 long root_window = nQueryPointer(display, window, query_pointer_buffer);
88
89 int root_x = query_pointer_buffer.get(0);
90 int root_y = query_pointer_buffer.get(1);
91 int win_x = query_pointer_buffer.get(2);
92 int win_y = query_pointer_buffer.get(3);
93 // Pretend that the cursor never moved
94 last_x = win_x;
95 last_y = transformY(win_y);
96 doHandlePointerMotion(grab, warp_pointer, root_window, root_x, root_y, win_x, win_y, last_event_nanos);
97 }
98
99 public void read(ByteBuffer buffer) {
100 event_queue.copyEvents(buffer);
101 }
102
103 public void poll(boolean grab, IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
104 if (grab) {
105 coord_buffer.put(0, accum_dx);
106 coord_buffer.put(1, accum_dy);
107 } else {
108 coord_buffer.put(0, last_x);
109 coord_buffer.put(1, last_y);
110 }
111 coord_buffer.put(2, accum_dz);
112 accum_dx = accum_dy = accum_dz = 0;
113 for (int i = 0; i < buttons.length; i++)
114 buttons_buffer.put(i, buttons[i]);
115 }
116
117 private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
118 event_buffer.clear();
119 event_buffer.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
120 event_buffer.flip();
121 event_queue.putEvent(event_buffer);
122 last_event_nanos = nanos;
123 }
124
125 private void setCursorPos(boolean grab, int x, int y, long nanos) {
126 y = transformY(y);
127 int dx = x - last_x;
128 int dy = y - last_y;
129 if (dx != 0 || dy != 0) {
130 accum_dx += dx;
131 accum_dy += dy;
132 last_x = x;
133 last_y = y;
134 if (grab) {
135 putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
136 } else {
137 putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
138 }
139 }
140 }
141
142 private void doWarpPointer(int center_x, int center_y) {
143 nSendWarpEvent(display, input_window, warp_atom, center_x, center_y);
144 nWarpCursor(display, window, center_x, center_y);
145 }
146 private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y);
147
148 private void doHandlePointerMotion(boolean grab, boolean warp_pointer, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) {
149 setCursorPos(grab, win_x, win_y, nanos);
150 if (!warp_pointer)
151 return;
152 int root_window_height = nGetWindowHeight(display, root_window);
153 int root_window_width = nGetWindowWidth(display, root_window);
154 int window_height = nGetWindowHeight(display, window);
155 int window_width = nGetWindowWidth(display, window);
156
157 // find the window position in root coordinates
158 int win_left = root_x - win_x;
159 int win_top = root_y - win_y;
160 int win_right = win_left + window_width;
161 int win_bottom = win_top + window_height;
162 // cap the window position to the screen dimensions
163 int border_left = Math.max(0, win_left);
164 int border_top = Math.max(0, win_top);
165 int border_right = Math.min(root_window_width, win_right);
166 int border_bottom = Math.min(root_window_height, win_bottom);
167 // determine whether the cursor is outside the bounds
168 boolean outside_limits = root_x < border_left + POINTER_WARP_BORDER || root_y < border_top + POINTER_WARP_BORDER ||
169 root_x > border_right - POINTER_WARP_BORDER || root_y > border_bottom - POINTER_WARP_BORDER;
170 if (outside_limits) {
171 // Find the center of the limits in window coordinates
172 int center_x = (border_right - border_left)/2;
173 int center_y = (border_bottom - border_top)/2;
174 doWarpPointer(center_x, center_y);
175 }
176 }
177
178 public void changeGrabbed(boolean grab, boolean warp_pointer) {
179 reset(grab, warp_pointer);
180 }
181
182 public int getButtonCount() {
183 return buttons.length;
184 }
185
186 private int transformY(int y) {
187 return nGetWindowHeight(display, window) - 1 - y;
188 }
189 private static native int nGetWindowHeight(long display, long window);
190 private static native int nGetWindowWidth(long display, long window);
191
192 private static native long nQueryPointer(long display, long window, IntBuffer result);
193
194 public void setCursorPosition(int x, int y) {
195 nWarpCursor(display, window, x, transformY(y));
196 }
197 private static native void nWarpCursor(long display, long window, int x, int y);
198
199 private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) {
200 doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000);
201 }
202
203 private void handleButton(boolean grab, int button, byte state, long nanos) {
204 byte button_num;
205 switch (button) {
206 case Button1:
207 button_num = (byte)0;
208 break;
209 case Button2:
210 button_num = (byte)2;
211 break;
212 case Button3:
213 button_num = (byte)1;
214 break;
215 default:
216 return;
217 }
218 buttons[button_num] = state;
219 putMouseEvent(grab, button_num, state, 0, nanos);
220 }
221
222 private void putMouseEvent(boolean grab, byte button, byte state, int dz, long nanos) {
223 if (grab)
224 putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
225 else
226 putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos);
227 }
228
229 private void handleButtonPress(boolean grab, byte button, long nanos) {
230 int delta = 0;
231 switch (button) {
232 case Button4:
233 delta = WHEEL_SCALE;
234 putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos);
235 accum_dz += delta;
236 break;
237 case Button5:
238 delta = -WHEEL_SCALE;
239 putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos);
240 accum_dz += delta;
241 break;
242 default:
243 handleButton(grab, button, (byte)1, nanos);
244 break;
245 }
246 }
247
248 private void handleButtonEvent(boolean grab, long millis, int type, byte button) {
249 long nanos = millis*1000000;
250 switch (type) {
251 case ButtonRelease:
252 handleButton(grab, button, (byte)0, nanos);
253 break;
254 case ButtonPress:
255 handleButtonPress(grab, button, nanos);
256 break;
257 default:
258 break;
259 }
260 }
261
262 private void resetCursor(int x, int y) {
263 last_x = x;
264 last_y = transformY(y);
265 }
266
267 private void handleWarpEvent(int x, int y) {
268 resetCursor(x, y);
269 }
270
271 public boolean filterEvent(boolean grab, boolean warp_pointer, LinuxEvent event) {
272 switch (event.getType()) {
273 case LinuxEvent.ClientMessage:
274 if (event.getClientMessageType() == warp_atom) {
275 handleWarpEvent(event.getClientData(0), event.getClientData(1));
276 return true;
277 }
278 break;
279 case LinuxEvent.ButtonPress: /* Fall through */
280 case LinuxEvent.ButtonRelease:
281 handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton());
282 return true;
283 case LinuxEvent.MotionNotify:
284 handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY());
285 return true;
286 default:
287 break;
288 }
289 return false;
290 }
291 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class LinuxPbufferPeerInfo extends LinuxPeerInfo {
44 LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
45 LinuxDisplay.lockAWT();
46 try {
47 GLContext.loadOpenGLLibrary();
48 try {
49 LinuxDisplay.incDisplay();
50 try {
51 nInitHandle(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), width, height, pixel_format);
52 } catch (LWJGLException e) {
53 LinuxDisplay.decDisplay();
54 throw e;
55 }
56 } catch (LWJGLException e) {
57 GLContext.unloadOpenGLLibrary();
58 throw e;
59 }
60 } finally {
61 LinuxDisplay.unlockAWT();
62 }
63 }
64 private static native void nInitHandle(long display, int screen, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
65
66 public void destroy() {
67 LinuxDisplay.lockAWT();
68 nDestroy(getHandle());
69 LinuxDisplay.decDisplay();
70 GLContext.unloadOpenGLLibrary();
71 LinuxDisplay.unlockAWT();
72 }
73 private static native void nDestroy(ByteBuffer handle);
74
75 protected void doLockAndInitHandle() throws LWJGLException {
76 // NO-OP
77 }
78
79 protected void doUnlock() throws LWJGLException {
80 // NO-OP
81 }
82 }
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 java.nio.ByteBuffer;
34
35 /**
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3116 $
39 * $Id: LinuxPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 */
41 abstract class LinuxPeerInfo extends PeerInfo {
42 LinuxPeerInfo() {
43 super(createHandle());
44 }
45 private static native ByteBuffer createHandle();
46
47 public final long getDisplay() {
48 return nGetDisplay(getHandle());
49 }
50 private static native long nGetDisplay(ByteBuffer handle);
51
52 public final long getDrawable() {
53 return nGetDrawable(getHandle());
54 }
55 private static native long nGetDrawable(ByteBuffer handle);
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.opengl;
32
33 import org.lwjgl.LWJGLException;
34
35 import java.awt.Canvas;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo {
44 private final Canvas component;
45
46 MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, support_pbuffer);
48 this.component = component;
49 }
50
51 protected void doLockAndInitHandle() throws LWJGLException {
52 initHandle(component);
53 }
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import java.awt.GraphicsConfiguration;
34 import java.awt.GraphicsDevice;
35 import java.awt.Canvas;
36
37 import org.lwjgl.LWJGLException;
38
39 /**
40 *
41 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3002 $
43 * $Id: MacOSXCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $
44 */
45 final class MacOSXCanvasImplementation implements AWTCanvasImplementation {
46 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
47 try {
48 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true);
49 } catch (LWJGLException e) {
50 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, false);
51 }
52 }
53
54 /**
55 * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
56 *
57 * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
58 */
59 public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
60 /*
61 * It seems like the best way is to simply return null
62 */
63 return null;
64 }
65 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * The AWT compatible Canvas for Mac OS X.
35 * @author elias_naur
36 */
37
38 import java.awt.Canvas;
39 import java.awt.event.ComponentEvent;
40 import java.awt.event.ComponentListener;
41 import java.awt.event.HierarchyEvent;
42 import java.awt.event.HierarchyListener;
43
44 final class MacOSXCanvasListener implements ComponentListener, HierarchyListener {
45 private final Canvas canvas;
46 private int width;
47 private int height;
48 private boolean context_update;
49
50 MacOSXCanvasListener(Canvas canvas) {
51 this.canvas = canvas;
52 canvas.addComponentListener(this);
53 canvas.addHierarchyListener(this);
54 setUpdate();
55 }
56
57 public void disableListeners() {
58 // Mac OS X applets will hang in Display.destroy() when parented when removing the listeners directly
59 java.awt.EventQueue.invokeLater(new Runnable() {
60 public void run() {
61 canvas.removeComponentListener(MacOSXCanvasListener.this);
62 canvas.removeHierarchyListener(MacOSXCanvasListener.this);
63 }
64 });
65 }
66
67 public boolean syncShouldUpdateContext() {
68 boolean should_update;
69 synchronized ( this ) {
70 should_update = context_update;
71 context_update = false;
72 }
73 return should_update;
74 }
75
76 private synchronized void setUpdate() {
77 synchronized ( this ) {
78 width = canvas.getWidth();
79 height = canvas.getHeight();
80 context_update = true;
81 }
82 }
83
84 public int syncGetWidth() {
85 synchronized ( this ) {
86 return width;
87 }
88 }
89
90 public int syncGetHeight() {
91 synchronized ( this ) {
92 return height;
93 }
94 }
95
96 public void componentShown(ComponentEvent e) {
97 }
98
99 public void componentHidden(ComponentEvent e) {
100 }
101
102 public void componentResized(ComponentEvent e) {
103 setUpdate();
104 }
105
106 public void componentMoved(ComponentEvent e) {
107 setUpdate();
108 }
109
110 public void hierarchyChanged(HierarchyEvent e) {
111 setUpdate();
112 }
113 }
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 java.awt.Canvas;
34 import java.nio.ByteBuffer;
35
36 import org.lwjgl.LWJGLException;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: MacOSXCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
45 private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
46
47 protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
48 super(pixel_format, true, true, support_pbuffer, true);
49 }
50
51 protected void initHandle(Canvas component) throws LWJGLException {
52 nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
53 }
54 private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
55
56 protected void doUnlock() throws LWJGLException {
57 awt_surface.unlock();
58 }
59 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An implementation of ContextAttribs for MacOS X.
35 * <p/><p/>
36 * ---- WIP - No XGL_create_context has been defined for MacOS X yet ----
37 *
38 * @author spasi <spasi@users.sourceforge.net>
39 */
40 final class MacOSXContextAttribs implements ContextAttribsImplementation {
41
42 private static final int XGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091;
43 private static final int XGL_CONTEXT_MINOR_VERSION_ARB = 0x2092;
44 private static final int XGL_CONTEXT_LAYER_PLANE_ARB = 0x2093;
45 private static final int XGL_CONTEXT_FLAGS_ARB = 0x2094;
46 private static final int XGL_CONTEXT_PROFILE_MASK_ARB = 0x9126;
47
48 private static final int XGL_CONTEXT_DEBUG_BIT_ARB = 0x0001;
49 private static final int XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
50
51 private static final int XGL_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
52 private static final int XGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
53
54 MacOSXContextAttribs() {
55 }
56
57 public int getMajorVersionAttrib() {
58 return XGL_CONTEXT_MAJOR_VERSION_ARB;
59 }
60
61 public int getMinorVersionAttrib() {
62 return XGL_CONTEXT_MINOR_VERSION_ARB;
63 }
64
65 public int getLayerPlaneAttrib() {
66 return XGL_CONTEXT_LAYER_PLANE_ARB;
67 }
68
69 public int getFlagsAttrib() {
70 return XGL_CONTEXT_FLAGS_ARB;
71 }
72
73 public int getDebugBit() {
74 return XGL_CONTEXT_DEBUG_BIT_ARB;
75 }
76
77 public int getForwardCompatibleBit() {
78 return XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
79 }
80
81 public int getProfileMaskAttrib() {
82 return XGL_CONTEXT_PROFILE_MASK_ARB;
83 }
84
85 public int getProfileCoreBit() {
86 return XGL_CONTEXT_CORE_PROFILE_BIT_ARB;
87 }
88
89 public int getProfileCompatibilityBit() {
90 return XGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
91 }
92
93 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.LWJGLException;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 /**
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class MacOSXContextImplementation implements ContextImplementation {
44
45 public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
46 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
47 try {
48 return nCreate(peer_handle, attribs, shared_context_handle);
49 } finally {
50 peer_info.unlock();
51 }
52 }
53
54 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException;
55
56 public void swapBuffers() throws LWJGLException {
57 Context current_context = Context.getCurrentContext();
58 if ( current_context == null )
59 throw new IllegalStateException("No context is current");
60 synchronized ( current_context ) {
61 nSwapBuffers(current_context.getHandle());
62 }
63 }
64
65 private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException;
66
67 public void update(ByteBuffer context_handle) {
68 nUpdate(context_handle);
69 }
70
71 private static native void nUpdate(ByteBuffer context_handle);
72
73 public void releaseCurrentContext() throws LWJGLException {
74 nReleaseCurrentContext();
75 }
76
77 private static native void nReleaseCurrentContext() throws LWJGLException;
78
79 public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException {
80 clearDrawable(context_handle);
81 }
82
83 private static native void clearDrawable(ByteBuffer handle) throws LWJGLException;
84
85 static void resetView(PeerInfo peer_info, Context context) throws LWJGLException {
86 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
87 try {
88 synchronized ( context ) {
89 clearDrawable(context.getHandle());
90 setView(peer_handle, context.getHandle());
91 }
92 } finally {
93 peer_info.unlock();
94 }
95 }
96
97 public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
98 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
99 try {
100 setView(peer_handle, handle);
101 nMakeCurrent(handle);
102 } finally {
103 peer_info.unlock();
104 }
105 }
106
107 private static native void setView(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
108
109 private static native void nMakeCurrent(ByteBuffer context_handle) throws LWJGLException;
110
111 public boolean isCurrent(ByteBuffer handle) throws LWJGLException {
112 boolean result = nIsCurrent(handle);
113 return result;
114 }
115
116 private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
117
118 public void setSwapInterval(int value) {
119 Context current_context = Context.getCurrentContext();
120 synchronized ( current_context ) {
121 nSetSwapInterval(current_context.getHandle(), value);
122 }
123 }
124
125 private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
126
127 public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
128 nDestroy(handle);
129 }
130
131 private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException;
132 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the Display implementation interface. Display delegates
35 * to implementors of this interface. There is one DisplayImplementation
36 * for each supported platform.
37 * @author elias_naur
38 */
39
40 import java.awt.Canvas;
41 import java.awt.Cursor;
42 import java.awt.Robot;
43 import java.nio.ByteBuffer;
44 import java.nio.FloatBuffer;
45 import java.nio.IntBuffer;
46 import java.security.AccessController;
47 import java.security.PrivilegedAction;
48 import java.security.PrivilegedExceptionAction;
49 import java.util.ArrayList;
50 import java.util.List;
51
52 import org.lwjgl.BufferUtils;
53 import org.lwjgl.LWJGLException;
54 import org.lwjgl.LWJGLUtil;
55
56 import com.apple.eawt.Application;
57 import com.apple.eawt.ApplicationAdapter;
58 import com.apple.eawt.ApplicationEvent;
59
60 final class MacOSXDisplay implements DisplayImplementation {
61 private static final int PBUFFER_HANDLE_SIZE = 24;
62 private static final int GAMMA_LENGTH = 256;
63
64 private MacOSXCanvasListener canvas_listener;
65 private MacOSXFrame frame;
66 private Canvas canvas;
67 private Robot robot;
68 private MacOSXMouseEventQueue mouse_queue;
69 private KeyboardEventQueue keyboard_queue;
70 private java.awt.DisplayMode requested_mode;
71
72 /* States */
73 private boolean close_requested;
74
75 MacOSXDisplay() {
76 try {
77 AccessController.doPrivileged(new PrivilegedExceptionAction() {
78 public Object run() throws Exception {
79 Application.getApplication().addApplicationListener(new ApplicationAdapter() {
80 public final void handleQuit(ApplicationEvent event) {
81 doHandleQuit();
82 }
83 });
84 return null;
85 }
86 });
87 } catch (Throwable e) {
88 /**
89 * In an applet environment, referencing com.apple.eawt.Application can fail with
90 * a native exception. So log any exceptions instead of re-throwing.
91 */
92 LWJGLUtil.log("Failed to register quit handler: " + e.getMessage());
93 }
94 }
95
96 public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
97 boolean fullscreen = Display.isFullscreen();
98 hideUI(fullscreen);
99 close_requested = false;
100 try {
101 if (parent == null) {
102 frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
103 canvas = frame.getCanvas();
104 } else {
105 frame = null;
106 canvas = parent;
107 }
108 canvas_listener = new MacOSXCanvasListener(canvas);
109 robot = AWTUtil.createRobot(canvas);
110 } catch (LWJGLException e) {
111 destroyWindow();
112 throw e;
113 }
114 }
115
116 private void doHandleQuit() {
117 synchronized (this) {
118 close_requested = true;
119 }
120 }
121
122 public void destroyWindow() {
123 if (canvas_listener != null) {
124 canvas_listener.disableListeners();
125 canvas_listener = null;
126 }
127 if (frame != null) {
128 AccessController.doPrivileged(new PrivilegedAction() {
129 public Object run() {
130 if (MacOSXFrame.getDevice().getFullScreenWindow() == frame)
131 MacOSXFrame.getDevice().setFullScreenWindow(null);
132 return null;
133 }
134 });
135 if (frame.isDisplayable())
136 frame.dispose();
137 frame = null;
138 }
139 hideUI(false);
140 }
141
142 public int getGammaRampLength() {
143 return GAMMA_LENGTH;
144 }
145
146 public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
147
148 public String getAdapter() {
149 return null;
150 }
151
152 public String getVersion() {
153 return null;
154 }
155
156 private boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
157 return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
158 && awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
159 }
160
161 public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
162 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];
166 return;
167 }
168 throw new LWJGLException(mode + " is not supported");
169 }
170
171 public void resetDisplayMode() {
172 if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
173 MacOSXFrame.getDevice().setFullScreenWindow(null);
174 requested_mode = null;
175 restoreGamma();
176 }
177
178 private native void restoreGamma();
179
180 private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
181 int bit_depth;
182 int refresh_rate;
183 int awt_bit_depth = awt_mode.getBitDepth();
184 int awt_refresh_rate = awt_mode.getRefreshRate();
185 if (awt_bit_depth != java.awt.DisplayMode.BIT_DEPTH_MULTI)
186 bit_depth = awt_bit_depth;
187 else
188 bit_depth = 32; // Assume the best bit depth
189 if (awt_refresh_rate != java.awt.DisplayMode.REFRESH_RATE_UNKNOWN)
190 refresh_rate = awt_refresh_rate;
191 else
192 refresh_rate = 0;
193 return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
194 }
195
196 public DisplayMode init() throws LWJGLException {
197 return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
198 }
199
200 public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
201 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;
209 }
210
211 public void setTitle(String title) {
212 if (frame != null)
213 frame.setTitle(title);
214 }
215
216 public boolean isCloseRequested() {
217 boolean result;
218 synchronized (this) {
219 result = close_requested || (frame != null && frame.syncIsCloseRequested());
220 close_requested = false;
221 }
222 return result;
223 }
224
225 public boolean isVisible() {
226 return frame == null || frame.syncIsVisible();
227 }
228
229 public boolean isActive() {
230 return canvas.isFocusOwner();
231 }
232
233 public Canvas getCanvas() {
234 return canvas;
235 }
236
237 public boolean isDirty() {
238 return frame != null && frame.getCanvas().syncIsDirty();
239 }
240
241 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
242 try {
243 return new MacOSXDisplayPeerInfo(pixel_format, true);
244 } catch (LWJGLException e) {
245 return new MacOSXDisplayPeerInfo(pixel_format, false);
246 }
247 }
248
249 private final static IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
250 public void update() {
251 boolean should_update = canvas_listener.syncShouldUpdateContext();
252 /*
253 * Workaround for the "white screen in fullscreen mode" problem
254 *
255 * Sometimes, switching from windowed mode to fullscreen or simply creating the Display
256 * in fullscreen mode will result in the context not being bound to the window correctly.
257 * The program runs fine, but the canvas background (white) is shown instead of the context
258 * front buffer.
259 *
260 * I've discovered that re-binding the context with another setView() won't fix the problem, while a
261 * clearDrawable() followed by a setView() does work. A straightforward workaround would be
262 * to simply run the combination at every update(). This is not sufficient, since the clearDrawable()
263 * call makes the the background appear shortly, causing visual artifacts.
264 * What we really need is a way to detect that a setView() failed, and then do the magic combo. I've not
265 * been able to find such a detection so alternatively I'm triggering the combo if the display is fullscreen
266 * (I've not seen the white screen problem in windowed mode) and if the canvas has gotten a paint message or
267 * if its update flag was set.
268 *
269 * My testing seems to indicate that the workaround works, since I've not seen the problem after the fix.
270 *
271 * - elias
272 */
273 if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) {
274 try {
275 MacOSXContextImplementation.resetView(Display.getDrawable().getContext().getPeerInfo(), Display.getDrawable().getContext());
276 } catch (LWJGLException e) {
277 LWJGLUtil.log("Failed to reset context: " + e);
278 }
279 }
280 if (should_update) {
281 Display.getDrawable().getContext().update();
282 /* This is necessary to make sure the context won't "forget" about the view size */
283 GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
284 GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
285 }
286 if (frame != null && mouse_queue != null) {
287 if (frame.syncShouldReleaseCursor())
288 MacOSXMouseEventQueue.nGrabMouse(false);
289 if (frame.syncShouldWarpCursor())
290 mouse_queue.warpCursor();
291 }
292 }
293
294 /**
295 * This is an interface to the native Carbon call
296 * SetSystemUIMode. It is used to hide the dock in a way
297 * that will prevent AWT from shifting the fullscreen window
298 *
299 * The workaround is not necessary on 10.4, and since 10.4 shows
300 * instability problems calling SetSystemUIMode, we'll only call it
301 * when the OS version is 10.3 or lower.
302 */
303 private void hideUI(boolean hide) {
304 if (!LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
305 nHideUI(hide);
306 }
307
308 private native void nHideUI(boolean hide);
309
310 public void reshape(int x, int y, int width, int height) {
311 if (frame != null)
312 frame.resize(x, y, width, height);
313 }
314
315 /* Mouse */
316 public boolean hasWheel() {
317 return AWTUtil.hasWheel();
318 }
319
320 public int getButtonCount() {
321 return AWTUtil.getButtonCount();
322 }
323
324 public void createMouse() throws LWJGLException {
325 this.mouse_queue = new MacOSXMouseEventQueue(canvas);
326 mouse_queue.register();
327 }
328
329 public void destroyMouse() {
330 if (mouse_queue != null) {
331 MacOSXMouseEventQueue.nGrabMouse(false);
332 mouse_queue.unregister();
333 }
334 this.mouse_queue = null;
335 }
336
337 public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
338 mouse_queue.poll(coord_buffer, buttons_buffer);
339 }
340
341 public void readMouse(ByteBuffer buffer) {
342 mouse_queue.copyEvents(buffer);
343 }
344
345 public void grabMouse(boolean grab) {
346 mouse_queue.setGrabbed(grab);
347 }
348
349 public int getNativeCursorCapabilities() {
350 return AWTUtil.getNativeCursorCapabilities();
351 }
352
353 public void setCursorPosition(int x, int y) {
354 AWTUtil.setCursorPosition(canvas, robot, x, y);
355 }
356
357 public void setNativeCursor(Object handle) throws LWJGLException {
358 Cursor awt_cursor = (Cursor)handle;
359 if (frame != null)
360 frame.setCursor(awt_cursor);
361 }
362
363 public int getMinCursorSize() {
364 return AWTUtil.getMinCursorSize();
365 }
366
367 public int getMaxCursorSize() {
368 return AWTUtil.getMaxCursorSize();
369 }
370
371 /* Keyboard */
372 public void createKeyboard() throws LWJGLException {
373 this.keyboard_queue = new KeyboardEventQueue(canvas);
374 keyboard_queue.register();
375 }
376
377 public void destroyKeyboard() {
378 if (keyboard_queue != null)
379 keyboard_queue.unregister();
380 this.keyboard_queue = null;
381 }
382
383 public void pollKeyboard(ByteBuffer keyDownBuffer) {
384 keyboard_queue.poll(keyDownBuffer);
385 }
386
387 public void readKeyboard(ByteBuffer buffer) {
388 keyboard_queue.copyEvents(buffer);
389 }
390
391 /* public int isStateKeySet(int key) {
392 int awt_key;
393 switch (key) {
394 case Keyboard.KEY_CAPITAL:
395 awt_key = KeyEvent.VK_CAPS_LOCK;
396 break;
397 case Keyboard.KEY_NUMLOCK:
398 awt_key = KeyEvent.VK_NUM_LOCK;
399 break;
400 case Keyboard.KEY_SYSRQ:
401 awt_key = KeyEvent.VK_SCROLL_LOCK;
402 break;
403 default:
404 return Keyboard.STATE_UNKNOWN;
405 }
406 try {
407 boolean state = Toolkit.getDefaultToolkit().getLockingKeyState(awt_key);
408 return state ? Keyboard.STATE_ON : Keyboard.STATE_OFF;
409 } catch (Exception e) {
410 LWJGLUtil.log("Failed to query key state: " + e);
411 return Keyboard.STATE_UNKNOWN;
412 }
413 }
414 */
415 /** Native cursor handles */
416 public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
417 return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
418 }
419
420 public void destroyCursor(Object cursor_handle) {
421 }
422
423 public int getPbufferCapabilities() {
424 if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 3))
425 return Pbuffer.PBUFFER_SUPPORTED;
426 else
427 return 0;
428 }
429
430 public boolean isBufferLost(PeerInfo handle) {
431 return false;
432 }
433
434 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
435 IntBuffer pixelFormatCaps,
436 IntBuffer pBufferAttribs) throws LWJGLException {
437 return new MacOSXPbufferPeerInfo(width, height, pixel_format);
438 }
439
440 public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
441 throw new UnsupportedOperationException();
442 }
443
444 public void bindTexImageToPbuffer(PeerInfo handle, int buffer) {
445 throw new UnsupportedOperationException();
446 }
447
448 public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
449 throw new UnsupportedOperationException();
450 }
451
452 /**
453 * Sets one or more icons for the Display.
454 * <ul>
455 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
456 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
457 * <li>Mac OS X should be supplied one 128x128 icon</li>
458 * </ul>
459 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
460 *
461 * @param icons Array of icons in RGBA mode
462 * @return number of icons used.
463 */
464 public int setIcon(ByteBuffer[] icons) {
465 /* int size = 0;
466 int biggest = -1;
467
468 for (int i=0;i<icons.length;i++) {
469 if (icons[i].remaining() > size) {
470 biggest = i;
471 size = icons[i].remaining();
472 }
473 }
474
475 if (biggest == -1) {
476 return 0;
477 }
478
479 int width;
480 int height;
481
482 IntBuffer biggest_icon = icons[biggest].asIntBuffer();
483 int[] imageData = new int[biggest_icon.remaining()];
484 width = height = (int) Math.sqrt(imageData.length);
485 biggest_icon.get(imageData);
486
487 BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
488 img.setRGB(0, 0, width, height, imageData, 0, width);
489 frame.setIconImage(img);
490
491 return 1;*/
492 // Don't use any icon, since Mac OS X windows don't have window icons
493 return 0;
494 }
495
496 public int getWidth() {
497 return Display.getDisplayMode().getWidth();
498 }
499
500 public int getHeight() {
501 return Display.getDisplayMode().getHeight();
502 }
503
504 public boolean isInsideWindow() {
505 return true;
506 }
507 }
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 java.awt.Canvas;
34
35 import org.lwjgl.LWJGLException;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class MacOSXDisplayPeerInfo extends MacOSXCanvasPeerInfo {
44 private boolean locked = false;
45
46 MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, support_pbuffer);
48 }
49
50 protected void doLockAndInitHandle() throws LWJGLException {
51 if (locked)
52 throw new RuntimeException("Already locked");
53 Canvas canvas = ((MacOSXDisplay)Display.getImplementation()).getCanvas();
54 if (canvas != null) {
55 initHandle(canvas);
56 locked = true;
57 }
58 }
59
60 protected void doUnlock() throws LWJGLException {
61 if (locked) {
62 super.doUnlock();
63 locked = false;
64 }
65 }
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 package org.lwjgl.opengl;
32
33 /**
34 * This is the Mac OS X AWT Frame. It contains thread safe
35 * methods to manipulateit from non-AWT threads
36 * @author elias_naur
37 */
38
39 import java.awt.BorderLayout;
40 import java.awt.Frame;
41 import java.awt.GraphicsDevice;
42 import java.awt.GraphicsEnvironment;
43 import java.awt.Insets;
44 import java.awt.Rectangle;
45 import java.awt.event.ComponentEvent;
46 import java.awt.event.ComponentListener;
47 import java.awt.event.WindowEvent;
48 import java.awt.event.WindowListener;
49 import java.security.AccessController;
50 import java.security.PrivilegedActionException;
51 import java.security.PrivilegedExceptionAction;
52
53 import org.lwjgl.LWJGLException;
54
55 final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
56
57 private static final long serialVersionUID = -5823294716668988777L;
58
59 private final MacOSXGLCanvas canvas;
60 private boolean close_requested;
61
62 /* States */
63 private Rectangle bounds;
64 private boolean active;
65 private boolean minimized;
66 private boolean should_warp_cursor;
67 private boolean should_release_cursor;
68
69 MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
70 setResizable(false);
71 addWindowListener(this);
72 addComponentListener(this);
73 canvas = new MacOSXGLCanvas();
74 canvas.setFocusTraversalKeysEnabled(false);
75 add(canvas, BorderLayout.CENTER);
76 boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
77 setUndecorated(fullscreen || undecorated);
78 if ( fullscreen ) {
79 try {
80 AccessController.doPrivileged(new PrivilegedExceptionAction() {
81 public Object run() throws Exception {
82 getDevice().setFullScreenWindow(MacOSXFrame.this);
83 getDevice().setDisplayMode(requested_mode);
84 java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
85 /** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */
86 if ( requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight() ) {
87 getDevice().setFullScreenWindow(null);
88 if (isDisplayable())
89 dispose();
90 throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() +
91 " but got " + real_mode.getWidth() + " " + real_mode.getHeight());
92 }
93 return null;
94 }
95 });
96 } catch (PrivilegedActionException e) {
97 throw new LWJGLException(e);
98 }
99 }
100 pack();
101 resize(x, y, mode.getWidth(), mode.getHeight());
102 setVisible(true);
103 requestFocus();
104 canvas.requestFocus();
105 updateBounds();
106 }
107
108 public void resize(int x, int y, int width, int height) {
109 Insets insets = getInsets();
110 setBounds(x, y, width + insets.left + insets.right, height + insets.top + insets.bottom);
111 }
112
113 public Rectangle syncGetBounds() {
114 synchronized ( this ) {
115 return bounds;
116 }
117 }
118
119 public void componentShown(ComponentEvent e) {
120 }
121
122 public void componentHidden(ComponentEvent e) {
123 }
124
125 private void updateBounds() {
126 synchronized ( this ) {
127 bounds = getBounds();
128 }
129 }
130
131 public void componentResized(ComponentEvent e) {
132 updateBounds();
133 }
134
135 public void componentMoved(ComponentEvent e) {
136 updateBounds();
137 }
138
139 public static GraphicsDevice getDevice() {
140 GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment();
141 GraphicsDevice device = g_env.getDefaultScreenDevice();
142 return device;
143 }
144
145 public void windowIconified(WindowEvent e) {
146 synchronized ( this ) {
147 minimized = true;
148 }
149 }
150
151 public void windowDeiconified(WindowEvent e) {
152 synchronized ( this ) {
153 minimized = false;
154 }
155 }
156
157 public void windowOpened(WindowEvent e) {
158 }
159
160 public void windowClosed(WindowEvent e) {
161 }
162
163 public void windowClosing(WindowEvent e) {
164 synchronized ( this ) {
165 close_requested = true;
166 }
167 }
168
169 public void windowDeactivated(WindowEvent e) {
170 synchronized ( this ) {
171 active = false;
172 should_release_cursor = true;
173 should_warp_cursor = false;
174 }
175 }
176
177 public void windowActivated(WindowEvent e) {
178 synchronized ( this ) {
179 active = true;
180 should_warp_cursor = true;
181 should_release_cursor = false;
182 }
183 }
184
185 public boolean syncIsCloseRequested() {
186 boolean result;
187 synchronized ( this ) {
188 result = close_requested;
189 close_requested = false;
190 }
191 return result;
192 }
193
194 public boolean syncIsVisible() {
195 synchronized ( this ) {
196 return !minimized;
197 }
198 }
199
200 public boolean syncIsActive() {
201 synchronized ( this ) {
202 return active;
203 }
204 }
205
206 public MacOSXGLCanvas getCanvas() {
207 return canvas;
208 }
209
210 public boolean syncShouldReleaseCursor() {
211 boolean result;
212 synchronized ( this ) {
213 result = should_release_cursor;
214 should_release_cursor = false;
215 }
216 return result;
217 }
218
219 public boolean syncShouldWarpCursor() {
220 boolean result;
221 synchronized ( this ) {
222 result = should_warp_cursor;
223 should_warp_cursor = false;
224 }
225 return result;
226 }
227 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * The AWT compatible Canvas for Mac OS X.
35 * @author elias_naur
36 */
37
38 import java.awt.Canvas;
39 import java.awt.Graphics;
40
41 final class MacOSXGLCanvas extends Canvas {
42
43 private static final long serialVersionUID = 6916664741667434870L;
44
45 private boolean canvas_painted;
46 private boolean dirty;
47
48 public void update(Graphics g) {
49 paint(g);
50 }
51
52 public void paint(Graphics g) {
53 synchronized ( this ) {
54 dirty = true;
55 canvas_painted = true;
56 }
57 }
58
59 public boolean syncCanvasPainted() {
60 boolean result;
61 synchronized (this) {
62 result = canvas_painted;
63 canvas_painted = false;
64 }
65 return result;
66 }
67
68 public boolean syncIsDirty() {
69 boolean result;
70 synchronized ( this ) {
71 result = dirty;
72 dirty = false;
73 }
74 return result;
75 }
76 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An AWT implementation of a LWJGL compatible Mouse event queue.
35 * @author elias_naur
36 */
37
38 import java.awt.Component;
39 import java.awt.Point;
40 import java.awt.Rectangle;
41 import java.nio.IntBuffer;
42
43 import org.lwjgl.BufferUtils;
44
45 final class MacOSXMouseEventQueue extends MouseEventQueue {
46 private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
47
48 private boolean skip_event;
49 private static boolean is_grabbed;
50
51 MacOSXMouseEventQueue(Component component) {
52 super(component);
53 }
54
55 public void setGrabbed(boolean grab) {
56 super.setGrabbed(grab);
57 warpCursor();
58 grabMouse(grab);
59 }
60
61 private static synchronized void grabMouse(boolean grab) {
62 if (is_grabbed != grab) {
63 is_grabbed = grab;
64 if (!grab)
65 nGrabMouse(grab);
66 }
67 }
68
69 protected void resetCursorToCenter() {
70 super.resetCursorToCenter();
71 /* Clear accumulated deltas */
72 getMouseDeltas(delta_buffer);
73 }
74
75 protected void updateDeltas(long nanos) {
76 super.updateDeltas(nanos);
77 synchronized ( this ) {
78 getMouseDeltas(delta_buffer);
79 int dx = delta_buffer.get(0);
80 int dy = -delta_buffer.get(1);
81 if (skip_event) {
82 skip_event = false;
83 nGrabMouse(isGrabbed());
84 return;
85 }
86 if ( dx != 0 || dy != 0 ) {
87 putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
88 addDelta(dx, dy);
89 }
90 }
91 }
92
93 void warpCursor() {
94 synchronized (this) {
95 // If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values
96 skip_event = isGrabbed();
97 }
98 /* if (isGrabbed()) {
99 Rectangle bounds = getComponent().getBounds();
100 Point location_on_screen = getComponent().getLocationOnScreen();
101 int x = location_on_screen.x + bounds.width/2;
102 int y = location_on_screen.y + bounds.height/2;
103 nWarpCursor(x, y);
104 }*/
105 }
106
107 private static native void getMouseDeltas(IntBuffer delta_buffer);
108
109 private static native void nWarpCursor(int x, int y);
110
111 static native void nGrabMouse(boolean grab);
112 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class MacOSXPbufferPeerInfo extends MacOSXPeerInfo {
44 MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
45 super(pixel_format, false, false, true, false);
46 nCreate(getHandle(), width, height);
47 }
48 private static native void nCreate(ByteBuffer handle, int width, int height) throws LWJGLException;
49
50 public void destroy() {
51 nDestroy(getHandle());
52 }
53 private static native void nDestroy(ByteBuffer handle);
54
55 protected void doLockAndInitHandle() throws LWJGLException {
56 // NO-OP
57 }
58
59 protected void doUnlock() throws LWJGLException {
60 // NO-OP
61 }
62 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36 import org.lwjgl.LWJGLUtil;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: MacOSXPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 abstract class MacOSXPeerInfo extends PeerInfo {
45 MacOSXPeerInfo(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
46 super(createHandle());
47 if (pixel_format.isFloatingPoint() && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
48 throw new LWJGLException("Floating point pixel format requested, but is not supported");
49 choosePixelFormat(pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered);
50 }
51 private static native ByteBuffer createHandle();
52
53 private void choosePixelFormat(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
54 nChoosePixelFormat(getHandle(), pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered);
55 }
56 private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException;
57
58 public void destroy() {
59 nDestroy(getHandle());
60 }
61 private static native void nDestroy(ByteBuffer handle);
62 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An AWT implementation of a LWJGL compatible Mouse event queue.
35 * @author elias_naur
36 */
37
38 import java.awt.Component;
39 import java.awt.Point;
40 import java.awt.event.MouseEvent;
41 import java.awt.event.MouseListener;
42 import java.awt.event.MouseMotionListener;
43 import java.awt.event.MouseWheelEvent;
44 import java.awt.event.MouseWheelListener;
45 import java.nio.ByteBuffer;
46 import java.nio.IntBuffer;
47
48 import org.lwjgl.input.Mouse;
49
50 class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener {
51 private static final int WHEEL_SCALE = 120;
52 public static final int NUM_BUTTONS = 3;
53
54 private final Component component;
55
56 private boolean grabbed;
57
58 /** The accumulated mouse deltas returned by poll() */
59 private int accum_dx;
60 private int accum_dy;
61 private int accum_dz;
62
63 /** The last mouse position */
64 private int last_x;
65 private int last_y;
66
67 /** Saved control key state for ctrl-click right button emulation */
68 private boolean saved_control_state;
69
70 /** Event scratch array */
71 private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE);
72
73 /** Buttons array */
74 private final byte[] buttons = new byte[NUM_BUTTONS];
75
76 MouseEventQueue(Component component) {
77 super(Mouse.EVENT_SIZE);
78 this.component = component;
79 }
80
81 public synchronized void register() {
82 resetCursorToCenter();
83 component.addMouseListener(this);
84 component.addMouseMotionListener(this);
85 component.addMouseWheelListener(this);
86 }
87
88 public synchronized void unregister() {
89 component.removeMouseListener(this);
90 component.removeMouseMotionListener(this);
91 component.removeMouseWheelListener(this);
92 }
93
94 protected Component getComponent() {
95 return component;
96 }
97
98 public synchronized void setGrabbed(boolean grabbed) {
99 this.grabbed = grabbed;
100 resetCursorToCenter();
101 }
102
103 public synchronized boolean isGrabbed() {
104 return grabbed;
105 }
106
107 private int transformY(int y) {
108 return component.getHeight() - 1 - y;
109 }
110
111 protected void resetCursorToCenter() {
112 clearEvents();
113 accum_dx = accum_dy = 0;
114 Point cursor_location = AWTUtil.getCursorPosition(component);
115 if (cursor_location != null) {
116 last_x = cursor_location.x;
117 last_y = cursor_location.y;
118 }
119 }
120
121 private void putMouseEvent(byte button, byte state, int dz, long nanos) {
122 if (grabbed)
123 putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
124 else
125 putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos);
126 }
127
128 protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
129 event.clear();
130 event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
131 event.flip();
132 putEvent(event);
133 }
134
135 public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
136 if ( grabbed ) {
137 coord_buffer.put(0, accum_dx);
138 coord_buffer.put(1, accum_dy);
139 } else {
140 coord_buffer.put(0, last_x);
141 coord_buffer.put(1, last_y);
142 }
143 coord_buffer.put(2, accum_dz);
144 accum_dx = accum_dy = accum_dz = 0;
145 int old_position = buttons_buffer.position();
146 buttons_buffer.put(buttons, 0, buttons.length);
147 buttons_buffer.position(old_position);
148 }
149
150 private void setCursorPos(int x, int y, long nanos) {
151 y = transformY(y);
152 if ( grabbed )
153 return;
154 int dx = x - last_x;
155 int dy = y - last_y;
156 addDelta(dx, dy);
157 last_x = x;
158 last_y = y;
159 putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
160 }
161
162 protected void addDelta(int dx, int dy) {
163 accum_dx += dx;
164 accum_dy += dy;
165 }
166
167 public void mouseClicked(MouseEvent e) {
168 }
169
170 public void mouseEntered(MouseEvent e) {
171 }
172
173 public void mouseExited(MouseEvent e) {
174 }
175
176 private void handleButton(MouseEvent e) {
177 byte state;
178 switch (e.getID()) {
179 case MouseEvent.MOUSE_PRESSED:
180 state = 1;
181 break;
182 case MouseEvent.MOUSE_RELEASED:
183 state = 0;
184 break;
185 default:
186 throw new IllegalArgumentException("Not a valid event ID: " + e.getID());
187 }
188 byte button;
189 switch (e.getButton()) {
190 case MouseEvent.NOBUTTON:
191 // Nothing to do, so return
192 return;
193 case MouseEvent.BUTTON1:
194 // Emulate right click if ctrl is down
195 if (state == 1)
196 saved_control_state = e.isControlDown();
197 if (saved_control_state) {
198 if (buttons[1] == state)
199 return; // ignore
200 button = (byte)1;
201 } else {
202 button = (byte)0;
203 }
204 break;
205 case MouseEvent.BUTTON2:
206 button = (byte)2;
207 break;
208 case MouseEvent.BUTTON3:
209 if (buttons[1] == state)
210 return; // ignore
211 button = (byte)1;
212 break;
213 default:
214 throw new IllegalArgumentException("Not a valid button: " + e.getButton());
215 }
216 setButton(button, state, e.getWhen()*1000000);
217 }
218
219 public synchronized void mousePressed(MouseEvent e) {
220 handleButton(e);
221 }
222
223 private void setButton(byte button, byte state, long nanos) {
224 buttons[button] = state;
225 putMouseEvent(button, state, 0, nanos);
226 }
227
228 public synchronized void mouseReleased(MouseEvent e) {
229 handleButton(e);
230 }
231
232 private void handleMotion(MouseEvent e) {
233 if (grabbed) {
234 updateDeltas(e.getWhen()*1000000);
235 } else {
236 setCursorPos(e.getX(), e.getY(), e.getWhen()*1000000);
237 }
238 }
239
240 public synchronized void mouseDragged(MouseEvent e) {
241 handleMotion(e);
242 }
243
244 public synchronized void mouseMoved(MouseEvent e) {
245 handleMotion(e);
246 }
247
248 private void handleWheel(int amount, long nanos) {
249 accum_dz += amount;
250 putMouseEvent((byte)-1, (byte)0, amount, nanos);
251 }
252
253 protected void updateDeltas(long nanos) {
254 }
255
256 public synchronized void mouseWheelMoved(MouseWheelEvent e) {
257 int wheel_amount = -e.getWheelRotation() * WHEEL_SCALE;
258 handleWheel(wheel_amount, e.getWhen()*1000000);
259 }
260 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * <p/>
35 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 * $Id: OpenGLException.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public class OpenGLException extends RuntimeException {
42
43 private static final long serialVersionUID = 1L;
44
45 /** Constructor for OpenGLException. */
46 public OpenGLException(int gl_error_code) {
47 this(createErrorMessage(gl_error_code));
48 }
49
50 private static String createErrorMessage(int gl_error_code) {
51 String error_string = Util.translateGLErrorString(gl_error_code);
52 return error_string + " (" + gl_error_code + ")";
53 }
54
55 /** Constructor for OpenGLException. */
56 public OpenGLException() {
57 super();
58 }
59
60 /**
61 * Constructor for OpenGLException.
62 *
63 * @param message
64 */
65 public OpenGLException(String message) {
66 super(message);
67 }
68
69 /**
70 * Constructor for OpenGLException.
71 *
72 * @param message
73 * @param cause
74 */
75 public OpenGLException(String message, Throwable cause) {
76 super(message, cause);
77 }
78
79 /**
80 * Constructor for OpenGLException.
81 *
82 * @param cause
83 */
84 public OpenGLException(Throwable cause) {
85 super(cause);
86 }
87
88 }
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 java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.LWJGLUtil;
38 import org.lwjgl.Sys;
39
40 /**
41 * <p/>
42 * Pbuffer encapsulates an OpenGL pbuffer.
43 * <p/>
44 *
45 * This class is thread-safe.
46 *
47 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3116 $
49 * $Id: Pbuffer.java 3116 2008-08-19 16:46:03Z spasi $
50 */
51 public final class Pbuffer implements Drawable {
52 /**
53 * Indicates that Pbuffers can be created.
54 */
55 public static final int PBUFFER_SUPPORTED = 1 << 0;
56
57 /**
58 * Indicates that Pbuffers can be used as render-textures.
59 */
60 public static final int RENDER_TEXTURE_SUPPORTED = 1 << 1;
61
62 /**
63 * Indicates that Pbuffers can be used as non-power-of-two render-textures.
64 */
65 public static final int RENDER_TEXTURE_RECTANGLE_SUPPORTED = 1 << 2;
66
67 /**
68 * Indicates that Pbuffers can be used as depth render-textures.
69 */
70 public static final int RENDER_DEPTH_TEXTURE_SUPPORTED = 1 << 3;
71
72 /**
73 * The render-to-texture mipmap level attribute.
74 */
75 public static final int MIPMAP_LEVEL = RenderTexture.WGL_MIPMAP_LEVEL_ARB;
76
77 /**
78 * The render-to-texture cube map face attribute.
79 */
80 public static final int CUBE_MAP_FACE = RenderTexture.WGL_CUBE_MAP_FACE_ARB;
81
82 /**
83 * The render-to-texture cube map positive X face value.
84 */
85 public static final int TEXTURE_CUBE_MAP_POSITIVE_X = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
86
87 /**
88 * The render-to-texture cube map negative X face value.
89 */
90 public static final int TEXTURE_CUBE_MAP_NEGATIVE_X = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB;
91
92 /**
93 * The render-to-texture cube map positive Y face value.
94 */
95 public static final int TEXTURE_CUBE_MAP_POSITIVE_Y = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB;
96
97 /**
98 * The render-to-texture cube map negative Y face value.
99 */
100 public static final int TEXTURE_CUBE_MAP_NEGATIVE_Y = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB;
101
102 /**
103 * The render-to-texture cube map positive Z face value.
104 */
105 public static final int TEXTURE_CUBE_MAP_POSITIVE_Z = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB;
106
107 /**
108 * The render-to-texture cube map negative Z face value.
109 */
110 public static final int TEXTURE_CUBE_MAP_NEGATIVE_Z = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB;
111
112 /**
113 * The Pbuffer front left buffer.
114 */
115 public static final int FRONT_LEFT_BUFFER = RenderTexture.WGL_FRONT_LEFT_ARB;
116
117 /**
118 * The Pbuffer front right buffer.
119 */
120 public static final int FRONT_RIGHT_BUFFER = RenderTexture.WGL_FRONT_RIGHT_ARB;
121
122 /**
123 * The Pbuffer back left buffer.
124 */
125 public static final int BACK_LEFT_BUFFER = RenderTexture.WGL_BACK_LEFT_ARB;
126
127 /**
128 * The Pbuffer back right buffer.
129 */
130 public static final int BACK_RIGHT_BUFFER = RenderTexture.WGL_BACK_RIGHT_ARB;
131
132 /**
133 * The Pbuffer depth buffer.
134 */
135 public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV;
136
137 /**
138 * Handle to the native GL rendering context
139 */
140 private final PeerInfo peer_info;
141
142 /**
143 * Width
144 */
145 private final int width;
146
147 /**
148 * Height
149 */
150 private final int height;
151
152 private final Context context;
153
154 private boolean destroyed;
155
156 static {
157 Sys.initialize();
158 }
159
160 /**
161 * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered.
162 * <p/>
163 * NOTE: The Pbuffer will have its own context that shares display lists and textures with <code>shared_context</code>,
164 * or, if <code>shared_context</code> is <code>null</code>, the Display context if it is created. The Pbuffer
165 * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa.
166 * <p/>
167 *
168 * @param width Pbuffer width
169 * @param height Pbuffer height
170 * @param pixel_format Minimum Pbuffer context properties
171 * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share
172 * with the Display context (if created).
173 */
174 public Pbuffer(int width, int height, PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException {
175 this(width, height, pixel_format, null, shared_drawable);
176 }
177
178 /**
179 * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered.
180 * <p/>
181 * NOTE: The Pbuffer will have its own context that shares display lists and textures with <code>shared_context</code>,
182 * or, if <code>shared_context</code> is <code>null</code>, the Display context if it is created. The Pbuffer
183 * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa.
184 * <p/>
185 * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null,
186 * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that
187 * it is supported. Currently only windows platform can support this feature, so it is recommended that EXT_framebuffer_object
188 * or similar is used if available, for maximum portability.
189 * <p/>
190 *
191 * @param width Pbuffer width
192 * @param height Pbuffer height
193 * @param pixel_format Minimum Pbuffer context properties
194 * @param renderTexture
195 * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share
196 * with the Display context (if created).
197 */
198 public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable) throws LWJGLException {
199 this(width, height, pixel_format, renderTexture, shared_drawable, null);
200 }
201
202 /**
203 * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered.
204 * <p/>
205 * NOTE: The Pbuffer will have its own context that shares display lists and textures with <code>shared_context</code>,
206 * or, if <code>shared_context</code> is <code>null</code>, the Display context if it is created. The Pbuffer
207 * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa.
208 * <p/>
209 * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null,
210 * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that
211 * it is supported. Currently only windows platform can support this feature, so it is recommended that EXT_framebuffer_object
212 * or similar is used if available, for maximum portability.
213 * <p/>
214 *
215 * @param width Pbuffer width
216 * @param height Pbuffer height
217 * @param pixel_format Minimum Pbuffer context properties
218 * @param renderTexture
219 * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share
220 * with the Display context (if created).
221 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
222 */
223 public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException {
224 if (pixel_format == null)
225 throw new NullPointerException("Pixel format must be non-null");
226 this.width = width;
227 this.height = height;
228 this.peer_info = createPbuffer(width, height, pixel_format, renderTexture);
229 Context shared_context = null;
230 if (shared_drawable != null) {
231 shared_context = shared_drawable.getContext();
232 } else {
233 Drawable display_drawable = Display.getDrawable();
234 if (display_drawable != null)
235 shared_context = display_drawable.getContext();
236 }
237 this.context = new Context(peer_info, attribs, shared_context);
238 }
239
240 private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
241 if ( renderTexture == null ) {
242 // Though null is a perfectly valid argument, Matrox Parhelia drivers expect
243 // a 0 terminated list, or else they crash. Supplying NULL or 0, should
244 // cause the drivers to use default settings
245 IntBuffer defaultAttribs = BufferUtils.createIntBuffer(1);
246 return Display.getImplementation().createPbuffer(width, height, pixel_format, null, defaultAttribs);
247 } else
248 return Display.getImplementation().createPbuffer(width, height, pixel_format,
249 renderTexture.pixelFormatCaps,
250 renderTexture.pBufferAttribs);
251 }
252
253 public Context getContext() {
254 return context;
255 }
256
257 private void checkDestroyed() {
258 if (destroyed)
259 throw new IllegalStateException("Pbuffer is destroyed");
260 }
261
262 /**
263 * Method to test for validity of the buffer. If this function returns true, the buffer contents is lost. The buffer can still
264 * be used, but the results are undefined. The application is expected to release the buffer if needed, destroy it and recreate
265 * a new buffer.
266 *
267 * @return true if the buffer is lost and destroyed, false if the buffer is valid.
268 */
269 public synchronized boolean isBufferLost() {
270 checkDestroyed();
271 return Display.getImplementation().isBufferLost(peer_info);
272 }
273
274 /**
275 * Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer.
276 * @throws LWJGLException if the context could not be made current
277 */
278 public synchronized void makeCurrent() throws LWJGLException {
279 checkDestroyed();
280 context.makeCurrent();
281 }
282
283 /**
284 * Gets the Pbuffer capabilities.
285 *
286 * @return a bitmask of Pbuffer capabilities.
287 */
288 public static int getCapabilities() {
289 return Display.getImplementation().getPbufferCapabilities();
290 }
291
292 /**
293 * Destroys the Pbuffer. After this call, there will be no valid GL rendering context - regardless of whether this Pbuffer was
294 * the current rendering context or not.
295 */
296 public synchronized void destroy() {
297 if (destroyed)
298 return;
299 try {
300 context.forceDestroy();
301 peer_info.destroy();
302 destroyed = true;
303 } catch (LWJGLException e) {
304 LWJGLUtil.log("Exception occurred while destroying pbuffer: " + e);
305 }
306 }
307
308 // -----------------------------------------------------------------------------------------
309 // ------------------------------- Render-to-Texture Methods -------------------------------
310 // -----------------------------------------------------------------------------------------
311
312 /**
313 * Sets a render-to-texture attribute.
314 * <p/>
315 * The attrib parameter can be one of MIPMAP_LEVEL and CUBE_MAP_FACE. When the attrib parameter is CUBE_MAP_FACE then the value
316 * parameter can be on of the following:
317 * <p/>
318 * TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y
319 * TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z
320 *
321 * @param attrib
322 * @param value
323 */
324 public synchronized void setAttrib(int attrib, int value) {
325 checkDestroyed();
326 Display.getImplementation().setPbufferAttrib(peer_info, attrib, value);
327 }
328
329 /**
330 * Binds the currently bound texture to the buffer specified. The buffer can be one of the following:
331 * <p/>
332 * FRONT_LEFT_BUFFER FRONT_RIGHT_BUFFER BACK_LEFT_BUFFER BACK_RIGHT_BUFFER DEPTH_BUFFER
333 *
334 * @param buffer
335 */
336 public synchronized void bindTexImage(int buffer) {
337 checkDestroyed();
338 Display.getImplementation().bindTexImageToPbuffer(peer_info, buffer);
339 }
340
341 /**
342 * Releases the currently bound texture from the buffer specified.
343 *
344 * @param buffer
345 */
346 public synchronized void releaseTexImage(int buffer) {
347 checkDestroyed();
348 Display.getImplementation().releaseTexImageFromPbuffer(peer_info, buffer);
349 }
350
351 /**
352 * @return Returns the height.
353 */
354 public synchronized int getHeight() {
355 checkDestroyed();
356 return height;
357 }
358
359 /**
360 * @return Returns the width.
361 */
362 public synchronized int getWidth() {
363 checkDestroyed();
364 return width;
365 }
366 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36 import org.lwjgl.LWJGLUtil;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: PeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 abstract class PeerInfo {
45 private final ByteBuffer handle;
46 private Thread locking_thread; // Thread that has locked this PeerInfo
47 private int lock_count;
48
49 protected PeerInfo(ByteBuffer handle) {
50 this.handle = handle;
51 }
52
53 private void lockAndInitHandle() throws LWJGLException {
54 doLockAndInitHandle();
55 }
56
57 public synchronized final void unlock() throws LWJGLException {
58 if (lock_count <= 0)
59 throw new IllegalStateException("PeerInfo not locked!");
60 if (Thread.currentThread() != locking_thread)
61 throw new IllegalStateException("PeerInfo already locked by " + locking_thread);
62 lock_count--;
63 if (lock_count == 0) {
64 doUnlock();
65 locking_thread = null;
66 notify();
67 }
68 }
69
70 protected abstract void doLockAndInitHandle() throws LWJGLException;
71 protected abstract void doUnlock() throws LWJGLException;
72
73 public synchronized final ByteBuffer lockAndGetHandle() throws LWJGLException {
74 Thread this_thread = Thread.currentThread();
75 while (locking_thread != null && locking_thread != this_thread) {
76 try {
77 wait();
78 } catch (InterruptedException e) {
79 LWJGLUtil.log("Interrupted while waiting for PeerInfo lock: " + e);
80 }
81 }
82 if (lock_count == 0) {
83 locking_thread = this_thread;
84 doLockAndInitHandle();
85 }
86 lock_count++;
87 return getHandle();
88 }
89
90 protected final ByteBuffer getHandle() {
91 return handle;
92 }
93
94 public void destroy() {
95 }
96 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This class describes pixel format properties for an OpenGL context. Instances
35 * of this class is used as arguments to Display.create(), Pbuffer.create() and
36 * AWTGLCanvas, to indicate minimum required properties.
37 * <p/>
38 * Instants of this class are immutable. An example of the expected way to set
39 * the PixelFormat property values is the following:
40 * <code>PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4).withSRGB(true);</code>
41 * <p/>
42 * WARNING: Some pixel formats are known to cause troubles on certain buggy drivers.
43 * Example: Under Windows, specifying samples != 0 will enable the ARB
44 * pixel format selection path, which could trigger a crash.
45 *
46 * @author elias_naur@sourceforge.net
47 * @version $Revision: 3116 $
48 */
49
50 public final class PixelFormat {
51
52 /**
53 * The number of bits per pixel, exluding alpha.
54 * This parameter is ignored in Display.create().
55 */
56 private int bpp;
57 /** The number of alpha bits. */
58 private int alpha;
59 /** The number of depth buffer bits */
60 private int depth;
61 /** The number of stencil bits */
62 private int stencil;
63 /**
64 * The number of samples to use in anti-aliasing.
65 * 0 means that anti-aliasing is disabled.
66 */
67 private int samples;
68 /** The number of auxiliary buffers */
69 private int num_aux_buffers;
70 /** The number of bits per pixel in the accumulation buffer */
71 private int accum_bpp;
72 /** The number of alpha bits in the accumulation buffer */
73 private int accum_alpha;
74 /** Whether this format requires a stereo buffer */
75 private boolean stereo;
76 /** Whether this format specifies a floating point format */
77 private boolean floating_point;
78 /** Whether this format specifies a packed floating point format (32 bit unsigned - R11F_G11F_B10F) */
79 private boolean floating_point_packed;
80 /** Whether this format specifies an sRGB format */
81 private boolean sRGB;
82
83 /**
84 * Default pixel format is minimum 8 bits depth, and no alpha
85 * nor stencil requirements.
86 */
87 public PixelFormat() {
88 this(0, 8, 0);
89 }
90
91 public PixelFormat(int alpha, int depth, int stencil) {
92 this(alpha, depth, stencil, 0);
93 }
94
95 public PixelFormat(int alpha, int depth, int stencil, int samples) {
96 this(0, alpha, depth, stencil, samples);
97 }
98
99 public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples) {
100 this(bpp, alpha, depth, stencil, samples, 0, 0, 0, false);
101 }
102
103 public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo) {
104 this(bpp, alpha, depth, stencil, samples, num_aux_buffers, accum_bpp, accum_alpha, stereo, false);
105 }
106
107 public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo, boolean floating_point) {
108 this.bpp = bpp;
109 this.alpha = alpha;
110 this.depth = depth;
111 this.stencil = stencil;
112
113 this.samples = samples;
114
115 this.num_aux_buffers = num_aux_buffers;
116
117 this.accum_bpp = accum_bpp;
118 this.accum_alpha = accum_alpha;
119
120 this.stereo = stereo;
121
122 this.floating_point = floating_point;
123 this.floating_point_packed = false;
124 this.sRGB = false;
125 }
126
127 private PixelFormat(final PixelFormat pf) {
128 this.bpp = pf.bpp;
129 this.alpha = pf.alpha;
130 this.depth = pf.depth;
131 this.stencil = pf.stencil;
132
133 this.samples = pf.samples;
134
135 this.num_aux_buffers = pf.num_aux_buffers;
136
137 this.accum_bpp = pf.accum_bpp;
138 this.accum_alpha = pf.accum_alpha;
139
140 this.stereo = pf.stereo;
141
142 this.floating_point = pf.floating_point;
143 this.floating_point_packed = pf.floating_point_packed;
144 this.sRGB = pf.sRGB;
145 }
146
147 public int getBitsPerPixel() {
148 return bpp;
149 }
150
151 /**
152 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel value.
153 *
154 * @param bpp the new bits per pixel value.
155 *
156 * @return the new PixelFormat
157 */
158 public PixelFormat withBitsPerPixel(final int bpp) {
159 if ( bpp < 0 )
160 throw new IllegalArgumentException("Invalid number of bits per pixel specified: " + bpp);
161
162 final PixelFormat pf = new PixelFormat(this);
163 pf.bpp = bpp;
164 return pf;
165 }
166
167 public int getAlphaBits() {
168 return alpha;
169 }
170
171 /**
172 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits value.
173 *
174 * @param alpha the new alpha bits value.
175 *
176 * @return the new PixelFormat
177 */
178 public PixelFormat withAlphaBits(final int alpha) {
179 if ( alpha < 0 )
180 throw new IllegalArgumentException("Invalid number of alpha bits specified: " + alpha);
181
182 final PixelFormat pf = new PixelFormat(this);
183 pf.alpha = alpha;
184 return pf;
185 }
186
187 public int getDepthBits() {
188 return depth;
189 }
190
191 /**
192 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new depth bits value.
193 *
194 * @param depth the new depth bits value.
195 *
196 * @return the new PixelFormat
197 */
198 public PixelFormat withDepthBits(final int depth) {
199 if ( depth < 0 )
200 throw new IllegalArgumentException("Invalid number of depth bits specified: " + depth);
201
202 final PixelFormat pf = new PixelFormat(this);
203 pf.depth = depth;
204 return pf;
205 }
206
207 public int getStencilBits() {
208 return stencil;
209 }
210
211 /**
212 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stencil bits value.
213 *
214 * @param stencil the new stencil bits value.
215 *
216 * @return the new PixelFormat
217 */
218 public PixelFormat withStencilBits(final int stencil) {
219 if ( stencil < 0 )
220 throw new IllegalArgumentException("Invalid number of stencil bits specified: " + stencil);
221
222 final PixelFormat pf = new PixelFormat(this);
223 pf.stencil = stencil;
224 return pf;
225 }
226
227 public int getSamples() {
228 return samples;
229 }
230
231 /**
232 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new samples value.
233 *
234 * @param samples the new samples value.
235 *
236 * @return the new PixelFormat
237 */
238 public PixelFormat withSamples(final int samples) {
239 if ( samples < 0 )
240 throw new IllegalArgumentException("Invalid number of samples specified: " + samples);
241
242 final PixelFormat pf = new PixelFormat(this);
243 pf.samples = samples;
244 return pf;
245 }
246
247 public int getAuxBuffers() {
248 return num_aux_buffers;
249 }
250
251 /**
252 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new auxiliary buffers value.
253 *
254 * @param num_aux_buffers the new auxiliary buffers value.
255 *
256 * @return the new PixelFormat
257 */
258 public PixelFormat withAuxBuffers(final int num_aux_buffers) {
259 if ( num_aux_buffers < 0 )
260 throw new IllegalArgumentException("Invalid number of auxiliary buffers specified: " + num_aux_buffers);
261
262 final PixelFormat pf = new PixelFormat(this);
263 pf.num_aux_buffers = num_aux_buffers;
264 return pf;
265 }
266
267 public int getAccumulationBitsPerPixel() {
268 return accum_bpp;
269 }
270
271 /**
272 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel in the accumulation buffer value.
273 *
274 * @param accum_bpp the new bits per pixel in the accumulation buffer value.
275 *
276 * @return the new PixelFormat
277 */
278 public PixelFormat withAccumulationBitsPerPixel(final int accum_bpp) {
279 if ( accum_bpp < 0 )
280 throw new IllegalArgumentException("Invalid number of bits per pixel in the accumulation buffer specified: " + accum_bpp);
281
282 final PixelFormat pf = new PixelFormat(this);
283 pf.accum_bpp = accum_bpp;
284 return pf;
285 }
286
287 public int getAccumulationAlpha() {
288 return accum_alpha;
289 }
290
291 /**
292 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits in the accumulation buffer value.
293 *
294 * @param accum_alpha the new alpha bits in the accumulation buffer value.
295 *
296 * @return the new PixelFormat
297 */
298 public PixelFormat withAccumulationAlpha(final int accum_alpha) {
299 if ( accum_alpha < 0 )
300 throw new IllegalArgumentException("Invalid number of alpha bits in the accumulation buffer specified: " + accum_alpha);
301
302 final PixelFormat pf = new PixelFormat(this);
303 pf.accum_alpha = accum_alpha;
304 return pf;
305 }
306
307 public boolean isStereo() {
308 return stereo;
309 }
310
311 /**
312 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stereo value.
313 *
314 * @param stereo the new stereo value.
315 *
316 * @return the new PixelFormat
317 */
318 public PixelFormat withStereo(final boolean stereo) {
319 final PixelFormat pf = new PixelFormat(this);
320 pf.stereo = stereo;
321 return pf;
322 }
323
324 public boolean isFloatingPoint() {
325 return floating_point;
326 }
327
328 /**
329 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new floating point value.
330 * If floating_point is true, floating_point_packed will be reset to false.
331 *
332 * @param floating_point the new floating point value.
333 *
334 * @return the new PixelFormat
335 */
336 public PixelFormat withFloatingPoint(final boolean floating_point) {
337 final PixelFormat pf = new PixelFormat(this);
338 pf.floating_point = floating_point;
339 if ( floating_point )
340 pf.floating_point_packed = false;
341 return pf;
342 }
343
344 /**
345 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new packed floating point value.
346 * If floating_point_packed is true, floating_point will be reset to false.
347 *
348 * @param floating_point_packed the new packed floating point value.
349 *
350 * @return the new PixelFormat
351 */
352 public PixelFormat withFloatingPointPacked(final boolean floating_point_packed) {
353 final PixelFormat pf = new PixelFormat(this);
354 pf.floating_point_packed = floating_point_packed;
355 if ( floating_point_packed )
356 pf.floating_point = false;
357 return pf;
358 }
359
360 public boolean isSRGB() {
361 return sRGB;
362 }
363
364 /**
365 * Returns a new PixelFormat object with the same properties as this PixelFormat and the new sRGB value.
366 *
367 * @param sRGB the new floating point value.
368 *
369 * @return the new PixelFormat
370 */
371 public PixelFormat withSRGB(final boolean sRGB) {
372 final PixelFormat pf = new PixelFormat(this);
373 pf.sRGB = sRGB;
374 return pf;
375 }
376
377 }
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 /** @author spasi <spasi@users.sourceforge.net> */
34 public interface PointerWrapper {
35
36 long getPointer();
37
38 }
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 class ReferencesStack {
34 private References[] references_stack;
35 private int stack_pos;
36
37 public References getReferences() {
38 return references_stack[stack_pos];
39 }
40
41 public void pushState() {
42 int pos = ++stack_pos;
43 if (pos == references_stack.length) {
44 growStack();
45 }
46 references_stack[pos].copy(references_stack[pos - 1], GL11.GL_ALL_CLIENT_ATTRIB_BITS);
47 }
48
49 public References popState(int mask) {
50 References result = references_stack[stack_pos--];
51
52 references_stack[stack_pos].copy(result, ~mask);
53 result.clear();
54
55 return result;
56 }
57
58 private void growStack() {
59 References[] new_references_stack = new References[references_stack.length + 1];
60 System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length);
61 references_stack = new_references_stack;
62 references_stack[references_stack.length - 1] = new References(GLContext.getCapabilities());
63 }
64
65 ReferencesStack() {
66 ContextCapabilities caps = GLContext.getCapabilities();
67 references_stack = new References[1];
68 stack_pos = 0;
69 for (int i = 0; i < references_stack.length; i++)
70 references_stack[i] = new References(caps);
71 }
72 }
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 java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36
37 /** This class represents the state necessary for render-to-texture. */
38 public final class RenderTexture {
39
40 // ----------------------------------------------------------------------------------
41 // ----------------------------- WGL_ARB_render_texture -----------------------------
42 // ----------------------------------------------------------------------------------
43
44 /*
45 Accepted by the <piAttributes> parameter of wglGetPixelFormatAttribivARB,
46 wglGetPixelFormatAttribfvARB, and the <piAttribIList> and <pfAttribIList>
47 parameters of wglChoosePixelFormatARB:
48 */
49 private static final int WGL_BIND_TO_TEXTURE_RGB_ARB = 0x2070;
50 private static final int WGL_BIND_TO_TEXTURE_RGBA_ARB = 0x2071;
51
52 /*
53 Accepted by the <piAttribList> parameter of wglCreatePbufferARB and
54 by the <iAttribute> parameter of wglQueryPbufferARB:
55 */
56 private static final int WGL_TEXTURE_FORMAT_ARB = 0x2072;
57 private static final int WGL_TEXTURE_TARGET_ARB = 0x2073;
58 private static final int WGL_MIPMAP_TEXTURE_ARB = 0x2074;
59
60 /*
61 Accepted as a value in the <piAttribList> parameter of
62 wglCreatePbufferARB and returned in the value parameter of
63 wglQueryPbufferARB when <iAttribute> is WGL_TEXTURE_FORMAT_ARB:
64 */
65 private static final int WGL_TEXTURE_RGB_ARB = 0x2075;
66 private static final int WGL_TEXTURE_RGBA_ARB = 0x2076;
67
68 /*
69 Accepted as a value in the <piAttribList> parameter of
70 wglCreatePbufferARB and returned in the value parameter of
71 wglQueryPbufferARB when <iAttribute> is WGL_TEXTURE_TARGET_ARB:
72 */
73 private static final int WGL_TEXTURE_CUBE_MAP_ARB = 0x2078;
74 private static final int WGL_TEXTURE_1D_ARB = 0x2079;
75 private static final int WGL_TEXTURE_2D_ARB = 0x207A;
76 private static final int WGL_NO_TEXTURE_ARB = 0x2077;
77
78 /*
79 Accepted by the <piAttribList> parameter of wglSetPbufferAttribARB and
80 by the <iAttribute> parameter of wglQueryPbufferARB:
81 */
82 static final int WGL_MIPMAP_LEVEL_ARB = 0x207B;
83 static final int WGL_CUBE_MAP_FACE_ARB = 0x207C;
84
85 /*
86 Accepted as a value in the <piAttribList> parameter of
87 wglSetPbufferAttribARB and returned in the value parameter of
88 wglQueryPbufferARB when <iAttribute> is WGL_CUBE_MAP_FACE_ARB:
89 */
90 static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x207D;
91 static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x207E;
92 static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x207F;
93 static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x2080;
94 static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x2081;
95 static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x2082;
96
97 /*
98 Accepted by the <iBuffer> parameter of wglBindTexImageARB and
99 wglReleaseTexImageARB:
100 */
101 static final int WGL_FRONT_LEFT_ARB = 0x2083;
102 static final int WGL_FRONT_RIGHT_ARB = 0x2084;
103 static final int WGL_BACK_LEFT_ARB = 0x2085;
104 static final int WGL_BACK_RIGHT_ARB = 0x2086;
105
106 /*
107 private static final int WGL_AUX0_ARB = 0x2087;
108 private static final int WGL_AUX1_ARB = 0x2088;
109 private static final int WGL_AUX2_ARB = 0x2089;
110 private static final int WGL_AUX3_ARB = 0x208A;
111 private static final int WGL_AUX4_ARB = 0x208B;
112 private static final int WGL_AUX5_ARB = 0x208C;
113 private static final int WGL_AUX6_ARB = 0x208D;
114 private static final int WGL_AUX7_ARB = 0x208E;
115 private static final int WGL_AUX8_ARB = 0x208F;
116 private static final int WGL_AUX9_ARB = 0x2090;
117 */
118
119 // -------------------------------------------------------------------------------------------
120 // ----------------------------- WGL_NV_render_texture_rectangle -----------------------------
121 // -------------------------------------------------------------------------------------------
122
123 /*
124 Accepted by the <piAttributes> parameter of wglGetPixelFormatAttribivARB,
125 wglGetPixelFormatAttribfvARB, and the <piAttribIList> and <pfAttribIList>
126 parameters of wglChoosePixelFormatARB:
127 */
128 private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = 0x20A0;
129 private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = 0x20A1;
130
131 /*
132 Accepted as a value in the <piAttribList> parameter of wglCreatePbufferARB
133 and returned in the value parameter of wglQueryPbufferARB when
134 <iAttribute> is WGL_TEXTURE_TARGET_ARB:
135 */
136 private static final int WGL_TEXTURE_RECTANGLE_NV = 0x20A2;
137
138 // ---------------------------------------------------------------------------------------
139 // ----------------------------- WGL_NV_render_depth_texture -----------------------------
140 // ---------------------------------------------------------------------------------------
141
142 /*
143 Accepted by the <piAttributes> parameter of wglGetPixelFormatAttribivARB,
144 wglGetPixelFormatAttribfvARB, and the <piAttribIList> and <pfAttribIList>
145 parameters of wglChoosePixelFormatARB:
146 */
147 private static final int WGL_BIND_TO_TEXTURE_DEPTH_NV = 0x20A3;
148 private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV = 0x20A4;
149
150 /*
151 Accepted by the <piAttribList> parameter of wglCreatePbufferARB and
152 by the <iAttribute> parameter of wglQueryPbufferARB:
153 */
154 private static final int WGL_DEPTH_TEXTURE_FORMAT_NV = 0x20A5;
155
156 /*
157 Accepted as a value in the <piAttribList> parameter of wglCreatePbufferARB
158 and returned in the value parameter of wglQueryPbufferARB when
159 <iAttribute> is WGL_DEPTH_TEXTURE_FORMAT_NV:
160 */
161 private static final int WGL_TEXTURE_DEPTH_COMPONENT_NV = 0x20A6;
162
163 /*
164 Accepted by the <iBuffer> parameter of wglBindTexImageARB:
165 */
166 static final int WGL_DEPTH_COMPONENT_NV = 0x20A7;
167
168 /** The TEXTURE_1D target. */
169 public static final int RENDER_TEXTURE_1D = WGL_TEXTURE_1D_ARB;
170
171 /** The TEXTURE_2D target. */
172 public static final int RENDER_TEXTURE_2D = WGL_TEXTURE_2D_ARB;
173
174 /** The TEXTURE_RECTANGLE target. */
175 public static final int RENDER_TEXTURE_RECTANGLE = WGL_TEXTURE_RECTANGLE_NV;
176
177 /** The TEXTURE_CUBE_MAP target. */
178 public static final int RENDER_TEXTURE_CUBE_MAP = WGL_TEXTURE_CUBE_MAP_ARB;
179
180 IntBuffer pixelFormatCaps;
181 IntBuffer pBufferAttribs;
182
183 /**
184 * Creates a RenderTexture object for enabling render-to-texture on a P-buffer.
185 * <p/>
186 * NOTE: Only one of useRGB and useRGBA can be true at the same time.
187 * <p/>
188 * NOTE: useRGB(A) and useDepth can be true at the same time, thus allowing two different render textures.
189 * <p/>
190 * NOTE: The target parameter can be one of the following:
191 * <p/>
192 * RENDER_TEXTURE_1D RENDER_TEXTURE_2D RENDER_TEXTURE_RECTANGLE RENDER_TEXTURE_CUBE_MAP
193 *
194 * @param useRGB - When true the P-buffer can be used as an RGB render texture.
195 * @param useRGBA - When true the P-buffer can be used as an RGBA render texture.
196 * @param useDepth - When true the P-buffer can be used as a depth render texture.
197 * @param isRectangle - When true rectangle textures will be allowed on the P-buffer.
198 * @param target - The texture target of the render texture.
199 * @param mipmaps - How many mipmap levels to allocate on the P-buffer.
200 */
201 public RenderTexture(boolean useRGB, boolean useRGBA, boolean useDepth, boolean isRectangle, int target, int mipmaps) {
202 if ( useRGB && useRGBA )
203 throw new IllegalArgumentException("A RenderTexture can't be both RGB and RGBA.");
204
205 if ( mipmaps < 0 )
206 throw new IllegalArgumentException("The mipmap levels can't be negative.");
207
208 if ( isRectangle && target != RENDER_TEXTURE_RECTANGLE )
209 throw new IllegalArgumentException("When the RenderTexture is rectangle the target must be RENDER_TEXTURE_RECTANGLE.");
210
211 pixelFormatCaps = BufferUtils.createIntBuffer(4);
212 pBufferAttribs = BufferUtils.createIntBuffer(8);
213
214 if ( useRGB ) {
215 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : WGL_BIND_TO_TEXTURE_RGB_ARB);
216 pixelFormatCaps.put(GL11.GL_TRUE);
217
218 pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB);
219 pBufferAttribs.put(WGL_TEXTURE_RGB_ARB);
220 } else if ( useRGBA ) {
221 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV : WGL_BIND_TO_TEXTURE_RGBA_ARB);
222 pixelFormatCaps.put(GL11.GL_TRUE);
223
224 pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB);
225 pBufferAttribs.put(WGL_TEXTURE_RGBA_ARB);
226 }
227
228 if ( useDepth ) {
229 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV : WGL_BIND_TO_TEXTURE_DEPTH_NV);
230 pixelFormatCaps.put(GL11.GL_TRUE);
231
232 pBufferAttribs.put(WGL_DEPTH_TEXTURE_FORMAT_NV);
233 pBufferAttribs.put(WGL_TEXTURE_DEPTH_COMPONENT_NV);
234 }
235
236 pBufferAttribs.put(WGL_TEXTURE_TARGET_ARB);
237 pBufferAttribs.put(target);
238
239 if ( mipmaps != 0 ) {
240 pBufferAttribs.put(WGL_MIPMAP_TEXTURE_ARB);
241 pBufferAttribs.put(mipmaps);
242 }
243
244 pixelFormatCaps.flip();
245 pBufferAttribs.flip();
246 }
247
248 }
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 class StateStack {
34 private int[] state_stack;
35 private int stack_pos;
36
37 public int getState() {
38 return state_stack[stack_pos];
39 }
40
41 public void pushState(int new_state) {
42 int pos = ++stack_pos;
43 if (pos == state_stack.length) {
44 growState();
45 }
46 state_stack[pos] = new_state;
47 }
48
49 public int popState() {
50 return state_stack[stack_pos--];
51 }
52
53 public void growState() {
54 int[] new_state_stack = new int[state_stack.length + 1];
55 System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length);
56 state_stack = new_state_stack;
57 }
58
59 StateStack(int initial_value) {
60 state_stack = new int[1];
61 stack_pos = 0;
62 state_stack[stack_pos] = initial_value;
63 }
64 }
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 final class StateTracker {
34 private ReferencesStack references_stack;
35 private final StateStack attrib_stack;
36
37 private boolean insideBeginEnd;
38
39 StateTracker() {
40 attrib_stack = new StateStack(0);
41 }
42
43 /** This is called after getting function addresses. */
44 void init() {
45 references_stack = new ReferencesStack();
46 }
47
48 static void setBeginEnd(ContextCapabilities caps, boolean inside) {
49 caps.tracker.insideBeginEnd = inside;
50 }
51
52 boolean isBeginEnd() {
53 return insideBeginEnd;
54 }
55
56 static void popAttrib(ContextCapabilities caps) {
57 caps.tracker.doPopAttrib();
58 }
59
60 private void doPopAttrib() {
61 references_stack.popState(attrib_stack.popState());
62 }
63
64 static void pushAttrib(ContextCapabilities caps, int mask) {
65 caps.tracker.doPushAttrib(mask);
66 }
67
68 private void doPushAttrib(int mask) {
69 attrib_stack.pushState(mask);
70 references_stack.pushState();
71 }
72
73 static ReferencesStack getReferencesStack(ContextCapabilities caps) {
74 return caps.tracker.references_stack;
75 }
76
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;
95
96 }
97 }
98 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33
34 /**
35 * Simple utility class.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3316 $
39 */
40
41 public final class Util {
42 /** No c'tor */
43 private Util() {
44 }
45
46 /**
47 * Throws OpenGLException if GL11.glGetError() returns anything else than GL11.GL_NO_ERROR
48 *
49 */
50 public static void checkGLError() throws OpenGLException {
51 if ( ContextCapabilities.DEBUG && GLContext.getCapabilities().tracker.isBeginEnd() ) // Do not call GetError inside a Begin/End pair.
52 return;
53 int err = GL11.glGetError();
54 if ( err != GL11.GL_NO_ERROR ) {
55 throw new OpenGLException(err);
56 }
57 }
58
59 /**
60 * Translate a GL error code to a String describing the error
61 */
62 public static String translateGLErrorString(int error_code) {
63 switch (error_code) {
64 case GL11.GL_NO_ERROR:
65 return "No error";
66 case GL11.GL_INVALID_ENUM:
67 return "Invalid enum";
68 case GL11.GL_INVALID_VALUE:
69 return "Invalid value";
70 case GL11.GL_INVALID_OPERATION:
71 return "Invalid operation";
72 case GL11.GL_STACK_OVERFLOW:
73 return "Stack overflow";
74 case GL11.GL_STACK_UNDERFLOW:
75 return "Stack underflow";
76 case GL11.GL_OUT_OF_MEMORY:
77 return "Out of memory";
78 case ARBImaging.GL_TABLE_TOO_LARGE:
79 return "Table too large";
80 case EXTFramebufferObject.GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
81 return "Invalid framebuffer operation";
82 default:
83 return null;
84 }
85 }
86 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36
37 import java.awt.Canvas;
38
39 /**
40 *
41 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: WindowsAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
44 */
45 final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo {
46 private final Canvas component;
47 private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
48 private final PixelFormat pixel_format;
49 private boolean has_pixel_format= false;
50
51 WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) {
52 this.component = component;
53 this.pixel_format = pixel_format;
54 }
55
56 protected void doLockAndInitHandle() throws LWJGLException {
57 nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
58 if (!has_pixel_format && pixel_format != null) {
59 // If we haven't applied a pixel format yet, do it now
60 int format = choosePixelFormat(getHdc(), component.getX(), component.getY(), pixel_format, null, true, true, false, true);
61 setPixelFormat(getHdc(), format);
62 has_pixel_format = true;
63 }
64 }
65 private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
66
67 protected void doUnlock() throws LWJGLException {
68 awt_surface.unlock();
69 }
70 }
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 java.awt.GraphicsConfiguration;
34 import java.awt.GraphicsDevice;
35 import java.awt.Toolkit;
36 import java.awt.Canvas;
37 import java.security.PrivilegedAction;
38 import java.security.AccessController;
39
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.LWJGLUtil;
42
43 /**
44 *
45 * @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 $
48 */
49 final class WindowsCanvasImplementation implements AWTCanvasImplementation {
50 static {
51 // Make sure the awt stuff is properly initialised (the jawt library in particular)
52 Toolkit.getDefaultToolkit();
53 AccessController.doPrivileged(new PrivilegedAction() {
54 public Object run() {
55 try {
56 System.loadLibrary("jawt");
57 } catch (UnsatisfiedLinkError e) {
58 /* It is probably already loaded, potentially by a different ClassLoader
59 * so just log the exception and continue
60 */
61 LWJGLUtil.log("Failed to load jawt: " + e.getMessage());
62 }
63 return null;
64 }
65 });
66 }
67
68 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
69 return new WindowsAWTGLCanvasPeerInfo(component, pixel_format);
70 }
71
72 /**
73 * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
74 *
75 * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
76 */
77 public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
78 /*
79 * It seems like the best way is to simply return null and
80 * use SetPixelFormat in JNI later.
81 */
82 return null;
83 }
84 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * An implementation of ContextAttribs using WGL_create_context.
35 *
36 * @author spasi <spasi@users.sourceforge.net>
37 */
38 final class WindowsContextAttribs implements ContextAttribsImplementation {
39
40 private static final int WGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091;
41 private static final int WGL_CONTEXT_MINOR_VERSION_ARB = 0x2092;
42 private static final int WGL_CONTEXT_LAYER_PLANE_ARB = 0x2093;
43 private static final int WGL_CONTEXT_FLAGS_ARB = 0x2094;
44 private static final int WGL_CONTEXT_PROFILE_MASK_ARB = 0x9126;
45
46 private static final int WGL_CONTEXT_DEBUG_BIT_ARB = 0x0001;
47 private static final int WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
48
49 private static final int WGL_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
50 private static final int WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
51
52 WindowsContextAttribs() {
53 }
54
55 public int getMajorVersionAttrib() {
56 return WGL_CONTEXT_MAJOR_VERSION_ARB;
57 }
58
59 public int getMinorVersionAttrib() {
60 return WGL_CONTEXT_MINOR_VERSION_ARB;
61 }
62
63 public int getLayerPlaneAttrib() {
64 return WGL_CONTEXT_LAYER_PLANE_ARB;
65 }
66
67 public int getFlagsAttrib() {
68 return WGL_CONTEXT_FLAGS_ARB;
69 }
70
71 public int getDebugBit() {
72 return WGL_CONTEXT_DEBUG_BIT_ARB;
73 }
74
75 public int getForwardCompatibleBit() {
76 return WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
77 }
78
79 public int getProfileMaskAttrib() {
80 return WGL_CONTEXT_PROFILE_MASK_ARB;
81 }
82
83 public int getProfileCoreBit() {
84 return WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
85 }
86
87 public int getProfileCompatibilityBit() {
88 return WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
89 }
90
91 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 /**
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 final class WindowsContextImplementation implements ContextImplementation {
45
46 public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
47 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
48 try {
49 return nCreate(peer_handle, attribs, shared_context_handle);
50 } finally {
51 peer_info.unlock();
52 }
53 }
54
55 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs_handle, ByteBuffer shared_context_handle) throws LWJGLException;
56
57 public void swapBuffers() throws LWJGLException {
58 Context current_context = Context.getCurrentContext();
59 if ( current_context == null )
60 throw new IllegalStateException("No context is current");
61 synchronized ( current_context ) {
62 PeerInfo current_peer_info = current_context.getPeerInfo();
63 ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
64 try {
65 nSwapBuffers(peer_handle);
66 } finally {
67 current_peer_info.unlock();
68 }
69 }
70 }
71
72 private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
73
74 public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException {
75 }
76
77 public void update(ByteBuffer context_handle) {
78 }
79
80 public void releaseCurrentContext() throws LWJGLException {
81 nReleaseCurrentContext();
82 }
83
84 private static native void nReleaseCurrentContext() throws LWJGLException;
85
86 public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
87 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
88 try {
89 nMakeCurrent(peer_handle, handle);
90 } finally {
91 peer_info.unlock();
92 }
93 }
94
95 private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
96
97 public boolean isCurrent(ByteBuffer handle) throws LWJGLException {
98 boolean result = nIsCurrent(handle);
99 return result;
100 }
101
102 private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
103
104 public void setSwapInterval(int value) {
105 boolean success = nSetSwapInterval(value);
106 if ( !success )
107 LWJGLUtil.log("Failed to set swap interval");
108 Util.checkGLError();
109 }
110
111 private static native boolean nSetSwapInterval(int value);
112
113 public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
114 nDestroy(handle);
115 }
116
117 private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException;
118 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the Display implementation interface. Display delegates
35 * to implementors of this interface. There is one DisplayImplementation
36 * for each supported platform.
37 * @author elias_naur
38 */
39
40 import java.nio.ByteBuffer;
41 import java.nio.FloatBuffer;
42 import java.nio.IntBuffer;
43 import java.awt.Canvas;
44
45 import org.lwjgl.LWJGLException;
46 import org.lwjgl.LWJGLUtil;
47 import org.lwjgl.BufferUtils;
48 import org.lwjgl.input.Cursor;
49 import org.lwjgl.input.Keyboard;
50 import org.lwjgl.input.Mouse;
51
52 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();
127 private static WindowsDisplay current_display;
128
129 private static boolean cursor_clipped;
130 private WindowsDisplayPeerInfo peer_info;
131 private Object current_cursor;
132 private Canvas parent;
133 private static boolean hasParent = false;
134
135 private WindowsKeyboard keyboard;
136 private WindowsMouse mouse;
137
138 private boolean close_requested;
139 private boolean is_dirty;
140
141 private ByteBuffer current_gamma;
142 private ByteBuffer saved_gamma;
143 private DisplayMode current_mode;
144
145 private boolean mode_set;
146 private boolean isMinimized;
147 private boolean isFocused;
148 private boolean did_maximize;
149 private boolean inAppActivate;
150
151 private long hwnd;
152 private long hdc;
153
154 private long small_icon;
155 private long large_icon;
156
157 private int captureMouse = -1;
158 private boolean trackingMouse = false;
159 private boolean mouseInside = false;
160
161 WindowsDisplay() {
162 current_display = this;
163 }
164
165 public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
166 close_requested = false;
167 is_dirty = false;
168 isMinimized = false;
169 isFocused = false;
170 did_maximize = false;
171 this.parent = parent;
172 hasParent = parent != null;
173 long parent_hwnd = parent != null ? getHwnd(parent) : 0;
174 this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
175 if (hwnd == 0) {
176 throw new LWJGLException("Failed to create window");
177 }
178 this.hdc = getDC(hwnd);
179 if (hdc == 0) {
180 nDestroyWindow(hwnd);
181 throw new LWJGLException("Failed to get dc");
182 }
183 try {
184 int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, peer_info.getPixelFormat(), null, true, true, false, true);
185 WindowsPeerInfo.setPixelFormat(getHdc(), format);
186 peer_info.initDC(getHwnd(), getHdc());
187 showWindow(getHwnd(), SW_SHOWDEFAULT);
188 if (parent == null) {
189 setForegroundWindow(getHwnd());
190 setFocus(getHwnd());
191 }
192 } catch (LWJGLException e) {
193 nReleaseDC(hwnd, hdc);
194 nDestroyWindow(hwnd);
195 throw e;
196 }
197 }
198 private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException;
199
200 private static boolean isUndecorated() {
201 return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
202 }
203
204 private static long getHwnd(Canvas parent) throws LWJGLException {
205 AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
206 WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null);
207 ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
208 try {
209 return parent_peer_info.getHwnd();
210 } finally {
211 parent_peer_info.unlock();
212 }
213 }
214
215 public void destroyWindow() {
216 nReleaseDC(hwnd, hdc);
217 nDestroyWindow(hwnd);
218 freeLargeIcon();
219 freeSmallIcon();
220 resetCursorClipping();
221 }
222 private static native void nReleaseDC(long hwnd, long hdc);
223 private static native void nDestroyWindow(long hwnd);
224 static void resetCursorClipping() {
225 if (cursor_clipped) {
226 try {
227 clipCursor(null);
228 } catch (LWJGLException e) {
229 LWJGLUtil.log("Failed to reset cursor clipping: " + e);
230 }
231 cursor_clipped = false;
232 }
233 }
234
235 private static void getGlobalClientRect(long hwnd, Rect rect) {
236 rect_buffer.put(0, 0).put(1, 0);
237 clientToScreen(hwnd, rect_buffer);
238 int offset_x = rect_buffer.get(0);
239 int offset_y = rect_buffer.get(1);
240 getClientRect(hwnd, rect_buffer);
241 rect.copyFromBuffer(rect_buffer);
242 rect.offset(offset_x, offset_y);
243 }
244
245 static void setupCursorClipping(long hwnd) throws LWJGLException {
246 cursor_clipped = true;
247 getGlobalClientRect(hwnd, rect);
248 rect.copyToBuffer(rect_buffer);
249 clipCursor(rect_buffer);
250 }
251 private static native void clipCursor(IntBuffer rect) throws LWJGLException;
252
253 public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
254 nSwitchDisplayMode(mode);
255 current_mode = mode;
256 mode_set = true;
257 }
258 private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException;
259
260 /*
261 * Called when the application is alt-tabbed to or from
262 */
263 private void appActivate(boolean active) {
264 if (inAppActivate) {
265 return;
266 }
267 inAppActivate = true;
268 isFocused = active;
269 if (active) {
270 if (Display.isFullscreen()) {
271 restoreDisplayMode();
272 }
273 if (parent == null) {
274 showWindow(getHwnd(), SW_RESTORE);
275 setForegroundWindow(getHwnd());
276 setFocus(getHwnd());
277 }
278 did_maximize = true;
279 if (Display.isFullscreen())
280 updateClipping();
281 } else if (Display.isFullscreen()) {
282 showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
283 resetDisplayMode();
284 } else
285 updateClipping();
286 updateCursor();
287 inAppActivate = false;
288 }
289 private static native void showWindow(long hwnd, int mode);
290 private static native void setForegroundWindow(long hwnd);
291 private static native void setFocus(long hwnd);
292
293 private void restoreDisplayMode() {
294 try {
295 doSetGammaRamp(current_gamma);
296 } catch (LWJGLException e) {
297 LWJGLUtil.log("Failed to restore gamma: " + e.getMessage());
298 }
299
300 if (!mode_set) {
301 mode_set = true;
302 try {
303 nSwitchDisplayMode(current_mode);
304 } catch (LWJGLException e) {
305 LWJGLUtil.log("Failed to restore display mode: " + e.getMessage());
306 }
307 }
308 }
309
310 public void resetDisplayMode() {
311 try {
312 doSetGammaRamp(saved_gamma);
313 } catch (LWJGLException e) {
314 LWJGLUtil.log("Failed to reset gamma ramp: " + e.getMessage());
315 }
316 current_gamma = saved_gamma;
317 if (mode_set) {
318 mode_set = false;
319 nResetDisplayMode();
320 }
321 resetCursorClipping();
322 }
323 private static native void nResetDisplayMode();
324
325 public int getGammaRampLength() {
326 return GAMMA_LENGTH;
327 }
328
329 public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException {
330 doSetGammaRamp(convertToNativeRamp(gammaRamp));
331 }
332 private static native ByteBuffer convertToNativeRamp(FloatBuffer gamma_ramp) throws LWJGLException;
333 private static native ByteBuffer getCurrentGammaRamp() throws LWJGLException;
334
335 private void doSetGammaRamp(ByteBuffer native_gamma) throws LWJGLException {
336 nSetGammaRamp(native_gamma);
337 current_gamma = native_gamma;
338 }
339 private static native void nSetGammaRamp(ByteBuffer native_ramp) throws LWJGLException;
340
341 public String getAdapter() {
342 try {
343 String maxObjNo = WindowsRegistry.queryRegistrationKey(
344 WindowsRegistry.HKEY_LOCAL_MACHINE,
345 "HARDWARE\\DeviceMap\\Video",
346 "MaxObjectNumber");
347 int maxObjectNumber = maxObjNo.charAt(0);
348 String vga_driver_value = "";
349 for(int i=0;i<maxObjectNumber;i++) {
350 String adapter_string = WindowsRegistry.queryRegistrationKey(
351 WindowsRegistry.HKEY_LOCAL_MACHINE,
352 "HARDWARE\\DeviceMap\\Video",
353 "\\Device\\Video" + i);
354 String root_key = "\\registry\\machine\\";
355 if (adapter_string.toLowerCase().startsWith(root_key)) {
356 String driver_value = WindowsRegistry.queryRegistrationKey(
357 WindowsRegistry.HKEY_LOCAL_MACHINE,
358 adapter_string.substring(root_key.length()),
359 "InstalledDisplayDrivers");
360 if(driver_value.toUpperCase().startsWith("VGA")) {
361 vga_driver_value = driver_value;
362 } else if(!driver_value.toUpperCase().startsWith("RDP") && !driver_value.toUpperCase().startsWith("NMNDD")) {
363 return driver_value;
364 }
365 }
366 }
367 if(!vga_driver_value.equals("")) {
368 return vga_driver_value;
369 }
370 } catch (LWJGLException e) {
371 LWJGLUtil.log("Exception occurred while querying registry: " + e);
372 }
373 return null;
374 }
375
376 public String getVersion() {
377 String driver = getAdapter();
378 if (driver != null) {
379 String[] drivers = driver.split(",");
380 if(drivers.length>0) {
381 WindowsFileVersion version = nGetVersion(drivers[0] + ".dll");
382 if (version != null)
383 return version.toString();
384 }
385 }
386 return null;
387 }
388 private native WindowsFileVersion nGetVersion(String driver);
389
390 public DisplayMode init() throws LWJGLException {
391 current_gamma = saved_gamma = getCurrentGammaRamp();
392 return current_mode = getCurrentDisplayMode();
393 }
394 private static native DisplayMode getCurrentDisplayMode() throws LWJGLException;
395
396 public void setTitle(String title) {
397 nSetTitle(hwnd, title);
398 }
399 private static native void nSetTitle(long hwnd, String title);
400
401 public boolean isCloseRequested() {
402 boolean saved = close_requested;
403 close_requested = false;
404 return saved;
405 }
406
407 public boolean isVisible() {
408 return !isMinimized;
409 }
410
411 public boolean isActive() {
412 return isFocused;
413 }
414
415 public boolean isDirty() {
416 boolean saved = is_dirty;
417 is_dirty = false;
418 return saved;
419 }
420
421 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
422 peer_info = new WindowsDisplayPeerInfo(pixel_format);
423 return peer_info;
424 }
425
426 public void update() {
427 nUpdate();
428 if (parent != null && parent.isFocusOwner()) {
429 setFocus(getHwnd());
430 }
431 if (did_maximize) {
432 did_maximize = false;
433 /**
434 * WORKAROUND:
435 * Making the context current (redundantly) when the window
436 * is maximized helps some gfx cards recover from fullscreen
437 */
438 try {
439 if (Display.getDrawable().getContext() != null && Display.getDrawable().getContext().isCurrent())
440 Display.getDrawable().getContext().makeCurrent();
441 } catch (LWJGLException e) {
442 LWJGLUtil.log("Exception occurred while trying to make context current: " + e);
443 }
444 }
445 }
446 private static native void nUpdate();
447
448 public void reshape(int x, int y, int width, int height) {
449 nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null);
450 }
451 private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child);
452 public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
453
454 /* Mouse */
455 public boolean hasWheel() {
456 return mouse.hasWheel();
457 }
458
459 public int getButtonCount() {
460 return mouse.getButtonCount();
461 }
462
463 public void createMouse() throws LWJGLException {
464 mouse = new WindowsMouse(getHwnd());
465 }
466
467 public void destroyMouse() {
468 if (mouse != null)
469 mouse.destroy();
470 mouse = null;
471 }
472
473 public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
474 mouse.poll(coord_buffer, buttons);
475 }
476
477 public void readMouse(ByteBuffer buffer) {
478 mouse.read(buffer);
479 }
480
481 public void grabMouse(boolean grab) {
482 mouse.grab(grab, shouldGrab());
483 updateCursor();
484 }
485
486 public int getNativeCursorCapabilities() {
487 return Cursor.CURSOR_ONE_BIT_TRANSPARENCY;
488 }
489
490 public void setCursorPosition(int x, int y) {
491 getGlobalClientRect(getHwnd(), rect);
492 int transformed_x = rect.left + x;
493 int transformed_y = rect.bottom - 1 - y;
494 nSetCursorPosition(transformed_x, transformed_y);
495 setMousePosition(x, y);
496 }
497 private static native void nSetCursorPosition(int x, int y);
498
499 public void setNativeCursor(Object handle) throws LWJGLException {
500 current_cursor = handle;
501 updateCursor();
502 }
503
504 private void updateCursor() {
505 try {
506 if (mouse != null && shouldGrab())
507 nSetNativeCursor(getHwnd(), mouse.getBlankCursor());
508 else
509 nSetNativeCursor(getHwnd(), current_cursor);
510 } catch (LWJGLException e) {
511 LWJGLUtil.log("Failed to update cursor: " + e);
512 }
513 }
514 static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException;
515
516 public int getMinCursorSize() {
517 return getSystemMetrics(SM_CXCURSOR);
518 }
519
520 public int getMaxCursorSize() {
521 return getSystemMetrics(SM_CXCURSOR);
522 }
523
524 static native int getSystemMetrics(int index);
525
526 private static native long getDllInstance();
527
528 private long getHwnd() {
529 return hwnd;
530 }
531
532 private long getHdc() {
533 return hdc;
534 }
535
536 private static native long getDC(long hwnd);
537 private static native long getDesktopWindow();
538 private static native long getForegroundWindow();
539
540 static void centerCursor(long hwnd) {
541 if (getForegroundWindow() != hwnd && !hasParent)
542 return;
543 getGlobalClientRect(hwnd, rect);
544 int local_offset_x = rect.left;
545 int local_offset_y = rect.top;
546 /* -- This is wrong on multi-monitor setups
547 getGlobalClientRect(getDesktopWindow(), rect2);
548 Rect.intersect(rect, rect2, rect);
549 */
550 int center_x = (rect.left + rect.right)/2;
551 int center_y = (rect.top + rect.bottom)/2;
552 nSetCursorPosition(center_x, center_y);
553 int local_x = center_x - local_offset_x;
554 int local_y = center_y - local_offset_y;
555 if (current_display != null)
556 current_display.setMousePosition(local_x, transformY(hwnd, local_y));
557 }
558
559 private void setMousePosition(int x, int y) {
560 if (mouse != null)
561 mouse.setPosition(x, y);
562 }
563
564 /* Keyboard */
565 public void createKeyboard() throws LWJGLException {
566 keyboard = new WindowsKeyboard(getHwnd());
567 }
568
569 public void destroyKeyboard() {
570 keyboard.destroy();
571 keyboard = null;
572 }
573
574 public void pollKeyboard(ByteBuffer keyDownBuffer) {
575 keyboard.poll(keyDownBuffer);
576 }
577
578 public void readKeyboard(ByteBuffer buffer) {
579 keyboard.read(buffer);
580 }
581
582 // public native int isStateKeySet(int key);
583
584 public static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
585
586 public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
587 return doCreateCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
588 }
589
590 static Object doCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
591 return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
592 }
593
594 public void destroyCursor(Object cursorHandle) {
595 doDestroyCursor(cursorHandle);
596 }
597 static native void doDestroyCursor(Object cursorHandle);
598
599 public int getPbufferCapabilities() {
600 try {
601 // Return the capabilities of a minimum pixel format
602 return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false));
603 } catch (LWJGLException e) {
604 LWJGLUtil.log("Exception occurred while determining pbuffer capabilities: " + e);
605 return 0;
606 }
607 }
608 private native int nGetPbufferCapabilities(PixelFormat format) throws LWJGLException;
609
610 public boolean isBufferLost(PeerInfo handle) {
611 return ((WindowsPbufferPeerInfo)handle).isBufferLost();
612 }
613
614 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
615 IntBuffer pixelFormatCaps,
616 IntBuffer pBufferAttribs) throws LWJGLException {
617 return new WindowsPbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs);
618 }
619
620 public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
621 ((WindowsPbufferPeerInfo)handle).setPbufferAttrib(attrib, value);
622 }
623
624 public void bindTexImageToPbuffer(PeerInfo handle, int buffer) {
625 ((WindowsPbufferPeerInfo)handle).bindTexImageToPbuffer(buffer);
626 }
627
628 public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
629 ((WindowsPbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer);
630 }
631
632 private void freeSmallIcon() {
633 if (small_icon != 0) {
634 destroyIcon(small_icon);
635 small_icon = 0;
636 }
637 }
638
639 private void freeLargeIcon() {
640 if (large_icon != 0) {
641 destroyIcon(large_icon);
642 large_icon = 0;
643 }
644 }
645
646 /**
647 * Sets one or more icons for the Display.
648 * <ul>
649 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
650 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
651 * <li>Mac OS X should be supplied one 128x128 icon</li>
652 * </ul>
653 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
654 *
655 * @param icons Array of icons in RGBA mode
656 * @return number of icons used.
657 */
658 public int setIcon(ByteBuffer[] icons) {
659 boolean done_small = false;
660 boolean done_large = false;
661 int used = 0;
662
663 int small_icon_size = 16;
664 int large_icon_size = 32;
665 for (int i=0;i<icons.length;i++) {
666 int size = icons[i].limit() / 4;
667
668 if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) {
669 freeSmallIcon();
670 small_icon = createIcon(small_icon_size, small_icon_size, icons[i].asIntBuffer());
671 sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_icon);
672 used++;
673 done_small = true;
674 }
675 if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) {
676 freeLargeIcon();
677 large_icon = createIcon(large_icon_size, large_icon_size, icons[i].asIntBuffer());
678 sendMessage(hwnd, WM_SETICON, ICON_BIG, large_icon);
679 used++;
680 done_large = true;
681 }
682 }
683
684 return used;
685 }
686 private static native long createIcon(int width, int height, IntBuffer icon);
687 private static native void destroyIcon(long handle);
688 private static native long sendMessage(long hwnd, long msg, long wparam, long lparam);
689
690 private void handleMouseButton(int button, int state, long millis) {
691 if (mouse != null) {
692 mouse.handleMouseButton((byte)button, (byte)state, millis);
693
694 // need to capture?
695 if (captureMouse == -1 && button != -1 && state == 1) {
696 captureMouse = button;
697 nSetCapture(hwnd);
698 }
699
700 // done with capture?
701 if(captureMouse != -1 && button == captureMouse && state == 0) {
702 captureMouse = -1;
703 nReleaseCapture();
704 }
705 }
706
707 if (parent != null && !isFocused) {
708 setFocus(getHwnd());
709 }
710 }
711
712 private boolean shouldGrab() {
713 return !isMinimized && isFocused && Mouse.isGrabbed();
714 }
715
716 private void handleMouseMoved(int x, int y, long millis) {
717 if (mouse != null) {
718 mouse.handleMouseMoved(x, y, millis, shouldGrab());
719 }
720 }
721
722 private static native long nSetCapture(long hwnd);
723 private static native boolean nReleaseCapture();
724
725 private void handleMouseScrolled(int amount, long millis) {
726 if (mouse != null)
727 mouse.handleMouseScrolled(amount, millis);
728 }
729
730 private static native void getClientRect(long hwnd, IntBuffer rect);
731
732 private void handleChar(long wParam, long lParam, long millis) {
733 byte previous_state = (byte)((lParam >>> 30) & 0x1);
734 byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
735 boolean repeat = state == previous_state;
736 if (keyboard != null)
737 keyboard.handleChar((int)(wParam & 0xFF), millis, repeat);
738 }
739
740 private void handleKeyButton(long wParam, long lParam, long millis) {
741 byte previous_state = (byte)((lParam >>> 30) & 0x1);
742 byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
743 boolean repeat = state == previous_state; // Repeat message
744 byte extended = (byte)((lParam >>> 24) & 0x1);
745 int scan_code = (int)((lParam >>> 16) & 0xFF);
746 if (keyboard != null) {
747 keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
748
749 if(captureMouse != -1 && keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
750 nReleaseCapture();
751 captureMouse = -1;
752 }
753 }
754 }
755
756 private static int transformY(long hwnd, int y) {
757 getClientRect(hwnd, rect_buffer);
758 rect.copyFromBuffer(rect_buffer);
759 return (rect.bottom - rect.top) - 1 - y;
760 }
761
762 private static native void clientToScreen(long hwnd, IntBuffer point);
763
764 private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
765 if (current_display != null)
766 return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
767 else
768 return defWindowProc(hwnd, msg, wParam, lParam);
769 }
770
771 private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam);
772
773 private void checkCursorState() {
774 updateClipping();
775 }
776
777 private void updateClipping() {
778 if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && (getForegroundWindow() == getHwnd() || hasParent)) {
779 try {
780 setupCursorClipping(getHwnd());
781 } catch (LWJGLException e) {
782 LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage());
783 }
784 } else {
785 resetCursorClipping();
786 }
787 }
788
789 private void setMinimized(boolean m) {
790 isMinimized = m;
791 checkCursorState();
792 }
793
794 private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
795 switch (msg) {
796 // disable screen saver and monitor power down messages which wreak havoc
797 case WM_ACTIVATE:
798 switch ((int)wParam) {
799 case WA_ACTIVE:
800 case WA_CLICKACTIVE:
801 appActivate(true);
802 break;
803 case WA_INACTIVE:
804 appActivate(false);
805 break;
806 }
807 return 0;
808 case WM_SIZE:
809 switch ((int)wParam) {
810 case SIZE_RESTORED:
811 case SIZE_MAXIMIZED:
812 setMinimized(false);
813 break;
814 case SIZE_MINIMIZED:
815 setMinimized(true);
816 break;
817 }
818 return defWindowProc(hwnd, msg, wParam, lParam);
819 case WM_KILLFOCUS:
820 appActivate(false);
821 return 0;
822 case WM_SETFOCUS:
823 appActivate(true);
824 return 0;
825 case WM_MOUSEMOVE:
826 int xPos = (int)(short)(lParam & 0xFFFF);
827 int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
828 handleMouseMoved(xPos, yPos, millis);
829 checkCursorState();
830 mouseInside = true;
831 if(!trackingMouse) {
832 trackingMouse = nTrackMouseEvent(hwnd);
833 }
834 return 0;
835 case WM_MOUSEWHEEL:
836 int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
837 handleMouseScrolled(dwheel, millis);
838 return 0;
839 case WM_LBUTTONDOWN:
840 handleMouseButton(0, 1, millis);
841 return 0;
842 case WM_LBUTTONUP:
843 handleMouseButton(0, 0, millis);
844 return 0;
845 case WM_RBUTTONDOWN:
846 handleMouseButton(1, 1, millis);
847 return 0;
848 case WM_RBUTTONUP:
849 handleMouseButton(1, 0, millis);
850 return 0;
851 case WM_MBUTTONDOWN:
852 handleMouseButton(2, 1, millis);
853 return 0;
854 case WM_MBUTTONUP:
855 handleMouseButton(2, 0, millis);
856 return 0;
857 case WM_SYSCHAR:
858 case WM_CHAR:
859 handleChar(wParam, lParam, millis);
860 return 0;
861 case WM_SYSKEYUP:
862 /* Fall through */
863 case WM_KEYUP:
864 // SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN
865 if (wParam == WindowsKeycodes.VK_SNAPSHOT && keyboard != null &&
866 !keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_SYSRQ)) {
867 // Set key state to pressed
868 long fake_lparam = lParam & ~(1 << 31);
869 // Set key previous state to released
870 fake_lparam = fake_lparam & ~(1 << 30);
871 handleKeyButton(wParam, fake_lparam, millis);
872 }
873 /* Fall through */
874 case WM_SYSKEYDOWN:
875 /* Fall through */
876 case WM_KEYDOWN:
877 handleKeyButton(wParam, lParam, millis);
878 return defWindowProc(hwnd, msg, wParam, lParam);
879 case WM_QUIT:
880 close_requested = true;
881 return 0;
882 case WM_SYSCOMMAND:
883 switch ((int)(wParam & 0xfff0)) {
884 case SC_KEYMENU:
885 case SC_MOUSEMENU:
886 case SC_SCREENSAVE:
887 case SC_MONITORPOWER:
888 return 0;
889 case SC_CLOSE:
890 close_requested = true;
891 return 0;
892 default:
893 break;
894 }
895 return defWindowProc(hwnd, msg, wParam, lParam);
896 case WM_PAINT:
897 is_dirty = true;
898 return defWindowProc(hwnd, msg, wParam, lParam);
899 case WM_MOUSELEAVE:
900 mouseInside = false;
901 trackingMouse = false;
902 return defWindowProc(hwnd, msg, wParam, lParam);
903 case WM_CANCELMODE:
904 nReleaseCapture();
905 /* fall through */
906 case WM_CAPTURECHANGED:
907 if(captureMouse != -1) {
908 handleMouseButton(captureMouse, 0, millis);
909 captureMouse = -1;
910 }
911 return 0;
912 default:
913 return defWindowProc(hwnd, msg, wParam, lParam);
914 }
915 }
916
917 public int getWidth() {
918 return Display.getDisplayMode().getWidth();
919 }
920
921 public int getHeight() {
922 return Display.getDisplayMode().getHeight();
923 }
924
925 private int firstMouseButtonDown() {
926 for(int i=0; i<Mouse.getButtonCount(); i++) {
927 if(Mouse.isButtonDown(i)) {
928 return i;
929 }
930 }
931 return -1;
932 }
933
934 private native boolean nTrackMouseEvent(long hwnd);
935
936 public boolean isInsideWindow() {
937 return mouseInside;
938 }
939
940 private static final class Rect {
941 public int top;
942 public int bottom;
943 public int left;
944 public int right;
945
946 public void copyToBuffer(IntBuffer buffer) {
947 buffer.put(0, top).put(1, bottom).put(2, left).put(3, right);
948 }
949
950 public void copyFromBuffer(IntBuffer buffer) {
951 top = buffer.get(0);
952 bottom = buffer.get(1);
953 left = buffer.get(2);
954 right = buffer.get(3);
955 }
956
957 public void offset(int offset_x, int offset_y) {
958 left += offset_x;
959 right += offset_x;
960 top += offset_y;
961 bottom += offset_y;
962 }
963
964 public static void intersect(Rect r1, Rect r2, Rect dst) {
965 dst.top = Math.max(r1.top, r2.top);
966 dst.bottom = Math.min(r1.bottom, r2.bottom);
967 dst.left = Math.max(r1.left, r2.left);
968 dst.right = Math.min(r1.right, r2.right);
969 }
970
971 public String toString() {
972 return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right;
973 }
974 }
975 }
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 java.nio.ByteBuffer;
34
35 import org.lwjgl.LWJGLException;
36
37 /**
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: WindowsDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 */
43 final class WindowsDisplayPeerInfo extends WindowsPeerInfo {
44 private final PixelFormat pixel_format;
45
46 WindowsDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
47 this.pixel_format = pixel_format;
48 GLContext.loadOpenGLLibrary();
49 }
50
51 PixelFormat getPixelFormat() {
52 return pixel_format;
53 }
54
55 void initDC(long hwnd, long hdc) throws LWJGLException {
56 nInitDC(getHandle(), hwnd, hdc);
57 }
58 private static native void nInitDC(ByteBuffer peer_info_handle, long hwnd, long hdc);
59
60 protected void doLockAndInitHandle() throws LWJGLException {
61 // NO-OP
62 }
63
64 protected void doUnlock() throws LWJGLException {
65 // NO-OP
66 }
67
68 public void destroy() {
69 super.destroy();
70 GLContext.unloadOpenGLLibrary();
71 }
72 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 final class WindowsFileVersion {
38 private final int product_version_ms;
39 private final int product_version_ls;
40
41 WindowsFileVersion(int product_version_ms, int product_version_ls) {
42 this.product_version_ms = product_version_ms;
43 this.product_version_ls = product_version_ls;
44 }
45
46 public String toString() {
47 int f1 = (product_version_ms >> 16) & 0xFFFF;
48 int f2 = product_version_ms & 0xFFFF;
49 int f3 = (product_version_ls >> 16) & 0xFFFF;
50 int f4 = product_version_ls & 0xFFFF;
51 return f1 + "." + f2 + "." + f3 + "." + f4;
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.opengl;
32
33 /**
34 * This is the Windows implementation of the Keyboard.
35 * @author elias_naur
36 */
37
38 import java.nio.ByteBuffer;
39 import java.nio.CharBuffer;
40
41 import org.lwjgl.BufferUtils;
42 import org.lwjgl.LWJGLException;
43 import org.lwjgl.input.Keyboard;
44
45 final class WindowsKeyboard {
46 private final static int MAPVK_VK_TO_VSC = 0;
47
48 private final static int BUFFER_SIZE = 50;
49
50 private final long hwnd;
51 private final ByteBuffer keyboard_state;
52 private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
53 private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE);
54 private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
55
56 private boolean grabbed;
57
58 private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR
59 private int retained_key_code;
60 private byte retained_state;
61 private int retained_char;
62 private long retained_millis;
63 private boolean retained_repeat;
64
65 WindowsKeyboard(long hwnd) throws LWJGLException {
66 this.hwnd = hwnd;
67 keyboard_state = BufferUtils.createByteBuffer(256);
68 }
69 private static native boolean isWindowsNT();
70
71 public void destroy() {
72 }
73
74 boolean isKeyDown(int lwjgl_keycode) {
75 return key_down_buffer[lwjgl_keycode] == 1;
76 }
77
78 public void grab(boolean grab) {
79 if(grab) {
80 if (!grabbed) {
81 grabbed = true;
82 }
83 } else {
84 if (grabbed) {
85 grabbed = false;
86 }
87 }
88 }
89
90 public void poll(ByteBuffer keyDownBuffer) {
91 int old_position = keyDownBuffer.position();
92 keyDownBuffer.put(key_down_buffer);
93 keyDownBuffer.position(old_position);
94 }
95
96 private static native int MapVirtualKey(int uCode, int uMapType);
97 private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags);
98 private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags);
99 private static native int GetKeyboardState(ByteBuffer lpKeyState);
100 private static native int GetKeyState(int virt_key);
101
102 private void putEvent(int keycode, byte state, int ch, long millis, boolean repeat) {
103 tmp_event.clear();
104 tmp_event.putInt(keycode).put(state).putInt(ch).putLong(millis*1000000).put(repeat ? (byte)1 : (byte)0);
105 tmp_event.flip();
106 event_queue.putEvent(tmp_event);
107 }
108
109 private boolean checkShiftKey(int virt_key, byte state) {
110 int key_state = (GetKeyState(virt_key) >>> 15) & 0x1;
111 int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key);
112 return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state);
113 }
114
115 private int translateShift(int scan_code, byte state) {
116 if (checkShiftKey(WindowsKeycodes.VK_LSHIFT, state)) {
117 return WindowsKeycodes.VK_LSHIFT;
118 } else if (checkShiftKey(WindowsKeycodes.VK_RSHIFT, state)) {
119 return WindowsKeycodes.VK_RSHIFT;
120 } else {
121 if (scan_code== 0x2A)
122 return WindowsKeycodes.VK_LSHIFT;
123 else {
124 if (scan_code == 0x36)
125 return WindowsKeycodes.VK_RSHIFT;
126 else
127 return WindowsKeycodes.VK_LSHIFT;
128 }
129 }
130 }
131
132 private int translateExtended(int virt_key, int scan_code, byte state, boolean extended) {
133 switch (virt_key) {
134 case WindowsKeycodes.VK_SHIFT:
135 return translateShift(scan_code, state);
136 case WindowsKeycodes.VK_CONTROL:
137 return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL;
138 case WindowsKeycodes.VK_MENU:
139 return extended ? WindowsKeycodes.VK_RMENU : WindowsKeycodes.VK_LMENU;
140 default:
141 return virt_key;
142 }
143 }
144
145 private void flushRetained() {
146 if (has_retained_event) {
147 has_retained_event = false;
148 putEvent(retained_key_code, retained_state, retained_char, retained_millis, retained_repeat);
149 }
150 }
151
152 public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) {
153 virt_key = translateExtended(virt_key, scan_code, event_state, extended);
154 flushRetained();
155 has_retained_event = true;
156 int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key);
157 if (keycode < key_down_buffer.length)
158 key_down_buffer[keycode] = event_state;
159 retained_key_code = keycode;
160 retained_state = event_state;
161 retained_millis = millis;
162 retained_char = 0;
163 retained_repeat = repeat;
164 }
165
166 public void handleChar(int event_char, long millis, boolean repeat) {
167 if (has_retained_event && retained_char != 0)
168 flushRetained();
169 if (!has_retained_event) {
170 putEvent(0, (byte)0, event_char, millis, repeat);
171 } else
172 retained_char = event_char;
173 }
174
175 public void read(ByteBuffer buffer) {
176 flushRetained();
177 event_queue.copyEvents(buffer);
178 }
179 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * @author elias_naur
35 */
36
37 import org.lwjgl.input.Keyboard;
38
39 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 */
47
48 /*
49 * 0x07 : unassigned
50 */
51
52 public final static int VK_BACK = 0x08;
53 public final static int VK_TAB = 0x09;
54
55 /*
56 * 0x0A - 0x0B : reserved
57 */
58
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;
99 /*
100 * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
101 * 0x40 : unassigned
102 * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
103 */
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;
145 /*
146 * 0x5E : reserved;
147 */
148
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;
191
192 /*
193 * 0x88 - 0x8F : unassigned;
194 */
195
196 public final static int VK_NUMLOCK = 0x90;
197 public final static int VK_SCROLL = 0x91;
198
199 /*
200 * NEC PC-9800 kbd definitions
201 */
202 public final static int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad
203 /*
204 * Fujitsu/OASYS kbd definitions
205 */
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
211
212 /*
213 * 0x97 - 0x9F : unassigned
214 */
215
216 /*
217 * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
218 * Used only as parameters to GetAsyncKeyState() and GetKeyState().
219 * No other API or message will distinguish left and right keys in this way.
220 */
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;
247
248 /*
249 * 0xB8 - 0xB9 : reserved
250 */
251
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
259
260 /*
261 * 0xC1 - 0xD7 : reserved
262 */
263
264 /*
265 * 0xD8 - 0xDA : unassigned
266 */
267
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;
273
274 /*
275 * 0xE0 : reserved
276 */
277
278 /*
279 * Various extended or enhanced keyboards
280 */
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;
292
293 /*
294 * 0xE8 : unassigned
295 */
296
297 /*
298 * Nokia/Ericsson definitions
299 */
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;
323
324 public static int mapVirtualKeyToLWJGLCode(int virt_key) {
325 switch (virt_key) {
326 case VK_ESCAPE:
327 return Keyboard.KEY_ESCAPE;
328 case VK_1:
329 return Keyboard.KEY_1;
330 case VK_2:
331 return Keyboard.KEY_2;
332 case VK_3:
333 return Keyboard.KEY_3;
334 case VK_4:
335 return Keyboard.KEY_4;
336 case VK_5:
337 return Keyboard.KEY_5;
338 case VK_6:
339 return Keyboard.KEY_6;
340 case VK_7:
341 return Keyboard.KEY_7;
342 case VK_8:
343 return Keyboard.KEY_8;
344 case VK_9:
345 return Keyboard.KEY_9;
346 case VK_0:
347 return Keyboard.KEY_0;
348 case VK_OEM_MINUS:
349 return Keyboard.KEY_MINUS;
350 case VK_OEM_PLUS:
351 return Keyboard.KEY_EQUALS;
352 case VK_BACK:
353 return Keyboard.KEY_BACK;
354 case VK_TAB:
355 return Keyboard.KEY_TAB;
356 case VK_Q:
357 return Keyboard.KEY_Q;
358 case VK_W:
359 return Keyboard.KEY_W;
360 case VK_E:
361 return Keyboard.KEY_E;
362 case VK_R:
363 return Keyboard.KEY_R;
364 case VK_T:
365 return Keyboard.KEY_T;
366 case VK_Y:
367 return Keyboard.KEY_Y;
368 case VK_U:
369 return Keyboard.KEY_U;
370 case VK_I:
371 return Keyboard.KEY_I;
372 case VK_O:
373 return Keyboard.KEY_O;
374 case VK_P:
375 return Keyboard.KEY_P;
376 case VK_OEM_4:
377 return Keyboard.KEY_LBRACKET;
378 case VK_OEM_6:
379 return Keyboard.KEY_RBRACKET;
380 case VK_RETURN:
381 return Keyboard.KEY_RETURN;
382 case VK_LCONTROL:
383 return Keyboard.KEY_LCONTROL;
384 case VK_A:
385 return Keyboard.KEY_A;
386 case VK_S:
387 return Keyboard.KEY_S;
388 case VK_D:
389 return Keyboard.KEY_D;
390 case VK_F:
391 return Keyboard.KEY_F;
392 case VK_G:
393 return Keyboard.KEY_G;
394 case VK_H:
395 return Keyboard.KEY_H;
396 case VK_J:
397 return Keyboard.KEY_J;
398 case VK_K:
399 return Keyboard.KEY_K;
400 case VK_L:
401 return Keyboard.KEY_L;
402 case VK_OEM_1:
403 return Keyboard.KEY_SEMICOLON;
404 case VK_OEM_7:
405 return Keyboard.KEY_APOSTROPHE;
406 case VK_OEM_3:
407 case VK_OEM_8:
408 return Keyboard.KEY_GRAVE;
409 case VK_LSHIFT:
410 return Keyboard.KEY_LSHIFT;
411 case VK_OEM_5:
412 return Keyboard.KEY_BACKSLASH;
413 case VK_Z:
414 return Keyboard.KEY_Z;
415 case VK_X:
416 return Keyboard.KEY_X;
417 case VK_C:
418 return Keyboard.KEY_C;
419 case VK_V:
420 return Keyboard.KEY_V;
421 case VK_B:
422 return Keyboard.KEY_B;
423 case VK_N:
424 return Keyboard.KEY_N;
425 case VK_M:
426 return Keyboard.KEY_M;
427 case VK_OEM_COMMA:
428 return Keyboard.KEY_COMMA;
429 case VK_OEM_PERIOD:
430 return Keyboard.KEY_PERIOD;
431 case VK_OEM_2:
432 return Keyboard.KEY_SLASH;
433 case VK_RSHIFT:
434 return Keyboard.KEY_RSHIFT;
435 case VK_MULTIPLY:
436 return Keyboard.KEY_MULTIPLY;
437 case VK_LMENU:
438 return Keyboard.KEY_LMENU;
439 case VK_SPACE:
440 return Keyboard.KEY_SPACE;
441 case VK_CAPITAL:
442 return Keyboard.KEY_CAPITAL;
443 case VK_F1:
444 return Keyboard.KEY_F1;
445 case VK_F2:
446 return Keyboard.KEY_F2;
447 case VK_F3:
448 return Keyboard.KEY_F3;
449 case VK_F4:
450 return Keyboard.KEY_F4;
451 case VK_F5:
452 return Keyboard.KEY_F5;
453 case VK_F6:
454 return Keyboard.KEY_F6;
455 case VK_F7:
456 return Keyboard.KEY_F7;
457 case VK_F8:
458 return Keyboard.KEY_F8;
459 case VK_F9:
460 return Keyboard.KEY_F9;
461 case VK_F10:
462 return Keyboard.KEY_F10;
463 case VK_NUMLOCK:
464 return Keyboard.KEY_NUMLOCK;
465 case VK_SCROLL:
466 return Keyboard.KEY_SCROLL;
467 case VK_NUMPAD7:
468 return Keyboard.KEY_NUMPAD7;
469 case VK_NUMPAD8:
470 return Keyboard.KEY_NUMPAD8;
471 case VK_NUMPAD9:
472 return Keyboard.KEY_NUMPAD9;
473 case VK_SUBTRACT:
474 return Keyboard.KEY_SUBTRACT;
475 case VK_NUMPAD4:
476 return Keyboard.KEY_NUMPAD4;
477 case VK_NUMPAD5:
478 return Keyboard.KEY_NUMPAD5;
479 case VK_NUMPAD6:
480 return Keyboard.KEY_NUMPAD6;
481 case VK_ADD:
482 return Keyboard.KEY_ADD;
483 case VK_NUMPAD1:
484 return Keyboard.KEY_NUMPAD1;
485 case VK_NUMPAD2:
486 return Keyboard.KEY_NUMPAD2;
487 case VK_NUMPAD3:
488 return Keyboard.KEY_NUMPAD3;
489 case VK_NUMPAD0:
490 return Keyboard.KEY_NUMPAD0;
491 case VK_DECIMAL:
492 return Keyboard.KEY_DECIMAL;
493 case VK_F11:
494 return Keyboard.KEY_F11;
495 case VK_F12:
496 return Keyboard.KEY_F12;
497 case VK_F13:
498 return Keyboard.KEY_F13;
499 case VK_F14:
500 return Keyboard.KEY_F14;
501 case VK_F15:
502 return Keyboard.KEY_F15;
503 case VK_KANA:
504 return Keyboard.KEY_KANA;
505 case VK_CONVERT:
506 return Keyboard.KEY_CONVERT;
507 case VK_NONCONVERT:
508 return Keyboard.KEY_NOCONVERT;
509 /* case VK_YEN:
510 return Keyboard.KEY_YEN;
511 case VK_NUMPADEQUALS:
512 return Keyboard.KEY_NUMPADEQUALS;
513 case VK_CIRCUMFLEX:
514 return Keyboard.KEY_CIRCUMFLEX;
515 case VK_AT:
516 return Keyboard.KEY_AT;
517 case VK_COLON:
518 return Keyboard.KEY_COLON;
519 case VK_UNDERLINE:
520 return Keyboard.KEY_UNDERLINE;*/
521 case VK_KANJI:
522 return Keyboard.KEY_KANJI;
523 /* case VK_STOP:
524 return Keyboard.KEY_STOP;
525 case VK_AX:
526 return Keyboard.KEY_AX;
527 case VK_UNLABELED:
528 return Keyboard.KEY_UNLABELED;
529 case VK_NUMPADENTER:
530 return Keyboard.KEY_NUMPADENTER;*/
531 case VK_RCONTROL:
532 return Keyboard.KEY_RCONTROL;
533 case VK_SEPARATOR:
534 return Keyboard.KEY_NUMPADCOMMA;
535 case VK_DIVIDE:
536 return Keyboard.KEY_DIVIDE;
537 case VK_SNAPSHOT:
538 return Keyboard.KEY_SYSRQ;
539 case VK_RMENU:
540 return Keyboard.KEY_RMENU;
541 case VK_PAUSE:
542 return Keyboard.KEY_PAUSE;
543 case VK_HOME:
544 return Keyboard.KEY_HOME;
545 case VK_UP:
546 return Keyboard.KEY_UP;
547 case VK_PRIOR:
548 return Keyboard.KEY_PRIOR;
549 case VK_LEFT:
550 return Keyboard.KEY_LEFT;
551 case VK_RIGHT:
552 return Keyboard.KEY_RIGHT;
553 case VK_END:
554 return Keyboard.KEY_END;
555 case VK_DOWN:
556 return Keyboard.KEY_DOWN;
557 case VK_NEXT:
558 return Keyboard.KEY_NEXT;
559 case VK_INSERT:
560 return Keyboard.KEY_INSERT;
561 case VK_DELETE:
562 return Keyboard.KEY_DELETE;
563 case VK_LWIN:
564 return Keyboard.KEY_LMETA;
565 case VK_RWIN:
566 return Keyboard.KEY_RMETA;
567 case VK_APPS:
568 return Keyboard.KEY_APPS;
569 /* case VK_POWER:
570 return Keyboard.KEY_POWER;*/
571 case VK_SLEEP:
572 return Keyboard.KEY_SLEEP;
573 default:
574 return Keyboard.KEY_NONE;
575 }
576 }
577 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is the Windows implementation of the Mouse.
35 * @author elias_naur
36 */
37
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40
41 import org.lwjgl.BufferUtils;
42 import org.lwjgl.LWJGLException;
43 import org.lwjgl.LWJGLUtil;
44 import org.lwjgl.input.Mouse;
45
46 final class WindowsMouse {
47 private final long hwnd;
48
49 private final int mouse_button_count;
50 private final boolean has_wheel;
51
52 private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE);
53
54 private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE);
55 private final Object blank_cursor;
56
57 private boolean mouse_grabbed;
58 private byte[] button_states;
59 private int accum_dx;
60 private int accum_dy;
61 private int accum_dwheel;
62 private int last_x;
63 private int last_y;
64
65 WindowsMouse(long hwnd) throws LWJGLException {
66 this.hwnd = hwnd;
67 this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS);
68 this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0;
69 this.blank_cursor = createBlankCursor();
70 this.button_states = new byte[mouse_button_count];
71 }
72
73 private Object createBlankCursor() throws LWJGLException {
74 int width = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CXCURSOR);
75 int height = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CYCURSOR);
76 IntBuffer pixels = BufferUtils.createIntBuffer(width*height);
77 return WindowsDisplay.doCreateCursor(width, height, 0, 0, 1, pixels, null);
78 }
79
80 public boolean isGrabbed() {
81 return mouse_grabbed;
82 }
83
84 public boolean hasWheel() {
85 return has_wheel;
86 }
87
88 public int getButtonCount() {
89 return mouse_button_count;
90 }
91
92 public void poll(IntBuffer coord_buffer, ByteBuffer buttons) {
93 for (int i = 0; i < coord_buffer.remaining(); i++)
94 coord_buffer.put(coord_buffer.position() + i, 0);
95 int num_buttons = mouse_button_count;
96 coord_buffer.put(coord_buffer.position() + 2, accum_dwheel);
97 if (num_buttons > button_states.length)
98 num_buttons = button_states.length;
99 for (int j = 0; j < num_buttons; j++) {
100 buttons.put(buttons.position() + j, button_states[j]);
101 }
102 if (isGrabbed()) {
103 coord_buffer.put(coord_buffer.position() + 0, accum_dx);
104 coord_buffer.put(coord_buffer.position() + 1, accum_dy);
105 } else {
106 coord_buffer.put(coord_buffer.position() + 0, last_x);
107 coord_buffer.put(coord_buffer.position() + 1, last_y);
108 }
109 accum_dx = accum_dy = accum_dwheel = 0;
110 }
111
112 private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
113 mouse_event.clear();
114 mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
115 mouse_event.flip();
116 event_queue.putEvent(mouse_event);
117 }
118
119 private void putMouseEvent(byte button, byte state, int dz, long nanos) {
120 if (mouse_grabbed)
121 putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
122 else
123 putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos);
124 }
125
126 public void read(ByteBuffer buffer) {
127 event_queue.copyEvents(buffer);
128 }
129
130 public Object getBlankCursor() {
131 return blank_cursor;
132 }
133
134 public void grab(boolean grab, boolean should_center) {
135 if (grab) {
136 if (!mouse_grabbed) {
137 mouse_grabbed = true;
138 if (should_center) {
139 try {
140 WindowsDisplay.setupCursorClipping(hwnd);
141 } catch (LWJGLException e) {
142 LWJGLUtil.log("Failed to setup cursor clipping: " + e);
143 }
144 centerCursor();
145 }
146 }
147 } else {
148 if (mouse_grabbed) {
149 mouse_grabbed = false;
150 WindowsDisplay.resetCursorClipping();
151 }
152 }
153 event_queue.clearEvents();
154 }
155
156 public void handleMouseScrolled(int event_dwheel, long millis) {
157 accum_dwheel += event_dwheel;
158 putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000);
159 }
160
161 private void centerCursor() {
162 WindowsDisplay.centerCursor(hwnd);
163 }
164
165 public void setPosition(int x, int y) {
166 this.last_x = x;
167 this.last_y = y;
168 }
169
170 public void destroy() {
171 WindowsDisplay.doDestroyCursor(blank_cursor);
172 }
173
174 public void handleMouseMoved(int x, int y, long millis, boolean should_center) {
175 int dx = x - last_x;
176 int dy = y - last_y;
177 if (dx != 0 || dy != 0) {
178 accum_dx += dx;
179 accum_dy += dy;
180 last_x = x;
181 last_y = y;
182 long nanos = millis*1000000;
183 if (mouse_grabbed) {
184 putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
185 if (should_center)
186 centerCursor();
187 } else {
188 putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
189 }
190 }
191 }
192
193 public void handleMouseButton(byte button, byte state, long millis) {
194 putMouseEvent(button, state, 0, millis*1000000);
195 if (button < button_states.length)
196 button_states[button] = state != 0 ? (byte)1 : (byte)0;
197 }
198 }
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 java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.LWJGLException;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 final class WindowsPbufferPeerInfo extends WindowsPeerInfo {
45 WindowsPbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException {
46 nCreate(getHandle(), width, height, pixel_format, pixelFormatCaps, pBufferAttribs);
47 }
48 private static native void nCreate(ByteBuffer handle, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException;
49
50 public boolean isBufferLost() {
51 return nIsBufferLost(getHandle());
52 }
53 private static native boolean nIsBufferLost(ByteBuffer handle);
54
55 public void setPbufferAttrib(int attrib, int value) {
56 nSetPbufferAttrib(getHandle(), attrib, value);
57 }
58 private static native void nSetPbufferAttrib(ByteBuffer handle, int attrib, int value);
59
60 public void bindTexImageToPbuffer(int buffer) {
61 nBindTexImageToPbuffer(getHandle(), buffer);
62 }
63 private static native void nBindTexImageToPbuffer(ByteBuffer handle, int buffer);
64
65 public void releaseTexImageFromPbuffer(int buffer) {
66 nReleaseTexImageFromPbuffer(getHandle(), buffer);
67 }
68 private static native void nReleaseTexImageFromPbuffer(ByteBuffer handle, int buffer);
69
70 public void destroy() {
71 nDestroy(getHandle());
72 }
73 private static native void nDestroy(ByteBuffer handle);
74
75 protected void doLockAndInitHandle() throws LWJGLException {
76 // NO-OP
77 }
78
79 protected void doUnlock() throws LWJGLException {
80 // NO-OP
81 }
82 }
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 java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.LWJGLException;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
43 */
44 abstract class WindowsPeerInfo extends PeerInfo {
45 protected WindowsPeerInfo() {
46 super(createHandle());
47 }
48 private static native ByteBuffer createHandle();
49
50 protected static int choosePixelFormat(long hdc, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
51 return nChoosePixelFormat(hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered);
52 }
53 private static native int nChoosePixelFormat(long hdc, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException;
54 protected static native void setPixelFormat(long hdc, int pixel_format) throws LWJGLException;
55
56 public final long getHdc() {
57 return nGetHdc(getHandle());
58 }
59 private static native long nGetHdc(ByteBuffer handle);
60
61 public final long getHwnd() {
62 return nGetHwnd(getHandle());
63 }
64 private static native long nGetHwnd(ByteBuffer handle);
65 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 /**
34 * This is an interface to the windows registry
35 * @author elias_naur
36 */
37
38 import org.lwjgl.LWJGLException;
39 import org.lwjgl.Sys;
40
41 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;
46
47 static {
48 Sys.initialize();
49 }
50
51 /**
52 * Query the registry value specified by the root key, subkey, value tuple
53 */
54 static String queryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException {
55 switch (root_key) {
56 case HKEY_CLASSES_ROOT:
57 case HKEY_CURRENT_USER:
58 case HKEY_LOCAL_MACHINE:
59 case HKEY_USERS:
60 break;
61 default:
62 throw new IllegalArgumentException("Invalid enum: " + root_key);
63 }
64 return nQueryRegistrationKey(root_key, subkey, value);
65 }
66
67 private static native String nQueryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException;
68 }
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.opengl;
33
34 import java.io.BufferedReader;
35 import java.io.IOException;
36 import java.io.InputStreamReader;
37 import java.util.ArrayList;
38 import java.util.HashMap;
39 import java.util.List;
40 import java.util.Map;
41 import java.util.regex.Pattern;
42 import java.security.AccessController;
43 import java.security.PrivilegedAction;
44
45 /**
46 * Utility for working with the xrandr commmand-line utility. Assumes
47 * xrandr v1.2 or higher.
48 *
49 * @author ryanm
50 */
51 public class XRandR {
52
53 private static Screen[] current;
54
55 private static Map /* <String, Screen[]> */screens;
56
57 private static void populate() {
58 if (screens == null) {
59 screens = new HashMap/* <String, Screen[]> */();
60
61 // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" );
62 // pb.redirectErrorStream();
63 try {
64 // Process p= pb.start();
65 Process p = Runtime.getRuntime().exec(new String[] { "xrandr", "-q"});
66
67 List/* <Screen> */currentList = new ArrayList/* <Screen> */();
68 List/* <Screen> */possibles = new ArrayList/* <Screen> */();
69 String name = null;
70
71 BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
72 String line;
73 while ((line = br.readLine()) != null) {
74 line = line.trim();
75 String[] sa = line.split("\\s+");
76
77 if (sa[1].equals("connected")) {
78 // found a new screen block
79 if (name != null) {
80 screens.put(name, possibles.toArray(new Screen[possibles.size()]));
81 possibles.clear();
82 }
83 name = sa[0];
84
85 // record the current config
86 currentList.add(new Screen(name, sa[2]));
87 } else if (Pattern.matches("\\d*x\\d*", sa[0])) {
88 // found a new mode line
89 possibles.add(new Screen(name, sa[0]));
90 }
91 }
92
93 screens.put(name, possibles.toArray(new Screen[possibles.size()]));
94
95 current = (Screen[]) currentList.toArray(new Screen[currentList.size()]);
96 } catch (IOException e) {
97 e.printStackTrace();
98 }
99 }
100 }
101
102 /**
103 * @return The current screen configuration, or an empty array if
104 * xrandr is not supported
105 */
106 public static Screen[] getConfiguration() {
107 AccessController.doPrivileged(new PrivilegedAction() {
108 public Object run() {
109 populate();
110 return null;
111 }
112 });
113
114 return (Screen[]) current.clone();
115 }
116
117 /**
118 * @param screens
119 * The desired screen set, may not be <code>null</code>
120 */
121 public static void setConfiguration(Screen[]/* ... */screens) {
122 if (screens.length == 0) {
123 throw new IllegalArgumentException("Must specify at least one screen");
124 }
125
126 List/* <String> */cmd = new ArrayList/* <String> */();
127 cmd.add("xrandr");
128
129 // switch off those in the current set not in the new set
130 for (int i = 0; i < current.length; i++) {
131 boolean found = false;
132 for (int j = 0; j < screens.length; j++) {
133 if (screens[j].name.equals(current[i].name)) {
134 found = true;
135 break;
136 }
137 }
138
139 if (!found) {
140 cmd.add("--output");
141 cmd.add(current[i].name);
142 cmd.add("--off");
143 }
144 }
145
146 // set up new set
147 for (int i = 0; i < screens.length; i++) {
148 screens[i].getArgs(cmd);
149 }
150
151 try {
152 // ProcessBuilder pb = new ProcessBuilder( cmd );
153 // pb.redirectErrorStream();
154 // Process p = pb.start();
155 Process p = Runtime.getRuntime().exec((String[]) cmd.toArray(new String[cmd.size()]));
156 // no output is expected, but check anyway
157 BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
158 String line;
159 while ((line = br.readLine()) != null) {
160 System.out.println(line);
161 }
162 current = screens;
163 } catch (IOException e) {
164 e.printStackTrace();
165 }
166
167 }
168
169 /**
170 * @return the name of connected screens, or an empty array if
171 * xrandr is not supported
172 */
173 public static String[] getScreenNames() {
174 populate();
175 return (String[]) screens.keySet().toArray(new String[screens.size()]);
176 }
177
178 /**
179 * @param name
180 * @return the possible resolutions of the named screen, or
181 * <code>null</code> if there is no such screen
182 */
183 public static Screen[] getResolutions(String name) {
184 populate();
185 // clone the array to prevent held copies being altered
186 return (Screen[]) ((Screen[]) screens.get(name)).clone();
187 }
188
189 /**
190 * Encapsulates the configuration of a monitor. Resolution is
191 * fixed, position is mutable
192 *
193 * @author ryanm
194 */
195 public static class Screen implements Cloneable {
196
197 /**
198 * Name for this output
199 */
200 public final String name;
201
202 /**
203 * Width in pixels
204 */
205 public final int width;
206
207 /**
208 * Height in pixels
209 */
210 public final int height;
211
212 /**
213 * Position on the x-axis, in pixels
214 */
215 public int xPos = 0;
216
217 /**
218 * Position on the y-axis, in pixels
219 */
220 public int yPos = 0;
221
222 /**
223 * @param name
224 * name of the screen
225 * @param conf
226 * config string, format either widthxheight or
227 * widthxheight+xPos+yPos
228 */
229 private Screen(String name, String conf) {
230 this.name = name;
231
232 String[] sa = conf.split("\\D");
233 width = Integer.parseInt(sa[0]);
234 height = Integer.parseInt(sa[1]);
235
236 if (sa.length > 2) {
237 xPos = Integer.parseInt(sa[2]);
238 yPos = Integer.parseInt(sa[3]);
239 }
240 }
241
242 private void getArgs(List/* <String> */argList) {
243 argList.add("--output");
244 argList.add(name);
245 argList.add("--mode");
246 argList.add(width + "x" + height);
247 argList.add("--pos");
248 argList.add(xPos + "x" + yPos);
249 }
250
251 // @Override
252 public String toString() {
253 return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos;
254 }
255 }
256 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.DisplayMode;
36
37 /**
38 * <br>
39 * Test class for Display & DisplayMode
40 *
41 * @author Brian Matzon <brian@matzon.dk>
42 * @version $Revision: 2983 $
43 * $Id: DisplayTest.java 2983 2008-04-07 18:36:09Z matzon $
44 */
45 public class DisplayTest {
46
47 /**
48 * Creates a new DisplayTest
49 */
50 public DisplayTest() {
51 }
52
53 /**
54 * Runs the tests
55 */
56 public void executeTest() throws LWJGLException {
57 currentTest();
58 queryModesTest();
59 setDisplayModeTest();
60 setDisplayConfigurationTest();
61 }
62
63 /**
64 * Prints some info about the current mode
65 */
66 private void currentTest() {
67 System.out.println("==== Test Current ====");
68
69 System.out.println("Info about current:");
70 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() + "@" +
75 Display.getDisplayMode().getFrequency() + "Hz");
76 System.out.println("---- Test Current ----");
77 }
78
79 /**
80 * Tests querying for modes
81 */
82 private void queryModesTest() throws LWJGLException {
83 DisplayMode[] modes = null;
84
85 System.out.println("==== Test query ====");
86 System.out.println("Retrieving available displaymodes");
87 modes = Display.getAvailableDisplayModes();
88
89 // no modes check
90 if (modes == null) {
91 System.out.println("FATAL: unable to find any modes!");
92 System.exit(-1);
93 }
94
95 // write some info
96 System.out.println("Found " + modes.length + " modes");
97 System.out.println("The first 5 are:");
98 for(int i=0;i<modes.length; i++) {
99 System.out.println(modes[i]);
100 if (i == 5) {
101 break;
102 }
103 }
104 System.out.println("---- Test query ----");
105 }
106
107
108 /**
109 * Tests setting display modes
110 */
111 private void setDisplayModeTest() throws LWJGLException {
112 DisplayMode mode = null;
113 DisplayMode[] modes = null;
114
115 System.out.println("==== Test setDisplayMode ====");
116 System.out.println("Retrieving available displaymodes");
117 modes = Display.getAvailableDisplayModes();
118
119 // no modes check
120 if (modes == null) {
121 System.out.println("FATAL: unable to find any modes!");
122 System.exit(-1);
123 }
124
125 // find a mode
126 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
136 // no mode check
137 if (mode == null) {
138 System.out.println("error\nFATAL: Unable to find basic mode.");
139 System.exit(-1);
140 }
141
142 // change to mode, and wait a bit
143 System.out.print("Changing to mode...");
144 try {
145 Display.setDisplayMode(mode);
146 Display.setFullscreen(true);
147 Display.create();
148 } catch (Exception e) {
149 System.out.println("error\nFATAL: Error setting mode");
150 System.exit(-1);
151 }
152 System.out.println("done");
153
154 System.out.println("Resolution: " +
155 Display.getDisplayMode().getWidth() + "x" +
156 Display.getDisplayMode().getHeight() + "x" +
157 Display.getDisplayMode().getBitsPerPixel() + "@" +
158 Display.getDisplayMode().getFrequency() + "Hz");
159
160 pause(5000);
161
162 // reset
163 System.out.print("Resetting mode...");
164 try {
165 Display.setFullscreen(false);
166 } catch (LWJGLException e) {
167 e.printStackTrace();
168 }
169 System.out.println("done");
170
171 System.out.println("---- Test setDisplayMode ----");
172 }
173
174 /**
175 * Tests the DisplayConfiguration
176 */
177 private void setDisplayConfigurationTest() {
178 System.out.println("==== Test setDisplayConfigurationTest ====");
179
180 System.out.println("Testing normal setting");
181 changeConfig(1.0f, 0f, 1f);
182
183 System.out.println("Testing gamma settings");
184 changeConfig(5.0f, 0f, 1f);
185 changeConfig(0.5f, 0f, 1f);
186
187 System.out.println("Testing brightness settings");
188 changeConfig(1.0f, -1.0f, 1f);
189 changeConfig(1.0f, -0.5f, 1f);
190 changeConfig(1.0f, 0.5f, 1f);
191 changeConfig(1.0f, 1.0f, 1f);
192
193 System.out.println("Testing contrast settings");
194 changeConfig(1.0f, 0f, 0f);
195 changeConfig(1.0f, 0f, 0.5f);
196 changeConfig(1.0f, 0f, 10000.0f);
197
198 System.out.print("resetting...");
199 try {
200 Display.setFullscreen(false);
201 } catch (LWJGLException e) {
202 e.printStackTrace();
203 }
204 System.out.println("done");
205
206 System.out.println("---- Test setDisplayConfigurationTest ----");
207 }
208
209 /**
210 * Changes the Displat configuration
211 *
212 * @param gamma gamma value to change to
213 * @param brightness brightness value to change to
214 * @param contrast contrast value to change to
215 */
216 private void changeConfig(float gamma, float brightness, float contrast) {
217 try {
218 Display.setDisplayConfiguration(gamma, brightness, contrast);
219 System.out.println("Configuration changed, gamma = " + gamma + " brightness = " + brightness + " contrast = " + contrast);
220 } catch (Exception e) {
221 System.out.println("Failed on: gamma = " + gamma + " brightness = " + brightness + " contrast = " + contrast);
222 }
223 pause(3000);
224 }
225
226 /**
227 * Pause current thread for a specified time
228 *
229 * @param time milliseconds to sleep
230 */
231 private void pause(long time) {
232 int SLEEP_DELAY = 100;
233 for (int i = 0; i < time; i += SLEEP_DELAY) {
234 try {
235 Display.processMessages();
236 Thread.sleep(SLEEP_DELAY);
237 } catch (InterruptedException inte) {
238 }
239 }
240 }
241
242 /**
243 * Tests the Sys class, and serves as basic usage test
244 *
245 * @param args ignored
246 */
247 public static void main(String[] args) throws LWJGLException {
248 new DisplayTest().executeTest();
249 System.exit(0);
250 }
251 }
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;
32
33 import org.lwjgl.Sys;
34 import java.awt.Toolkit;
35
36 /**
37 * <br>
38 * Simple test that just checks that the native library loads
39 *
40 * @author Brian Matzon <brian@matzon.dk>
41 * @version $Revision: 2983 $
42 * $Id: SysTest.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44 public class NativeTest {
45
46 public void invokeSys() {
47 Sys.getVersion();
48 }
49
50 /**
51 * Entry point for test
52 *
53 * @param args ignored
54 */
55 public static void main(String[] args) {
56 // try to "load" awt - work around for headless issue on linux
57 Toolkit.getDefaultToolkit();
58 new NativeTest().invokeSys();
59 System.out.println("OK");
60 }
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36 import org.lwjgl.opengl.Display;
37
38 /**
39 * <br>
40 * Test class for Sys
41 *
42 * @author Brian Matzon <brian@matzon.dk>
43 * @version $Revision: 2983 $
44 * $Id: SysTest.java 2983 2008-04-07 18:36:09Z matzon $
45 */
46 public class SysTest {
47
48 /**
49 * Creates a new SysTest
50 */
51 public SysTest() {
52 }
53
54 /**
55 * Runs the tests
56 */
57 public void executeTest() {
58 testAlert();
59 testDebug();
60 testTimer();
61 testUrl();
62 testClipboard();
63 }
64
65 /**
66 * Tests debug mode
67 */
68 private void testDebug() {
69 System.out.println("==== Test Debug ====");
70 if (LWJGLUtil.DEBUG) {
71 LWJGLUtil.log("Debug is enabled, you should now see output from LWJGL during the following tests.");
72 } else {
73 System.out.println("Debug is not enabled. Please set the org.lwjgl.Sys.debug property to true to enable debugging");
74 System.out.println("Example:\n java -Dorg.lwjgl.util.Debug=true ...");
75 System.out.println("You will not see any debug output in the following tests.");
76 }
77
78 // get some display modes, to force some debug info
79 try {
80 Display.getAvailableDisplayModes();
81 } catch (LWJGLException e) {
82 throw new RuntimeException(e);
83 }
84
85 System.out.println("---- Test Debug ----\n");
86 }
87
88 /**
89 * Tests the timer
90 */
91 private void testTimer() {
92 long resolution = Sys.getTimerResolution();
93 long time = Sys.getTime();
94
95 System.out.println("==== Test Timer ====");
96 System.out.println("Resolution of timer (ticks per second): " + resolution);
97 System.out.println("Current time: " + time);
98 System.out.println("Sleeping for 2 seconds, using Thread.sleep()");
99
100 pause(2000);
101
102 long time2 = Sys.getTime();
103 System.out.println("Current time: " + time2);
104 System.out.println("Actually slept for: " + ((time2 - time) / (float) resolution) + " seconds");
105 System.out.println("---- Test Timer ----\n");
106 }
107
108 /**
109 * Tests the alert
110 */
111 private void testAlert() {
112 System.out.println("==== Test Alert ====");
113
114 System.out.println("Opening native alert window");
115 Sys.alert("SysTest", "Hello World!");
116
117 System.out.println("---- Test Alert ----\n");
118 }
119
120 /**
121 * Tests the openUrl
122 */
123 private void testUrl() {
124 System.out.println("==== Test URL ====");
125
126 System.out.println("Opening a browser window to http://www.lwjgl.org");
127 Sys.openURL("http://www.lwjgl.org");
128
129 System.out.println("---- Test URL ----\n");
130 }
131
132 /**
133 * Busy waits for a specified number of seconds
134 *
135 * @param priority Priority to busy wait in
136 * @param seconds Number of seconds to busy wait
137 * @param message Message to print to user
138 */
139 private void busyWait(int priority, int seconds, String message) {
140 long future = Sys.getTime() + (Sys.getTimerResolution() * seconds);
141
142 System.out.print(message);
143
144 // waste some cycles
145 while (Sys.getTime() < future) {
146 }
147
148 System.out.println("done");
149 }
150
151 /**
152 * Pause current thread for a specified time
153 *
154 * @param time milliseconds to sleep
155 */
156 private void pause(long time) {
157 try {
158 Thread.sleep(time);
159 } catch (InterruptedException inte) {
160 }
161 }
162
163 /**
164 * Tests the clipboard. Helps to have something in it first...
165 */
166 private void testClipboard() {
167 System.out.println("Contents of clipboard: '"+Sys.getClipboard()+"'");
168 }
169
170 /**
171 * Tests the Sys class, and serves as basic usage test
172 *
173 * @param args ignored
174 */
175 public static void main(String[] args) {
176 new SysTest().executeTest();
177 System.exit(0);
178 }
179 }
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;
32
33 import java.io.File;
34
35 import javax.sound.sampled.AudioInputStream;
36 import javax.sound.sampled.AudioSystem;
37
38 import org.lwjgl.LWJGLException;
39 import org.lwjgl.util.WaveData;
40
41 /**
42 * <br>
43 * Test class WaveDataTest
44 *
45 * @author Brian Matzon <brian@matzon.dk>
46 */
47 public class WaveDataTest {
48
49 String filePath = "Footsteps.wav";
50
51 /**
52 * Creates a new DisplayTest
53 */
54 public WaveDataTest() {
55 }
56
57 /**
58 * Runs the tests
59 */
60 public void executeTest() throws LWJGLException {
61 executeCreationTest();
62 executeBrokenCreationTest();
63 executeMidStreamCreationTest();
64 }
65
66
67 private void executeCreationTest() {
68 WaveData wd = WaveData.create(filePath);
69 if(wd != null) {
70 System.out.println("executeCreationTest::success");
71 }
72 }
73
74 private void executeBrokenCreationTest() {
75 WaveData wd = WaveData.create("");
76 if(wd == null) {
77 System.out.println("executeBrokenCreationTest::success");
78 }
79 }
80
81 private void executeStreamCreationTest() {
82 try {
83 AudioInputStream ais = AudioSystem.getAudioInputStream(new File(filePath));
84 WaveData wd = WaveData.create(ais);
85 if(wd == null) {
86 System.out.println("executeMidStreamCreationTest::success");
87 }
88 } catch (Exception e) {
89 e.printStackTrace();
90 }
91 }
92
93 private void executeMidStreamCreationTest() {
94 try {
95
96 AudioInputStream ais = AudioSystem.getAudioInputStream(WaveDataTest.class.getClassLoader().getResource(filePath));
97 int totalSize = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8;
98
99 // skip 1/4 of the stream
100 int skip = totalSize / 4;
101 long skipped = ais.skip(skip);
102
103 WaveData wd = WaveData.create(ais);
104 if(wd == null) {
105 System.out.println("executeMidStreamCreationTest::success");
106 }
107 } catch (Exception e) {
108 e.printStackTrace();
109 }
110 }
111
112 /**
113 * Pause current thread for a specified time
114 *
115 * @param time milliseconds to sleep
116 */
117 private void pause(long time) {
118 try {
119 Thread.sleep(time);
120 } catch (InterruptedException inte) {
121 /* ignored */
122 }
123 }
124
125 /**
126 * Tests the Sys class, and serves as basic usage test
127 *
128 * @param args ignored
129 */
130 public static void main(String[] args) throws LWJGLException {
131 new WaveDataTest().executeTest();
132 System.exit(0);
133 }
134 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.input.Keyboard;
35 import org.lwjgl.opengl.Display;
36 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
38
39 /**
40 * Small class for testing that the Window is creatable
41 * If this class can't run, LWJGL wont work!
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 */
45 public class WindowCreationTest {
46
47 /** Locatable modes */
48 private DisplayMode[] located_modes;
49
50 /** Fixed selectable modes */
51 private DisplayMode[] fixed_modes = new DisplayMode[10];
52
53
54 /** Window position x */
55 private int window_x = 0;
56
57 /** Window position y */
58 private int window_y = 0;
59
60 /** Color being cleared to */
61 private float color = 0f;
62
63 /** Direction moving clearing color */
64 private int direction = 1;
65
66 /** Whether we're running */
67 private boolean running = false;
68
69 /** Whether we're in fullscreen mode */
70 private boolean fullscreen = false;
71
72 /**
73 * Initializes the test
74 * @return true if initialization was successfull
75 */
76 public boolean initialize() {
77 try {
78 // get available modes, and print out
79 located_modes = Display.getAvailableDisplayModes();
80 System.out.println("Found " + located_modes.length + " display modes");
81
82 // get 640x480, 800x600, 1024x768 modes
83 findFixedModes();
84
85 // create default windowed display 640*480 @ 100, 100
86 setDefaultDisplayMode();
87
88 window_x = window_y = 100;
89 Display.setLocation(window_x, window_y);
90
91 Display.create();
92 return true;
93 } catch (LWJGLException le) {
94 le.printStackTrace();
95 }
96 return false;
97 }
98
99 /** Locate fixed modes */
100 private void findFixedModes() {
101 // get 640*480 modes
102 fixed_modes[0] = getDisplayMode(640, 480, 16, -1);
103 fixed_modes[1] = getDisplayMode(640, 480, 24, -1);
104 fixed_modes[2] = getDisplayMode(640, 480, 32, -1);
105
106 // get 800*600*16*60
107 fixed_modes[3] = getDisplayMode(800, 600, 16, -1);
108 fixed_modes[4] = getDisplayMode(800, 600, 24, -1);
109 fixed_modes[5] = getDisplayMode(800, 600, 32, -1);
110
111 // get 1024*768*16*60
112 fixed_modes[6] = getDisplayMode(1024, 768, 16, -1);
113 fixed_modes[7] = getDisplayMode(1024, 768, 24, -1);
114 fixed_modes[8] = getDisplayMode(1024, 768, 32, -1);
115 }
116
117 /**
118 * Executes the test
119 */
120 private void execute() {
121 running = true;
122
123 // wait for user to close window
124 while (!Display.isCloseRequested() && running) {
125
126 // handle input accordingly
127 handleInput();
128
129 // render something
130 render();
131
132 // update display as needed
133 Display.update();
134
135 // no need to run at full speed
136 try {
137 Thread.sleep(100);
138 } catch (Exception e) {
139 e.printStackTrace();
140 }
141 }
142 }
143
144 /**
145 * Destroys any resources used while running test
146 */
147 public void destroy() {
148 // nuke window and get out
149 Display.destroy();
150 }
151
152 /**
153 * Handles the input
154 */
155 private void handleInput() {
156 while (Keyboard.next()) {
157
158 // we only want key down events
159 if (!Keyboard.getEventKeyState()) {
160 continue;
161 }
162
163 // check for exit
164 if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
165 running = false;
166 }
167
168 // check for listing of modes
169 if (Keyboard.getEventKey() == Keyboard.KEY_L) {
170 for(int i=0;i<fixed_modes.length; i++) {
171 System.out.println("[" + i + "]: " + fixed_modes[i]);
172 }
173 }
174
175 // check for display mode
176 // ================================
177 if (Keyboard.getEventKey() == Keyboard.KEY_0) { setMode(0); }
178 if (Keyboard.getEventKey() == Keyboard.KEY_1) { setMode(1); }
179 if (Keyboard.getEventKey() == Keyboard.KEY_2) { setMode(2); }
180 if (Keyboard.getEventKey() == Keyboard.KEY_3) { setMode(3); }
181 if (Keyboard.getEventKey() == Keyboard.KEY_4) { setMode(4); }
182 if (Keyboard.getEventKey() == Keyboard.KEY_5) { setMode(5); }
183 if (Keyboard.getEventKey() == Keyboard.KEY_6) { setMode(6); }
184 if (Keyboard.getEventKey() == Keyboard.KEY_7) { setMode(7); }
185 if (Keyboard.getEventKey() == Keyboard.KEY_8) { setMode(8); }
186 // --------------------------------
187
188 // check for window move
189 // ================================
190 if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) {
191 if (!Display.isFullscreen()) {
192 Display.setLocation(window_x -= 10, window_y);
193 }
194 }
195
196 if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) {
197 if (!Display.isFullscreen()) {
198 Display.setLocation(window_x += 10, window_y);
199 }
200 }
201
202 if (Keyboard.getEventKey() == Keyboard.KEY_UP) {
203 if (!Display.isFullscreen()) {
204 Display.setLocation(window_x, window_y -= 10);
205 }
206 }
207
208 if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) {
209 if (!Display.isFullscreen()) {
210 Display.setLocation(window_x, window_y += 10);
211 }
212 }
213 // --------------------------------
214
215 // check for fullscreen
216 if (Keyboard.getEventKey() == Keyboard.KEY_F) {
217 try {
218 if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ||
219 Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
220 System.out.println("Performing Display.destroy()/create() cycle");
221 DisplayMode saved_mode = Display.getDisplayMode();
222 Display.destroy();
223 Display.setDisplayMode(saved_mode);
224 Display.setFullscreen(fullscreen = !fullscreen);
225 Display.create();
226 } else
227 Display.setFullscreen(fullscreen = !fullscreen);
228 } catch (LWJGLException lwjgle) {
229 lwjgle.printStackTrace();
230 }
231 }
232 }
233 }
234
235 private void setMode(int mode) {
236 if(fixed_modes[mode] == null) {
237 System.out.println("Unable to set mode. Not valid: " + mode);
238 return;
239 }
240
241 try {
242 Display.setDisplayMode(fixed_modes[mode]);
243 } catch (LWJGLException le) {
244 le.printStackTrace();
245 System.out.println("Exception while setting mode: " + fixed_modes[mode]);
246 }
247 }
248
249 /**
250 *
251 */
252 private void render() {
253 GL11.glClearColor(color, color, color, 1f);
254 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
255
256 color += direction * .05f;
257
258 if (color > 1f) {
259 color = 1f;
260 direction = -1 * direction;
261 } else if (color < 0f) {
262 direction = -1 * direction;
263 color = 0f;
264 }
265 }
266
267 /**
268 * Main entry point
269 *
270 * @param args ignored params to app
271 */
272 public static void main(String[] args) throws LWJGLException {
273
274 System.out.println("The following keys are available:\n" +
275 "ESCAPE:\t\tExit test\n" +
276 "ARROW Keys:\tMove window when in non-fullscreen mode\n" +
277 "L:\t\tList selectable display modes\n" +
278 "0-8:\t\tSelection of display modes\n" +
279 "F:\t\tToggle fullscreen\n" +
280 "SHIFT-F:\tToggle fullscreen with Display.destroy()/create() cycle");
281
282 WindowCreationTest wct = new WindowCreationTest();
283 if (wct.initialize()) {
284 wct.execute();
285 wct.destroy();
286 }
287 System.exit(0);
288 }
289
290 /**
291 * Sets the display mode for fullscreen mode
292 */
293 protected boolean setDefaultDisplayMode() {
294 try {
295 // get modes
296 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, -1, -1);
297
298 org.lwjgl.util.Display.setDisplayMode(dm, new String[] { "width=" + 640, "height=" + 480, "freq=" + 60,
299 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()});
300 return true;
301 } catch (Exception e) {
302 e.printStackTrace();
303 }
304 return false;
305 }
306
307 /**
308 * Gets a specific display mode
309 */
310 private DisplayMode getDisplayMode(int width, int height, int bpp, int freq) {
311 DisplayMode[] dm = null;
312 try {
313 dm = org.lwjgl.util.Display.getAvailableDisplayModes(width, height, width, height, bpp, bpp, freq, freq);
314 if(dm == null || dm.length == 0) {
315 System.out.println("Problem retrieving mode with " + width + "x" + height + "x" + bpp + "@" + freq);
316 }
317 } catch (LWJGLException le) {
318 le.printStackTrace();
319 System.out.println("Problem retrieving mode with " + width + "x" + height + "x" + bpp + "@" + freq);
320 }
321 return (dm != null && dm.length != 0) ? dm[0] : 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.test.applet;
32
33 import java.applet.Applet;
34 import java.awt.BorderLayout;
35 import java.awt.Canvas;
36
37 public class AppletLoaderTest extends Applet {
38
39 Test test = null;
40
41 public void destroy() {
42 super.destroy();
43 System.out.println("*** destroy ***");
44 }
45
46 public void start() {
47 super.start();
48 System.out.println("*** start ***");
49 }
50
51 public void stop() {
52 super.stop();
53 System.out.println("*** stop ***");
54 test.stop();
55 }
56
57 public void init() {
58 System.out.println("*** init ***");
59
60 setLayout(new BorderLayout());
61 try {
62 test = (Test) Class.forName(getParameter("test")).newInstance();
63 Canvas canvas = (Canvas) test;
64 canvas.setSize(getWidth(), getHeight());
65 add(canvas);
66 } catch (Exception e) {
67 e.printStackTrace();
68 }
69 test.start();
70 }
71 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.applet;
32
33 import java.awt.Canvas;
34
35 import org.lwjgl.LWJGLException;
36 import org.lwjgl.input.Controllers;
37
38 public class ControllersTest extends Canvas implements Test {
39 public void start() {
40 try {
41 Controllers.create();
42 } catch (LWJGLException e) {
43 e.printStackTrace();
44 return;
45 }
46 System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
47 }
48
49 public void stop() {
50 }
51 }
0 package org.lwjgl.test.applet;
1
2 import java.applet.Applet;
3 import java.awt.BorderLayout;
4 import java.awt.Canvas;
5 import java.nio.FloatBuffer;
6 import org.lwjgl.BufferUtils;
7 import org.lwjgl.LWJGLException;
8 import org.lwjgl.opengl.ARBTransposeMatrix;
9 import org.lwjgl.opengl.Display;
10 import org.lwjgl.input.Keyboard;
11 import org.lwjgl.input.Mouse;
12 import org.lwjgl.opengl.GL11;
13 import org.lwjgl.opengl.GLContext;
14
15 public class GearsApplet extends Applet {
16
17 /** The Canvas where the LWJGL Display is added */
18 Canvas display_parent;
19
20 /** Thread which runs the main game loop */
21 Thread gameThread;
22
23 /** is the game loop running */
24 boolean running = false;
25
26 /** variables used to rotate the view */
27 private float view_rotx = 20.0f;
28 private float view_roty = 30.0f;
29 private float view_rotz = 0.0f;
30
31 private int gear1;
32 private int gear2;
33 private int gear3;
34 private float angle;
35
36 boolean keyDown = false;
37
38 private int prevMouseX, prevMouseY;
39 private boolean mouseButtonDown = false;
40
41
42 /**
43 * Once the Canvas is created its add notify method will call this method to
44 * start the LWJGL Display and game loop in another thread.
45 */
46 public void startLWJGL() {
47 gameThread = new Thread() {
48 public void run() {
49 running = true;
50 try {
51 Display.setParent(display_parent);
52 //Display.setVSyncEnabled(true);
53 Display.create();
54 initGL();
55 } catch (LWJGLException e) {
56 e.printStackTrace();
57 }
58 gameLoop();
59 }
60 };
61 gameThread.start();
62 }
63
64
65 /**
66 * Tell game loop to stop running, after which the LWJGL Display will be destoryed.
67 * The main thread will wait for the Display.destroy() to complete
68 */
69 private void stopLWJGL() {
70 running = false;
71 try {
72 gameThread.join();
73 } catch (InterruptedException e) {
74 e.printStackTrace();
75 }
76 }
77
78 public void start() {
79
80 }
81
82 public void stop() {
83
84 }
85
86 /**
87 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
88 * stopLWJGL() to stop main game loop and to destroy the Display
89 */
90 public void destroy() {
91 remove(display_parent);
92 super.destroy();
93 System.out.println("Clear up");
94 }
95
96 /**
97 * 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
99 * applet is destroyed.
100 */
101 public void init() {
102 setLayout(new BorderLayout());
103 try {
104 display_parent = new Canvas() {
105 public final void addNotify() {
106 super.addNotify();
107 startLWJGL();
108 }
109 public final void removeNotify() {
110 stopLWJGL();
111 super.removeNotify();
112 }
113 };
114 display_parent.setSize(getWidth(),getHeight());
115 add(display_parent);
116 display_parent.setFocusable(true);
117 display_parent.requestFocus();
118 display_parent.setIgnoreRepaint(true);
119 //setResizable(true);
120 setVisible(true);
121 } catch (Exception e) {
122 System.err.println(e);
123 throw new RuntimeException("Unable to create display");
124 }
125 }
126
127 public void gameLoop() {
128 long startTime = System.currentTimeMillis() + 5000;
129 long fps = 0;
130
131 while(running) {
132 angle += 2.0f;
133
134 // draw the gears
135 drawLoop();
136
137 Display.update();
138
139 if (startTime > System.currentTimeMillis()) {
140 fps++;
141 } else {
142 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
143 startTime = System.currentTimeMillis() + 5000;
144 System.out.println(fps + " frames 2 in " + (float) (timeUsed / 1000f) + " seconds = "
145 + (fps / (timeUsed / 1000f)));
146 fps = 0;
147 }
148
149 if (Mouse.isButtonDown(0)) {
150 if (!mouseButtonDown) {
151 prevMouseX = Mouse.getX();
152 prevMouseY= Mouse.getY();
153 }
154 mouseButtonDown = true;
155 }
156 else {
157 mouseButtonDown = false;
158 }
159
160 if (mouseButtonDown) {
161 int x = Mouse.getX();
162 int y = Mouse.getY();
163
164 float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)display_parent.getWidth());
165 float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)display_parent.getHeight());
166
167 prevMouseX = x;
168 prevMouseY = y;
169
170 view_rotx += thetaX;
171 view_roty += thetaY;
172 }
173
174 // F Key Pressed (i.e. released)
175 if (keyDown && !Keyboard.isKeyDown(Keyboard.KEY_F)) {
176 keyDown = false;
177
178 try {
179 if (Display.isFullscreen()) {
180 Display.setFullscreen(false);
181 }
182 else {
183 Display.setFullscreen(true);
184 }
185 } catch (LWJGLException e) {
186 e.printStackTrace();
187 }
188 }
189 }
190
191 Display.destroy();
192 }
193
194 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();
222 }
223
224 protected void initGL() {
225 try {
226 // setup ogl
227 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
228 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
229 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
230 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
231
232 pos.flip();
233 red.flip();
234 green.flip();
235 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);
242
243 /* 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 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);
253 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);
259 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));
267 System.err.println();
268 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
269
270 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
271 // --- not using extensions
272 GL11.glLoadIdentity();
273 } else {
274 // --- using extensions
275 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
276 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
277 0, 0, 1, 0, 0, 0, 0, 1});
278 identityTranspose.flip();
279 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
280 }
281 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 } catch (Exception e) {
287 System.err.println(e);
288 running = false;
289 }
290 }
291
292 /**
293 * Draw a gear wheel. You'll probably want to call this function when
294 * building a display list since we do a lot of trig here.
295 *
296 * @param inner_radius radius of hole at center
297 * @param outer_radius radius at center of teeth
298 * @param width width of gear
299 * @param teeth number of teeth
300 * @param tooth_depth depth of tooth
301 */
302 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
303 int i;
304 float r0, r1, r2;
305 float angle, da;
306 float u, v, len;
307
308 r0 = inner_radius;
309 r1 = outer_radius - tooth_depth / 2.0f;
310 r2 = outer_radius + tooth_depth / 2.0f;
311 da = 2.0f * (float) Math.PI / teeth / 4.0f;
312 GL11.glShadeModel(GL11.GL_FLAT);
313 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
314 /* draw front face */
315 GL11.glBegin(GL11.GL_QUAD_STRIP);
316 for (i = 0; i <= teeth; i++) {
317 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);
320 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),
323 width * 0.5f);
324 }
325 }
326 GL11.glEnd();
327
328 /* draw front sides of teeth */
329 GL11.glBegin(GL11.GL_QUADS);
330 for (i = 0; i < teeth; i++) {
331 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();
338
339 /* draw back face */
340 GL11.glBegin(GL11.GL_QUAD_STRIP);
341 for (i = 0; i <= teeth; i++) {
342 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();
349
350 /* draw back sides of teeth */
351 GL11.glBegin(GL11.GL_QUADS);
352 for (i = 0; i < teeth; i++) {
353 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();
360
361 /* draw outward faces of teeth */
362 GL11.glBegin(GL11.GL_QUAD_STRIP);
363 for (i = 0; i < teeth; i++) {
364 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);
367 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
368 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
369 len = (float) Math.sqrt(u * u + v * v);
370 u /= len;
371 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);
378 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
379 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);
390 /* draw inside radius cylinder */
391 GL11.glBegin(GL11.GL_QUAD_STRIP);
392 for (i = 0; i <= teeth; i++) {
393 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();
399 }
400 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.applet;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.openal.AL;
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.opengl.AWTGLCanvas;
40 import org.lwjgl.opengl.Display;
41 import org.lwjgl.opengl.GL11;
42 import org.lwjgl.util.WaveData;
43
44 public class OpenAL extends AWTGLCanvas implements Test {
45
46 float angle = 0;
47
48 // create 1 buffer and 1 source
49 IntBuffer buffers = BufferUtils.createIntBuffer(1);
50 IntBuffer sources = BufferUtils.createIntBuffer(1);
51
52 public OpenAL() throws LWJGLException {
53
54 try {
55 AL.create();
56 } catch (Exception e) {
57 System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
58 return;
59 }
60
61 Thread t = new Thread() {
62
63 public void run() {
64 while (true) {
65 if (isVisible())
66 repaint();
67 Display.sync(60);
68 }
69 }
70 };
71 t.setDaemon(true);
72 t.start();
73 }
74
75 private void playOpenAL() {
76 int lastError;
77
78 // al generate buffers and sources
79 buffers.position(0).limit(1);
80 AL10.alGenBuffers(buffers);
81 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
82 exit(lastError);
83 }
84
85 sources.position(0).limit(1);
86 AL10.alGenSources(sources);
87 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
88 exit(lastError);
89 }
90
91 // load wave data from buffer
92 WaveData wavefile = WaveData.create(getClass().getClassLoader().getResourceAsStream("Footsteps.wav"));
93
94 //copy to buffers
95 AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate);
96
97 //unload file again
98 wavefile.dispose();
99
100 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
101 exit(lastError);
102 }
103
104 //set up source input
105 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
106 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
107 exit(lastError);
108 }
109
110 //lets loop the sound
111 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
112 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
113 exit(lastError);
114 }
115
116 //play source 0
117 AL10.alSourcePlay(sources.get(0));
118 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
119 exit(lastError);
120 }
121 }
122
123 private void exit(int error) {
124 System.out.println("OpenAL Error: " + AL10.alGetString(error));
125 }
126
127 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);
133
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();
144
145 angle += 1;
146
147 try {
148 swapBuffers();
149 } catch (Exception e) {/*OK*/
150 }
151 }
152
153 public void start() {
154 playOpenAL();
155 }
156
157 public void stop() {
158 int lastError;
159
160 //stop source 0
161 AL10.alSourceStop(sources.get(0));
162 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
163 exit(lastError);
164 }
165
166 //delete buffers and sources
167 sources.position(0).limit(1);
168 AL10.alDeleteSources(sources);
169 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
170 exit(lastError);
171 }
172
173 buffers.position(0).limit(1);
174 AL10.alDeleteBuffers(buffers);
175 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
176 exit(lastError);
177 }
178
179 AL.destroy();
180 }
181 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.applet;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.input.Keyboard;
35 import org.lwjgl.input.Mouse;
36 import org.lwjgl.opengl.AWTGLCanvas;
37 import org.lwjgl.opengl.GL11;
38
39 public class OpenGL extends AWTGLCanvas implements Test {
40
41 float angle = 0;
42 float x;
43 float y;
44
45 public OpenGL() throws LWJGLException {
46 }
47
48 public void initGL() {
49 GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
50 GL11.glLoadIdentity();
51 GL11.glOrtho(0, 640, 0, 480, 1, -1);
52 x = 320;
53 y = 240;
54 GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
55 setVSyncEnabled(true);
56 }
57
58 public void paintGL() {
59 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
60
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();
71
72 angle += 1;
73
74 if (Mouse.isCreated()) {
75 Mouse.poll();
76 while (Mouse.next()) {
77 x += Mouse.getEventDX();
78 y += Mouse.getEventDY();
79 }
80 }
81 if (Keyboard.isCreated()) {
82 Keyboard.poll();
83 }
84 while (Keyboard.isCreated() && Keyboard.next()) {
85 if (Keyboard.getEventKey() != Keyboard.KEY_NONE) {
86 String key_name = Keyboard.getKeyName(Keyboard.getEventKey());
87 if (Keyboard.getEventKeyState()) {
88 switch (Keyboard.getEventKey()) {
89 case Keyboard.KEY_G:
90 Mouse.setGrabbed(!Mouse.isGrabbed());
91 break;
92 default:
93 break;
94 }
95 System.out.println("Pressed: " + key_name);
96 } else
97 System.out.println("Released: " + key_name);
98 }
99 if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE)
100 System.out.println("Typed: " + Keyboard.getEventCharacter());
101 }
102 if (Keyboard.isCreated()) {
103 if (Keyboard.isKeyDown(Keyboard.KEY_UP))
104 y += 5;
105 else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN))
106 y -= 5;
107 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT))
108 x -= 5;
109 else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
110 x += 5;
111 }
112 try {
113 swapBuffers();
114 if (isVisible()) {
115 Thread.yield(); // Helps input responsiveness on linux
116 repaint();
117 }
118 } catch (Exception e) {/*OK*/
119 }
120 }
121
122 public void start() {
123 }
124
125 public void stop() {
126 }
127 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.applet;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.AWTGLCanvas;
35 import org.lwjgl.opengl.GL11;
36
37 public class Speed extends AWTGLCanvas implements Test {
38
39 private float angle = 0;
40 private long startTime = System.currentTimeMillis() + 5000;
41 private long fps = 0;
42
43 public Speed() throws LWJGLException {
44 }
45
46 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);
52
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();
63
64 angle += 1;
65
66 try {
67 swapBuffers();
68 if (isVisible()) {
69 Thread.yield(); // Helps input responsiveness on linux
70 repaint();
71 }
72 } catch (Exception e) {/*OK*/
73 }
74 if (startTime > System.currentTimeMillis()) {
75 fps++;
76 } else {
77 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
78 startTime = System.currentTimeMillis() + 5000;
79 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
80 + (fps / (timeUsed / 1000f)));
81 fps = 0;
82 }
83 }
84
85 public void start() {
86 }
87
88 public void stop() {
89 }
90 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.applet;
32
33
34 public interface Test {
35 public void start();
36 public void stop();
37 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.glu.tessellation;
32
33 import org.lwjgl.opengl.GL11;
34 import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
35
36 public class TessCallback extends GLUtessellatorCallbackAdapter {
37
38 public void begin(int type) {
39 GL11.glBegin(type);
40 }
41
42 public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
43 for (int i=0;i<outData.length;i++) {
44 double[] combined = new double[6];
45 combined[0] = coords[0];
46 combined[1] = coords[1];
47 combined[2] = coords[2];
48 combined[3] = 1;
49 combined[4] = 1;
50 combined[5] = 1;
51
52 outData[i] = new VertexData(combined);
53 }
54 // vertex[0] = coords[0];
55 // vertex[1] = coords[1];
56 // vertex[2] = coords[2];
57 //
58 // for (int i = 3; i < 6; i++)
59 // {
60 // vertex[i] = weight[0] * vertex_data[0][i] +
61 // indent indweight[1] * vertex_data[1][i] +
62 // indent indweight[2] * vertex_data[2][i] +
63 // indent indweight[3] * vertex_data[3][i];
64 // }
65 //
66 // *dataOut = vertex;
67 }
68
69 public void end() {
70 GL11.glEnd();
71 }
72
73 public void vertex(Object vertexData) {
74 VertexData vertex = (VertexData) vertexData;
75
76 GL11.glVertex3d(vertex.data[0], vertex.data[1], vertex.data[2]);
77 GL11.glColor3d(vertex.data[3], vertex.data[4], vertex.data[5]);
78 }
79 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.glu.tessellation;
32 import org.lwjgl.LWJGLException;
33 import org.lwjgl.opengl.Display;
34 import org.lwjgl.opengl.DisplayMode;
35 import org.lwjgl.opengl.GL11;
36 import org.lwjgl.util.glu.GLU;
37 import org.lwjgl.util.glu.GLUtessellator;
38
39 public class TessellationTest {
40 private GLUtessellator tesselator;
41
42 void init()
43 {
44 // Create a new tessellation object
45 tesselator = GLU.gluNewTess();
46
47 // Set callback functions
48 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);
53 }
54
55 void setWindingRule(int windingRule)
56 {
57 // Set the winding rule
58 tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, windingRule);
59 }
60
61 void renderContour(double obj_data[][], int num_vertices)
62 {
63 for (int x = 0; x < num_vertices; x++) //loop through the vertices
64 {
65 tesselator.gluTessVertex(obj_data[x], 0, new VertexData(obj_data[x])); //store the vertex
66 }
67 }
68
69 void beginPolygon()
70 {
71 tesselator.gluTessBeginPolygon(null);
72 }
73
74 void endPolygon()
75 {
76 tesselator.gluTessEndPolygon();
77 }
78
79 void beginContour()
80 {
81 tesselator.gluTessBeginContour();
82 }
83
84 void endContour()
85 {
86 tesselator.gluTessEndContour();
87 }
88
89 void end()
90 {
91 tesselator.gluDeleteTess();
92 }
93
94 private void createDisplay() throws LWJGLException {
95 int width = 300;
96 int height = 300;
97
98 Display.setDisplayMode(new DisplayMode(width,height));
99 Display.create();
100 Display.setVSyncEnabled(true);
101
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);
115
116 GL11.glMatrixMode(GL11.GL_PROJECTION);
117 GL11.glLoadIdentity();
118 GL11.glOrtho(0, width, height, 0, 1, -1);
119 GL11.glMatrixMode(GL11.GL_MODELVIEW);
120 }
121
122 private void loop() {
123 while (true) {
124 render();
125 Display.update();
126 Display.sync(100);
127
128 if (Display.isCloseRequested()) {
129 System.exit(0);
130 }
131 }
132 }
133
134 private void render() {
135 GL11.glTranslatef(150,125,0);
136
137 GL11.glScalef(50,50,1);
138 // first polygon: a star-5 vertices and color information
139 double star[][] = { {0.6f, -0.1f, 0f, 1.0f, 1.0f, 1.0f},
140 {1.35f, 1.4f, 0f, 1.0f, 1.0f, 1.0f},
141 {2.1f, -0.1f, 0f, 1.0f, 1.0f, 1.0f},
142 {0.6f, 0.9f, 0f, 1.0f, 1.0f, 1.0f},
143 {2.1f, 0.9f, 0f, 1.0f, 1.0f, 1.0f} };
144
145 //second polygon: a quad-4 vertices; first contour
146 double quad[][] = { {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f},
147 {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
148 {1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f},
149 {0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f} };
150
151 //second polygon: a triangle-3 vertices; second contour
152 double tri[][] = {{0.3f, 0.3f, 0.0f, 0.0f, 0.0f, 0.0f},
153 {0.7f, 0.3f, 0.0f, 0.0f, 0.0f, 0.0f},
154 {0.5f, 0.7f, 0.0f, 0.0f, 0.0f, 0.0f} };
155
156 // render the first polygon: the textured star
157
158 // set winding rule to positive
159 setWindingRule(GLU.GLU_TESS_WINDING_POSITIVE);
160 beginPolygon();
161 beginContour();
162 renderContour(star, 5);
163 endContour();
164 endPolygon();
165
166 // render the second polygon: triangle cut out of a quad
167
168 GL11.glTranslatef(-2,0,0);
169 // set winding rule to odd
170 setWindingRule(GLU.GLU_TESS_WINDING_ODD);
171 // begin the new polygon
172 beginPolygon();
173 beginContour();
174 renderContour(quad, 4);
175 endContour();
176 beginContour();
177 renderContour(tri, 3);
178 endContour();
179 endPolygon();
180 // delete the tess object
181 end();
182 }
183
184 private void start() throws LWJGLException {
185 createDisplay();
186 init();
187 loop();
188 }
189
190 public static void main(String[] argv) throws LWJGLException {
191 TessellationTest test = new TessellationTest();
192 test.start();
193 }
194 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.glu.tessellation;
32
33 class VertexData {
34 public double[] data;
35
36 VertexData(double[] data) {
37 this.data = data;
38 }
39 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.input;
32
33 import java.nio.ByteBuffer;
34 import java.nio.ByteOrder;
35 import java.nio.IntBuffer;
36
37 import org.lwjgl.input.Cursor;
38 import org.lwjgl.input.Keyboard;
39 import org.lwjgl.input.Mouse;
40 import org.lwjgl.opengl.Display;
41 import org.lwjgl.opengl.DisplayMode;
42 import org.lwjgl.opengl.GL11;
43 import org.lwjgl.util.glu.GLU;
44
45 /**
46 *
47 * Tests switching between windowed and fullscreen - including hardware cursor test
48 *
49 * @author Brian Matzon <brian@matzon.dk>
50 * @version $Revision: 2983 $
51 * $Id: HWCursorTest.java 2983 2008-04-07 18:36:09Z matzon $
52 */
53 public class HWCursorTest {
54
55 /** The native cursor */
56 private static Cursor[] cursor = null;
57
58 /** The mouse cursor position */
59 private static int mouse_x;
60 private static int mouse_y;
61 private static int mouse_btn = 0;
62
63 /**
64 * Executes the test
65 */
66 public void execute() {
67 initialize();
68
69 mainLoop();
70
71 cleanup();
72 }
73
74 /**
75 * Sets the display mode for fullscreen mode
76 */
77 protected boolean setDisplayMode() {
78 try {
79 // get modes
80 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
81
82 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
83 "width=" + 640,
84 "height=" + 480,
85 "freq=" + 60,
86 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
87 });
88 return true;
89 } catch (Exception e) {
90 e.printStackTrace();
91 }
92
93 return false;
94 }
95
96 /**
97 * Initializes the test
98 */
99 private void initialize() {
100 try {
101 // start of in windowed mode
102 setDisplayMode();
103 Display.create();
104
105 glInit();
106
107 initNativeCursors();
108
109 } catch (Exception e) {
110 e.printStackTrace();
111 System.exit(-1);
112 }
113 }
114
115 private static void initNativeCursors() throws Exception {
116 if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0) {
117 System.out.println("No HW cursor support!");
118 System.exit(0);
119 }
120
121 cursor = new Cursor[3];
122
123 int cursorImageCount = 1;
124 int cursorWidth = Math.min(64, Cursor.getMaxCursorSize());
125 int cursorHeight = cursorWidth;
126 IntBuffer cursorImages;
127 IntBuffer cursorDelays;
128
129
130 // Create a single cursor
131 // ==================================
132 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
133 cursorDelays = null;
134 for(int j=0; j<cursorWidth; j++) {
135 for(int l=0; l<cursorHeight; l++) {
136 cursorImages.put(0xffffffff);
137 }
138 }
139 cursorImages.flip();
140 cursor[0] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
141 // ----------------------------------
142
143 // Create 3 piece animation
144 // ==================================
145 cursorImageCount = 3;
146 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
147 cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
148 for(int i=0; i<cursorImageCount; i++) {
149
150 // make a colored square with a chocolate center
151 int offColor = 0x00000000;
152 int onColor = 0xffff0000;
153
154 // change color according to cursor
155 if(i == 1) {
156 onColor = 0xff00ff00;
157 } else if (i == 2) {
158 onColor = 0xff0000ff;
159 }
160
161 // calculate size of center
162 int centerSize = (cursorWidth / 5) * (i + 1);
163 int centerLeft = cursorWidth / 2 - centerSize / 2;
164 int centerRight = cursorWidth / 2 + centerSize / 2;
165
166 // go!
167 for(int j=0; j<cursorWidth; j++) {
168 for(int l=0; l<cursorHeight; l++) {
169 if(j >= centerLeft && j < centerRight && l >= centerLeft && l < centerRight) {
170 cursorImages.put(offColor);
171 } else {
172 cursorImages.put(onColor);
173 }
174 }
175 }
176 }
177 cursorDelays.put(2000).put(2000).put(2000);
178 cursorDelays.flip();
179 cursorImages.flip();
180
181 cursor[1] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
182 // ----------------------------------
183
184
185 // Create a 20 piece animation
186 // ==================================
187 cursorImageCount = 20;
188 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
189 cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
190 cursorDelays.put(
191 new int[] {
192 100, 100, 100, 100, 100,
193 100, 100, 100, 100, 100,
194 100, 100, 100, 100, 100,
195 100, 100, 100, 100, 100
196 });
197
198 float step = 0xffffffff / 20.0f;
199 for(int i=0; i<cursorImageCount; i++) {
200 for(int j=0; j<cursorWidth; j++) {
201 for(int l=0; l<cursorHeight; l++) {
202 cursorImages.put((int)step);
203 }
204 }
205 step += step;
206 }
207 cursorImages.flip();
208 cursorDelays.flip();
209 cursor[2] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
210 // ----------------------------------
211
212 Mouse.setNativeCursor(cursor[0]);
213 }
214
215 /**
216 * Runs the main loop of the "test"
217 */
218 private void mainLoop() {
219 while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
220 && !Display.isCloseRequested()) {
221 // allow subsystem to get a chance to run too
222 Display.update();
223
224 if (Display.isVisible()) {
225 // check keyboard input
226 processKeyboard();
227 processMouse();
228
229 render();
230 } else {
231
232 // no need to render/paint if nothing has changed (ie. window dragged over)
233 if (Display.isDirty()) {
234 render();
235 }
236
237 // don't waste cpu time, sleep more
238 try {
239 Thread.sleep(100);
240 } catch (InterruptedException inte) {
241 }
242 }
243 }
244 }
245
246 /**
247 * Performs the logic
248 */
249 private void render() {
250 //clear background
251 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
252
253 // draw white quad
254 GL11.glPushMatrix();
255 {
256 GL11.glTranslatef(mouse_x, mouse_y, 0);
257 GL11.glColor3f(1.0f, 1.0f, 1.0f);
258 GL11.glBegin(GL11.GL_QUADS);
259 {
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
270 private void processMouse() {
271 mouse_x = Mouse.getX();
272 mouse_y = Mouse.getY();
273
274 while(Mouse.next()) {
275 int button = Mouse.getEventButton();
276 if(button >= 0 && button < 3 && Mouse.getEventButtonState()) {
277 mouse_btn = Mouse.getEventButton();
278 switchCursor();
279 }
280 }
281 }
282
283 /**
284 * Processes keyboard input
285 */
286 private void processKeyboard() {
287 //check for fullscreen key
288 if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
289
290 try {
291 try {
292 Mouse.setNativeCursor(null);
293 } catch (Exception e) {
294 e.printStackTrace();
295 System.exit(1);
296 }
297 for(int i=0; i<cursor.length; i++) {
298 cursor[i].destroy();
299 }
300 Display.setFullscreen(true);
301
302 glInit();
303
304 initNativeCursors();
305 } catch (Exception e) {
306 e.printStackTrace();
307 }
308 }
309
310 //check for window key
311 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
312 try {
313 try {
314 Mouse.setNativeCursor(null);
315 } catch (Exception e) {
316 e.printStackTrace();
317 System.exit(1);
318 }
319 for(int i=0; i<cursor.length; i++) {
320 cursor[i].destroy();
321 }
322 Display.setFullscreen(false);
323 glInit();
324
325 initNativeCursors();
326 } catch (Exception e) {
327 e.printStackTrace();
328 }
329 }
330
331 if (Keyboard.isKeyDown(Keyboard.KEY_M)) {
332 try {
333 Mouse.setNativeCursor(null);
334 } catch (Exception e) {
335 e.printStackTrace();
336 }
337 }
338
339 if (Keyboard.isKeyDown(Keyboard.KEY_N)) {
340 switchCursor();
341 }
342
343 while(Keyboard.next()) {
344 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
345 Mouse.setGrabbed(!Mouse.isGrabbed());
346 }
347 }
348 }
349
350 private void switchCursor() {
351 try {
352 Mouse.setNativeCursor(cursor[mouse_btn]);
353 } catch (Exception e) {
354 e.printStackTrace();
355 }
356 }
357
358 /**
359 * Cleans up the test
360 */
361 private void cleanup() {
362 try {
363 Mouse.setNativeCursor(null);
364 } catch (Exception e) {
365 e.printStackTrace();
366 System.exit(1);
367 }
368 for(int i=0; i<cursor.length; i++) {
369 cursor[i].destroy();
370 }
371 Display.destroy();
372 }
373
374 /**
375 * Initializes OGL
376 */
377 private void glInit() {
378 // 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
386 //set clear color to black
387 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
388
389 //sync frame (only works on windows)
390 Display.setVSyncEnabled(true);
391 }
392
393 /**
394 * Test entry point
395 */
396 public static void main(String[] args) {
397 System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively. Enable hw cursor with N and disable it with M.");
398 HWCursorTest cursorTest = new HWCursorTest();
399 cursorTest.execute();
400 System.exit(0);
401 }
402 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.input;
32
33 import org.lwjgl.input.Keyboard;
34 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.DisplayMode;
36 import org.lwjgl.opengl.GL11;
37 import org.lwjgl.util.vector.Vector2f;
38 import org.lwjgl.util.glu.GLU;
39
40 /**
41 * <br>
42 * Keyboard test
43 *
44 * @author Brian Matzon <brian@matzon.dk>
45 * @version $Revision: 3042 $
46 * $Id: KeyboardTest.java 3042 2008-04-22 21:26:39Z elias_naur $
47 */
48 public class KeyboardTest {
49
50 /** position of quad to draw */
51 private Vector2f position = new Vector2f(320.0f, 240.0f);
52
53 /** Display mode selected */
54 private DisplayMode displayMode;
55
56 /** Creates a new instance of MouseTest */
57 public KeyboardTest() {
58 }
59
60 private void initialize() {
61 // create display and opengl
62 setupDisplay(false);
63
64 try {
65 Keyboard.create();
66 } catch (Exception e) {
67 e.printStackTrace();
68 System.exit(-1);
69 }
70 }
71
72 /**
73 * Sets the display mode for fullscreen mode
74 */
75 protected boolean setDisplayMode() {
76 try {
77 // get modes
78 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
79
80 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
81 "width=" + 640,
82 "height=" + 480,
83 "freq=" + 60,
84 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
85 });
86 return true;
87 } catch (Exception e) {
88 e.printStackTrace();
89 }
90
91 return false;
92 }
93
94 private void setupDisplay(boolean fullscreen) {
95 try {
96 setDisplayMode();
97 Display.create();
98 } catch (Exception e) {
99 e.printStackTrace();
100 System.exit(-1);
101 }
102
103 initializeOpenGL();
104 }
105
106 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);
114 }
115
116 public void executeTest() {
117 initialize();
118
119 createKeyboard();
120
121 wiggleKeyboard();
122
123 Keyboard.destroy();
124 Display.destroy();
125 }
126
127 private void createKeyboard() {
128 try {
129 Keyboard.create();
130 } catch (Exception e) {
131 e.printStackTrace();
132 System.exit(-1);
133 }
134 }
135
136 private void wiggleKeyboard() {
137
138 while (!Display.isCloseRequested()) {
139 Display.update();
140
141 if (!Display.isVisible()) {
142 try {
143 Thread.sleep(100);
144 } catch (InterruptedException inte) {
145 inte.printStackTrace();
146 }
147 continue;
148 }
149
150 //check keys, buffered
151 Keyboard.poll();
152
153 int count = Keyboard.getNumKeyboardEvents();
154 while (Keyboard.next()) {
155 int character_code = ((int)Keyboard.getEventCharacter()) & 0xffff;
156 System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.getEventKey()));
157 System.out.println("Pressed:" + Keyboard.getEventKeyState());
158 System.out.println("Key character code: 0x" + Integer.toHexString(character_code));
159 System.out.println("Key character: " + Keyboard.getEventCharacter());
160 System.out.println("Repeat event: " + Keyboard.isRepeatEvent());
161
162 if (Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) {
163 Keyboard.enableRepeatEvents(!Keyboard.areRepeatEventsEnabled());
164 }
165 if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
166 return;
167 }
168 }
169 if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
170 position.x += 1;
171 }
172
173 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
174 position.x -= 1;
175 }
176
177 if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
178 position.y += 1;
179 }
180
181 if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
182 position.y -= 1;
183 }
184
185 if (count > 0) {
186 System.out.println();
187 }
188
189 if (position.x < 0) {
190 position.x = 0;
191 } else if (position.x > 640 - 60) {
192 position.x = 640 - 60;
193 }
194
195 if (position.y < 0) {
196 position.y = 0;
197 } else if (position.y > 480 - 30) {
198 position.y = 480 - 30;
199 }
200
201 render();
202
203 try {
204 Thread.sleep(0);
205 } catch (Exception e) {
206 }
207 }
208 }
209
210 private void render() {
211 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
212
213 GL11.glBegin(GL11.GL_POLYGON);
214 {
215 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();
225 }
226
227 /**
228 * @param args the command line arguments
229 */
230 public static void main(String[] args) {
231 KeyboardTest kt = new KeyboardTest();
232 kt.executeTest();
233 System.exit(0);
234 }
235 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.input;
32
33 import org.lwjgl.Sys;
34 import org.lwjgl.input.Mouse;
35 import org.lwjgl.opengl.Display;
36 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
38 import org.lwjgl.util.vector.Vector2f;
39
40 /**
41 * <br>
42 * Mouse test
43 *
44 * @author Brian Matzon <brian@matzon.dk>
45 * @version $Revision: 3108 $
46 * $Id: MouseCreationTest.java 3108 2008-07-02 20:00:49Z matzon $
47 */
48 public class MouseCreationTest {
49 /** position of quad to draw */
50 private Vector2f position = new Vector2f(320.0f, 240.0f);
51
52 /** Creates a new instance of MouseTest */
53 public MouseCreationTest() {
54 }
55
56 private void initialize(boolean fullscreen) {
57 try {
58 setDisplayMode();
59 Display.setFullscreen(fullscreen);
60 Display.create();
61 Mouse.setGrabbed(true);
62 } catch (Exception e) {
63 e.printStackTrace();
64 System.exit(-1);
65 }
66
67 initializeOpenGL();
68 }
69
70 /**
71 * Sets the display mode for fullscreen mode
72 */
73 protected boolean setDisplayMode() {
74 try {
75 // get modes
76 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
77
78 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
79 "width=" + 640,
80 "height=" + 480,
81 "freq=" + 60,
82 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
83 });
84 return true;
85 } catch (Exception e) {
86 e.printStackTrace();
87 }
88
89 return false;
90 }
91
92 private void initializeOpenGL() {
93 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
94 // Put the window into orthographic projection mode with 1:1 pixel ratio.
95 // 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());
102 }
103
104 public void executeTest() {
105 initialize(false);
106
107 System.out.println("Test ready:\n");
108
109 // windowed mode
110 System.out.println("=========== WINDOWED MODE ==============");
111 for(int i=0; i<2; i++) {
112 System.out.println("Test " + (i+1) + ":");
113 wiggleMouse();
114 System.out.println("");
115 }
116
117 // recreate display in fullscreen mode
118 System.out.print("Destroying display...");
119
120 System.out.println("success");
121
122 System.out.print("Entering fullscreen mode...");
123 try {
124 Display.destroy();
125 initialize(true);
126 } catch (Exception e) {
127 e.printStackTrace();
128 }
129 System.out.println("success");
130
131
132 // fullscreen mode
133 System.out.println("=========== FULLSCREEN MODE ==============");
134 for(int i=0; i<2; i++) {
135 System.out.println("Test " + (i+3) + ":");
136 wiggleMouse();
137 System.out.println("");
138 }
139
140 System.out.println("Test completed successfully!");
141 System.out.print("Shutting down...");
142 Display.destroy();
143 System.out.println("shutdown complete");
144 }
145
146 private void wiggleMouse() {
147 System.out.print("Please move the mouse around");
148
149 long statustime = Sys.getTime();
150 long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;
151
152 while (Sys.getTime() < endtime) {
153 Display.update();
154
155 // empty mouse buffer
156 while(Mouse.next());
157
158 position.x += Mouse.getDX();
159 position.y += Mouse.getDY();
160
161 if(position.x<0) {
162 position.x = 0;
163 } else if (position.x>640-60) {
164 position.x = 640-60;
165 }
166
167 if(position.y < 0) {
168 position.y = 0;
169 } else if (position.y>480-30) {
170 position.y = 480-30;
171 }
172
173 render();
174
175 if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
176 System.out.print(".");
177 statustime = Sys.getTime();
178 }
179 }
180 System.out.println("thank you");
181 }
182
183 private void render() {
184 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
185
186 GL11.glBegin(GL11.GL_POLYGON);
187 {
188 float color = 1.0f;
189 int buttonDown = 0;
190
191 for(int i=0;i<Mouse.getButtonCount(); i++) {
192 if(Mouse.isButtonDown(i)) {
193 color = (1.0f / Mouse.getButtonCount()) * (i+1);
194 break;
195 }
196 }
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();
206 }
207
208 /**
209 * @param args the command line arguments
210 */
211 public static void main(String[] args) {
212 MouseCreationTest mt = new MouseCreationTest();
213 mt.executeTest();
214 System.exit(0);
215 }
216 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.input;
32
33 import org.lwjgl.input.Keyboard;
34 import org.lwjgl.input.Mouse;
35 import org.lwjgl.opengl.Display;
36 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
38 import org.lwjgl.util.glu.GLU;
39 import org.lwjgl.util.vector.Vector2f;
40 import org.lwjgl.util.vector.Vector3f;
41
42 /**
43 * <br>
44 * Mouse test
45 *
46 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 3240 $
48 * $Id: MouseTest.java 3240 2009-09-12 22:15:21Z matzon $
49 */
50 public class MouseTest {
51 /** Direction mouse has moved */
52 private int direction;
53
54 /** Last button pressed */
55 private int lastButton = 0;
56
57 /** Last direction we scrolled in */
58 private int lastScrollDirection = -1;
59
60 /** Width of window */
61 private static int WINDOW_WIDTH = 640;
62
63 /** Height of window */
64 private static int WINDOW_HEIGHT = 640;
65
66 /** Triangle size */
67 private Vector2f triangleSize = new Vector2f(120, 100);
68
69 /** Triangle color */
70 private Vector3f triangleColor[] = new Vector3f[] {
71 new Vector3f(1,1,1),
72 new Vector3f(1,0,0),
73 new Vector3f(0,1,0),
74 new Vector3f(0,0,1)
75 };
76
77 private Vector3f quadColor[] = new Vector3f[] {
78 new Vector3f(1,1,1),
79 new Vector3f(1,0,0),
80 new Vector3f(0,1,0),
81 new Vector3f(0,0,1)
82 };
83
84 /** Triangles to paint */
85 private Vector2f[] triangles = {
86 new Vector2f(WINDOW_WIDTH/2, WINDOW_HEIGHT - triangleSize.y),
87 new Vector2f(triangleSize.y, WINDOW_HEIGHT/2),
88 new Vector2f(WINDOW_WIDTH/2, triangleSize.y),
89 new Vector2f(WINDOW_WIDTH-triangleSize.y, WINDOW_HEIGHT/2)
90 };
91
92 /** Whether the test is closing */
93 private boolean closing = false;
94
95 /** Fullscreen or not */
96 public static final boolean FULLSCREEN = false;
97
98 /** Creates a new instance of MouseTest */
99 public MouseTest() {
100 }
101
102 private void initialize() {
103 // create display and opengl
104 setupDisplay();
105
106 setupMouse();
107 setupKeyboard();
108 }
109
110 /**
111 * Setup display
112 */
113 private void setupDisplay() {
114 try {
115 setDisplayMode();
116 Display.setFullscreen(FULLSCREEN);
117 Display.setVSyncEnabled(true);
118 Display.create();
119 Mouse.setGrabbed(true);
120 } catch (Exception e) {
121 e.printStackTrace();
122 System.exit(-1);
123 }
124
125 initializeOpenGL();
126 }
127
128 /**
129 * Sets the display mode for fullscreen mode
130 */
131 protected boolean setDisplayMode() {
132 // get modes
133 DisplayMode dm = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT);
134
135 try {
136 Display.setDisplayMode(dm);
137 return true;
138 } catch (Exception e) {
139 e.printStackTrace();
140 }
141
142 return false;
143 }
144
145 /**
146 * Initializes OpenGL
147 *
148 */
149 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);
157 }
158
159 /**
160 * Executes the actual test
161 */
162 public void executeTest() {
163 initialize();
164
165 runTest();
166
167 Display.destroy();
168 }
169
170 /**
171 * Creates the mouse
172 */
173 private void setupMouse() {
174 }
175
176 /**
177 * Creates the keyboard
178 */
179 private void setupKeyboard() {
180 }
181
182 /**
183 * Runs the test
184 */
185 private void runTest() {
186 // while not exiting
187 while (!closing) {
188 handleWindow();
189
190 // secondary check
191 if(!closing) {
192
193 // poll and check keyboard and mouse
194 handleKeyboard();
195 handleMouse();
196
197 // pause and continue if minimized
198 if(!Display.isVisible()) {
199 if(Display.isDirty()) {
200 render();
201 }
202 pause(100);
203 continue;
204 }
205
206 // render and flip
207 logic();
208 render();
209 }
210 Thread.yield();
211 }
212 }
213
214 /**
215 * Pauses the current thread for a specified time
216 *
217 * @param time milliseconds to pause
218 */
219 private void pause(long time) {
220 try {
221 Thread.sleep(time);
222 } catch (InterruptedException inte) {
223 inte.printStackTrace();
224 }
225 }
226
227 /**
228 * Handles the window
229 */
230 private void handleWindow() {
231 Display.update();
232 closing = Display.isCloseRequested();
233 }
234
235 /**
236 * handles the mouse
237 */
238 private void handleMouse() {
239 readBufferedMouse();
240
241 Display.setTitle("x: " + Mouse.getX() + ", y: " + Mouse.getY() + ", [0]: " + Mouse.isButtonDown(0) + ", [1]: " + Mouse.isButtonDown(1) + ", [2]: " + Mouse.isButtonDown(2) + ", inside: " + Mouse.isInsideWindow());
242 }
243
244 /**
245 * reads a mouse in buffered mode
246 */
247 private void readBufferedMouse() {
248 // iterate all events, use the last button down
249 while(Mouse.next()) {
250 if(Mouse.getEventButton() != -1 && Mouse.getEventButtonState()) {
251 lastButton = Mouse.getEventButton();
252 }
253 }
254
255 updateState();
256 }
257
258 /**
259 * Updates our "model"
260 *
261 */
262 private void updateState() {
263 direction = -1;
264
265 int dx = Mouse.getDX();
266 int dy = Mouse.getDY();
267 int dw = Mouse.getDWheel();
268
269
270 // get out if no movement
271 if (dx == dy && dx == 0 && dw == 0) {
272 return;
273 }
274
275 // determine direction moved
276 // ============================
277 if(dx > 0) {
278 direction = 3;
279 }
280
281 if(dx < 0) {
282 direction = 1;
283 }
284
285 if(dy > 0) {
286 direction = 0;
287 }
288
289 if(dy < 0) {
290 direction = 2;
291 }
292
293 // ----------------------------
294 if(direction > -1) {
295
296 // based on which button was last pushed, update model
297 switch(lastButton) {
298 case -1:
299 break;
300 case 1:
301 triangleColor[direction].y = 1;
302 break;
303 case 2:
304 triangleColor[direction].z = 1;
305 break;
306 case 3:
307 triangleColor[direction].x = 1;
308 triangleColor[direction].y = 1;
309 triangleColor[direction].z = 1;
310 break;
311 case 0: // fall through
312 default:
313 triangleColor[direction].x = 1;
314 break;
315 }
316 }
317
318 // get direction to update in
319 if (dw > 0) {
320 lastScrollDirection++;
321 } else if (dw < 0) {
322 lastScrollDirection--;
323 } else if (dw == 0) {
324 return;
325 }
326
327 // over/underflow
328 if(lastScrollDirection < 0) {
329 lastScrollDirection = 3;
330 }
331 if(lastScrollDirection > 3) {
332 lastScrollDirection = 0;
333 }
334
335 // 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
341 /**
342 * Handles the keyboard
343 */
344 private void handleKeyboard() {
345
346 while(Keyboard.next()) {
347 // closing on ESCAPE
348 if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
349 closing = true;
350 }
351
352 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
353 Mouse.setGrabbed(!Mouse.isGrabbed());
354 }
355 }
356 }
357
358 /**
359 * Does the "model logic"
360 */
361 private void logic() {
362 // "we fade to black"
363 // ===========================================
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 }
375 // -------------------------------------------
376 }
377
378 /**
379 * Render our triangles
380 */
381 private void render() {
382 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
383
384 // for each triangle, render it at position, rotating degrees for each
385 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);
396 }
397 GL11.glEnd();
398 }
399 GL11.glPopMatrix();
400 }
401
402 // 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();
414 }
415
416 /**
417 * @param args the command line arguments
418 */
419 public static void main(String[] args) {
420 MouseTest mt = new MouseTest();
421 mt.executeTest();
422 System.exit(0);
423 }
424 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.input;
32
33 import java.awt.Dimension;
34 import java.awt.event.WindowAdapter;
35 import java.awt.event.WindowEvent;
36
37 import javax.swing.JFrame;
38 import javax.swing.JPanel;
39 import javax.swing.JScrollPane;
40 import javax.swing.JTextField;
41
42 import org.lwjgl.input.Controller;
43 import org.lwjgl.input.Controllers;
44
45 /**
46 * Oops. Forgot to document this one.
47 *
48 * @author Kevin Glass
49 */
50 public class TestControllers extends JPanel {
51 public static int total = 0;
52
53 private JTextField[] values;
54 private JTextField[] names;
55 private Controller controller;
56 private int buttonCount;
57 private int itemCount;
58
59 public TestControllers(int index) {
60 controller = Controllers.getController(index);
61 setLayout(null);
62
63 buttonCount = controller.getButtonCount();
64 itemCount = controller.getButtonCount() + controller.getAxisCount() + 2;
65 values = new JTextField[itemCount];
66 names = new JTextField[itemCount];
67
68 for (int i=0;i<controller.getButtonCount();i++) {
69 names[i] = new JTextField();
70 names[i].setEditable(false);
71 names[i].setBounds(0,i*30,100,30);
72 names[i].setText(controller.getButtonName(i));
73 add(names[i]);
74 values[i] = new JTextField();
75 values[i].setEditable(false);
76 values[i].setBounds(100,i*30,100,30);
77 add(values[i]);
78 }
79 for (int i=buttonCount;i<buttonCount+controller.getAxisCount();i++) {
80 names[i] = new JTextField();
81 names[i].setEditable(false);
82 names[i].setBounds(0,i*30,100,30);
83 names[i].setText(controller.getAxisName(i-buttonCount));
84 add(names[i]);
85 values[i] = new JTextField();
86 values[i].setEditable(false);
87 values[i].setBounds(100,i*30,100,30);
88 add(values[i]);
89 }
90
91 int i = itemCount - 2;
92 names[i] = new JTextField();
93 names[i].setEditable(false);
94 names[i].setBounds(0,i*30,100,30);
95 names[i].setText("POV X");
96 add(names[i]);
97 values[i] = new JTextField();
98 values[i].setEditable(false);
99 values[i].setBounds(100,i*30,100,30);
100 add(values[i]);
101
102 i = itemCount - 1;
103 names[i] = new JTextField();
104 names[i].setEditable(false);
105 names[i].setBounds(0,i*30,100,30);
106 names[i].setText("POV Y");
107 add(names[i]);
108 values[i] = new JTextField();
109 values[i].setEditable(false);
110 values[i].setBounds(100,i*30,100,30);
111 add(values[i]);
112
113 total++;
114
115 setPreferredSize(new Dimension(200,30*itemCount));
116 JFrame frame = new JFrame(controller.getName());
117 frame.setContentPane(new JScrollPane(this));
118 frame.addWindowListener(new WindowAdapter() {
119 public void windowClosing(WindowEvent e) {
120 total--;
121 if (total == 0) {
122 System.exit(0);
123 }
124 }
125 });
126 frame.setSize(230,400);
127 frame.setLocation(index*30,index*30);
128 frame.setVisible(true);
129 }
130
131 public void updateDetails() {
132 for (int i=0;i<controller.getButtonCount();i++) {
133 values[i].setText(""+controller.isButtonPressed(i));
134 }
135 for (int i=buttonCount;i<buttonCount+controller.getAxisCount();i++) {
136 values[i].setText(""+controller.getAxisValue(i-buttonCount));
137 }
138
139 values[itemCount-2].setText(""+controller.getPovX());
140 values[itemCount-1].setText(""+controller.getPovY());
141 }
142
143 public static void main(String[] argv) {
144 try {
145 Controllers.create();
146 } catch (Exception e) {
147 e.printStackTrace();
148 System.exit(0);
149 }
150
151 int count = Controllers.getControllerCount();
152 System.out.println(count+" Controllers Found");
153 for (int i=0;i<count;i++) {
154 Controller controller = Controllers.getController(i);
155 System.out.println(controller.getName());
156 }
157
158 if (count == 0) {
159 System.exit(0);
160 }
161
162 TestControllers[] controllerWindows = new TestControllers[count];
163 for (int i=0;i<count;i++) {
164 controllerWindows[i] = new TestControllers(i);
165 }
166
167 boolean running = true;
168 while (running) {
169 try { Thread.sleep(100); } catch (Exception e) {};
170
171 Controllers.poll();
172
173 while (Controllers.next()) {
174 System.out.println("Event Fired: ");
175 System.out.println("\t"+Controllers.getEventNanoseconds());
176 System.out.println("\t"+Controllers.getEventSource()+":"+Controllers.getEventControlIndex()+":"+Controllers.isEventButton());
177 System.out.println("\t"+Controllers.isEventXAxis()+":"+Controllers.isEventYAxis());
178 }
179
180 for (int i=0;i<count;i++) {
181 controllerWindows[i].updateDetails();
182 }
183 }
184 }
185 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.ByteBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.BufferUtils;
37 import org.lwjgl.openal.AL;
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.openal.ALC10;
40 import org.lwjgl.openal.ALC11;
41 import org.lwjgl.openal.ALCdevice;
42 import org.lwjgl.openal.OpenALException;
43
44 /**
45 *
46 * This is a test for the ALC part of OpenAL
47 *
48 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2286 $
50 * $Id: ALCTest.java 2286 2006-03-23 19:32:21Z matzon $
51 */
52 public class ALCCaptureTest extends BasicTest {
53
54 /**
55 * Creates an instance of ALCTest
56 */
57 public ALCCaptureTest() {
58 super();
59 }
60
61 /**
62 * Runs the actual test, using supplied arguments
63 */
64 protected void execute(String[] args) {
65 int lastError = ALC10.ALC_NO_ERROR;
66 IntBuffer sampleCount = BufferUtils.createIntBuffer(1);
67
68 int state = AL10.AL_PLAYING;
69 int FMT = AL10.AL_FORMAT_MONO16;
70 int FMTSIZE = 16/8;
71 int FREQ = 44100;
72 int TIME = 5;
73 int SAMPS = (FREQ * TIME);
74 ByteBuffer buf = BufferUtils.createByteBuffer(SAMPS * FMTSIZE);
75
76 // check that capture is available
77 if(!ALC10.alcIsExtensionPresent(AL.getDevice(), "ALC_EXT_CAPTURE")) {
78 throw new OpenALException("ALC_EXT_CAPTURE extension not available");
79 }
80
81 // get list of devices
82 String[] captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER).split("\0");
83 System.out.println("Available Capture Devices: ");
84 for(int i=0; i<captureDevices.length; i++) {
85 System.out.println(i + ": " + captureDevices[i]);
86 }
87
88 String defaultRecorder = ALC10.alcGetString(AL.getDevice(), ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
89 System.out.println("Default capture device: " + defaultRecorder);
90
91 ALCdevice device = ALC11.alcCaptureOpenDevice(null, FREQ, FMT, SAMPS);
92
93 if(device != null) {
94 // record some sound
95 // =====================================
96 System.out.print("Recording using " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER) + "...");
97 ALC11.alcCaptureStart(device);
98 while (sampleCount.get(0) < SAMPS) {
99 pause(1000);
100 ALC10.alcGetInteger(device, ALC11.ALC_CAPTURE_SAMPLES, sampleCount);
101 }
102 System.out.println("done");
103 ALC11.alcCaptureStop(device);
104
105 // capure the samples
106 ALC11.alcCaptureSamples(device, buf, SAMPS);
107 ALC11.alcCaptureCloseDevice(device);
108 // -------------------------------------
109
110 // play back recording
111 // ===================
112 IntBuffer buffers = BufferUtils.createIntBuffer(1);
113 IntBuffer sources = BufferUtils.createIntBuffer(1);
114
115 buffers.position(0).limit(1);
116 AL10.alGenBuffers(buffers);
117
118 sources.position(0).limit(1);
119 AL10.alGenSources(sources);
120
121 System.out.print("Playing...");
122
123 AL10.alBufferData(buffers.get(0), FMT, buf, FREQ);
124 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
125 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_FALSE);
126 AL10.alSourcePlay(sources.get(0));
127
128 while (state == AL10.AL_PLAYING)
129 {
130 pause(100);
131 state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
132 }
133
134 System.out.println("done");
135
136 AL10.alDeleteSources(sources);
137 AL10.alDeleteBuffers(buffers);
138 }
139
140 alExit();
141 }
142
143 /**
144 * main entry point
145 *
146 * @param args String array containing arguments
147 */
148 public static void main(String[] args) {
149 ALCCaptureTest alcTest = new ALCCaptureTest();
150 alcTest.execute(args);
151 System.exit(0);
152 }
153 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.openal.AL;
37 import org.lwjgl.openal.ALC10;
38
39 /**
40 *
41 * This is a test for the ALC part of OpenAL
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: ALCTest.java 2983 2008-04-07 18:36:09Z matzon $
46 */
47 public class ALCTest extends BasicTest {
48
49 /**
50 * Creates an instance of ALCTest
51 */
52 public ALCTest() {
53 super();
54 }
55
56 /**
57 * Runs the actual test, using supplied arguments
58 */
59 protected void execute(String[] args) {
60 //error stuff
61 int lastError = ALC10.ALC_NO_ERROR;
62
63 //create attribute list for context creation
64 IntBuffer buffer = BufferUtils.createIntBuffer(7);
65
66 if ((lastError = ALC10.alcGetError(AL.getDevice())) != ALC10.ALC_NO_ERROR) {
67 System.out.println("ALC Error: " + ALC10.alcGetString(AL.getDevice(), lastError));
68 System.exit(-1);
69 }
70
71 //query
72 System.out.println(
73 "DEFAULT_DEVICE_SPECIFIER: "
74 + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
75 System.out.println(
76 "DEVICE_SPECIFIER: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEVICE_SPECIFIER));
77 System.out.println("EXTENSIONS: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_EXTENSIONS));
78
79 //mo query
80 buffer.rewind();
81 buffer.position(0);
82 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, buffer);
83 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1));
84
85 System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0));
86 System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));
87
88 //no check for ALC_ALL_ATTRIBUTES / ALC_ATTRIBUTES_SIZE since it
89 //is buggy on win32 - my dev platform
90
91 //get an enumerstion value
92 System.out.println(
93 "Value of ALC_MAJOR_VERSION: "
94 + ALC10.alcGetEnumValue(AL.getDevice(), "ALC_MAJOR_VERSION"));
95
96 alExit();
97 }
98
99 /**
100 * main entry point
101 *
102 * @param args String array containing arguments
103 */
104 public static void main(String[] args) {
105 ALCTest alcTest = new ALCTest();
106 alcTest.execute(args);
107 System.exit(0);
108 }
109 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.FloatBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.openal.AL;
37 import org.lwjgl.openal.AL10;
38 import org.lwjgl.openal.ALC10;
39 import org.lwjgl.opengl.DisplayMode;
40
41 /**
42 *
43 * This is a basic test, which contains the most used stuff
44 *
45 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 2983 $
47 * $Id: BasicTest.java 2983 2008-04-07 18:36:09Z matzon $
48 */
49 public abstract class BasicTest {
50
51 /**
52 * Creates an instance of PlayTest
53 */
54 public BasicTest() {
55 try {
56 AL.create();
57
58 System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
59
60 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
61 String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
62 System.out.println("Available devices: ");
63 for(int i=0; i<devices.length; i++) {
64 System.out.println(i +": " + devices[i]);
65 }
66 }
67 } catch (Exception e) {
68 System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
69 return;
70 }
71 }
72
73 /**
74 * Shutdowns OpenAL
75 */
76 protected void alExit() {
77 if(AL.isCreated()) {
78 AL.destroy();
79 }
80 }
81
82 /**
83 * Creates a float buffer to hold specified float array
84 * - strictly a utility method
85 *
86 * @param array to hold
87 * @return created FloatBuffer
88 */
89 protected FloatBuffer createFloatBuffer(float[] data) {
90 FloatBuffer temp = BufferUtils.createFloatBuffer(data.length).put(data);
91 temp.flip();
92 return temp;
93 }
94
95 /**
96 * Pauses the invoking thread for specified milliseconds
97 *
98 * @param time Milliseconds to sleep
99 */
100 protected void pause(long time) {
101 try {
102 Thread.sleep(time);
103 } catch (InterruptedException inte) {
104 }
105 }
106
107 /**
108 * Exits the test NOW, printing errorcode to stdout
109 *
110 * @param error Error code causing exit
111 */
112 protected void exit(int error) {
113 System.out.println("OpenAL Error: " + AL10.alGetString(error));
114 alExit();
115 System.exit(-1);
116 }
117
118 /**
119 * Sets the display mode for fullscreen mode
120 */
121 protected boolean setDisplayMode() {
122 try {
123 // get modes
124 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
125
126 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
127 "width=" + 640,
128 "height=" + 480,
129 "freq=" + 60,
130 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
131 });
132 return true;
133 } catch (Exception e) {
134 e.printStackTrace();
135 }
136
137 return false;
138 }
139 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.input.Keyboard;
37 import org.lwjgl.openal.AL10;
38 import org.lwjgl.opengl.Display;
39 import org.lwjgl.util.WaveData;
40 import org.lwjgl.util.vector.Vector3f;
41
42 /**
43 *
44 * This test simulates a listener positioned in the center, and
45 * a source moving around the listener using the keyboard
46 *
47 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2983 $
49 * $Id: MovingSoundTest.java 2983 2008-04-07 18:36:09Z matzon $
50 */
51 public class MovingSoundTest extends BasicTest {
52
53 public static float MOVEMENT = 50.00f;
54
55 /**
56 * Creates an instance of MovingSoundTest
57 */
58 public MovingSoundTest() {
59 super();
60 }
61
62 /**
63 * Runs the actual test, using supplied arguments
64 */
65 protected void execute(String[] args) {
66 if (args.length < 1) {
67 System.out.println("no argument supplied, assuming Footsteps.wav");
68 args = new String[] {"Footsteps.wav"};
69 }
70
71 try {
72 setDisplayMode();
73 Display.create();
74 } catch (Exception e) {
75 e.printStackTrace();
76 }
77
78
79 int lastError;
80 Vector3f sourcePosition = new Vector3f();
81 Vector3f listenerPosition = new Vector3f();
82
83 //initialize keyboard
84 try {
85 Keyboard.create();
86 } catch (Exception e) {
87 e.printStackTrace();
88 exit(-1);
89 }
90
91 //create 1 buffer and 1 source
92 IntBuffer buffers = BufferUtils.createIntBuffer(1);
93 IntBuffer sources = BufferUtils.createIntBuffer(1);
94
95 // al generate buffers and sources
96 buffers.position(0).limit(1);
97 AL10.alGenBuffers(buffers);
98 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
99 exit(lastError);
100 }
101
102 sources.position(0).limit(1);
103 AL10.alGenSources(sources);
104 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
105 exit(lastError);
106 }
107
108 //load wave data
109 WaveData wavefile = WaveData.create(args[0]);
110
111 //copy to buffers
112 AL10.alBufferData(
113 buffers.get(0),
114 wavefile.format,
115 wavefile.data,
116 wavefile.samplerate);
117 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
118 exit(lastError);
119 }
120
121 //unload file again
122 wavefile.dispose();
123
124 //set up source input
125 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
126 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
127 exit(lastError);
128 }
129
130 AL10.alSourcef(sources.get(0), AL10.AL_REFERENCE_DISTANCE, 1024.0f);
131 AL10.alSourcef(sources.get(0), AL10.AL_ROLLOFF_FACTOR, 0.5f);
132
133 //lets loop the sound
134 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
135 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
136 exit(lastError);
137 }
138
139 //play source 0
140 AL10.alSourcePlay(sources.get(0));
141 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
142 exit(lastError);
143 }
144
145 System.out.println("Move source with arrow keys\nMove listener with right shift and arrowkeys\nExit with ESC");
146
147 while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
148 Display.update();
149
150 Keyboard.poll();
151 if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
152 if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
153 listenerPosition.x -= MOVEMENT;
154 AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
155 System.out.println("listenerx: " + listenerPosition.x);
156 } else {
157 sourcePosition.x -= MOVEMENT;
158 AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
159 System.out.println("sourcex: " + sourcePosition.x);
160 }
161 }
162 if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
163 if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
164 listenerPosition.x += MOVEMENT;
165 AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z);
166 System.out.println("listenerx: " + listenerPosition.x);
167 } else {
168 sourcePosition.x += MOVEMENT;
169 AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z);
170 System.out.println("sourcex: " + sourcePosition.x);
171 }
172 }
173
174 if(Display.isCloseRequested()) {
175 break;
176 }
177
178 try {
179 Thread.sleep(100);
180 } catch (InterruptedException inte) {
181 }
182 }
183
184 //stop source 0
185 AL10.alSourceStop(sources.get(0));
186 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
187 exit(lastError);
188 }
189
190 //delete buffers and sources
191 sources.position(0).limit(1);
192 AL10.alDeleteSources(sources);
193 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
194 exit(lastError);
195 }
196
197 buffers.position(0).limit(1);
198 AL10.alDeleteBuffers(buffers);
199 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
200 exit(lastError);
201 }
202
203 //shutdown
204 alExit();
205 }
206
207 /**
208 * main entry point
209 *
210 * @param args String array containing arguments
211 */
212 public static void main(String[] args) {
213 MovingSoundTest movingSoundTest = new MovingSoundTest();
214 movingSoundTest.execute(args);
215 System.exit(0);
216 }
217 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.ByteBuffer;
34 import java.nio.ByteOrder;
35 import java.nio.IntBuffer;
36
37 import org.lwjgl.openal.AL;
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.util.WaveData;
40
41 /**
42 * <br>
43 * Performs a creation test, by creating and destroying OpenAL twice.
44 * We cannot inherit from BasicTest since it follows another structure.
45 *
46 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 2983 $
48 * $Id: OpenALCreationTest.java 2983 2008-04-07 18:36:09Z matzon $
49 */
50 public class OpenALCreationTest {
51
52 /**
53 * Creates an instance of OpenALCreationTest
54 */
55 public OpenALCreationTest() {
56 }
57
58 public void alInitialize() {
59 try {
60 AL.create();
61 } catch (Exception e) {
62 e.printStackTrace();
63 return;
64 }
65 }
66
67 public void alExit() {
68 AL.destroy();
69 }
70
71 /**
72 * Creates an integer buffer to hold specified ints
73 * - strictly a utility method
74 *
75 * @param size how many int to contain
76 * @return created IntBuffer
77 */
78 protected IntBuffer createIntBuffer(int size) {
79 ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
80 temp.order(ByteOrder.nativeOrder());
81
82 return temp.asIntBuffer();
83 }
84
85 /**
86 * Exits the test NOW, printing errorcode to stdout
87 *
88 * @param error Error code causing exit
89 */
90 protected void exit(int error) {
91 System.out.println("OpenAL Error: " + AL10.alGetString(error));
92 alExit();
93 System.exit(-1);
94 }
95
96 /**
97 * Runs the actual test, using supplied arguments
98 */
99 protected void execute(String[] args) {
100 int lastError;
101
102 //initialize AL, using ALC
103 System.out.print("initialize...");
104 alInitialize();
105 System.out.println("success");
106
107 //do some audio
108 executeAudioTest();
109
110 //shutdown
111 System.out.print("shutdown...");
112 alExit();
113 System.out.println("success");
114
115 //initialize AL, using ALC
116 System.out.print("initialize...");
117 alInitialize();
118 System.out.println("success");
119
120 //do some audio
121 executeAudioTest();
122
123 //shutdown
124 System.out.print("shutdown...");
125 alExit();
126 System.out.println("success");
127 }
128
129 /**
130 * Executes the audio test, which just plays some sound
131 */
132 private void executeAudioTest() {
133 int lastError;
134
135 //create 1 buffer and 1 source
136 IntBuffer buffers = createIntBuffer(1);
137 IntBuffer sources = createIntBuffer(1);
138
139 // al generate buffers and sources
140 buffers.position(0).limit(1);
141 AL10.alGenBuffers(buffers);
142 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
143 exit(lastError);
144 }
145
146 sources.position(0).limit(1);
147 AL10.alGenSources(sources);
148 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
149 exit(lastError);
150 }
151
152 //load wave data
153 WaveData wavefile = WaveData.create("Footsteps.wav");
154
155 //copy to buffers
156 AL10.alBufferData(
157 buffers.get(0),
158 wavefile.format,
159 wavefile.data,
160 wavefile.samplerate);
161 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
162 exit(lastError);
163 }
164
165 //unload file again
166 wavefile.dispose();
167
168 //set up source input
169 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
170 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
171 exit(lastError);
172 }
173
174 //lets loop the sound
175 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
176 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
177 exit(lastError);
178 }
179
180 //play source 0
181 AL10.alSourcePlay(sources.get(0));
182 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
183 exit(lastError);
184 }
185
186 //wait 5 secs
187 try {
188 System.out.print("Playing 'Footsteps.wav' for 2 seconds...");
189 Thread.sleep(2000);
190 } catch (InterruptedException inte) {
191 }
192 System.out.println("done");
193
194 //stop source 0
195 AL10.alSourceStop(sources.get(0));
196 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
197 exit(lastError);
198 }
199
200 //delete buffers and sources
201 sources.position(0).limit(1);
202 AL10.alDeleteSources(sources);
203 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
204 exit(lastError);
205 }
206
207 buffers.position(0).limit(1);
208 AL10.alDeleteBuffers(buffers);
209 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
210 exit(lastError);
211 }
212 }
213
214 /**
215 * main entry point
216 *
217 * @param args String array containing arguments
218 */
219 public static void main(String[] args) {
220 OpenALCreationTest oalCreationTest = new OpenALCreationTest();
221 oalCreationTest.execute(args);
222 System.exit(0);
223 }
224 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.openal.AL;
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.openal.ALC10;
40 import org.lwjgl.openal.ALC11;
41 import org.lwjgl.openal.ALCdevice;
42
43 /**
44 *
45 * idea from openal-info
46 *
47 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2983 $
49 * $Id$
50 */
51 public class OpenALInfo {
52
53 /**
54 * Creates an instance of OpenALInfo
55 */
56 public OpenALInfo() {
57 }
58
59 /**
60 * Runs the actual test, using supplied arguments
61 */
62 protected void execute(String[] args) {
63 try {
64 AL.create(null, -1, 60, false);
65 checkForErrors();
66 } catch (LWJGLException le) {
67 die("Init", le.getMessage());
68 }
69
70 printALCInfo();
71 printALInfo();
72
73 checkForErrors();
74
75 AL.destroy();
76 }
77
78 private void printALCInfo() {
79 IntBuffer version = BufferUtils.createIntBuffer(2);
80 ALCdevice device;
81
82 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
83 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
84 printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
85 } else {
86 printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
87 }
88 printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
89 } else {
90 System.out.println("No device enumeration available");
91 }
92
93 device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
94 checkForErrors();
95
96 System.out.println("Default device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
97
98 System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
99
100 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
101 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
102 checkForErrors();
103
104 System.out.println("ALC version: " + (int)version.get(0) + "." + (int)version.get(1));
105
106 System.out.println("ALC extensions:");
107 String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
108 for(int i=0; i<extensions.length; i++) {
109 if(extensions[i].trim().length() == 0) {
110 continue;
111 }
112 System.out.println(" " + extensions[i]);
113 }
114 checkForErrors();
115 }
116
117 private void printALInfo() {
118 System.out.println("OpenAL vendor string: " + AL10.alGetString(AL10.AL_VENDOR));
119 System.out.println("OpenAL renderer string: " + AL10.alGetString(AL10.AL_RENDERER));
120 System.out.println("OpenAL version string: " + AL10.alGetString(AL10.AL_VERSION));
121 System.out.println("AL extensions:");
122 String[] extensions = AL10.alGetString(AL10.AL_EXTENSIONS).split(" ");
123 for(int i=0; i<extensions.length; i++) {
124 if(extensions[i].trim().length() == 0) {
125 continue;
126 }
127 System.out.println(" " + extensions[i]);
128 }
129 checkForErrors();
130 }
131
132 private void printDevices(int which, String kind) {
133 String[] devices = ALC10.alcGetString(null, which).split("\0");
134 checkForErrors();
135
136 System.out.println("Available " + kind + " devices: ");
137 for(int i=0; i<devices.length; i++) {
138 System.out.println(" " + devices[i]);
139 }
140 }
141
142 private void die(String kind, String description) {
143 System.out.println(kind + " error " + description + " occured");
144 }
145
146 private void checkForErrors() {
147 {
148 ALCdevice device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
149 int error = ALC10.alcGetError(device);
150 if(error != ALC10.ALC_NO_ERROR) {
151 die("ALC", ALC10.alcGetString(device, error));
152 }
153 }
154 {
155 int error = AL10.alGetError();
156 if(error != AL10.AL_NO_ERROR) {
157 die("AL", AL10.alGetString(error));
158 }
159 }
160 }
161
162 /**
163 * main entry point
164 *
165 * @param args String array containing arguments
166 */
167 public static void main(String[] args) {
168 OpenALInfo openalInfo = new OpenALInfo();
169 openalInfo.execute(args);
170 System.exit(0);
171 }
172 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.io.BufferedInputStream;
34 import java.io.ByteArrayOutputStream;
35 import java.nio.ByteBuffer;
36 import java.nio.ByteOrder;
37 import java.nio.IntBuffer;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.openal.AL10;
41 import org.lwjgl.util.WaveData;
42
43 /**
44 *
45 * This is a basic play test
46 * Yes, over zealous use of getError ;)
47 *
48 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: PlayTest.java 2983 2008-04-07 18:36:09Z matzon $
51 */
52 public class PlayTest extends BasicTest {
53
54 private boolean usingVorbis;
55
56 /**
57 * Creates an instance of PlayTest
58 */
59 public PlayTest() {
60 super();
61 }
62
63 /**
64 * Runs the actual test, using supplied arguments
65 */
66 protected void execute(String[] args) {
67 if(args.length < 1) {
68 System.out.println("no argument supplied, assuming Footsteps.wav");
69 args = new String[] {"Footsteps.wav"};
70 }
71
72 if(args[0].endsWith(".ogg")) {
73 System.out.print("Attempting to load Ogg Vorbis file, checking for extension...");
74 if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) {
75 System.out.println("found");
76 usingVorbis = true;
77 } else {
78 System.out.println("not supported");
79 alExit();
80 System.exit(-1);
81 }
82 }
83
84 int lastError;
85
86 //create 1 buffer and 1 source
87 IntBuffer buffers = BufferUtils.createIntBuffer(1);
88 IntBuffer sources = BufferUtils.createIntBuffer(1);
89
90 // al generate buffers and sources
91 buffers.position(0).limit(1);
92 AL10.alGenBuffers(buffers);
93 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
94 exit(lastError);
95 }
96
97 sources.position(0).limit(1);
98 AL10.alGenSources(sources);
99 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
100 exit(lastError);
101 }
102
103 if(usingVorbis) {
104 ByteBuffer filebuffer = getData(args[0]);
105
106 // pass directly to buffer data
107 AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1);
108 filebuffer.clear();
109 } else {
110 // load wave data from buffer
111 WaveData wavefile = WaveData.create(args[0]);
112
113 //copy to buffers
114 AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate);
115
116 //unload file again
117 wavefile.dispose();
118 }
119
120 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
121 exit(lastError);
122 }
123
124 //set up source input
125 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
126 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
127 exit(lastError);
128 }
129
130 //lets loop the sound
131 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
132 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
133 exit(lastError);
134 }
135
136 //play source 0
137 AL10.alSourcePlay(sources.get(0));
138 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
139 exit(lastError);
140 }
141
142 //wait 5 secs
143 try {
144 System.out.println("Waiting 5 seconds for sound to complete");
145 Thread.sleep(5000);
146 } catch (InterruptedException inte) {
147 }
148
149 //stop source 0
150 AL10.alSourceStop(sources.get(0));
151 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
152 exit(lastError);
153 }
154
155 //delete buffers and sources
156 sources.position(0).limit(1);
157 AL10.alDeleteSources(sources);
158 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
159 exit(lastError);
160 }
161
162 buffers.position(0).limit(1);
163 AL10.alDeleteBuffers(buffers);
164 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
165 exit(lastError);
166 }
167
168 //no errorchecking from now on, since our context is gone.
169 //shutdown
170 alExit();
171 }
172
173 /**
174 * Reads the file into a ByteBuffer
175 *
176 * @param filename Name of file to load
177 * @return ByteBuffer containing file data
178 */
179 protected ByteBuffer getData(String filename) {
180 ByteBuffer buffer = null;
181
182 System.out.println("Attempting to load: " + filename);
183
184 try {
185 BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
186 ByteArrayOutputStream baos = new ByteArrayOutputStream();
187
188 int bufferLength = 4096;
189 byte[] readBuffer = new byte[bufferLength];
190 int read = -1;
191
192 while((read = bis.read(readBuffer, 0, bufferLength)) != -1) {
193 baos.write(readBuffer, 0, read);
194 }
195
196 //done reading, close
197 bis.close();
198
199 // if ogg vorbis data, we need to pass it unmodified to alBufferData
200 buffer = ByteBuffer.allocateDirect(baos.size());
201 buffer.order(ByteOrder.nativeOrder());
202 buffer.put(baos.toByteArray());
203 buffer.rewind();
204 } catch (Exception ioe) {
205 ioe.printStackTrace();
206 }
207 return buffer;
208 }
209
210 /**
211 * main entry point
212 *
213 * @param args String array containing arguments
214 */
215 public static void main(String[] args) {
216 PlayTest playTest = new PlayTest();
217 playTest.execute(args);
218 System.exit(0);
219 }
220 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.io.BufferedInputStream;
34 import java.io.ByteArrayOutputStream;
35 import java.nio.ByteBuffer;
36 import java.nio.ByteOrder;
37 import java.nio.IntBuffer;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.openal.AL10;
41 import org.lwjgl.util.WaveData;
42
43 /**
44 *
45 * This is a basic play test
46 * Yes, over zealous use of getError ;)
47 *
48 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: PlayTestMemory.java 2983 2008-04-07 18:36:09Z matzon $
51 */
52 public class PlayTestMemory extends BasicTest {
53
54 private boolean usingVorbis;
55
56 /**
57 * Creates an instance of PlayTestMemory
58 */
59 public PlayTestMemory() {
60 super();
61 }
62
63 /**
64 * Runs the actual test, using supplied arguments
65 */
66 protected void execute(String[] args) {
67 if(args.length < 1) {
68 System.out.println("no argument supplied, assuming Footsteps.wav");
69 args = new String[] {"Footsteps.wav"};
70 }
71
72 if(args[0].endsWith(".ogg")) {
73 System.out.print("Attempting to load Ogg Vorbis file, checking for extension...");
74 if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) {
75 System.out.println("found");
76 usingVorbis = true;
77 } else {
78 System.out.println("not supported");
79 alExit();
80 System.exit(-1);
81 }
82 }
83
84 int lastError;
85
86 //create 1 buffer and 1 source
87 IntBuffer buffers = BufferUtils.createIntBuffer(1);
88 IntBuffer sources = BufferUtils.createIntBuffer(1);
89
90 // al generate buffers and sources
91 buffers.position(0).limit(1);
92 AL10.alGenBuffers(buffers);
93 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
94 exit(lastError);
95 }
96
97 sources.position(0).limit(1);
98 AL10.alGenSources(sources);
99 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
100 exit(lastError);
101 }
102
103 //load wave data
104 ByteBuffer filebuffer = getData(args[0]);
105 if(filebuffer == null) {
106 System.out.println("Error loading file: " + args[0]);
107 System.exit(-1);
108 }
109
110 System.out.println("loaded " + filebuffer.capacity());
111
112 //ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer));
113 if(usingVorbis) {
114 // pass directly to buffer data
115 AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1);
116 filebuffer.clear();
117 } else {
118 // load wave data from buffer
119 WaveData wavefile = WaveData.create(filebuffer.array());
120
121 //copy to buffers
122 AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate);
123
124 //unload file again
125 wavefile.dispose();
126 }
127
128 // check for errors
129 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
130 exit(lastError);
131 }
132
133
134 //set up source input
135 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
136 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
137 exit(lastError);
138 }
139
140 //lets loop the sound
141 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
142 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
143 exit(lastError);
144 }
145
146 //play source 0
147 AL10.alSourcePlay(sources.get(0));
148 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
149 exit(lastError);
150 }
151
152 //wait 5 secs
153 try {
154 System.out.println("Waiting 5 seconds for sound to complete");
155 Thread.sleep(5000);
156 } catch (InterruptedException inte) {
157 }
158
159 //stop source 0
160 AL10.alSourceStop(sources.get(0));
161 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
162 exit(lastError);
163 }
164
165 //delete buffers and sources
166 sources.position(0).limit(1);
167 AL10.alDeleteSources(sources);
168 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
169 exit(lastError);
170 }
171
172 buffers.position(0).limit(1);
173 AL10.alDeleteBuffers(buffers);
174 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
175 exit(lastError);
176 }
177
178 //no errorchecking from now on, since our context is gone.
179 alExit();
180 }
181
182 /**
183 * Reads the file into a ByteBuffer
184 *
185 * @param filename Name of file to load
186 * @return ByteBuffer containing file data
187 */
188 protected ByteBuffer getData(String filename) {
189 ByteBuffer buffer = null;
190
191 System.out.println("Attempting to load: " + filename);
192
193 try {
194 BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
195 ByteArrayOutputStream baos = new ByteArrayOutputStream();
196
197 int bufferLength = 4096;
198 byte[] readBuffer = new byte[bufferLength];
199 int read = -1;
200
201 while((read = bis.read(readBuffer, 0, bufferLength)) != -1) {
202 baos.write(readBuffer, 0, read);
203 }
204
205 //done reading, close
206 bis.close();
207
208 // if ogg vorbis data, we need to pass it unmodified to alBufferData
209 if(usingVorbis) {
210 buffer = ByteBuffer.allocateDirect(baos.size());
211 } else {
212 buffer = ByteBuffer.allocate(baos.size());
213 }
214 buffer.order(ByteOrder.nativeOrder());
215 buffer.put(baos.toByteArray());
216 buffer.rewind();
217 } catch (Exception ioe) {
218 ioe.printStackTrace();
219 }
220 return buffer;
221 }
222
223 /**
224 * main entry point
225 *
226 * @param args String array containing arguments
227 */
228 public static void main(String[] args) {
229 PlayTestMemory playTestMemory = new PlayTestMemory();
230 playTestMemory.execute(args);
231 System.exit(0);
232 }
233 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.FloatBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.BufferUtils;
37 import org.lwjgl.LWJGLUtil;
38 import org.lwjgl.input.Keyboard;
39 import org.lwjgl.input.Mouse;
40 import org.lwjgl.openal.AL;
41 import org.lwjgl.openal.AL10;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.GL11;
44 import org.lwjgl.util.glu.GLU;
45 import org.lwjgl.util.WaveData;
46
47 /**
48 * <br>
49 * This test demonstrates OpenAL positioning Based on the example by Chad Armstrong
50 * (http://www.edenwaith.com/products/pige/tutorials/openal.php)
51 *
52 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 2983 $
54 * $Id: PositionTest.java 2983 2008-04-07 18:36:09Z matzon $
55 */
56 public class PositionTest extends BasicTest {
57
58 /** *Small* glut implementation :) */
59 private GLUT glut;
60
61 /** Width of window */
62 public static final int WINDOW_WIDTH = 640;
63
64 /** Height of window */
65 public static final int WINDOW_HEIGHT = 480;
66
67 /** LEFT enumeration */
68 public static final int LEFT = 0;
69
70 /** CENTER enumeration */
71 public static final int CENTER = 1;
72
73 /** RIGHT enumeration */
74 public static final int RIGHT = 2;
75
76 /** Whether the demo is done */
77 private boolean finished = false;
78
79 /** Whether in pause mode */
80 private boolean pauseMode = false;
81
82 // OpenAL stuff
83 // ===================================================
84
85 /** OpenAL buffers */
86 private IntBuffer soundBuffers = BufferUtils.createIntBuffer(3);
87
88 /** OpenAL sources */
89 private IntBuffer soundSources = BufferUtils.createIntBuffer(3);
90
91 /** Position of listener */
92 private FloatBuffer listenerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
93
94 /** Velocity of listener */
95 private FloatBuffer listenerVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
96
97 /** Orientation of listener */
98 private FloatBuffer listenerOrientation =
99 createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f });
100
101 /** Position of left sound */
102 private FloatBuffer leftPosition = createFloatBuffer(new float[] { -2.0f, 0.0f, 0.0f });
103
104 /** Velocity of left sound */
105 private FloatBuffer leftVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
106
107 /** Position of center sound */
108 private FloatBuffer centerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, -4.0f });
109
110 /** Velocity of center sound */
111 private FloatBuffer centerVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
112
113 /** Position of right sound */
114 private FloatBuffer rightPosition = createFloatBuffer(new float[] { 2.0f, 0.0f, 0.0f });
115
116 /** Velocity of right sound */
117 private FloatBuffer rightVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
118 // ---------------------------------------------------
119
120 /**
121 * Runs the actual test, using supplied arguments
122 */
123 protected void execute(String[] args) {
124 // Setup needed stuff
125 try {
126 setup();
127 } catch (Exception e) {
128 System.out.println("Error setting up demonstration: ");
129 e.printStackTrace();
130 System.exit(-1);
131 }
132
133 // run the actual demonstration
134 run();
135
136 // shutdown
137 shutdown();
138 }
139
140 /**
141 * Performs setup of demonstration
142 */
143 private void setup() throws Exception {
144
145 // Setup Window
146 // =====================================================
147 LWJGLUtil.log("Setting up window");
148
149 // calc center
150 int centerX = (Display.getDisplayMode().getWidth() - WINDOW_WIDTH) / 2;
151 int centerY = (Display.getDisplayMode().getHeight() - WINDOW_HEIGHT) / 2;
152
153 // setup window
154 setDisplayMode();
155 Display.create();
156 // -----------------------------------------------------
157
158 // Setup OpenGL
159 // =====================================================
160 LWJGLUtil.log("Setting up OpenGL");
161
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);
170 glut = this.new GLUT();
171
172 Display.setVSyncEnabled(true);
173 // -----------------------------------------------------
174
175 // Setup OpenAL
176 // =====================================================
177 LWJGLUtil.log("Setting up OpenAL");
178
179 AL10.alListener(AL10.AL_POSITION, listenerPosition);
180 AL10.alListener(AL10.AL_VELOCITY, listenerVelocity);
181 AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation);
182
183 // creating buffers
184 LWJGLUtil.log("Creating buffers");
185 AL10.alGenBuffers(soundBuffers);
186 soundBuffers.rewind();
187
188 // creating sources
189 AL10.alGenSources(soundSources);
190 soundSources.rewind();
191
192 // load sound files (left, center, right).wav
193 LWJGLUtil.log("Loading soundfiles...");
194
195 LWJGLUtil.log("Loading left.wav");
196 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);
204
205 LWJGLUtil.log("Loading center.wav");
206 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);
214
215 LWJGLUtil.log("Loading right.wav");
216 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);
224
225 LWJGLUtil.log("Soundfiles loaded successfully");
226 // -----------------------------------------------------
227
228 Mouse.setGrabbed(true);
229 }
230
231 /**
232 * Runs the actual demonstration
233 */
234 private void run() {
235 boolean firstRun = true;
236
237 System.out.println("Press 1/4 (left), 2/5 (center) or 3/6 (right) to toggle sound");
238 System.out.println("Press LEFT/RIGHT to move along x axis");
239 System.out.println("Press SHIFT and either UP/DOWN to move along y axis");
240 System.out.println("Press UP/DOWN to move along z axis");
241 System.out.println("Move along the x and y axis with the mouse");
242 System.out.println("Press LEFT or RIGHT mouse button to move along z axis");
243 System.out.println("Press ESC to exit demo");
244
245 LWJGLUtil.log(
246 "Listener position: "
247 + listenerPosition.get(0)
248 + ", "
249 + listenerPosition.get(1)
250 + ", "
251 + listenerPosition.get(2));
252 LWJGLUtil.log("Left position: " + leftPosition.get(0) + ", " + leftPosition.get(1) + ", " + leftPosition.get(2));
253 LWJGLUtil.log("Center position: " + centerPosition.get(0) + ", " + centerPosition.get(1) + ", " + centerPosition.get(2));
254 LWJGLUtil.log("Right position: " + rightPosition.get(0) + ", " + rightPosition.get(1) + ", " + rightPosition.get(2));
255
256 while (!finished) {
257 // handle any input
258 handleInput();
259
260 // allow window to process internal messages
261 Display.update();
262
263 // render and paint if !minimized and not dirty
264 if(Display.isVisible()) {
265 render();
266 } else {
267 // sleeeeeep
268 pause(100);
269 }
270
271 // act on pause mode
272 paused(!(Display.isVisible() || Display.isActive()));
273
274 // start sound after first paint, since we don't want
275 // the delay before something is painted on the screen
276 if (firstRun && !pauseMode) {
277 firstRun = false;
278
279 // start sounds with delays
280 startSounds();
281 }
282 }
283 }
284
285 /**
286 * Starts playing the sounds at different times
287 */
288 private void startSounds() {
289 AL10.alSourcePlay(soundSources.get(LEFT));
290 pause(300);
291 AL10.alSourcePlay(soundSources.get(CENTER));
292 pause(500);
293 AL10.alSourcePlay(soundSources.get(RIGHT));
294 }
295
296 /**
297 * Handles any changes in pause mode
298 *
299 * @param paused Which pause mode to enter
300 */
301 private void paused(boolean paused) {
302 // if requesting pause, and not paused - pause and stop sound
303 if(paused && !pauseMode) {
304 pauseMode = true;
305 AL10.alSourcePause(soundSources);
306 System.out.println("pauseMode = true");
307 }
308
309 // else go out of pause mode and start sounds
310 else if(!paused && pauseMode) {
311 pauseMode = false;
312 startSounds();
313 System.out.println("pauseMode = false");
314 }
315 }
316
317 /**
318 * Handles any input
319 */
320 private void handleInput() {
321 // User wants to exit?
322 finished = Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE);
323 if (finished) {
324 return;
325 }
326
327 boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
328
329 // Test for play
330 // ============================================
331 if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
332 AL10.alSourcePlay(soundSources.get(LEFT));
333 LWJGLUtil.log("Playing left.wav");
334 }
335
336 if (Keyboard.isKeyDown(Keyboard.KEY_2)) {
337 AL10.alSourcePlay(soundSources.get(CENTER));
338 LWJGLUtil.log("Playing center.wav");
339 }
340
341 if (Keyboard.isKeyDown(Keyboard.KEY_3)) {
342 AL10.alSourcePlay(soundSources.get(RIGHT));
343 LWJGLUtil.log("Playing right.wav");
344 }
345 // --------------------------------------------
346
347 // Test for stop
348 // ============================================
349 if (Keyboard.isKeyDown(Keyboard.KEY_4)) {
350 AL10.alSourceStop(soundSources.get(LEFT));
351 LWJGLUtil.log("Stopped left.wav");
352 }
353
354 if (Keyboard.isKeyDown(Keyboard.KEY_5)) {
355 AL10.alSourceStop(soundSources.get(CENTER));
356 LWJGLUtil.log("Stopped center.wav");
357 }
358
359 if (Keyboard.isKeyDown(Keyboard.KEY_6)) {
360 AL10.alSourceStop(soundSources.get(RIGHT));
361 LWJGLUtil.log("Stopped right.wav");
362 }
363 // --------------------------------------------
364
365 // Test for movement with keyboard
366 // ============================================
367 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
368 listenerPosition.put(0, listenerPosition.get(0) - 0.1f);
369 AL10.alListener(AL10.AL_POSITION, listenerPosition);
370 }
371
372 if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
373 listenerPosition.put(0, listenerPosition.get(0) + 0.1f);
374 AL10.alListener(AL10.AL_POSITION, listenerPosition);
375 }
376
377 if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
378 if (shift) {
379 listenerPosition.put(1, listenerPosition.get(1) + 0.1f);
380 } else {
381 listenerPosition.put(2, listenerPosition.get(2) - 0.1f);
382 }
383 AL10.alListener(AL10.AL_POSITION, listenerPosition);
384 }
385
386 if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
387 if (shift) {
388 listenerPosition.put(1, listenerPosition.get(1) - 0.1f);
389 } else {
390 listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
391 }
392 AL10.alListener(AL10.AL_POSITION, listenerPosition);
393 }
394 // --------------------------------------------
395
396 // Test for movement with Mouse
397 // ============================================
398 listenerPosition.put(0, listenerPosition.get(0) + (0.01f * Mouse.getDX()));
399 listenerPosition.put(1, listenerPosition.get(1) + (0.01f * Mouse.getDY()));
400 if (Mouse.isButtonDown(0)) {
401 listenerPosition.put(2, listenerPosition.get(2) - 0.1f);
402 }
403 if (Mouse.isButtonDown(1)) {
404 listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
405 }
406
407 AL10.alListener(AL10.AL_POSITION, listenerPosition);
408
409 // empty mouse buffer
410 while(Mouse.next());
411 }
412
413 /**
414 * Render the scene
415 */
416 private void render() {
417 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
418 GL11.glPushMatrix();
419 {
420 GL11.glRotatef(20.0f, 1.0f, 1.0f, 0.0f);
421
422 // left
423 GL11.glPushMatrix();
424 {
425 GL11.glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2));
426 GL11.glColor3f(1.0f, 0.0f, 0.0f);
427 glut.glutWireCube(0.5f);
428 }
429 GL11.glPopMatrix();
430
431 // center
432 GL11.glPushMatrix();
433 {
434 GL11.glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2));
435 GL11.glColor3f(0.0f, 0.0f, 1.0f);
436 glut.glutWireCube(0.5f);
437 }
438 GL11.glPopMatrix();
439
440 // right
441 GL11.glPushMatrix();
442 {
443 GL11.glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2));
444 GL11.glColor3f(0.0f, 1.0f, 0.0f);
445 glut.glutWireCube(0.5f);
446 }
447 GL11.glPopMatrix();
448
449 // listener
450 GL11.glPushMatrix();
451 {
452 GL11.glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2));
453 GL11.glColor3f(1.0f, 1.0f, 1.0f);
454 glut.glutSolidCube(0.5f);
455 }
456 GL11.glPopMatrix();
457 }
458 GL11.glPopMatrix();
459 }
460
461 /**
462 * Shutdown of demonstration
463 */
464 private void shutdown() {
465 LWJGLUtil.log("Shutting down OpenAL");
466 AL10.alSourceStop(soundSources);
467 AL10.alDeleteSources(soundSources);
468 AL10.alDeleteBuffers(soundBuffers);
469 AL.destroy();
470
471 LWJGLUtil.log("Shutting down Window");
472 Display.destroy();
473 }
474
475 /**
476 * main entry point
477 *
478 * @param args
479 * String array containing arguments
480 */
481 public static void main(String[] args) {
482 PositionTest positionTest = new PositionTest();
483 positionTest.execute(args);
484 System.exit(0);
485 }
486
487 /**
488 * Minute implementation of GLUT: <br>COPYRIGHT:
489 *
490 * The OpenGL Utility Toolkit distribution for Win32 (Windows NT & Windows
491 * 95) contains source code modified from the original source code for GLUT
492 * version 3.3 which was developed by Mark J. Kilgard. The original source
493 * code for GLUT is Copyright 1997 by Mark J. Kilgard. GLUT for Win32 is
494 * Copyright 1997 by Nate Robins and is not in the public domain, but it is
495 * freely distributable without licensing fees. It is provided without
496 * guarantee or warrantee expressed or implied. It was ported with the
497 * permission of Mark J. Kilgard by Nate Robins.
498 *
499 * THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
500 * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
501 * OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
502 */
503 class GLUT {
504
505 float n[][] = new float[][] { { -1.0f, 0.0f, 0.0f }, {
506 0.0f, 1.0f, 0.0f }, {
507 1.0f, 0.0f, 0.0f }, {
508 0.0f, -1.0f, 0.0f }, {
509 0.0f, 0.0f, 1.0f }, {
510 0.0f, 0.0f, -1.0f }
511 };
512
513 int faces[][] = new int[][] { { 0, 1, 2, 3 }, {
514 3, 2, 6, 7 }, {
515 7, 6, 5, 4 }, {
516 4, 5, 1, 0 }, {
517 5, 6, 2, 1 }, {
518 7, 4, 0, 3 }
519 };
520 float v[][] = new float[8][3];
521
522 public void glutWireCube(float size) {
523 drawBox(size, GL11.GL_LINE_LOOP);
524 }
525
526 public void glutSolidCube(float size) {
527 drawBox(size, GL11.GL_QUADS);
528 }
529
530 private void drawBox(float size, int type) {
531
532 v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
533 v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
534 v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
535 v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
536 v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
537 v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
538
539 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();
547 }
548
549 }
550 }
551 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.openal.AL10;
37 import org.lwjgl.openal.OpenALException;
38
39 /**
40 *
41 * Simple test for testing the number of available sources
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: SourceLimitTest.java 2983 2008-04-07 18:36:09Z matzon $
46 */
47 public class SourceLimitTest extends BasicTest {
48
49 /** Sources to create */
50 protected int sourcesToCreate = 64;
51
52 /**
53 * Creates an instance of SourceLimitTest
54 */
55 public SourceLimitTest() {
56 super();
57 }
58
59 /**
60 * Runs the actual test, using supplied arguments
61 */
62 protected void execute(String[] args) {
63 //parse 1st arg to sourcecount
64 if (args.length > 0) {
65 try {
66 sourcesToCreate = Integer.parseInt(args[0]);
67 } catch (NumberFormatException nfe) {
68 System.out.println(
69 "Unable to parse parameter to integer. Defaulting to 64 sources.");
70 }
71 }
72
73 System.out.print("Creating " + sourcesToCreate + " in one go...");
74 try {
75 CreateAllSources();
76 } catch(OpenALException oale) {
77 oale.printStackTrace();
78 }
79
80
81 System.out.print("Creating " + sourcesToCreate + " one at a time...");
82 try {
83 CreateSourcesStep();
84 } catch(Exception e) {
85 e.printStackTrace();
86 }
87 //shutdown
88 alExit();
89 }
90
91 /**
92 * Tests the creation of n sources in on go
93 */
94 protected void CreateAllSources() {
95 int lastError;
96
97 //make bytbuffer that can hold sourcesToCreate sources
98 IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);
99
100 //Create sourcesToCreate sources in one fell swoop
101 try {
102 sources.position(0).limit(sourcesToCreate);
103 AL10.alGenSources(sources);
104
105 //delete sources
106 sources.position(0).limit(sourcesToCreate);
107 AL10.alDeleteSources(sources);
108
109 System.out.println("created " + sourcesToCreate + " sources successfully!");
110 } catch (OpenALException oale) {
111 System.out.println("Unable to create " + sourcesToCreate + " sources");
112 }
113 }
114
115 /**
116 * Tests if n sources can be created one at a time
117 */
118 protected void CreateSourcesStep() {
119 int lastError;
120 int sourcesCreated = 0;
121
122 //make bytbuffer that can hold sourcesToCreate sources
123 IntBuffer[] sources = new IntBuffer[sourcesToCreate];
124
125 //create the sources
126 try {
127 for (int i = 0; i < sourcesToCreate; i++) {
128 sources[i] = BufferUtils.createIntBuffer(1);
129 sources[i].position(0).limit(1);
130 AL10.alGenSources(sources[i]);
131 if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
132 break;
133 }
134 sourcesCreated++;
135 }
136 } catch (OpenALException oale) {
137 System.out.println("failed to create source: " + (sourcesCreated + 1));
138 }
139
140 //delete allocated sources
141 for (int i = 0; i < sourcesCreated; i++) {
142 //delete buffers and sources
143 sources[i].position(0).limit(1);
144 AL10.alDeleteSources(sources[i]);
145 }
146
147 if(sourcesCreated != sourcesToCreate) {
148 System.out.println("created " + sourcesCreated + " sources before failing");
149 } else {
150 System.out.println("created " + sourcesCreated + " sources successfully!");
151 }
152 }
153
154 /**
155 * main entry point
156 *
157 * @param args String array containing arguments
158 */
159 public static void main(String[] args) {
160 SourceLimitTest sourceLimitTest = new SourceLimitTest();
161 sourceLimitTest.execute(args);
162 System.exit(0);
163 }
164 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.openal;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.openal.AL10;
37 import org.lwjgl.util.WaveData;
38
39 /**
40 *
41 * Simple test for stresstesting OpenAL playing random samples ad nausea
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: StressTest.java 2983 2008-04-07 18:36:09Z matzon $
46 */
47 public class StressTest extends BasicTest {
48
49 /** Buffer containing sources */
50 private IntBuffer sources;
51
52 /** Buffer containing buffers */
53 private IntBuffer buffers;
54
55 /**
56 * Creates an instance of StressTest
57 */
58 public StressTest() {
59 super();
60 }
61
62 /**
63 * Runs the actual test, using supplied arguments
64 */
65 protected void execute(String[] args) {
66
67 createSources();
68
69 createBuffers();
70
71 try {
72 loadSamples();
73 runTest();
74 } catch (Exception e) {
75 e.printStackTrace();
76 }
77
78
79 alExit();
80 }
81
82 private void createSources() {
83 sources = BufferUtils.createIntBuffer(4);
84 sources.position(0).limit(4);
85 AL10.alGenSources(sources);
86 if (AL10.alGetError() != AL10.AL_NO_ERROR) {
87 System.out.println("Unable to create 4 sources");
88 alExit();
89 }
90 }
91
92 private void createBuffers() {
93 buffers = BufferUtils.createIntBuffer(10);
94 buffers.position(0).limit(10);
95 AL10.alGenBuffers(buffers);
96 if (AL10.alGetError() != AL10.AL_NO_ERROR) {
97 System.out.println("Unable to create 10 buffers");
98 sources.position(0).limit(4);
99 AL10.alDeleteSources(sources);
100 alExit();
101 }
102 }
103
104 private void loadSamples() throws Exception {
105 AL10.alGetError();
106 WaveData data = WaveData.create("ding.wav");
107 for (int i = 1; i <= 10; i++) {
108 AL10.alBufferData(
109 buffers.get(i - 1),
110 data.format,
111 data.data,
112 data.samplerate);
113
114 if (AL10.alGetError() != AL10.AL_NO_ERROR) {
115 System.out.println("Failed to load " + i + ".wav into buffer");
116 sources.position(0).limit(4);
117 AL10.alDeleteSources(sources);
118 buffers.position(0).limit(10);
119 AL10.alDeleteBuffers(buffers);
120
121 alExit();
122 }
123 }
124 data.dispose();
125 }
126
127 public void runTest() {
128 int iterations = 0;
129 int randomBuffer;
130 int startSlot = 1;
131 int nextSlot = startSlot;
132 long startTime = System.currentTimeMillis();
133
134 //mark background source as looping
135 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
136
137 //play background
138 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
139 AL10.alSourcePlay(sources.get(0));
140
141 while (System.currentTimeMillis() - startTime < (2000)) {
142
143 randomBuffer = getRandomBuffer();
144 System.out.println("random:" + randomBuffer);
145
146 //stop source at slot
147 AL10.alSourceStop(sources.get(nextSlot));
148 if (AL10.alGetError() != AL10.AL_NO_ERROR) {
149 System.out.println("Error stopping source.");
150 }
151 System.out.println("Stopped source: " + nextSlot);
152
153 //link source<->buffer
154 AL10.alSourcei(sources.get(nextSlot), AL10.AL_BUFFER, buffers.get(randomBuffer));
155 if (AL10.alGetError() != AL10.AL_NO_ERROR) {
156 System.out.println("Error linking buffer and source.");
157 }
158 System.out.println("linked source " + nextSlot + " with buffer " + randomBuffer);
159
160 //start playing
161 System.out.println("playing source " + nextSlot);
162 AL10.alSourcePlay(sources.get(nextSlot++));
163 if (nextSlot == 4) {
164 nextSlot = startSlot;
165 }
166
167 //pause
168 try {
169 Thread.sleep(500);
170 } catch (InterruptedException inte) {
171 }
172
173 //debug info
174 if ((++iterations % 10) == 0) {
175 System.out.println("========================");
176 System.out.println("MaxMemory: " + Runtime.getRuntime().maxMemory() / 1024);
177 System.out.println("FreeMemory: " + Runtime.getRuntime().freeMemory() / 1024);
178 System.out.println("TotalMemory: " + Runtime.getRuntime().totalMemory() / 1024);
179 System.out.println("========================");
180 }
181 }
182
183 //stop all sources
184 for (int i = 0; i < 4; i++) {
185 AL10.alSourceStop(sources.get(i));
186 System.out.println("Stopping source " + (i+1));
187 }
188
189 //test done - ask for user input
190 try {
191 System.out.println("Test completed");
192 System.out.println("========================");
193 System.out.println("MaxMemory: " + Runtime.getRuntime().maxMemory() / 1024);
194 System.out.println("FreeMemory: " + Runtime.getRuntime().freeMemory() / 1024);
195 System.out.println("TotalMemory: " + Runtime.getRuntime().totalMemory() / 1024);
196 System.out.println("========================");
197 System.out.println("Push any key to exit...");
198 System.in.read();
199 } catch (Exception e) {
200 }
201
202 sources.position(0).limit(4);
203 AL10.alDeleteSources(sources);
204 buffers.position(0).limit(10);
205 AL10.alDeleteBuffers(buffers);
206 }
207
208 private int getRandomBuffer() {
209 return (int) (Math.random() * 10.0);
210 }
211
212 /**
213 * main entry point
214 *
215 * @param args String array containing arguments
216 */
217 public static void main(String[] args) {
218 StressTest stressTest = new StressTest();
219 stressTest.execute(args);
220 System.exit(0);
221 }
222 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.input.Keyboard;
35 import org.lwjgl.opengl.Display;
36 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
38 import org.lwjgl.util.glu.GLU;
39 import org.lwjgl.util.vector.Vector2f;
40
41 /**
42 *
43 * Tests switching between windowed and fullscreen
44 *
45 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3172 $
47 * $Id: FullScreenWindowedTest.java 3172 2008-12-28 19:30:43Z elias_naur $
48 */
49 public class FullScreenWindowedTest {
50 /** Intended deiplay mode */
51 private DisplayMode mode;
52 /** our quad moving around */
53 private Vector2f quadPosition;
54 /** our quadVelocity */
55 private Vector2f quadVelocity;
56 /** angle of quad */
57 private float angle;
58 /** degrees to rotate per frame */
59 private float angleRotation = 1.0f;
60 /** Max speed of all changable attributes */
61 private static final float MAX_SPEED = 20.0f;
62
63 /**
64 * Creates a FullScreenWindowedTest
65 */
66 public FullScreenWindowedTest() {
67 }
68 /**
69 * Executes the test
70 */
71 public void execute() {
72 initialize();
73 mainLoop();
74 cleanup();
75 }
76
77 private void switchMode() throws LWJGLException {
78 mode = findDisplayMode(800, 600, Display.getDisplayMode().getBitsPerPixel());
79 Display.setDisplayModeAndFullscreen(mode);
80 }
81
82 /**
83 * Initializes the test
84 */
85 private void initialize() {
86 try {
87 //find displaymode
88 switchMode();
89 // start of in windowed mode
90 Display.create();
91 glInit();
92 quadPosition = new Vector2f(100f, 100f);
93 quadVelocity = new Vector2f(1.0f, 1.0f);
94 } catch (Exception e) {
95 e.printStackTrace();
96 }
97 }
98 /**
99 * Runs the main loop of the "test"
100 */
101 private void mainLoop() {
102 while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) {
103 if (Display.isVisible()) {
104 // check keyboard input
105 processKeyboard();
106 // do "game" logic, and render it
107 logic();
108 render();
109 } else {
110 // no need to render/paint if nothing has changed (ie. window
111 // dragged over)
112 if (Display.isDirty()) {
113 render();
114 }
115 // don't waste cpu time, sleep more
116 try {
117 Thread.sleep(100);
118 } catch (InterruptedException inte) {
119 }
120 }
121 // Update window
122 Display.update();
123 }
124 }
125 /**
126 * Performs the logic
127 */
128 private void logic() {
129 angle += angleRotation;
130 if (angle > 90.0f) {
131 angle = 0.0f;
132 }
133 quadPosition.x += quadVelocity.x;
134 quadPosition.y += quadVelocity.y;
135 //check colision with vertical border border
136 if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) {
137 quadVelocity.x *= -1;
138 }
139 //check collision with horizontal border
140 if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) {
141 quadVelocity.y *= -1;
142 }
143 }
144 private void render() {
145 //clear background
146 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
147 // draw white quad
148 GL11.glPushMatrix();
149 {
150 GL11.glTranslatef(quadPosition.x, quadPosition.y, 0);
151 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
152 GL11.glColor3f(1.0f, 1.0f, 1.0f);
153 GL11.glBegin(GL11.GL_QUADS);
154 {
155 GL11.glVertex2i(-50, -50);
156 GL11.glVertex2i(50, -50);
157 GL11.glVertex2i(50, 50);
158 GL11.glVertex2i(-50, 50);
159 }
160 GL11.glEnd();
161 }
162 GL11.glPopMatrix();
163 }
164 /**
165 * Processes keyboard input
166 */
167 private void processKeyboard() {
168 //check for fullscreen key
169 if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
170 try {
171 switchMode();
172 } catch (Exception e) {
173 e.printStackTrace();
174 }
175 }
176 //check for window key
177 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
178 try {
179 mode = new DisplayMode(640, 480);
180 Display.setDisplayModeAndFullscreen(mode);
181 glInit();
182 } catch (Exception e) {
183 e.printStackTrace();
184 }
185 }
186 //check for speed changes
187 if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
188 quadVelocity.y += 0.1f;
189 }
190 if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
191 quadVelocity.y -= 0.1f;
192 }
193 if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
194 quadVelocity.x += 0.1f;
195 }
196 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
197 quadVelocity.x -= 0.1f;
198 }
199 if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) {
200 angleRotation += 0.1f;
201 }
202 if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) {
203 angleRotation -= 0.1f;
204 }
205 //throttle
206 if (quadVelocity.x < -MAX_SPEED) {
207 quadVelocity.x = -MAX_SPEED;
208 }
209 if (quadVelocity.x > MAX_SPEED) {
210 quadVelocity.x = MAX_SPEED;
211 }
212 if (quadVelocity.y < -MAX_SPEED) {
213 quadVelocity.y = -MAX_SPEED;
214 }
215 if (quadVelocity.y > MAX_SPEED) {
216 quadVelocity.y = MAX_SPEED;
217 }
218 if (angleRotation < 0.0f) {
219 angleRotation = 0.0f;
220 }
221 if (angleRotation > MAX_SPEED) {
222 angleRotation = MAX_SPEED;
223 }
224 }
225 /**
226 * Cleans up the test
227 */
228 private void cleanup() {
229 Display.destroy();
230 }
231
232 /**
233 * Retrieves a displaymode, if one such is available
234 *
235 * @param width
236 * Required width
237 * @param height
238 * Required height
239 * @param bpp
240 * Minimum required bits per pixel
241 * @return
242 */
243 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
244 DisplayMode[] modes = Display.getAvailableDisplayModes();
245 for (int i = 0; i < modes.length; i++) {
246 if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) {
247 return modes[i];
248 }
249 }
250 return Display.getDesktopDisplayMode();
251 }
252 /**
253 * Initializes OGL
254 */
255 private void glInit() {
256 // Go into orthographic projection mode.
257 GL11.glMatrixMode(GL11.GL_PROJECTION);
258 GL11.glLoadIdentity();
259 GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
260 GL11.glMatrixMode(GL11.GL_MODELVIEW);
261 GL11.glLoadIdentity();
262 GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
263 //set clear color to black
264 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
265 //sync frame (only works on windows)
266 Display.setVSyncEnabled(true);
267 }
268 /**
269 * Test entry point
270 */
271 public static void main(String[] args) {
272 System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively");
273 System.out.println("Move quad using arrowkeys, and change rotation using +/-");
274 FullScreenWindowedTest fswTest = new FullScreenWindowedTest();
275 fswTest.execute();
276 System.exit(0);
277 }
278 }
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 * 3-D gear wheels. Originally by Brian Paul
34 */
35 package org.lwjgl.test.opengl;
36
37 import java.nio.FloatBuffer;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.opengl.ARBTransposeMatrix;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.DisplayMode;
44 import org.lwjgl.opengl.GL11;
45 import org.lwjgl.opengl.GLContext;
46
47 /**
48 * <p>
49 * This is the OpenGL "standard" Gears demo, originally by Brian Paul
50 * </p>
51 * @author Brian Matzon <brian@matzon.dk>
52 * @version $Revision: 3276 $
53 * $Id: Gears.java 3276 2010-02-21 21:18:17Z matzon $
54 */
55 public class Gears {
56
57 private float view_rotx = 20.0f;
58
59 private float view_roty = 30.0f;
60
61 private float view_rotz = 0.0f;
62
63 private int gear1;
64
65 private int gear2;
66
67 private int gear3;
68
69 private float angle = 0.0f;
70
71 public static void main(String[] args) {
72 new Gears().execute();
73 System.exit(0);
74 }
75
76 /**
77 *
78 */
79 private void execute() {
80 try {
81 init();
82 } catch (LWJGLException le) {
83 le.printStackTrace();
84 System.out.println("Failed to initialize Gears.");
85 return;
86 }
87
88 loop();
89
90 destroy();
91 }
92
93 /**
94 *
95 */
96 private void destroy() {
97 Display.destroy();
98 }
99
100 /**
101 *
102 */
103 private void loop() {
104 long startTime = System.currentTimeMillis() + 5000;
105 long fps = 0;
106
107 while (!Display.isCloseRequested()) {
108 angle += 2.0f;
109
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();
136
137 Display.update();
138 if (startTime > System.currentTimeMillis()) {
139 fps++;
140 } else {
141 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
142 startTime = System.currentTimeMillis() + 5000;
143 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
144 + (fps / (timeUsed / 1000f)));
145 fps = 0;
146 }
147 }
148 }
149
150 /**
151 *
152 */
153 private void init() throws LWJGLException {
154 // create Window of size 300x300
155 Display.setLocation((Display.getDisplayMode().getWidth() - 300) / 2,
156 (Display.getDisplayMode().getHeight() - 300) / 2);
157 Display.setDisplayMode(new DisplayMode(300, 300));
158 Display.setTitle("Gears");
159 Display.create();
160
161 // setup ogl
162 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
163 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
164 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
165 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
166
167 pos.flip();
168 red.flip();
169 green.flip();
170 blue.flip();
171
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);
177
178 /* 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 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);
188 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);
194 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));
204 System.err.println();
205 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
206 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
207 // --- not using extensions
208 GL11.glLoadIdentity();
209 } else {
210 // --- using extensions
211 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
212 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
213 0, 0, 1, 0, 0, 0, 0, 1});
214 identityTranspose.flip();
215 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
216 }
217
218 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 }
224
225 /**
226 * Draw a gear wheel. You'll probably want to call this function when
227 * building a display list since we do a lot of trig here.
228 *
229 * @param inner_radius radius of hole at center
230 * @param outer_radius radius at center of teeth
231 * @param width width of gear
232 * @param teeth number of teeth
233 * @param tooth_depth depth of tooth
234 */
235 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
236 int i;
237 float r0, r1, r2;
238 float angle, da;
239 float u, v, len;
240
241 r0 = inner_radius;
242 r1 = outer_radius - tooth_depth / 2.0f;
243 r2 = outer_radius + tooth_depth / 2.0f;
244
245 da = 2.0f * (float) Math.PI / teeth / 4.0f;
246
247 GL11.glShadeModel(GL11.GL_FLAT);
248
249 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
250
251 /* draw front face */
252 GL11.glBegin(GL11.GL_QUAD_STRIP);
253 for (i = 0; i <= teeth; i++) {
254 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);
257 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),
260 width * 0.5f);
261 }
262 }
263 GL11.glEnd();
264
265 /* draw front sides of teeth */
266 GL11.glBegin(GL11.GL_QUADS);
267 for (i = 0; i < teeth; i++) {
268 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();
275
276 /* draw back face */
277 GL11.glBegin(GL11.GL_QUAD_STRIP);
278 for (i = 0; i <= teeth; i++) {
279 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();
286
287 /* draw back sides of teeth */
288 GL11.glBegin(GL11.GL_QUADS);
289 for (i = 0; i < teeth; i++) {
290 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();
297
298 /* draw outward faces of teeth */
299 GL11.glBegin(GL11.GL_QUAD_STRIP);
300 for (i = 0; i < teeth; i++) {
301 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);
304 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
305 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
306 len = (float) Math.sqrt(u * u + v * v);
307 u /= len;
308 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);
315 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
316 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);
327
328 /* draw inside radius cylinder */
329 GL11.glBegin(GL11.GL_QUAD_STRIP);
330 for (i = 0; i <= teeth; i++) {
331 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();
337 }
338 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl;
32
33 import java.nio.ByteBuffer;
34 import java.nio.ByteOrder;
35 import java.nio.IntBuffer;
36
37 import org.lwjgl.LWJGLException;
38 import org.lwjgl.input.Keyboard;
39 import org.lwjgl.opengl.Display;
40 import org.lwjgl.opengl.DisplayMode;
41 import org.lwjgl.opengl.GL11;
42 import org.lwjgl.opengl.Pbuffer;
43 import org.lwjgl.opengl.PixelFormat;
44 import org.lwjgl.util.glu.GLU;
45 import org.lwjgl.util.vector.Vector2f;
46
47 /**
48 *
49 * Tests Pbuffers
50 *
51 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 2983 $
53 * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $
54 */
55 public class PbufferTest {
56
57 /** Intended deiplay mode */
58 private DisplayMode mode;
59
60 /** our quad moving around */
61 private Vector2f quadPosition;
62
63 /** our quadVelocity */
64 private Vector2f quadVelocity;
65
66 /** angle of quad */
67 private float angle;
68
69 /** degrees to rotate per frame */
70 private float angleRotation = 1.0f;
71
72 /** Max speed of all changable attributes */
73 private static final float MAX_SPEED = 20.0f;
74
75 /** Pbuffer instance */
76 private static Pbuffer pbuffer;
77
78 /** The shared texture */
79 private static int tex_handle;
80
81 /**
82 * Executes the test
83 */
84 public void execute() {
85 initialize();
86
87 mainLoop();
88
89 cleanup();
90 }
91
92 /**
93 * Initializes the test
94 */
95 private void initialize() {
96 try {
97 //find displaymode
98 pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null);
99 mode = findDisplayMode(800, 600, 16);
100 Display.setDisplayMode(mode);
101 // start of in windowed mode
102 Display.create();
103 // gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
104 if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
105 System.out.println("No Pbuffer support!");
106 System.exit(1);
107 }
108 System.out.println("Pbuffer support detected");
109
110 glInit();
111 initPbuffer();
112
113 Keyboard.create();
114
115 quadPosition = new Vector2f(100f, 100f);
116 quadVelocity = new Vector2f(1.0f, 1.0f);
117 } catch (Exception e) {
118 e.printStackTrace();
119 }
120 }
121
122 /**
123 * Runs the main loop of the "test"
124 */
125 private void mainLoop() {
126 while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) {
127 if (Display.isVisible()) {
128 // check keyboard input
129 processKeyboard();
130 // do "game" logic, and render it
131 logic();
132 render();
133 } else {
134 // no need to render/paint if nothing has changed (ie. window
135 // dragged over)
136 if (Display.isDirty()) {
137 render();
138 }
139 // don't waste cpu time, sleep more
140 try {
141 Thread.sleep(100);
142 } catch (InterruptedException inte) {
143 }
144 }
145 // Update window
146 Display.update();
147 }
148 }
149
150 /**
151 * Performs the logic
152 */
153 private void logic() {
154 angle += angleRotation;
155 if (angle > 90.0f) {
156 angle = 0.0f;
157 }
158
159 quadPosition.x += quadVelocity.x;
160 quadPosition.y += quadVelocity.y;
161
162 //check colision with vertical border border
163 if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) {
164 quadVelocity.x *= -1;
165 }
166
167 //check collision with horizontal border
168 if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) {
169 quadVelocity.y *= -1;
170 }
171 }
172
173 private void render() {
174 if (pbuffer.isBufferLost()) {
175 System.out.println("Buffer contents lost - will recreate the buffer");
176 pbuffer.destroy();
177 try {
178 pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null);
179 initPbuffer();
180 } catch (LWJGLException e) {
181 e.printStackTrace();
182 }
183 }
184 try {
185 pbuffer.makeCurrent();
186 } catch (LWJGLException e) {
187 throw new RuntimeException(e);
188 }
189 // Pbuffer rendering
190 //clear background
191 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
192
193 // draw white quad
194 GL11.glPushMatrix();
195 {
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);
200 {
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);
210 try {
211 Display.makeCurrent();
212 } catch (LWJGLException e) {
213 throw new RuntimeException(e);
214 }
215
216 // OpenGL window rendering
217 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
218 // draw white quad
219 GL11.glPushMatrix();
220 {
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);
225 {
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();
238 }
239
240 private void initPbuffer() {
241 try {
242 pbuffer.makeCurrent();
243 initGLState(256, 256, 0.5f);
244 GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle);
245 Display.makeCurrent();
246 } catch (Exception e) {
247 e.printStackTrace();
248 }
249 }
250
251 /**
252 * Processes keyboard input
253 */
254 private void processKeyboard() {
255 Keyboard.poll();
256
257 //check for fullscreen key
258 if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
259
260 try {
261 Display.setDisplayMode(mode);
262 Display.setFullscreen(true);
263 } catch (Exception e) {
264 e.printStackTrace();
265 }
266 }
267
268 //check for window key
269 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
270 try {
271 Display.setFullscreen(false);
272 } catch (Exception e) {
273 e.printStackTrace();
274 }
275 }
276
277 //check for speed changes
278 if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
279 quadVelocity.y += 0.1f;
280 }
281 if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
282 quadVelocity.y -= 0.1f;
283 }
284 if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
285 quadVelocity.x += 0.1f;
286 }
287 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
288 quadVelocity.x -= 0.1f;
289 }
290
291 if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) {
292 angleRotation += 0.1f;
293 }
294 if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) {
295 angleRotation -= 0.1f;
296 }
297
298 //throttle
299 if (quadVelocity.x < -MAX_SPEED) {
300 quadVelocity.x = -MAX_SPEED;
301 }
302 if (quadVelocity.x > MAX_SPEED) {
303 quadVelocity.x = MAX_SPEED;
304 }
305 if (quadVelocity.y < -MAX_SPEED) {
306 quadVelocity.y = -MAX_SPEED;
307 }
308 if (quadVelocity.y > MAX_SPEED) {
309 quadVelocity.y = MAX_SPEED;
310 }
311
312 if (angleRotation < 0.0f) {
313 angleRotation = 0.0f;
314 }
315 if (angleRotation > MAX_SPEED) {
316 angleRotation = MAX_SPEED;
317 }
318 }
319
320 private void destroyTexture() {
321 IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
322 buffer.put(0, tex_handle);
323 GL11.glDeleteTextures(buffer);
324 }
325
326 /**
327 * Cleans up the test
328 */
329 private void cleanup() {
330 destroyTexture();
331 pbuffer.destroy();
332 Display.destroy();
333 }
334
335 /**
336 * Retrieves a displaymode, if one such is available
337 *
338 * @param width Required width
339 * @param height Required height
340 * @param bpp Minimum required bits per pixel
341 * @return
342 */
343 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
344 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 }
352 return null;
353 }
354
355 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);
362
363 //set clear color to black
364 GL11.glClearColor(color, color, color, 0.0f);
365 }
366
367 /**
368 * Initializes OGL
369 */
370 private void glInit() {
371 //sync frame (only works on windows)
372 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);
376 // Create shared texture
377 IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
378 GL11.glGenTextures(buffer);
379 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);
385 initGLState(mode.getWidth(), mode.getHeight(), 0f);
386 }
387
388 /**
389 * Test entry point
390 */
391 public static void main(String[] args) {
392 System.out.println(
393 "Change between fullscreen and windowed mode, by pressing F and W respectively");
394 System.out.println("Move quad using arrowkeys, and change rotation using +/-");
395 PbufferTest fswTest = new PbufferTest();
396 fswTest.execute();
397 System.exit(0);
398 }
399 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.Sys;
35 import org.lwjgl.opengl.*;
36
37 import java.util.Random;
38
39 /** @author spasi <spasi@users.sourceforge.net> */
40 public final class SyncTest {
41
42 private SyncTest() {
43 }
44
45 public static void main(String[] args) {
46 runTest(args);
47 cleanup();
48 System.exit(0);
49 }
50
51 private static void runTest(String[] args) {
52 if ( args.length < 2 )
53 argsError("Insufficient number of arguments.");
54
55 int clears = 1;
56 int timeout = 0;
57
58 try {
59 clears = Integer.parseInt(args[0]);
60 timeout = Integer.parseInt(args[1]);
61 } catch (NumberFormatException e) {
62 argsError("Invalid number format.");
63 }
64
65 ContextAttribs ca = new ContextAttribs();
66
67 try {
68 DisplayMode[] modes = Display.getAvailableDisplayModes();
69
70 DisplayMode displayMode = chooseMode(modes, 1024, 768);
71 if ( displayMode == null )
72 displayMode = chooseMode(modes, 800, 600);
73 if ( displayMode == null )
74 displayMode = chooseMode(modes, 640, 480);
75 if ( displayMode == null )
76 kill("Failed to set an appropriate display mode.");
77
78 System.out.println("Setting display mode to: " + displayMode);
79 Display.setDisplayMode(displayMode);
80 Display.create(new PixelFormat(8, 24, 0), ca);
81 } catch (LWJGLException e) {
82 kill(e.getMessage());
83 }
84
85 System.out.println("\n---------\n");
86
87 final String version = GL11.glGetString(GL11.GL_VERSION);
88
89 System.out.println("GL Version: " + version);
90 System.out.println("ARB_sync: " + GLContext.getCapabilities().GL_ARB_sync);
91
92 if ( !GLContext.getCapabilities().OpenGL32 && !GLContext.getCapabilities().GL_ARB_sync )
93 kill("OpenGL3.2 or ARB_sync support is required for this test.");
94
95 System.out.println("\n---------\n");
96
97 System.out.println("Clearing the framebuffer a gazillion times...");
98
99 Random rand = new Random(System.currentTimeMillis());
100 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);
103 }
104
105 GLSync sync = GL32.glFenceSync(GL32.GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
106
107 System.out.println("\nWaiting on fence...");
108 long time = Sys.getTime();
109 int status = GL32.glClientWaitSync(sync, 0, timeout < 0 ? GL32.GL_TIMEOUT_IGNORED : timeout * 1000 * 1000);
110 System.out.println("\nFence sync complete after: " + ((Sys.getTime() - time) / (double)Sys.getTimerResolution()) + " seconds.");
111 System.out.print("\nWait Status: ");
112 switch ( status ) {
113 case GL32.GL_ALREADY_SIGNALED:
114 System.out.println("ALREADY_SIGNALED");
115 break;
116 case GL32.GL_CONDITION_SATISFIED:
117 System.out.println("CONDITION_SATISFIED");
118 break;
119 case GL32.GL_TIMEOUT_EXPIRED:
120 System.out.println("TIMEOUT_EXPIRED");
121 break;
122 case GL32.GL_WAIT_FAILED:
123 System.out.println("WAIT_FAILED");
124 break;
125 default:
126 System.out.println("Unexpected wait status: 0x" + Integer.toHexString(status));
127 }
128
129 System.out.println("Sync Status: " + (GL32.glGetSync(sync, GL32.GL_SYNC_STATUS) == GL32.GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
130
131 GL32.glDeleteSync(sync);
132
133 int error = GL11.glGetError();
134 if ( error != 0 )
135 System.out.println("\nTest failed with OpenGL error: " + error);
136 else
137 System.out.println("\nTest completed successfully.");
138 }
139
140 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
141 DisplayMode bestMode = null;
142
143 for ( int i = 0; i < modes.length; i++ ) {
144 DisplayMode mode = modes[i];
145 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
146 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
147 bestMode = mode;
148 }
149 }
150
151 return bestMode;
152 }
153
154 private static void cleanup() {
155 if ( Display.isCreated() )
156 Display.destroy();
157 }
158
159 private static void argsError(final String msg) {
160 System.out.println("\nInvalid arguments error: " + msg);
161 System.out.println("\nUsage: SyncTest <clears> <timeout>:\n");
162 System.out.println("clears\t- Number of times to clear the framebuffer.");
163 System.out.println("timeout\t- WaitSync timeout in milliseconds.");
164
165 cleanup();
166 System.exit(-1);
167 }
168
169 static void kill(String reason) {
170 System.out.println("The SyncTest program was terminated because an error occured.\n");
171 System.out.println("Reason: " + (reason == null ? "Unknown" : reason));
172
173 cleanup();
174 System.exit(-1);
175 }
176
177 }
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 * $Id: VBOIndexTest.java 2983 2008-04-07 18:36:09Z matzon $
34 *
35 * Simple java test program.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 */
40
41 package org.lwjgl.test.opengl;
42
43 import java.nio.ByteBuffer;
44 import java.nio.ByteOrder;
45 import java.nio.FloatBuffer;
46 import java.nio.IntBuffer;
47
48 import org.lwjgl.Sys;
49 import org.lwjgl.input.Keyboard;
50 import org.lwjgl.input.Mouse;
51 import org.lwjgl.opengl.ARBBufferObject;
52 import org.lwjgl.opengl.ARBVertexBufferObject;
53 import org.lwjgl.opengl.Display;
54 import org.lwjgl.opengl.DisplayMode;
55 import org.lwjgl.opengl.GL11;
56 import org.lwjgl.opengl.GLContext;
57 import org.lwjgl.util.glu.GLU;
58
59 public final class VBOIndexTest {
60
61 static {
62 try {
63 //find first display mode that allows us 640*480*16
64 int mode = -1;
65 DisplayMode[] modes = Display.getAvailableDisplayModes();
66 for ( int i = 0; i < modes.length; i++ ) {
67 if ( modes[i].getWidth() == 640
68 && modes[i].getHeight() == 480
69 && modes[i].getBitsPerPixel() >= 16 ) {
70 mode = i;
71 break;
72 }
73 }
74 if ( mode != -1 ) {
75 //select above found displaymode
76 System.out.println("Setting display mode to " + modes[mode]);
77 Display.setDisplayMode(modes[mode]);
78 System.out.println("Created display.");
79 }
80 } catch (Exception e) {
81 System.err.println("Failed to create display due to " + e);
82 }
83 }
84
85 static {
86 try {
87 Display.create();
88 System.out.println("Created OpenGL.");
89 } catch (Exception e) {
90 System.err.println("Failed to create OpenGL due to " + e);
91 System.exit(1);
92 }
93 }
94
95 /**
96 * Is the game finished?
97 */
98 private static boolean finished;
99
100 /**
101 * A rotating square!
102 */
103 private static float angle;
104 private static int buffer_id;
105 private static int indices_buffer_id;
106 private static FloatBuffer vertices;
107 private static ByteBuffer mapped_buffer = null;
108 private static FloatBuffer mapped_float_buffer = null;
109 private static IntBuffer indices;
110 private static ByteBuffer mapped_indices_buffer = null;
111 private static IntBuffer mapped_indices_int_buffer = null;
112
113 public static void main(String[] arguments) {
114 try {
115 init();
116 while ( !finished ) {
117 Display.update();
118
119 if ( !Display.isVisible() )
120 Thread.sleep(200);
121 else if ( Display.isCloseRequested() )
122 System.exit(0);
123
124 mainLoop();
125 render();
126 }
127 } catch (Throwable t) {
128 t.printStackTrace();
129 } finally {
130 cleanup();
131 }
132 System.exit(0);
133 }
134
135 /**
136 * All calculations are done in here
137 */
138 private static void mainLoop() {
139 angle += 1f;
140 if ( angle > 360.0f )
141 angle = 0.0f;
142
143 if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
144 System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
145 for ( int i = 0; i < Mouse.getButtonCount(); i++ )
146 if ( Mouse.isButtonDown(i) )
147 System.out.println("Button " + i + " down");
148 if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
149 finished = true;
150 for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
151 Keyboard.next();
152 if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
153 finished = true;
154 if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
155 System.out.println("Current time: " + Sys.getTime());
156 }
157 }
158
159 /**
160 * All rendering is done in here
161 */
162 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,
171 mapped_buffer);
172 if ( new_mapped_buffer != mapped_buffer )
173 mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
174 mapped_buffer = new_mapped_buffer;
175
176 new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
177 ARBBufferObject.GL_WRITE_ONLY_ARB,
178 mapped_indices_buffer);
179 if ( new_mapped_buffer != mapped_indices_buffer )
180 mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer();
181
182 mapped_float_buffer.rewind();
183 vertices.rewind();
184 mapped_float_buffer.put(vertices);
185
186 mapped_indices_int_buffer.rewind();
187 indices.rewind();
188 mapped_indices_int_buffer.put(indices);
189 if ( ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB) &&
190 ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB) ) {
191 GL11.glDrawElements(GL11.GL_QUADS, 4, GL11.GL_UNSIGNED_INT, 0);
192 }
193 GL11.glPopMatrix();
194 }
195
196 /**
197 * Initialize
198 */
199 private static void init() throws Exception {
200
201 System.out.println("Timer resolution: " + Sys.getTimerResolution());
202 // Go into orthographic projection mode.
203 GL11.glMatrixMode(GL11.GL_PROJECTION);
204 GL11.glLoadIdentity();
205 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
206 GL11.glMatrixMode(GL11.GL_MODELVIEW);
207 GL11.glLoadIdentity();
208 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
209 if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
210 System.out.println("ARB VBO not supported!");
211 System.exit(1);
212 }
213 IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer();
214 ARBBufferObject.glGenBuffersARB(int_buffer);
215 buffer_id = int_buffer.get(0);
216 indices_buffer_id = int_buffer.get(1);
217 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id);
218 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer_id);
219 vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
220 vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
221 vertices.rewind();
222 indices = ByteBuffer.allocateDirect(4 * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
223 indices.put(0).put(1).put(2).put(3);
224 indices.rewind();
225 ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB);
226 ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB);
227 GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
228 GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
229 }
230
231 /**
232 * Cleanup
233 */
234 private static void cleanup() {
235 IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer();
236 int_buffer.put(0, buffer_id);
237 int_buffer.put(1, indices_buffer_id);
238 ARBBufferObject.glDeleteBuffersARB(int_buffer);
239 Display.destroy();
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
32 /**
33 * $Id: VBOTest.java 3287 2010-03-14 23:24:40Z spasi $
34 *
35 * Simple java test program.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3287 $
39 */
40
41 package org.lwjgl.test.opengl;
42
43 import java.nio.ByteBuffer;
44 import java.nio.ByteOrder;
45 import java.nio.FloatBuffer;
46
47 import org.lwjgl.Sys;
48 import org.lwjgl.input.Keyboard;
49 import org.lwjgl.input.Mouse;
50 import org.lwjgl.opengl.ARBBufferObject;
51 import org.lwjgl.opengl.ARBVertexBufferObject;
52 import org.lwjgl.opengl.Display;
53 import org.lwjgl.opengl.DisplayMode;
54 import org.lwjgl.opengl.GL11;
55 import org.lwjgl.opengl.GLContext;
56 import org.lwjgl.util.glu.GLU;
57
58 public final class VBOTest {
59
60 static {
61 try {
62 //find first display mode that allows us 640*480*16
63 int mode = -1;
64 DisplayMode[] modes = Display.getAvailableDisplayModes();
65 for ( int i = 0; i < modes.length; i++ ) {
66 if ( modes[i].getWidth() == 640
67 && modes[i].getHeight() == 480
68 && modes[i].getBitsPerPixel() >= 16 ) {
69 mode = i;
70 break;
71 }
72 }
73 if ( mode != -1 ) {
74 //select above found displaymode
75 System.out.println("Setting display mode to " + modes[mode]);
76 Display.setDisplayMode(modes[mode]);
77 System.out.println("Created display.");
78 }
79 } catch (Exception e) {
80 System.err.println("Failed to create display due to " + e);
81 }
82 }
83
84 static {
85 try {
86 Display.create();
87 System.out.println("Created OpenGL.");
88 } catch (Exception e) {
89 System.err.println("Failed to create OpenGL due to " + e);
90 System.exit(1);
91 }
92 }
93
94 /**
95 * Is the game finished?
96 */
97 private static boolean finished;
98
99 /**
100 * A rotating square!
101 */
102 private static float angle;
103 private static int buffer_id;
104 private static FloatBuffer vertices;
105 private static ByteBuffer mapped_buffer = null;
106 private static FloatBuffer mapped_float_buffer = null;
107
108 public static void main(String[] arguments) {
109 try {
110 init();
111 while ( !finished ) {
112 Display.update();
113
114 if ( !Display.isVisible() )
115 Thread.sleep(200);
116 else if ( Display.isCloseRequested() )
117 System.exit(0);
118
119 mainLoop();
120 render();
121 }
122 } catch (Throwable t) {
123 t.printStackTrace();
124 } finally {
125 cleanup();
126 }
127 System.exit(0);
128 }
129
130 /**
131 * All calculations are done in here
132 */
133 private static void mainLoop() {
134 angle += 1f;
135 if ( angle > 360.0f )
136 angle = 0.0f;
137
138 if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
139 System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
140 for ( int i = 0; i < Mouse.getButtonCount(); i++ )
141 if ( Mouse.isButtonDown(i) )
142 System.out.println("Button " + i + " down");
143 if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
144 finished = true;
145 for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
146 Keyboard.next();
147 if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
148 finished = true;
149 if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
150 System.out.println("Current time: " + Sys.getTime());
151 }
152 }
153
154 /**
155 * All rendering is done in here
156 */
157 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,
164 mapped_buffer);
165 if ( new_mapped_buffer != mapped_buffer )
166 mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
167 mapped_buffer = new_mapped_buffer;
168 mapped_float_buffer.rewind();
169 vertices.rewind();
170 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();
174 }
175
176 /**
177 * Initialize
178 */
179 private static void init() throws Exception {
180 System.out.println("Timer resolution: " + Sys.getTimerResolution());
181 // 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());
188 if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
189 System.out.println("ARB VBO not supported!");
190 System.exit(1);
191 }
192 buffer_id = ARBBufferObject.glGenBuffersARB();
193 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id);
194 vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
195 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);
199 }
200
201 /**
202 * Cleanup
203 */
204 private static void cleanup() {
205 ARBBufferObject.glDeleteBuffersARB(buffer_id);
206 Display.destroy();
207 }
208 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2009-04-04
35 * Time: 21:20:24 pm
36 */
37
38 package org.lwjgl.test.opengl;
39
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.opengl.*;
42
43 import java.util.StringTokenizer;
44 import java.util.regex.Pattern;
45
46 public final class VersionTest {
47
48 private VersionTest() {
49 }
50
51 public static void main(String[] args) {
52 initialize(args);
53 cleanup();
54 System.exit(0);
55 }
56
57 private static void initialize(String[] args) {
58 if ( args.length < 2 )
59 argsError("Insufficient number of arguments");
60
61 int majorInput = 1;
62 int minorInput = 0;
63
64 try {
65 majorInput = Integer.parseInt(args[0]);
66 minorInput = Integer.parseInt(args[1]);
67 } catch (NumberFormatException e) {
68 argsError("Invalid number format");
69 }
70
71 ContextAttribs ca = new ContextAttribs(majorInput, minorInput);
72
73 if ( 2 < args.length ) {
74 for ( int i = 2; i < args.length; i++ ) {
75 if ( Pattern.matches("[0-9]+", args[i]) )
76 ca = ca.withLayer(Integer.parseInt(args[i]));
77 else if ( "debug".equalsIgnoreCase(args[i]) )
78 ca = ca.withDebug(true);
79 else if ( "fc".equalsIgnoreCase(args[i]) )
80 ca = ca.withForwardCompatible(true);
81 else if ( "core".equalsIgnoreCase(args[i]) )
82 ca = ca.withProfileCore(true);
83 else if ( "compatibility".equalsIgnoreCase(args[i]) )
84 ca = ca.withProfileCompatibility(true);
85 else
86 argsError("Unknown argument: \'" + args[i] + "\'");
87 }
88 }
89
90 try {
91 DisplayMode[] modes = Display.getAvailableDisplayModes();
92
93 DisplayMode displayMode;
94
95 displayMode = chooseMode(modes, 1024, 768);
96 if ( displayMode == null )
97 displayMode = chooseMode(modes, 800, 600);
98 if ( displayMode == null )
99 displayMode = chooseMode(modes, 640, 480);
100 if ( displayMode == null )
101 kill("Failed to set an appropriate display mode.");
102
103 System.out.println("Setting display mode to: " + displayMode);
104 Display.setDisplayMode(displayMode);
105 Display.create(new PixelFormat(8, 24, 0), ca);
106 } catch (LWJGLException e) {
107 kill(e.getMessage());
108 }
109
110 System.out.println("\n---------\n");
111
112 final String version = GL11.glGetString(GL11.GL_VERSION);
113
114 System.out.print("GL Version requested: " + majorInput + '.' + minorInput);
115 if ( ca.isProfileCore() )
116 System.out.print(" - Core Profile");
117 else if ( ca.isProfileCompatibility() )
118 System.out.print(" - Compatibility Profile");
119 System.out.println("\nGL Version returned : " + version);
120
121 final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
122
123 int majorVersion = Integer.parseInt(version_tokenizer.nextToken());
124 int minorVersion = Integer.parseInt(version_tokenizer.nextToken());
125
126 if ( majorVersion != majorInput || minorVersion != minorInput ) {
127 if ( majorInput == 1 && minorInput == 0 )
128 System.out.println("\tThe maximum supported version has been returned. The driver is well-behaved. :)");
129 else if ( majorInput < 3 && majorVersion < 3 )
130 System.out.println("\tThe maximum supported version pre-3.0 has been returned. The driver is well-behaved. :)");
131 else
132 System.out.println("\tThe requested version was not returned. The driver is buggy! :(");
133 } else
134 System.out.println("\tThe requested version was returned. :)");
135
136 if ( ca.isProfileCompatibility() && !GLContext.getCapabilities().GL_ARB_compatibility )
137 System.out.println("\tThe driver does not support the Compatibility Profile.");
138
139 System.out.println("\n---------\n");
140
141 System.out.println("Debug mode: " + ca.isDebug());
142 System.out.println("Forward compatible mode: " + ca.isForwardCompatible());
143 System.out.println("ARB_compatibility: " + GLContext.getCapabilities().GL_ARB_compatibility);
144 try {
145 GL11.glVertex3f(0.0f, 0.0f, 0.0f);
146 System.out.println("Deprecated functionality present: " + true);
147 } catch (Throwable t) {
148 System.out.println("Deprecated functionality present: " + false);
149 if ( GLContext.getCapabilities().GL_ARB_compatibility ) {
150 System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode.");
151 }
152 }
153 }
154
155 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
156 DisplayMode bestMode = null;
157
158 for ( int i = 0; i < modes.length; i++ ) {
159 DisplayMode mode = modes[i];
160 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
161 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
162 bestMode = mode;
163 }
164 }
165
166 return bestMode;
167 }
168
169 private static void cleanup() {
170 if ( Display.isCreated() )
171 Display.destroy();
172 }
173
174 private static void argsError(final String msg) {
175 System.out.println("\nInvalid arguments error: " + msg);
176 System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {<layer>, 'debug', 'fc'}:\n");
177 System.out.println("majorVersion\t- Major OpenGL version.");
178 System.out.println("majorVersion\t- Minor OpenGL version.");
179 System.out.println("layer\t- Layer plane (optional).");
180 System.out.println("debug\t- Enables debug mode (optional).");
181 System.out.println("fc\t- Enables forward compatibility mode (optional).");
182
183 cleanup();
184 System.exit(-1);
185 }
186
187 static void kill(String reason) {
188 System.out.println("The VersionTest program was terminated because an error occured.\n");
189 System.out.println("Reason: " + (reason == null ? "Unknown" : reason));
190
191 cleanup();
192 System.exit(-1);
193 }
194
195 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.awt;
32
33 import java.awt.Frame;
34 import java.awt.Color;
35 import java.awt.event.WindowAdapter;
36 import java.awt.event.WindowEvent;
37 import java.nio.FloatBuffer;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.LWJGLException;
41 import org.lwjgl.opengl.ARBTransposeMatrix;
42 import org.lwjgl.opengl.AWTGLCanvas;
43 import org.lwjgl.opengl.GL11;
44 import org.lwjgl.opengl.GLContext;
45
46 /**
47 * <p>
48 * AWT version of the gears demo
49 * <p>
50 * @version $Revision$
51 * @author Brian Matzon <brian@matzon.dk>
52 * $Id$
53 */
54 public class AWTGears extends Frame {
55
56 /** AWT GL canvas */
57 private AWTGLCanvas canvas0;
58
59 private float view_rotx = 20.0f;
60
61 private float view_roty = 30.0f;
62
63 private float view_rotz = 0.0f;
64
65 private int gear1;
66
67 private int gear2;
68
69 private int gear3;
70
71 private float angle = 0.0f;
72
73 /**
74 * C'tor
75 */
76 public AWTGears() throws LWJGLException {
77 setTitle("Gears");
78 setBackground(Color.BLACK);
79 AWTGearsCanvas canvas = new AWTGearsCanvas();
80 canvas.setSize(300, 300);
81 add(canvas);
82 addWindowListener(new WindowAdapter() {
83 public void windowClosing(WindowEvent e) {
84 dispose();
85 System.exit(0);
86 }
87 });
88 setResizable(true);
89 pack();
90 setVisible(true);
91 }
92
93 private void setup() {
94 // setup ogl
95 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
96 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
97 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
98 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
99 pos.flip();
100 red.flip();
101 green.flip();
102 blue.flip();
103
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);
109
110 /* 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 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);
120 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);
126 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));
136 System.err.println();
137 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
138 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
139 // --- not using extensions
140 GL11.glLoadIdentity();
141 } else {
142 // --- using extensions
143 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
144 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
145 0, 0, 1, 0, 0, 0, 0, 1});
146 identityTranspose.flip();
147 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
148 }
149
150 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
157 /**
158 * Draw a gear wheel. You'll probably want to call this function when
159 * building a display list since we do a lot of trig here.
160 *
161 * @param inner_radius radius of hole at center
162 * @param outer_radius radius at center of teeth
163 * @param width width of gear
164 * @param teeth number of teeth
165 * @param tooth_depth depth of tooth
166 */
167 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
168 int i;
169 float r0, r1, r2;
170 float angle, da;
171 float u, v, len;
172
173 r0 = inner_radius;
174 r1 = outer_radius - tooth_depth / 2.0f;
175 r2 = outer_radius + tooth_depth / 2.0f;
176
177 da = 2.0f * (float) Math.PI / teeth / 4.0f;
178
179 GL11.glShadeModel(GL11.GL_FLAT);
180
181 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
182
183 /* draw front face */
184 GL11.glBegin(GL11.GL_QUAD_STRIP);
185 for (i = 0; i <= teeth; i++) {
186 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);
189 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),
192 width * 0.5f);
193 }
194 }
195 GL11.glEnd();
196
197 /* draw front sides of teeth */
198 GL11.glBegin(GL11.GL_QUADS);
199 for (i = 0; i < teeth; i++) {
200 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();
207
208 /* draw back face */
209 GL11.glBegin(GL11.GL_QUAD_STRIP);
210 for (i = 0; i <= teeth; i++) {
211 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();
218
219 /* draw back sides of teeth */
220 GL11.glBegin(GL11.GL_QUADS);
221 for (i = 0; i < teeth; i++) {
222 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();
229
230 /* draw outward faces of teeth */
231 GL11.glBegin(GL11.GL_QUAD_STRIP);
232 for (i = 0; i < teeth; i++) {
233 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);
236 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
237 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
238 len = (float) Math.sqrt(u * u + v * v);
239 u /= len;
240 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);
247 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
248 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);
259
260 /* draw inside radius cylinder */
261 GL11.glBegin(GL11.GL_QUAD_STRIP);
262 for (i = 0; i <= teeth; i++) {
263 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 }
270
271 public static void main(String[] args) throws LWJGLException {
272 new AWTGears();
273 }
274 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.awt;
32
33 import java.nio.FloatBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.opengl.ARBTransposeMatrix;
38 import org.lwjgl.opengl.AWTGLCanvas;
39 import org.lwjgl.opengl.GL11;
40 import org.lwjgl.opengl.GLContext;
41 import org.lwjgl.test.applet.Test;
42
43 /**
44 * <p>
45 * AWT version of the gears demo
46 * <p>
47 * @version $Revision$
48 * @author Brian Matzon <brian@matzon.dk>
49 * $Id$
50 */
51 public class AWTGearsCanvas extends AWTGLCanvas implements Test {
52
53 private float view_rotx = 20.0f;
54
55 private float view_roty = 30.0f;
56
57 private float view_rotz = 0.0f;
58
59 private int gear1;
60
61 private int gear2;
62
63 private int gear3;
64
65 private float angle = 0.0f;
66
67 long startTime = 0;
68 long fps = 0;
69 int current_width;
70 int current_height;
71
72 /**
73 * C'tor
74 */
75 public AWTGearsCanvas() throws LWJGLException {
76 super();
77 }
78
79 public void paintGL() {
80
81 if(startTime == 0) {
82 setup();
83 startTime = System.currentTimeMillis() + 5000;
84 }
85
86 try {
87 angle += 2.0f;
88 if (getWidth() != current_width || getHeight() != current_height) {
89 current_width = getWidth();
90 current_height = getHeight();
91 GL11.glViewport(0, 0, current_width, current_height);
92 }
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();
119 swapBuffers();
120 repaint();
121 } catch (LWJGLException e) {
122 throw new RuntimeException(e);
123 }
124 if (startTime > System.currentTimeMillis()) {
125 fps++;
126 } else {
127 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
128 startTime = System.currentTimeMillis() + 5000;
129 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
130 + (fps / (timeUsed / 1000f)));
131 fps = 0;
132 }
133 }
134
135 private void setup() {
136 // setup ogl
137 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
138 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
139 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
140 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
141 pos.flip();
142 red.flip();
143 green.flip();
144 blue.flip();
145
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);
151
152 /* 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);
156 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);
162 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);
168 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));
178 System.err.println();
179 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
180 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
181 // --- not using extensions
182 GL11.glLoadIdentity();
183 } else {
184 // --- using extensions
185 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
186 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
187 0, 0, 1, 0, 0, 0, 0, 1});
188 identityTranspose.flip();
189 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
190 }
191
192 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
199 /**
200 * Draw a gear wheel. You'll probably want to call this function when
201 * building a display list since we do a lot of trig here.
202 *
203 * @param inner_radius radius of hole at center
204 * @param outer_radius radius at center of teeth
205 * @param width width of gear
206 * @param teeth number of teeth
207 * @param tooth_depth depth of tooth
208 */
209 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
210 int i;
211 float r0, r1, r2;
212 float angle, da;
213 float u, v, len;
214
215 r0 = inner_radius;
216 r1 = outer_radius - tooth_depth / 2.0f;
217 r2 = outer_radius + tooth_depth / 2.0f;
218
219 da = 2.0f * (float) Math.PI / teeth / 4.0f;
220
221 GL11.glShadeModel(GL11.GL_FLAT);
222
223 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
224
225 /* draw front face */
226 GL11.glBegin(GL11.GL_QUAD_STRIP);
227 for (i = 0; i <= teeth; i++) {
228 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);
231 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),
234 width * 0.5f);
235 }
236 }
237 GL11.glEnd();
238
239 /* draw front sides of teeth */
240 GL11.glBegin(GL11.GL_QUADS);
241 for (i = 0; i < teeth; i++) {
242 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();
249
250 /* draw back face */
251 GL11.glBegin(GL11.GL_QUAD_STRIP);
252 for (i = 0; i <= teeth; i++) {
253 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();
260
261 /* draw back sides of teeth */
262 GL11.glBegin(GL11.GL_QUADS);
263 for (i = 0; i < teeth; i++) {
264 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();
271
272 /* draw outward faces of teeth */
273 GL11.glBegin(GL11.GL_QUAD_STRIP);
274 for (i = 0; i < teeth; i++) {
275 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);
278 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
279 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
280 len = (float) Math.sqrt(u * u + v * v);
281 u /= len;
282 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);
289 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
290 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);
301
302 /* draw inside radius cylinder */
303 GL11.glBegin(GL11.GL_QUAD_STRIP);
304 for (i = 0; i <= teeth; i++) {
305 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();
311 }
312
313 /*
314 * @see org.lwjgl.test.applet.Test#start()
315 */
316 public void start() {
317 }
318
319 /*
320 * @see org.lwjgl.test.applet.Test#stop()
321 */
322 public void stop() {
323 }
324 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.awt;
32
33 import java.awt.Frame;
34 import java.awt.GridLayout;
35 import java.awt.event.WindowAdapter;
36 import java.awt.event.WindowEvent;
37
38 import org.lwjgl.LWJGLException;
39 import org.lwjgl.opengl.AWTGLCanvas;
40 import org.lwjgl.opengl.GL11;
41 import org.lwjgl.util.glu.GLU;
42
43 /**
44 * <p>
45 * Tests AWTGLCanvas functionality
46 * <p>
47 * @version $Revision: 2983 $
48 * @author $Author: matzon $
49 * $Id: AWTTest.java 2983 2008-04-07 18:36:09Z matzon $
50 */
51 public class AWTTest extends Frame {
52
53 /** AWT GL canvas */
54 private AWTGLCanvas canvas0, canvas1;
55
56 private volatile float angle;
57
58 /**
59 * C'tor
60 */
61 public AWTTest() throws LWJGLException {
62 setTitle("LWJGL AWT Canvas Test");
63 setSize(640, 320);
64 setLayout(new GridLayout(1, 2));
65 add(canvas0 = new AWTGLCanvas() {
66 int current_height;
67 int current_width;
68 public void paintGL() {
69 try {
70 if (getWidth() != current_width || getHeight() != current_height) {
71 current_width = getWidth();
72 current_height = getHeight();
73 GL11.glViewport(0, 0, current_width, current_height);
74 }
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();
88 swapBuffers();
89 repaint();
90 } catch (LWJGLException e) {
91 throw new RuntimeException(e);
92 }
93 }
94 });
95 add(canvas1 = new AWTGLCanvas() {
96 int current_height;
97 int current_width;
98 public void paintGL() {
99 try {
100 angle += 1.0f;
101 if (getWidth() != current_width || getHeight() != current_height) {
102 current_width = getWidth();
103 current_height = getHeight();
104 GL11.glViewport(0, 0, current_width, current_height);
105 }
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();
118 swapBuffers();
119 repaint();
120 } catch (LWJGLException e) {
121 throw new RuntimeException(e);
122 }
123 }
124 });
125 addWindowListener(new WindowAdapter() {
126 public void windowClosing(WindowEvent e) {
127 dispose();
128 System.exit(0);
129 }
130 });
131 setResizable(true);
132 setVisible(true);
133 }
134
135 public static void main(String[] args) throws LWJGLException {
136 new AWTTest();
137 }
138 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.awt;
32
33 import java.awt.BorderLayout;
34 import java.awt.Button;
35 import java.awt.Frame;
36 import java.awt.GridBagConstraints;
37 import java.awt.GridBagLayout;
38 import java.awt.Label;
39 import java.awt.List;
40 import java.awt.Panel;
41 import java.awt.event.ActionEvent;
42 import java.awt.event.ActionListener;
43 import java.awt.event.ItemEvent;
44 import java.awt.event.ItemListener;
45 import java.awt.event.WindowAdapter;
46 import java.awt.event.WindowEvent;
47 import java.nio.FloatBuffer;
48 import java.util.Enumeration;
49 import java.util.Hashtable;
50
51 import org.lwjgl.BufferUtils;
52 import org.lwjgl.LWJGLException;
53 import org.lwjgl.opengl.ARBTransposeMatrix;
54 import org.lwjgl.opengl.AWTGLCanvas;
55 import org.lwjgl.opengl.GL11;
56 import org.lwjgl.opengl.GLContext;
57
58 /**
59 * <p>
60 * </p>
61 * @version $Revision$
62 * @author Brian Matzon <brian@matzon.dk>
63 * $Id$
64 */
65 public class DemoBox extends Frame {
66
67 /** GL canvas */
68 private DemoBoxGLCanvas demoCanvas;
69
70 /** Demo selection panel */
71 private Panel selectionPanel;
72
73 /** Hashtable of demos */
74 private Hashtable selectableDemos;
75
76 /**
77 * Creates a new demo box instance
78 */
79 public DemoBox() {
80 selectableDemos = new Hashtable();
81 selectableDemos.put("default", new NullDemoBox());
82 selectableDemos.put("clear_color", new ClearColorDemoBox());
83 selectableDemos.put("gears", new GearsDemoBox());
84 }
85
86 /**
87 * @return
88 */
89 public boolean initialize() {
90 setTitle("LWJGL - Demo Box");
91 setSize(640, 480);
92 setLayout(new GridBagLayout());
93
94 // Setup selection panel
95 // =================================
96 selectionPanel = new Panel();
97 selectionPanel.setLayout(new BorderLayout());
98 selectionPanel.add(new Label("Demo", Label.CENTER), BorderLayout.NORTH);
99
100 Button fullScreen = new Button("Fullscreen");
101 fullScreen.addActionListener(new ActionListener() {
102
103 public void actionPerformed(ActionEvent event) {
104 toggleFullscreen();
105 }
106 });
107 selectionPanel.add(fullScreen, BorderLayout.SOUTH);
108
109 final List demos = new List();
110 for (Enumeration e = selectableDemos.keys(); e.hasMoreElements();) {
111 demos.add(e.nextElement().toString());
112 }
113 selectionPanel.add(demos, BorderLayout.CENTER);
114
115 demos.addItemListener(new ItemListener() {
116
117 public void itemStateChanged(ItemEvent event) {
118 demoSelected(event.getItemSelectable().getSelectedObjects()[0].toString());
119 }
120 });
121
122 GridBagConstraints gbc = new GridBagConstraints();
123 gbc.gridx = 0;
124 gbc.gridy = 0;
125 gbc.fill = java.awt.GridBagConstraints.BOTH;
126 gbc.weightx = 0.05;
127 gbc.weighty = 1.0;
128 add(selectionPanel, gbc);
129 // ---------------------------------
130
131 // setup demo canvas
132 // =================================
133 try {
134 demoCanvas = new DemoBoxGLCanvas(this);
135
136 gbc = new GridBagConstraints();
137 gbc.gridx = 1;
138 gbc.gridy = 0;
139 gbc.fill = java.awt.GridBagConstraints.BOTH;
140 gbc.weightx = 0.95;
141 gbc.weighty = 1.0;
142 add(demoCanvas, gbc);
143 } catch (LWJGLException le) {
144 le.printStackTrace();
145 return false;
146 }
147 // ---------------------------------
148
149 addWindowListener(new WindowAdapter() {
150
151 public void windowClosing(WindowEvent e) {
152 demoCanvas.destroy();
153 dispose();
154 System.exit(0);
155 }
156 });
157
158 //demos.select(0);
159 //demoSelected(demos.getSelectedItem());
160 return true;
161 }
162
163 public void updateFPS(float fps) {
164 if(fps != -1) {
165 setTitle("LWJGL - Demo Box (FPS: " + fps + ")");
166 } else {
167 setTitle("LWJGL - Demo Box");
168 }
169 }
170
171 /**
172 * Enter fullscreen mode for this demo
173 */
174 protected void toggleFullscreen() {
175 System.out.println("Toggle Fullscreen");
176 }
177
178 /**
179 * Selected a demo
180 * @param demo Name of demo that was selected
181 */
182 protected void demoSelected(String demo) {
183 System.out.println("Selecting demo: " + demo);
184 demoCanvas.setActiveDemo((Demo) selectableDemos.get(demo));
185 }
186
187 /**
188 * @param args
189 * @throws LWJGLException
190 */
191 public static void main(String[] args) throws LWJGLException {
192 DemoBox demo = new DemoBox();
193 demo.initialize();
194 demo.setVisible(true);
195 }
196
197 /**
198 * Interface for a demo
199 */
200 public interface Demo {
201 public boolean isInitialized();
202 public boolean initialize();
203 public void render();
204 public void destroy();
205 }
206
207 /**
208 *
209 */
210 private class DemoBoxGLCanvas extends AWTGLCanvas implements Runnable {
211
212 /** Parent demo box */
213 DemoBox parent;
214
215 /** Currently active demo */
216 Demo activeDemo;
217
218 /** last active demo */
219 Demo lastActiveDemo;
220
221 /** Render thread */
222 private Thread renderThread;
223
224 public DemoBoxGLCanvas(DemoBox parent) throws LWJGLException {
225 super();
226 this.parent = parent;
227 }
228
229 // FPS
230 long startTime = 0;
231 long fps = 0;
232
233 protected void paintGL() {
234 synchronized (this) {
235 if (lastActiveDemo != null && lastActiveDemo != activeDemo) {
236 lastActiveDemo.destroy();
237 lastActiveDemo = null;
238 if (activeDemo != null) {
239 activeDemo.initialize();
240 startTime = System.currentTimeMillis() + 5000;
241 } else {
242 parent.updateFPS(-1);
243 }
244 }
245
246 if (activeDemo != null) {
247
248 if(!activeDemo.isInitialized()) {
249 activeDemo.initialize();
250 }
251
252 activeDemo.render();
253 try {
254 swapBuffers();
255 } catch (LWJGLException le) {
256 le.printStackTrace();
257 }
258
259 if (startTime > System.currentTimeMillis()) {
260 fps++;
261 } else {
262 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
263 startTime = System.currentTimeMillis() + 5000;
264 parent.updateFPS((fps / (timeUsed / 1000f)));
265 fps = 0;
266 }
267 }
268 }
269 }
270
271 public void destroy() {
272 setActiveDemo(null);
273 renderThread = null;
274 }
275
276 public void setActiveDemo(Demo activeDemo) {
277 synchronized (this) {
278 // setting no current demo
279 if (activeDemo == null) {
280 lastActiveDemo = this.activeDemo;
281 this.activeDemo = null;
282 return;
283 }
284
285 // setting to new demo
286 lastActiveDemo = this.activeDemo;
287 this.activeDemo = activeDemo;
288 }
289
290 if (renderThread == null) {
291 renderThread = new Thread(this);
292 renderThread.setName("DemoBox-Renderer");
293 renderThread.start();
294 }
295 }
296
297 public DemoBoxGLCanvas() throws LWJGLException {
298 super();
299 }
300
301 public void run() {
302 long sleep_time = 1000;
303 while (renderThread != null) {
304
305 // check for change of demo
306 synchronized (this) {
307 // if no demo set, just sleep
308 if (activeDemo == null) {
309 sleep_time = 1000;
310 } else {
311 // we have a demo!
312 sleep_time = 16;
313 repaint();
314 }
315 }
316 sleep(sleep_time);
317 }
318 System.out.println("dead");
319 }
320
321 private void sleep(long time) {
322 try {
323 Thread.sleep(time);
324 } catch (InterruptedException inte) {
325 }
326 }
327 }
328
329 // Demo box demo
330 // ========================================================
331 public class ClearColorDemoBox implements Demo {
332
333 private boolean initialized;
334
335 int direction = 1;
336
337 float color;
338
339 public boolean isInitialized() {
340 return initialized;
341 }
342
343 public boolean initialize() {
344 return initialized = true;
345 }
346
347 public void render() {
348 GL11.glClearColor(color, color, color, 1f);
349 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
350
351 color += direction * .05f;
352
353 if (color > 1f) {
354 color = 1f;
355 direction = -1 * direction;
356 } else if (color < 0f) {
357 direction = -1 * direction;
358 color = 0f;
359 }
360 }
361
362 public void destroy() {
363 initialized = false;
364 }
365 }
366
367 // --------------------------------------------------------
368
369 // Demo box demo
370 // ========================================================
371 public class NullDemoBox implements Demo {
372
373 private boolean initialized;
374
375 public boolean isInitialized() {
376 return initialized;
377 }
378
379 public boolean initialize() {
380 GL11.glClearColor(0, 0, 0, 1f);
381 return true;
382 }
383
384 public void render() {
385 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
386 }
387
388 public void destroy() {
389 initialized = false;
390 }
391 }
392 // --------------------------------------------------------
393
394 // Demo box demo
395 // ========================================================
396 public class GearsDemoBox implements Demo {
397
398 private boolean initialized;
399
400 private float view_rotx = 20.0f;
401
402 private float view_roty = 30.0f;
403
404 private float view_rotz = 0.0f;
405
406 private int gear1;
407
408 private int gear2;
409
410 private int gear3;
411
412 private float angle = 0.0f;
413
414 public boolean isInitialized() {
415 return initialized;
416 }
417
418 public boolean initialize() {
419 // setup ogl
420 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
421 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
422 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
423 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
424 pos.flip();
425 red.flip();
426 green.flip();
427 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);
436
437 /* 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);
441 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);
447 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);
453 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));
463 System.err.println();
464 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
465 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
466 // --- not using extensions
467 GL11.glLoadIdentity();
468 } else {
469 // --- using extensions
470 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
471 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
472 0, 0, 1, 0, 0, 0, 0, 1});
473 identityTranspose.flip();
474 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
475 }
476
477 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);
482 return initialized = true;
483 }
484
485 public void render() {
486 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
515 /**
516 * Draw a gear wheel. You'll probably want to call this function when
517 * building a display list since we do a lot of trig here.
518 *
519 * @param inner_radius radius of hole at center
520 * @param outer_radius radius at center of teeth
521 * @param width width of gear
522 * @param teeth number of teeth
523 * @param tooth_depth depth of tooth
524 */
525 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
526 int i;
527 float r0, r1, r2;
528 float angle, da;
529 float u, v, len;
530
531 r0 = inner_radius;
532 r1 = outer_radius - tooth_depth / 2.0f;
533 r2 = outer_radius + tooth_depth / 2.0f;
534
535 da = 2.0f * (float) Math.PI / teeth / 4.0f;
536
537 GL11.glShadeModel(GL11.GL_FLAT);
538
539 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
540
541 /* draw front face */
542 GL11.glBegin(GL11.GL_QUAD_STRIP);
543 for (i = 0; i <= teeth; i++) {
544 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);
547 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),
550 width * 0.5f);
551 }
552 }
553 GL11.glEnd();
554
555 /* draw front sides of teeth */
556 GL11.glBegin(GL11.GL_QUADS);
557 for (i = 0; i < teeth; i++) {
558 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();
565
566 /* draw back face */
567 GL11.glBegin(GL11.GL_QUAD_STRIP);
568 for (i = 0; i <= teeth; i++) {
569 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();
576
577 /* draw back sides of teeth */
578 GL11.glBegin(GL11.GL_QUADS);
579 for (i = 0; i < teeth; i++) {
580 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();
587
588 /* draw outward faces of teeth */
589 GL11.glBegin(GL11.GL_QUAD_STRIP);
590 for (i = 0; i < teeth; i++) {
591 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);
594 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
595 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
596 len = (float) Math.sqrt(u * u + v * v);
597 u /= len;
598 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);
605 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
606 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);
617
618 /* draw inside radius cylinder */
619 GL11.glBegin(GL11.GL_QUAD_STRIP);
620 for (i = 0; i <= teeth; i++) {
621 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 }
628
629 public void destroy() {
630 GL11.glDeleteLists(gear1, 1);
631 GL11.glDeleteLists(gear2, 1);
632 GL11.glDeleteLists(gear3, 1);
633 initialized = false;
634 }
635 }
636 // --------------------------------------------------------
637 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.awt;
32
33 import java.awt.Canvas;
34 import java.awt.Frame;
35 import java.awt.GridLayout;
36 import java.awt.event.WindowAdapter;
37 import java.awt.event.WindowEvent;
38
39 import org.lwjgl.LWJGLException;
40 import org.lwjgl.input.Keyboard;
41 import org.lwjgl.input.Mouse;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.GL11;
44 import org.lwjgl.util.glu.GLU;
45
46 /**
47 * <p>
48 * Tests Display.setParent()
49 * <p>
50 * @version $Revision: 3102 $
51 * @author $Author: matzon $
52 * $Id: DisplayParentTest.java 3102 2008-06-08 09:30:24Z matzon $
53 */
54 public class DisplayParentTest extends Frame {
55 boolean killswitch = false;
56 public DisplayParentTest() throws LWJGLException {
57 setTitle("LWJGL Display Parent Test");
58 setSize(640, 320);
59 setLayout(new GridLayout(1, 2));
60 final Canvas display_parent = new Canvas();
61 display_parent.setFocusable(true);
62 display_parent.setIgnoreRepaint(true);
63 add(display_parent);
64 addWindowListener(new WindowAdapter() {
65 public void windowClosing(WindowEvent e) {
66 killswitch = true;
67 }
68 });
69 setResizable(true);
70 setVisible(true);
71 Display.setParent(display_parent);
72 Display.setVSyncEnabled(true);
73 Display.create();
74 float angle = 0f;
75
76 while (isVisible() && !killswitch) {
77 angle += 1.0f;
78 int width;
79 int height;
80 if (!Display.isFullscreen()) {
81 width = display_parent.getWidth();
82 height = display_parent.getHeight();
83 } else {
84 width = Display.getDisplayMode().getWidth();
85 height = Display.getDisplayMode().getHeight();
86 }
87
88 if(width < 1 || height < 1) {
89 continue;
90 }
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();
104 Display.update();
105 while(Keyboard.next()) {
106 // closing on ESCAPE
107 if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
108 Display.destroy();
109 dispose();
110 break;
111 }
112
113 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
114 Mouse.setGrabbed(!Mouse.isGrabbed());
115 }
116 if(Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState()) {
117 Display.setFullscreen(!Display.isFullscreen());
118 }
119 }
120 /* while (Mouse.next()) {
121 System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY());
122 }*/
123 }
124 Display.destroy();
125 dispose();
126 }
127
128 public static void main(String[] args) throws LWJGLException {
129 new DisplayParentTest();
130 }
131 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.pbuffers;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.LWJGLException;
37 import org.lwjgl.input.Keyboard;
38 import org.lwjgl.opengl.Display;
39 import org.lwjgl.opengl.DisplayMode;
40 import org.lwjgl.opengl.GL11;
41 import org.lwjgl.opengl.Pbuffer;
42 import org.lwjgl.opengl.PixelFormat;
43 import org.lwjgl.util.glu.GLU;
44 import org.lwjgl.util.vector.Vector2f;
45
46 /**
47 * <p/>
48 * Tests Pbuffers
49 *
50 * @author elias_naur <elias_naur@users.sourceforge.net>
51 * @version $Revision: 2983 $
52 * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $
53 */
54 public final class PbufferTest {
55
56 /**
57 * Texture and pbuffer size
58 */
59 private static final int TEXTURE_SIZE = 512;
60
61 /**
62 * Size of the animated quad
63 */
64 private static final int QUAD_SIZE = 64;
65
66 /**
67 * The renderer to use when rendering to texture.
68 */
69 private TextureRenderer texRenderer;
70
71 /**
72 * Intended deiplay mode
73 */
74 private DisplayMode mode;
75
76 /**
77 * our quad moving around
78 */
79 private Vector2f quadPosition;
80
81 /**
82 * For positioning our quad in the texture
83 */
84 private float texScaleX, texScaleY;
85
86 /**
87 * our quadVelocity
88 */
89 private Vector2f quadVelocity;
90
91 /**
92 * angle of quad
93 */
94 private float angle;
95
96 /**
97 * degrees to rotate per frame
98 */
99 private float angleRotation = 1.0f;
100
101 /**
102 * Max speed of all changable attributes
103 */
104 private static final float MAX_SPEED = 20.0f;
105
106 /**
107 * The shared texture
108 */
109 private static int texID;
110
111 public PbufferTest(final int renderMode) {
112 try {
113 //find displaymode
114 mode = findDisplayMode(800, 600, 16);
115 Display.setDisplayMode(mode);
116 Display.create(new PixelFormat(16, 0, 0, 0, 0));
117
118 glInit();
119
120 if ( (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0 ) {
121 System.out.println("No Pbuffer support!");
122 System.exit(-1);
123 }
124 System.out.println("Pbuffer support detected. Initializing...\n");
125
126 switch ( renderMode ) {
127 case 1:
128 System.out.print("Creating pbuffer with unique context...");
129 texRenderer = new UniqueRenderer(TEXTURE_SIZE, TEXTURE_SIZE, texID);
130 break;
131 case 2:
132 System.out.print("Creating render-to-texture pbuffer with unique context...");
133 texRenderer = new UniqueRendererRTT(TEXTURE_SIZE, TEXTURE_SIZE, texID);
134 break;
135 }
136
137 System.out.println("OK");
138
139 quadPosition = new Vector2f(100f, 100f);
140 quadVelocity = new Vector2f(1.0f, 1.0f);
141
142 texScaleX = TEXTURE_SIZE / (float)mode.getWidth();
143 texScaleY = TEXTURE_SIZE / (float)mode.getHeight();
144 } catch (Exception e) {
145 e.printStackTrace();
146 }
147 }
148
149 /**
150 * Executes the test
151 */
152 public void execute() {
153 mainLoop();
154 cleanup();
155 }
156
157 /**
158 * Runs the main loop of the "test"
159 */
160 private void mainLoop() {
161 while ( !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested() ) {
162 if ( Display.isVisible() ) {
163 // check keyboard input
164 processKeyboard();
165
166 // do "game" logic, and render it
167 logic();
168
169 render();
170 } else {
171 // no need to render/paint if nothing has changed (ie. window dragged over)
172 if ( Display.isDirty() )
173 render();
174
175
176 // don't waste cpu time, sleep more
177 try {
178 Thread.sleep(100);
179 } catch (InterruptedException inte) {
180 }
181 }
182 // Update window
183 Display.update();
184 // Sync
185 Display.sync(100);
186 }
187 }
188
189 /**
190 * Performs the logic
191 */
192 private void logic() {
193 angle += angleRotation;
194 if ( angle > 360.0f )
195 angle -= 360.0f;
196
197 quadPosition.x += quadVelocity.x;
198 quadPosition.y += quadVelocity.y;
199
200 // check colision with vertical border border
201 if ( quadPosition.x + QUAD_SIZE >= mode.getWidth() || quadPosition.x - QUAD_SIZE <= 0 )
202 quadVelocity.x *= -1;
203
204 // check collision with horizontal border
205 if ( quadPosition.y + QUAD_SIZE >= mode.getHeight() || quadPosition.y - QUAD_SIZE <= 0 )
206 quadVelocity.y *= -1;
207 }
208
209 private void render() {
210 // -----------------------------------------------------------
211 // -------------------- Pbuffer rendering --------------------
212 // -----------------------------------------------------------
213 // Tell the pbuffer to get ready for rendering
214 texRenderer.enable();
215
216 // Clear the background
217 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
218
219 // Draw quad with gradient
220 GL11.glPushMatrix();
221 {
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);
225 {
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();
236
237 // Refresh the texture
238 texRenderer.updateTexture();
239
240 // -----------------------------------------------------------
241 // -------------------- Display rendering --------------------
242 // -----------------------------------------------------------
243 try {
244 Display.makeCurrent();
245 } catch (LWJGLException e) {
246 throw new RuntimeException(e);
247 }
248
249 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
250
251 // draw white quad
252 GL11.glPushMatrix();
253 {
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);
258 {
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();
271 }
272
273 /**
274 * Processes keyboard input
275 */
276 private void processKeyboard() {
277 Keyboard.poll();
278
279 //check for fullscreen key
280 if ( Keyboard.isKeyDown(Keyboard.KEY_F) ) {
281 try {
282 Display.setDisplayMode(mode);
283 Display.setFullscreen(true);
284 } catch (Exception e) {
285 e.printStackTrace();
286 }
287 }
288
289 //check for window key
290 if ( Keyboard.isKeyDown(Keyboard.KEY_W) ) {
291 try {
292 Display.setFullscreen(false);
293 } catch (Exception e) {
294 e.printStackTrace();
295 }
296 }
297
298 //check for speed changes
299 if ( Keyboard.isKeyDown(Keyboard.KEY_UP) )
300 quadVelocity.y += 0.1f;
301 if ( Keyboard.isKeyDown(Keyboard.KEY_DOWN) )
302 quadVelocity.y -= 0.1f;
303 if ( Keyboard.isKeyDown(Keyboard.KEY_RIGHT) )
304 quadVelocity.x += 0.1f;
305 if ( Keyboard.isKeyDown(Keyboard.KEY_LEFT) )
306 quadVelocity.x -= 0.1f;
307
308 if ( Keyboard.isKeyDown(Keyboard.KEY_ADD) )
309 angleRotation += 0.1f;
310 if ( Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT) )
311 angleRotation -= 0.1f;
312
313 //throttle
314 if ( quadVelocity.x < -MAX_SPEED )
315 quadVelocity.x = -MAX_SPEED;
316 if ( quadVelocity.x > MAX_SPEED )
317 quadVelocity.x = MAX_SPEED;
318 if ( quadVelocity.y < -MAX_SPEED )
319 quadVelocity.y = -MAX_SPEED;
320 if ( quadVelocity.y > MAX_SPEED )
321 quadVelocity.y = MAX_SPEED;
322
323 if ( angleRotation < 0.0f )
324 angleRotation = 0.0f;
325 if ( angleRotation > MAX_SPEED )
326 angleRotation = MAX_SPEED;
327 }
328
329 /**
330 * Cleans up the test
331 */
332 private void cleanup() {
333 // Destroy texture
334 IntBuffer buffer = BufferUtils.createIntBuffer(1);
335 buffer.put(0, texID);
336 GL11.glDeleteTextures(buffer);
337
338 texRenderer.destroy();
339 Display.destroy();
340 }
341
342 /**
343 * Retrieves a displaymode, if one such is available
344 *
345 * @param width Required width
346 * @param height Required height
347 * @param bpp Minimum required bits per pixel
348 *
349 * @return
350 */
351 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
352 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 }
359 }
360 return null;
361 }
362
363 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);
371
372 //set clear color
373 GL11.glClearColor(color, color, color, 0.0f);
374 }
375
376 /**
377 * Initializes OGL
378 */
379 private void glInit() {
380 // Sync frame (only works on windows)
381 Display.setVSyncEnabled(true);
382
383 // Create shared texture
384 IntBuffer buffer = BufferUtils.createIntBuffer(1);
385 GL11.glGenTextures(buffer);
386 texID = buffer.get(0);
387
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);
397
398 initGLState(mode.getWidth(), mode.getHeight(), 0.0f);
399 }
400
401 /**
402 * Test entry point
403 */
404 public static void main(String[] args) {
405 if ( args.length != 1 )
406 kill("Invalid arguments length.");
407
408 int mode = -1;
409 try {
410 mode = Integer.parseInt(args[0]);
411 } catch (NumberFormatException e) {
412 kill("Invalid mode.");
413 }
414
415 if ( mode != 1 && mode != 2 )
416 kill("Invalid mode.");
417
418 System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively");
419 System.out.println("Move quad using arrowkeys, and change rotation using +/-");
420
421 PbufferTest test = new PbufferTest(mode);
422
423 test.execute();
424 System.exit(0);
425 }
426
427 private static void kill(final String msg) {
428 System.out.println(msg);
429 System.out.println("-------");
430 System.out.println("Usage: java org.lwjgl.test.opengl.pbuffer.PbufferTest <mode>");
431 System.out.println("\n<mode>.");
432 System.out.println("\t1: no render-to-texture");
433 System.out.println("\t2: with render-to-texture");
434
435 System.exit(-1);
436 }
437 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.pbuffers;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.Pbuffer;
35
36 /**
37 * Implementations of this class should create a pbuffer and implement "render-to-texture" accordingly.
38 */
39 abstract class TextureRenderer {
40
41 protected final int width;
42 protected final int height;
43 private final int texID;
44
45 protected Pbuffer pbuffer;
46
47 protected TextureRenderer(final int width, final int height, final int texID) {
48 this.width = width;
49 this.height = height;
50 this.texID = texID;
51
52 try {
53 pbuffer = init(width, height, texID);
54 } catch (LWJGLException e) {
55 e.printStackTrace();
56 System.exit(-1);
57 }
58 }
59
60 /**
61 * Create and initialize the pbuffer.
62 *
63 * @param width
64 * @param height
65 * @param texID
66 * @return
67 * @throws LWJGLException
68 */
69 protected abstract Pbuffer init(int width, int height, int texID) throws LWJGLException;
70
71 /**
72 * This will be called before rendering to the renderer. Implementations should setup the pbuffer context as necessary.
73 */
74 void enable() {
75 try {
76 if ( pbuffer.isBufferLost() ) {
77 System.out.println("Buffer contents lost - recreating the pbuffer");
78 pbuffer.destroy();
79 pbuffer = init(width, height, texID);
80 }
81
82 pbuffer.makeCurrent();
83 } catch (LWJGLException e) {
84 throw new RuntimeException(e);
85 }
86 }
87
88 /**
89 * Implementations should update the texture contents here.
90 */
91 abstract void updateTexture();
92
93 /**
94 * Clean-up resources held by the renderer
95 */
96 final void destroy() {
97 pbuffer.destroy();
98 }
99
100 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.pbuffers;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.GL11;
36 import org.lwjgl.opengl.Pbuffer;
37 import org.lwjgl.opengl.PixelFormat;
38
39 final class UniqueRenderer extends TextureRenderer {
40
41 UniqueRenderer(final int width, final int height, final int texID) {
42 super(width, height, texID);
43 }
44
45 protected Pbuffer init(final int width, final int height, final int texID) {
46 Pbuffer pbuffer = null;
47
48 try {
49 pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), null, null);
50
51 // Initialise state of the pbuffer context.
52 pbuffer.makeCurrent();
53
54 PbufferTest.initGLState(width, height, 0.5f);
55 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
56
57 Display.makeCurrent();
58 } catch (LWJGLException e) {
59 e.printStackTrace();
60 System.exit(-1);
61 }
62
63 return pbuffer;
64 }
65
66 public void updateTexture() {
67 // Copy the pbuffer contents to the texture.
68 GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, width, height, 0);
69 }
70
71 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.test.opengl.pbuffers;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.GL11;
36 import org.lwjgl.opengl.Pbuffer;
37 import org.lwjgl.opengl.PixelFormat;
38 import org.lwjgl.opengl.RenderTexture;
39
40 final class UniqueRendererRTT extends TextureRenderer {
41
42 UniqueRendererRTT(final int width, final int height, final int texID) {
43 super(width, height, texID);
44 }
45
46 // Initialize texture renderer
47 protected Pbuffer init(final int width, final int height, final int texID) {
48 Pbuffer pbuffer = null;
49
50 try {
51 final RenderTexture rt = new RenderTexture(true, false, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
52 pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), rt, null);
53
54 // Initialise state of the pbuffer context.
55 pbuffer.makeCurrent();
56
57 PbufferTest.initGLState(width, height, 0.5f);
58 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
59
60 Display.makeCurrent();
61 } catch (LWJGLException e) {
62 e.printStackTrace();
63 System.exit(-1);
64 }
65
66 return pbuffer;
67 }
68
69 void enable() {
70 super.enable();
71
72 // Put the renderer contents to the texture
73 pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
74 }
75
76 void updateTexture() {
77 // Bind the texture after rendering.
78 pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER);
79 }
80
81 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 8:41:42 pm
36 */
37 package org.lwjgl.test.opengl.shaders;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.opengl.ARBProgram;
41 import org.lwjgl.opengl.ARBShaderObjects;
42 import org.lwjgl.opengl.GL11;
43
44 import java.io.BufferedInputStream;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.nio.ByteBuffer;
48
49 abstract class Shader {
50
51 protected static ByteBuffer fileBuffer = BufferUtils.createByteBuffer(1024 * 10);
52
53 protected Shader() {
54 }
55
56 abstract void render();
57
58 abstract void cleanup();
59
60 protected static String getShaderText(String file) {
61 String shader = null;
62
63 try {
64 ClassLoader loader = ShadersTest.class.getClassLoader();
65 InputStream inputStream = loader.getResourceAsStream("org/lwjgl/test/opengl/shaders/" + file);
66
67 if ( inputStream == null )
68 ShadersTest.kill("A shader source file could not be found: " + file);
69
70 BufferedInputStream stream = new BufferedInputStream(inputStream);
71
72 byte character;
73 while ( (character = (byte)stream.read()) != -1 )
74 fileBuffer.put(character);
75
76 stream.close();
77
78 fileBuffer.flip();
79
80 byte[] array = new byte[fileBuffer.remaining()];
81 fileBuffer.get(array);
82 shader = new String(array);
83
84 fileBuffer.clear();
85 } catch (IOException e) {
86 ShadersTest.kill("Failed to read the shader source file: " + file, e);
87 }
88
89 return shader;
90 }
91
92 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);
95 int lineStart = 0;
96 int lineEnd = -1;
97 for ( int i = 0; i < programSource.length(); i++ ) {
98 if ( programSource.charAt(i) == '\n' ) {
99 if ( i <= errorPos ) {
100 lineStart = i + 1;
101 } else {
102 lineEnd = i;
103 break;
104 }
105 }
106 }
107
108 if ( lineEnd == -1 )
109 lineEnd = programSource.length();
110
111 ShadersTest.kill("Low-level program error in file: " + programFile
112 + "\n\tError line: " + programSource.substring(lineStart, lineEnd)
113 + "\n\tError message: " + GL11.glGetString(ARBProgram.GL_PROGRAM_ERROR_STRING_ARB));
114 }
115 }
116
117 protected static int getUniformLocation(int ID, String name) {
118 final int location = ARBShaderObjects.glGetUniformLocationARB(ID, name);
119
120 if ( location == -1 )
121 throw new IllegalArgumentException("The uniform \"" + name + "\" does not exist in the Shader Program.");
122
123 return location;
124 }
125
126 protected static void printShaderObjectInfoLog(String file, int ID) {
127 final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB);
128 if ( logLength <= 1 )
129 return;
130
131 System.out.println("\nInfo Log of Shader Object: " + file);
132 System.out.println("--------------------------");
133 System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength));
134
135 }
136
137 protected static void printShaderProgramInfoLog(int ID) {
138 final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB);
139 if ( logLength <= 1 )
140 return;
141
142 System.out.println("\nShader Program Info Log: ");
143 System.out.println("--------------------------");
144 System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength));
145 }
146
147 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 9:55:38 pm
36 */
37
38 package org.lwjgl.test.opengl.shaders;
39
40 import org.lwjgl.opengl.ARBFragmentProgram;
41 import org.lwjgl.opengl.ARBProgram;
42 import org.lwjgl.opengl.ARBVertexProgram;
43 import org.lwjgl.opengl.GL11;
44
45 final class ShaderFP extends Shader {
46
47 final String vpFile;
48 final String vpSource;
49
50 final int vpID;
51
52 final String fpFile;
53 final String fpSource;
54
55 final int fpID;
56
57 ShaderFP(final String vpShaderFile, final String fpShaderFile) {
58 // Initialize the vertex program.
59 vpFile = vpShaderFile;
60 vpSource = getShaderText(vpShaderFile);
61
62 vpID = ARBProgram.glGenProgramsARB();
63
64 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
65 ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, vpSource);
66
67 checkProgramError(vpFile, vpSource);
68
69 // Initialize the fragment program.
70 fpFile = fpShaderFile;
71 fpSource = getShaderText(fpShaderFile);
72
73 fpID = ARBProgram.glGenProgramsARB();
74
75 ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
76 ARBProgram.glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, fpSource);
77
78 checkProgramError(fpFile, fpSource);
79 }
80
81 void render() {
82 GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
83 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
84
85 GL11.glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
86 ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
87
88 ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0,
89 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
90
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);
94
95 ShadersTest.renderObject();
96
97 GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
98 GL11.glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
99 }
100
101 void cleanup() {
102 ARBProgram.glDeleteProgramsARB(vpID);
103 ARBProgram.glDeleteProgramsARB(fpID);
104 }
105
106 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 9:55:38 pm
36 */
37
38 package org.lwjgl.test.opengl.shaders;
39
40 import org.lwjgl.opengl.ARBFragmentShader;
41 import org.lwjgl.opengl.ARBShaderObjects;
42 import org.lwjgl.opengl.ARBVertexShader;
43 import org.lwjgl.opengl.GL11;
44
45 final class ShaderFSH extends Shader {
46
47 final String vshFile;
48 final String vshSource;
49
50 final int vshID;
51
52 final String fshFile;
53 final String fshSource;
54
55 final int fshID;
56
57 final int programID;
58
59 final int uniformLocation;
60
61 ShaderFSH(final String vshFile, final String fshFile) {
62 // Initialize the vertex shader.
63 this.vshFile = vshFile;
64 vshSource = getShaderText(vshFile);
65
66 vshID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
67 ARBShaderObjects.glShaderSourceARB(vshID, vshSource);
68 ARBShaderObjects.glCompileShaderARB(vshID);
69
70 printShaderObjectInfoLog(this.vshFile, vshID);
71
72 if ( ARBShaderObjects.glGetObjectParameteriARB(vshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
73 ShadersTest.kill("A compilation error occured in a vertex shader.");
74
75 // Initialize the fragment shader.
76 this.fshFile = fshFile;
77 fshSource = getShaderText(fshFile);
78
79 fshID = ARBShaderObjects.glCreateShaderObjectARB(ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);
80 ARBShaderObjects.glShaderSourceARB(fshID, fshSource);
81 ARBShaderObjects.glCompileShaderARB(fshID);
82
83 printShaderObjectInfoLog(this.fshFile, fshID);
84
85 if ( ARBShaderObjects.glGetObjectParameteriARB(fshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
86 ShadersTest.kill("A compilation error occured in a fragment shader.");
87
88 // Initialize the shader program.
89 programID = ARBShaderObjects.glCreateProgramObjectARB();
90
91 ARBShaderObjects.glAttachObjectARB(programID, vshID);
92 ARBShaderObjects.glAttachObjectARB(programID, fshID);
93
94 ARBShaderObjects.glLinkProgramARB(programID);
95
96 printShaderProgramInfoLog(programID);
97
98 if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE )
99 ShadersTest.kill("A linking error occured in a shader program.");
100
101 uniformLocation = getUniformLocation(programID, "UNIFORMS");
102 }
103
104 void render() {
105 ARBShaderObjects.glUseProgramObjectARB(programID);
106
107 ARBShaderObjects.glUniform4fARB(uniformLocation,
108 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f,
109 -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f);
110
111 ShadersTest.renderObject();
112
113 ARBShaderObjects.glUseProgramObjectARB(0);
114 }
115
116 void cleanup() {
117 ARBShaderObjects.glDetachObjectARB(programID, vshID);
118 ARBShaderObjects.glDetachObjectARB(programID, fshID);
119
120 ARBShaderObjects.glDeleteObjectARB(vshID);
121 ARBShaderObjects.glDeleteObjectARB(fshID);
122
123 ARBShaderObjects.glDeleteObjectARB(programID);
124 }
125
126 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2009-12-04
35 */
36
37 package org.lwjgl.test.opengl.shaders;
38
39 import org.lwjgl.BufferUtils;
40 import org.lwjgl.opengl.*;
41
42 import java.nio.FloatBuffer;
43 import java.nio.IntBuffer;
44
45 final class ShaderUNI extends Shader {
46
47 final String file;
48 final String source;
49
50 final int shaderID;
51 final int programID;
52
53 final int bufferID;
54 final FloatBuffer buffer;
55
56 final int uniformA_index;
57 final int uniformA_offset;
58
59 final int uniformB_index;
60 final int uniformB_offset;
61
62 ShaderUNI(final String shaderFile) {
63 file = shaderFile;
64 source = getShaderText(shaderFile);
65
66 shaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
67 GL20.glShaderSource(shaderID, source);
68 GL20.glCompileShader(shaderID);
69
70 printShaderObjectInfoLog(file, shaderID);
71
72 if ( GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE )
73 ShadersTest.kill("A compilation error occured in a vertex shader.");
74
75 programID = GL20.glCreateProgram();
76
77 GL20.glAttachShader(programID, shaderID);
78 GL20.glLinkProgram(programID);
79
80 printShaderProgramInfoLog(programID);
81
82 if ( GL20.glGetProgram(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE )
83 ShadersTest.kill("A linking error occured in a shader program.");
84
85 final String[] uniformNames = { "uniformA", "uniformB" };
86
87 // 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);
90
91 System.out.println("blockSize = " + blockSize);
92
93 // 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);
97 buffer = BufferUtils.createFloatBuffer(blockSize);
98
99 // 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);
102
103 // Get uniform information
104 IntBuffer indexes = BufferUtils.createIntBuffer(uniformNames.length);
105 IntBuffer params = BufferUtils.createIntBuffer(uniformNames.length);
106
107 ARBUniformBufferObject.glGetUniformIndices(programID, uniformNames, indexes);
108 uniformA_index = indexes.get(0);
109 uniformB_index = indexes.get(1);
110
111 ARBUniformBufferObject.glGetActiveUniforms(programID, indexes, ARBUniformBufferObject.GL_UNIFORM_OFFSET, params);
112 uniformA_offset = params.get(0);
113 uniformB_offset = params.get(1);
114
115 System.out.println("\nuniformA index = " + uniformA_index);
116 System.out.println("uniformB index = " + uniformB_index);
117
118 System.out.println("\nuniformA offset = " + uniformA_offset + " - should be 0 for std140");
119 System.out.println("uniformB offset = " + uniformB_offset + " - should be 16 for std140");
120
121 Util.checkGLError();
122 }
123
124 void render() {
125 GL20.glUseProgram(programID);
126
127 //* -- std140 layout
128 // Uniform A
129 buffer.put(0, ShadersTest.getSin()).put(1, ShadersTest.getSpecularity() * 8.0f);
130 // Uniform B - str140 alignment at 16 bytes
131 buffer.put(4, 0.0f).put(5, 0.7f).put(6, 0.0f);
132
133 GL15.glBindBuffer(ARBUniformBufferObject.GL_UNIFORM_BUFFER, bufferID);
134 GL15.glBufferData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW);
135 //*/
136
137 /* -- non-std140 layout
138 // Uniform A
139 buffer.put(ShadersTest.getSin()).put(ShadersTest.getSpecularity() * 8.0f);
140 buffer.flip();
141 GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformA_offset, buffer);
142 // Uniform B
143 buffer.clear();
144 buffer.put(0.0f).put(0.7f).put(0.0f);
145 buffer.flip();
146 GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformB_offset, buffer);
147 //*/
148
149 ShadersTest.renderObject();
150
151 GL20.glUseProgram(0);
152 }
153
154 void cleanup() {
155 GL15.glDeleteBuffers(bufferID);
156
157 GL20.glDetachShader(programID, shaderID);
158
159 GL20.glDeleteShader(shaderID);
160 GL20.glDeleteProgram(programID);
161 }
162
163 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 9:55:38 pm
36 */
37
38 package org.lwjgl.test.opengl.shaders;
39
40 import org.lwjgl.opengl.ARBProgram;
41 import org.lwjgl.opengl.ARBVertexProgram;
42 import org.lwjgl.opengl.GL11;
43
44 final class ShaderVP extends Shader {
45
46 final String file;
47 final String source;
48
49 final int ID;
50
51 ShaderVP(final String shaderFile) {
52 file = shaderFile;
53 source = getShaderText(shaderFile);
54
55 ID = ARBProgram.glGenProgramsARB();
56
57 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID);
58 ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, source);
59
60 checkProgramError(file, source);
61 }
62
63 void render() {
64 GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
65 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID);
66
67 ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0,
68 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
69
70 ShadersTest.renderObject();
71
72 GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
73 }
74
75 void cleanup() {
76 ARBProgram.glDeleteProgramsARB(ID);
77 }
78
79 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 9:55:38 pm
36 */
37
38 package org.lwjgl.test.opengl.shaders;
39
40 import org.lwjgl.opengl.ARBShaderObjects;
41 import org.lwjgl.opengl.ARBVertexShader;
42 import org.lwjgl.opengl.GL11;
43
44 final class ShaderVSH extends Shader {
45
46 final String file;
47 final String source;
48
49 final int shaderID;
50 final int programID;
51
52 final int uniformLocation;
53
54 ShaderVSH(final String shaderFile) {
55 file = shaderFile;
56 source = getShaderText(shaderFile);
57
58 shaderID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
59 ARBShaderObjects.glShaderSourceARB(shaderID, source);
60 ARBShaderObjects.glCompileShaderARB(shaderID);
61
62 printShaderObjectInfoLog(file, shaderID);
63
64 if ( ARBShaderObjects.glGetObjectParameteriARB(shaderID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
65 ShadersTest.kill("A compilation error occured in a vertex shader.");
66
67 programID = ARBShaderObjects.glCreateProgramObjectARB();
68
69 ARBShaderObjects.glAttachObjectARB(programID, shaderID);
70 ARBShaderObjects.glLinkProgramARB(programID);
71
72 printShaderProgramInfoLog(programID);
73
74 if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE )
75 ShadersTest.kill("A linking error occured in a shader program.");
76
77 uniformLocation = getUniformLocation(programID, "UNIFORMS");
78 }
79
80 void render() {
81 ARBShaderObjects.glUseProgramObjectARB(programID);
82
83 ARBShaderObjects.glUniform2fARB(uniformLocation, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f);
84
85 ShadersTest.renderObject();
86
87 ARBShaderObjects.glUseProgramObjectARB(0);
88 }
89
90 void cleanup() {
91 ARBShaderObjects.glDetachObjectARB(programID, shaderID);
92
93 ARBShaderObjects.glDeleteObjectARB(shaderID);
94 ARBShaderObjects.glDeleteObjectARB(programID);
95 }
96
97 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2004-03-30
35 * Time: 8:41:42 pm
36 */
37
38 package org.lwjgl.test.opengl.shaders;
39
40 import java.nio.FloatBuffer;
41
42 import org.lwjgl.BufferUtils;
43 import org.lwjgl.LWJGLException;
44 import org.lwjgl.Sys;
45 import org.lwjgl.input.Keyboard;
46 import org.lwjgl.input.Mouse;
47 import org.lwjgl.opengl.*;
48 import org.lwjgl.util.glu.GLU;
49 import org.lwjgl.util.glu.Sphere;
50
51 public final class ShadersTest {
52
53 private static DisplayMode displayMode;
54
55 private static boolean run = true;
56
57 private static final FloatBuffer vectorBuffer = BufferUtils.createFloatBuffer(4);
58
59 private static Sphere sphere;
60
61 private static Shader shader;
62
63 private static float frameTime;
64
65 private static float angle;
66 private static float sin;
67 private static int specularity = 4;
68
69 private ShadersTest() {
70 }
71
72 public static void main(String[] args) {
73 initialize(args);
74
75 long frameStart;
76 long lastFrameTime = 0;
77
78 while ( run ) {
79 if (!Display.isVisible() )
80 Thread.yield();
81 else {
82 // This is the current frame time.
83 frameStart = Sys.getTime();
84
85 // How many seconds passed since last frame.
86 frameTime = (float)((frameStart - lastFrameTime) / (double)Sys.getTimerResolution());
87
88 lastFrameTime = frameStart;
89
90 //angle += frameTime * 90.0f;
91 angle += 0.1f;
92 sin = (float)Math.sin(Math.toRadians(angle));
93
94 handleIO();
95
96 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
97
98 if ( shader != null )
99 shader.render();
100 else
101 renderObject();
102
103 // Restore camera position.
104 GL11.glPopMatrix();
105 GL11.glPushMatrix();
106 }
107
108 Display.update();
109
110 if ( Display.isCloseRequested() )
111 break;
112 }
113
114 cleanup();
115 System.exit(0);
116 }
117
118 private static void initialize(String[] args) {
119 if ( args.length != 1 )
120 argsError();
121
122 try {
123 DisplayMode[] modes = Display.getAvailableDisplayModes();
124
125 DisplayMode displayMode;
126
127 displayMode = chooseMode(modes, 1024, 768);
128 if ( displayMode == null )
129 displayMode = chooseMode(modes, 800, 600);
130 if ( displayMode == null )
131 displayMode = chooseMode(modes, 640, 480);
132 if ( displayMode == null )
133 kill("Failed to set an appropriate display mode.");
134
135 System.out.println("Setting display mode to: " + displayMode);
136 Display.setDisplayMode(displayMode);
137 Display.create(new PixelFormat(8, 24, 0), "UNI".equalsIgnoreCase(args[0]) ? new ContextAttribs(3, 1) : null);
138 ShadersTest.displayMode = displayMode;
139 } catch (LWJGLException e) {
140 kill(e.getMessage());
141 }
142
143 final ContextCapabilities caps = GLContext.getCapabilities();
144
145 if ( "NONE".equalsIgnoreCase(args[0]) ) {
146 shader = null;
147 } else if ( "VP".equalsIgnoreCase(args[0]) ) {
148 if ( !caps.GL_ARB_vertex_program )
149 kill("The ARB_vertex_program extension is not supported.");
150
151 shader = new ShaderVP("shaderVP.vp");
152 } else if ( "FP".equalsIgnoreCase(args[0]) ) {
153 if ( !caps.GL_ARB_vertex_program )
154 kill("The ARB_vertex_program extension is not supported.");
155 if ( !caps.GL_ARB_fragment_program )
156 kill("The ARB_fragment_program extension is not supported.");
157
158 shader = new ShaderFP("shaderFP.vp", "shaderFP.fp");
159 } else if ( "VSH".equalsIgnoreCase(args[0]) ) {
160 if ( !caps.GL_ARB_vertex_shader )
161 kill("The ARB_vertex_shader extension is not supported.");
162
163 shader = new ShaderVSH("shaderVSH.vsh");
164 } else if ( "FSH".equalsIgnoreCase(args[0]) ) {
165 if ( !caps.GL_ARB_vertex_shader )
166 kill("The ARB_vertex_shader extension is not supported.");
167 if ( !caps.GL_ARB_fragment_shader )
168 kill("The ARB_fragment_shader extension is not supported.");
169
170 shader = new ShaderFSH("shaderFSH.vsh", "shaderFSH.fsh");
171 } else if ("UNI".equalsIgnoreCase(args[0]) ) {
172 if ( !(caps.OpenGL31 || caps.GL_ARB_uniform_buffer_object) )
173 kill("Neither OpenGL version 3.1 nor ARB_uniform_buffer_object are supported.");
174
175 shader = new ShaderUNI("shaderUNI.vsh");
176 } else {
177 argsError();
178 }
179
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();
188
189 // 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);
210
211 // Setup lighting for when we have fixed function fragment rendering.
212 GL11.glShadeModel(GL11.GL_SMOOTH);
213
214 if ( shader == null ) {
215 GL11.glEnable(GL11.GL_LIGHTING);
216 GL11.glEnable(GL11.GL_LIGHT0);
217 }
218
219 vectorBuffer.clear();
220 vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
221 vectorBuffer.clear();
222 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, vectorBuffer);
223
224 vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
225 vectorBuffer.clear();
226 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, vectorBuffer);
227
228 vectorBuffer.put(1.0f).put(1.0f).put(0.5f).put(1.0f);
229 vectorBuffer.clear();
230 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, vectorBuffer);
231
232 vectorBuffer.put(-1.0f / 3.0f).put(1.0f / 3.0f).put(1.0f / 3.0f).put(0.0f); // Infinite
233 vectorBuffer.clear();
234 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, vectorBuffer);
235
236 vectorBuffer.put(0.2f).put(0.2f).put(0.2f).put(1.0f);
237 vectorBuffer.clear();
238 GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
239
240 sphere = new Sphere();
241 }
242
243 private static void handleIO() {
244 if ( Keyboard.getNumKeyboardEvents() != 0 ) {
245 while ( Keyboard.next() ) {
246 if ( Keyboard.getEventKeyState() )
247 continue;
248
249 switch ( Keyboard.getEventKey() ) {
250 case Keyboard.KEY_EQUALS:
251 if ( specularity < 8 )
252 specularity++;
253 break;
254 case Keyboard.KEY_MINUS:
255 if ( specularity > 1 )
256 specularity--;
257 break;
258 case Keyboard.KEY_ESCAPE:
259 run = false;
260 break;
261 }
262 }
263 }
264
265 while ( Mouse.next() ) ;
266 }
267
268 static int getDisplayWidth() {
269 return displayMode.getWidth();
270 }
271
272 static int getDisplayHeight() {
273 return displayMode.getHeight();
274 }
275
276 static float getSin() {
277 return sin;
278 }
279
280 static int getSpecularity() {
281 return specularity;
282 }
283
284 static void renderObject() {
285 GL11.glColor3b((byte)255, (byte)255, (byte)255);
286 sphere.draw(1.0f, 32, 32);
287 }
288
289 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
290 DisplayMode bestMode = null;
291
292 for ( int i = 0; i < modes.length; i++ ) {
293 DisplayMode mode = modes[i];
294 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
295 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
296 bestMode = mode;
297 }
298 }
299
300 return bestMode;
301 }
302
303 private static void cleanup() {
304 // This is not necessary, just showing how to properly delete a program/shader.
305 if ( shader != null )
306 shader.cleanup();
307
308 if ( Display.isCreated() )
309 Display.destroy();
310 }
311
312 private static void argsError() {
313 System.out.println("\nInvalid program arguments.");
314 System.out.println("\nUsage: ShadersTest <shaderType>, where <shaderType> argument can be one of the following:\n");
315 System.out.println("none\t- Use fixed function rendering.");
316 System.out.println("vp\t- Use ARB_vertex_program (low-level) only.");
317 System.out.println("vsh\t- Use ARB_vertex_shader (GLSL) only.");
318 System.out.println("fp\t- Use ARB_vertex_program + ARB_fragment_program (low-level).");
319 System.out.println("fsh\t- Use ARB_vertex_shader + ARB_fragment_shader (GLSL).");
320 System.out.println("uni\t- Use ARB_uniform_buffer_object to update shader uniforms (GLSL).");
321
322 cleanup();
323 System.exit(-1);
324 }
325
326 static void kill(String reason) {
327 System.out.println("The ShaderTest program was terminated because an error occured.\n");
328 System.out.println("Reason: " + (reason == null ? "Unknown" : reason));
329
330 cleanup();
331 System.exit(-1);
332 }
333
334 static void kill(String reason, Throwable t) {
335 System.out.println("The ShaderTest program was terminated because an exception occured.\n");
336 System.out.println("Reason: " + reason == null ? "Unknown" : reason);
337
338 System.out.println("Exception message: " + t.getMessage());
339
340 cleanup();
341 System.exit(-1);
342 }
343
344 }
0 !!ARBfp1.0
1 OPTION ARB_precision_hint_fastest;
2
3 ATTRIB winPos = fragment.position;
4 ATTRIB iDots = fragment.texcoord[0];
5
6 PARAM ambience = state.lightmodel.ambient;
7
8 PARAM specularColor = state.light[0].specular;
9
10 PARAM UNIFORMS = program.local[0];
11
12 TEMP temp;
13
14 OUTPUT oColor = result.color;
15
16 # Offset window-space fragment position.
17 ADD temp.xyz, winPos, UNIFORMS.zwxx;
18 # Normalize position.
19 DP3 temp.w, temp, temp;
20 RSQ temp.w, temp.w;
21 MUL temp.xy, temp, temp.w;
22
23 # Multiply with current sin.
24 MUL temp.xy, temp, UNIFORMS.x;
25 # {-1..1} => {0..1}
26 MAD temp.xy, temp, 0.5, 0.5;
27 # Intensify colors.
28 MUL temp.xy, temp, 2.0;
29 MOV temp.z, 1.0;
30
31 # Accumulate color contributions.
32 MAD temp.xyz, iDots.x, temp, ambience;
33 # Calculate <specular dot product>^<specular exponent>
34 POW temp.w, iDots.y, UNIFORMS.y;
35 MAD oColor.xyz, temp.w, specularColor, temp;
36
37 MOV oColor.w, 1.0;
38
39 END
0 !!ARBvp1.0
1
2 ATTRIB iPos = vertex.position;
3 ATTRIB iNormal = vertex.normal;
4
5 PARAM mvp[4] = { state.matrix.mvp };
6 PARAM mvIT[4] = { state.matrix.modelview.invtrans };
7
8 PARAM lightDir = state.light[0].position;
9 PARAM halfDir = state.light[0].half;
10
11 PARAM UNIFORMS = program.local[0];
12
13 TEMP normal, dots;
14
15 OUTPUT oPos = result.position;
16 OUTPUT oDots = result.texcoord[0];
17
18 # Transform the vertex to clip coordinates.
19 DP4 oPos.x, mvp[0], iPos;
20 DP4 oPos.y, mvp[1], iPos;
21 DP4 oPos.z, mvp[2], iPos;
22 DP4 oPos.w, mvp[3], iPos;
23
24 # Transform the normal to eye coordinates.
25 DP3 normal.x, mvIT[0], iNormal;
26 DP3 normal.y, mvIT[1], iNormal;
27 DP3 normal.z, mvIT[2], iNormal;
28
29 # Compute diffuse and specular dot products and clamp them.
30 DP3 dots.x, normal, lightDir;
31 MAX oDots.x, dots.x, 0.0;
32
33 DP3 dots.y, normal, halfDir;
34 MAX oDots.y, dots.y, 0.0;
35
36 END
0 uniform vec4 UNIFORMS;
1
2 varying vec2 dots;
3
4 void main(void) {
5 // Offset window-space fragment position.
6 vec3 color2D = vec3(gl_FragCoord + UNIFORMS.zwxx);
7
8 // Normalize position.
9 // Multiply with current sin.
10 color2D.xy = normalize(color2D).xy * UNIFORMS.x;
11 // {-1..1} => {0..1} & Intensify colors.
12 color2D.xy = (vec2(color2D) * 0.5 + 0.5) * 2.0;
13 color2D.z = 1.0;
14
15 // Accumulate color contributions.
16 // Hardcoded ambience and specular color, due to buggy drivers.
17 color2D = dots.x * color2D + vec3(0.2, 0.2, 0.2);
18 gl_FragColor.rgb = pow(dots.y, UNIFORMS.y) * vec3(1.0, 1.0, 0.5) + color2D;
19 gl_FragColor.a = 1.0;
20 }
0 uniform vec4 UNIFORMS;
1
2 varying vec2 dots;
3
4 void main(void) {
5 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
6
7 vec3 normal = gl_NormalMatrix * gl_Normal;
8
9 // Pass the dot products to the fragment shader.
10 dots.x = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
11 dots.y = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
12 }
0 #version 140
1 #extension GL_ARB_uniform_buffer_object : enable
2
3 layout(std140) uniform test {
4 vec2 uniformA;
5 vec3 uniformB;
6 };
7
8 void main(void) {
9 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
10
11 vec3 normal = gl_NormalMatrix * gl_Normal;
12
13 float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
14 float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
15 specularDot = pow(specularDot, uniformA.y);
16
17 // Normalize position, to get a {-1..1} value for each vertex.
18 // Multiply with current sin.
19 vec3 color3D = normalize(vec3(gl_Vertex)) * uniformA.x;
20 // {-1..1} => {0..1} & Intensify colors.
21 color3D = (color3D * 0.5 + 0.5) * 2.0;
22
23 // Accumulate color contributions.
24 color3D = diffuseDot * (uniformB + color3D) + vec3(gl_LightModel.ambient);
25 gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D;
26 gl_FrontColor.a = 1.0;
27 }
0 !!ARBvp1.0
1
2 ATTRIB iPos = vertex.position;
3 ATTRIB iNormal = vertex.normal;
4
5 PARAM mvp[4] = { state.matrix.mvp };
6 PARAM mvIT[4] = { state.matrix.modelview.invtrans };
7
8 PARAM ambience = state.lightmodel.ambient;
9
10 PARAM lightDir = state.light[0].position;
11 PARAM halfDir = state.light[0].half;
12 PARAM diffuseColor = state.light[0].diffuse;
13 PARAM specularColor = state.light[0].specular;
14
15 PARAM UNIFORMS = program.local[0];
16
17 TEMP temp, temp2, normal, dots;
18
19 OUTPUT oPos = result.position;
20 OUTPUT oColor = result.color;
21
22 # Transform the vertex to clip coordinates.
23 DP4 oPos.x, mvp[0], iPos;
24 DP4 oPos.y, mvp[1], iPos;
25 DP4 oPos.z, mvp[2], iPos;
26 DP4 oPos.w, mvp[3], iPos;
27
28 # Transform the normal to eye coordinates.
29 DP3 normal.x, mvIT[0], iNormal;
30 DP3 normal.y, mvIT[1], iNormal;
31 DP3 normal.z, mvIT[2], iNormal;
32
33 # Compute diffuse and specular dot products and use LIT to compute
34 # lighting coefficients.
35 DP3 dots.x, normal, lightDir;
36 DP3 dots.y, normal, halfDir;
37 MOV dots.w, UNIFORMS.y;
38 LIT dots, dots;
39
40 # Normalize position, to get a {-1..1} value for each vertex.
41 DP3 temp.w, iPos, iPos;
42 RSQ temp.w, temp.w;
43 MUL temp.xyz, iPos, temp.w;
44
45 # Multiply with current sin.
46 MUL temp.xyz, temp, UNIFORMS.x;
47 # {-1..1} => {0..1}
48 MAD temp.xyz, temp, 0.5, 0.5;
49 # Intensify colors.
50 MUL temp.xyz, temp, 2.0;
51
52 # Accumulate color contributions.
53 MAD temp.xyz, dots.y, temp, ambience;
54 MAD oColor.xyz, dots.z, specularColor, temp;
55 MOV oColor.w, 1.0;
56
57
58 END
0 uniform vec2 UNIFORMS;
1
2 void main(void) {
3 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
4
5 vec3 normal = gl_NormalMatrix * gl_Normal;
6
7 float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
8 float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
9 specularDot = pow(specularDot, UNIFORMS.y);
10
11 // Normalize position, to get a {-1..1} value for each vertex.
12 // Multiply with current sin.
13 vec3 color3D = normalize(vec3(gl_Vertex)) * UNIFORMS.x;
14 // {-1..1} => {0..1} & Intensify colors.
15 color3D = (color3D * 0.5 + 0.5) * 2.0;
16
17 // Accumulate color contributions.
18 color3D = diffuseDot * color3D + vec3(gl_LightModel.ambient);
19 gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D;
20 gl_FrontColor.a = 1.0;
21 }
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;
32 import java.io.Serializable;
33 import java.nio.ByteBuffer;
34
35 /**
36 * A mutable Color class
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Color.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public final class Color implements ReadableColor, Serializable, WritableColor {
42
43 static final long serialVersionUID = 1L;
44
45 /** Color components, publicly accessible */
46 private byte red, green, blue, alpha;
47
48 /**
49 * Constructor for Color.
50 */
51 public Color() {
52 this(0, 0, 0, 255);
53 }
54
55 /**
56 * Constructor for Color. Alpha defaults to 255.
57 */
58 public Color(int r, int g, int b) {
59 this(r, g, b, 255);
60 }
61
62 /**
63 * Constructor for Color. Alpha defaults to 255.
64 */
65 public Color(byte r, byte g, byte b) {
66 this(r, g, b, (byte) 255);
67 }
68
69 /**
70 * Constructor for Color.
71 */
72 public Color(int r, int g, int b, int a) {
73 set(r, g, b, a);
74 }
75
76 /**
77 * Constructor for Color.
78 */
79 public Color(byte r, byte g, byte b, byte a) {
80 set(r, g, b, a);
81 }
82
83 /**
84 * Constructor for Color
85 */
86 public Color(ReadableColor c) {
87 setColor(c);
88 }
89
90 /**
91 * Set a color
92 */
93 public void set(int r, int g, int b, int a) {
94 red = (byte) r;
95 green = (byte) g;
96 blue = (byte) b;
97 alpha = (byte) a;
98 }
99
100 /**
101 * Set a color
102 */
103 public void set(byte r, byte g, byte b, byte a) {
104 this.red = r;
105 this.green = g;
106 this.blue = b;
107 this.alpha = a;
108 }
109
110 /**
111 * Set a color
112 */
113 public void set(int r, int g, int b) {
114 set(r, g, b, 255);
115 }
116
117 /**
118 * Set a color
119 */
120 public void set(byte r, byte g, byte b) {
121 set(r, g, b, (byte) 255);
122 }
123
124 /**
125 * Accessor
126 */
127 public int getRed() {
128 return red & 0xFF;
129 }
130
131 /**
132 * Accessor
133 */
134 public int getGreen() {
135 return green & 0xFF;
136 }
137
138 /**
139 * Accessor
140 */
141 public int getBlue() {
142 return blue & 0xFF;
143 }
144
145 /**
146 * Accessor
147 */
148 public int getAlpha() {
149 return alpha & 0xFF;
150 }
151
152 /**
153 * Set the Red component
154 */
155 public void setRed(int red) {
156 this.red = (byte) red;
157 }
158
159 /**
160 * Set the Green component
161 */
162 public void setGreen(int green) {
163 this.green = (byte) green;
164 }
165
166 /**
167 * Set the Blue component
168 */
169 public void setBlue(int blue) {
170 this.blue = (byte) blue;
171 }
172
173 /**
174 * Set the Alpha component
175 */
176 public void setAlpha(int alpha) {
177 this.alpha = (byte) alpha;
178 }
179
180 /**
181 * Set the Red component
182 */
183 public void setRed(byte red) {
184 this.red = red;
185 }
186
187 /**
188 * Set the Green component
189 */
190 public void setGreen(byte green) {
191 this.green = green;
192 }
193
194 /**
195 * Set the Blue component
196 */
197 public void setBlue(byte blue) {
198 this.blue = blue;
199 }
200
201 /**
202 * Set the Alpha component
203 */
204 public void setAlpha(byte alpha) {
205 this.alpha = alpha;
206 }
207
208 /**
209 * Stringify
210 */
211 public String toString() {
212 return "Color [" + getRed() + ", " + getGreen() + ", " + getBlue() + ", " + getAlpha() + "]";
213 }
214
215 /**
216 * Equals
217 */
218 public boolean equals(Object o) {
219 return (o != null)
220 && (o instanceof ReadableColor)
221 && (((ReadableColor) o).getRed() == this.getRed())
222 && (((ReadableColor) o).getGreen() == this.getGreen())
223 && (((ReadableColor) o).getBlue() == this.getBlue())
224 && (((ReadableColor) o).getAlpha() == this.getAlpha());
225 }
226
227 /**
228 * Hashcode
229 */
230 public int hashCode() {
231 return (red << 24) | (green << 16) | (blue << 8) | alpha;
232 }
233
234 /* (Overrides)
235 * @see com.shavenpuppy.jglib.ReadableColor#getAlphaByte()
236 */
237 public byte getAlphaByte() {
238 return alpha;
239 }
240
241 /* (Overrides)
242 * @see com.shavenpuppy.jglib.ReadableColor#getBlueByte()
243 */
244 public byte getBlueByte() {
245 return blue;
246 }
247
248 /* (Overrides)
249 * @see com.shavenpuppy.jglib.ReadableColor#getGreenByte()
250 */
251 public byte getGreenByte() {
252 return green;
253 }
254
255 /* (Overrides)
256 * @see com.shavenpuppy.jglib.ReadableColor#getRedByte()
257 */
258 public byte getRedByte() {
259 return red;
260 }
261
262 /* (Overrides)
263 * @see com.shavenpuppy.jglib.ReadableColor#writeRGBA(java.nio.ByteBuffer)
264 */
265 public void writeRGBA(ByteBuffer dest) {
266 dest.put(red);
267 dest.put(green);
268 dest.put(blue);
269 dest.put(alpha);
270 }
271
272 /* (Overrides)
273 * @see com.shavenpuppy.jglib.ReadableColor#writeRGB(java.nio.ByteBuffer)
274 */
275 public void writeRGB(ByteBuffer dest) {
276 dest.put(red);
277 dest.put(green);
278 dest.put(blue);
279 }
280
281 /* (Overrides)
282 * @see com.shavenpuppy.jglib.ReadableColor#writeABGR(java.nio.ByteBuffer)
283 */
284 public void writeABGR(ByteBuffer dest) {
285 dest.put(alpha);
286 dest.put(blue);
287 dest.put(green);
288 dest.put(red);
289 }
290
291 /* (Overrides)
292 * @see com.shavenpuppy.jglib.ReadableColor#writeARGB(java.nio.ByteBuffer)
293 */
294 public void writeARGB(ByteBuffer dest) {
295 dest.put(alpha);
296 dest.put(red);
297 dest.put(green);
298 dest.put(blue);
299 }
300
301 /* (Overrides)
302 * @see com.shavenpuppy.jglib.ReadableColor#writeBGR(java.nio.ByteBuffer)
303 */
304 public void writeBGR(ByteBuffer dest) {
305 dest.put(blue);
306 dest.put(green);
307 dest.put(red);
308 }
309
310 /* (Overrides)
311 * @see com.shavenpuppy.jglib.ReadableColor#writeBGRA(java.nio.ByteBuffer)
312 */
313 public void writeBGRA(ByteBuffer dest) {
314 dest.put(blue);
315 dest.put(green);
316 dest.put(red);
317 dest.put(alpha);
318 }
319
320 /**
321 * Read a color from a byte buffer
322 * @param src The source buffer
323 */
324 public void readRGBA(ByteBuffer src) {
325 red = src.get();
326 green = src.get();
327 blue = src.get();
328 alpha = src.get();
329 }
330
331 /**
332 * Read a color from a byte buffer
333 * @param src The source buffer
334 */
335 public void readRGB(ByteBuffer src) {
336 red = src.get();
337 green = src.get();
338 blue = src.get();
339 }
340
341 /**
342 * Read a color from a byte buffer
343 * @param src The source buffer
344 */
345 public void readARGB(ByteBuffer src) {
346 alpha = src.get();
347 red = src.get();
348 green = src.get();
349 blue = src.get();
350 }
351
352 /**
353 * Read a color from a byte buffer
354 * @param src The source buffer
355 */
356 public void readBGRA(ByteBuffer src) {
357 blue = src.get();
358 green = src.get();
359 red = src.get();
360 alpha = src.get();
361 }
362
363 /**
364 * Read a color from a byte buffer
365 * @param src The source buffer
366 */
367 public void readBGR(ByteBuffer src) {
368 blue = src.get();
369 green = src.get();
370 red = src.get();
371 }
372
373 /**
374 * Read a color from a byte buffer
375 * @param src The source buffer
376 */
377 public void readABGR(ByteBuffer src) {
378 alpha = src.get();
379 blue = src.get();
380 green = src.get();
381 red = src.get();
382 }
383
384 /**
385 * Set this color's color by copying another color
386 * @param src The source color
387 */
388 public void setColor(ReadableColor src) {
389 red = src.getRedByte();
390 green = src.getGreenByte();
391 blue = src.getBlueByte();
392 alpha = src.getAlphaByte();
393 }
394
395 /**
396 * HSB to RGB conversion, pinched from java.awt.Color.
397 * @param hue (0..1.0f)
398 * @param saturation (0..1.0f)
399 * @param brightness (0..1.0f)
400 */
401 public void fromHSB(float hue, float saturation, float brightness) {
402 if (saturation == 0.0F) {
403 red = green = blue = (byte) (brightness * 255F + 0.5F);
404 } else {
405 float f3 = (hue - (float) Math.floor(hue)) * 6F;
406 float f4 = f3 - (float) Math.floor(f3);
407 float f5 = brightness * (1.0F - saturation);
408 float f6 = brightness * (1.0F - saturation * f4);
409 float f7 = brightness * (1.0F - saturation * (1.0F - f4));
410 switch ((int) f3) {
411 case 0 :
412 red = (byte) (brightness * 255F + 0.5F);
413 green = (byte) (f7 * 255F + 0.5F);
414 blue = (byte) (f5 * 255F + 0.5F);
415 break;
416 case 1 :
417 red = (byte) (f6 * 255F + 0.5F);
418 green = (byte) (brightness * 255F + 0.5F);
419 blue = (byte) (f5 * 255F + 0.5F);
420 break;
421 case 2 :
422 red = (byte) (f5 * 255F + 0.5F);
423 green = (byte) (brightness * 255F + 0.5F);
424 blue = (byte) (f7 * 255F + 0.5F);
425 break;
426 case 3 :
427 red = (byte) (f5 * 255F + 0.5F);
428 green = (byte) (f6 * 255F + 0.5F);
429 blue = (byte) (brightness * 255F + 0.5F);
430 break;
431 case 4 :
432 red = (byte) (f7 * 255F + 0.5F);
433 green = (byte) (f5 * 255F + 0.5F);
434 blue = (byte) (brightness * 255F + 0.5F);
435 break;
436 case 5 :
437 red = (byte) (brightness * 255F + 0.5F);
438 green = (byte) (f5 * 255F + 0.5F);
439 blue = (byte) (f6 * 255F + 0.5F);
440 break;
441 }
442 }
443 }
444
445 /**
446 * RGB to HSB conversion, pinched from java.awt.Color.
447 * The HSB value is returned in dest[] if dest[] is supplied.
448 * Values range from 0..1
449 * @param dest Destination floats, or null
450 * @return dest, or a new float array
451 */
452 public float[] toHSB(float dest[]) {
453 int r = getRed();
454 int g = getGreen();
455 int b = getBlue();
456 if (dest == null)
457 dest = new float[3];
458 int l = r <= g ? g : r;
459 if (b > l)
460 l = b;
461 int i1 = r >= g ? g : r;
462 if (b < i1)
463 i1 = b;
464 float brightness = l / 255F;
465 float saturation;
466 if (l != 0)
467 saturation = (float) (l - i1) / (float) l;
468 else
469 saturation = 0.0F;
470 float hue;
471 if (saturation == 0.0F) {
472 hue = 0.0F;
473 } else {
474 float f3 = (float) (l - r) / (float) (l - i1);
475 float f4 = (float) (l - g) / (float) (l - i1);
476 float f5 = (float) (l - b) / (float) (l - i1);
477 if (r == l)
478 hue = f5 - f4;
479 else if (g == l)
480 hue = (2.0F + f3) - f5;
481 else
482 hue = (4F + f4) - f3;
483 hue /= 6F;
484 if (hue < 0.0F)
485 hue++;
486 }
487 dest[0] = hue;
488 dest[1] = saturation;
489 dest[2] = brightness;
490 return dest;
491 }
492
493 }
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;
32
33 import java.io.Serializable;
34
35 /**
36 * A 2D integer Dimension class, which looks remarkably like an AWT one.
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Dimension.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public final class Dimension implements Serializable, ReadableDimension, WritableDimension {
42
43 static final long serialVersionUID = 1L;
44
45 /** The dimensions! */
46 private int width, height;
47
48 /**
49 * Constructor for Dimension.
50 */
51 public Dimension() {
52 super();
53 }
54
55 /**
56 * Constructor for Dimension.
57 */
58 public Dimension(int w, int h) {
59 this.width = w;
60 this.height = h;
61 }
62
63 /**
64 * Constructor for Dimension.
65 */
66 public Dimension(ReadableDimension d) {
67 setSize(d);
68 }
69
70 public void setSize(int w, int h) {
71 this.width = w;
72 this.height = h;
73 }
74
75 public void setSize(ReadableDimension d) {
76 this.width = d.getWidth();
77 this.height = d.getHeight();
78 }
79
80 /* (Overrides)
81 * @see com.shavenpuppy.jglib.ReadableDimension#getSize(com.shavenpuppy.jglib.Dimension)
82 */
83 public void getSize(WritableDimension dest) {
84 dest.setSize(this);
85 }
86
87 /**
88 * Checks whether two dimension objects have equal values.
89 */
90 public boolean equals(Object obj) {
91 if (obj instanceof ReadableDimension) {
92 ReadableDimension d = (ReadableDimension) obj;
93 return (width == d.getWidth()) && (height == d.getHeight());
94 }
95 return false;
96 }
97
98 /**
99 * Returns the hash code for this <code>Dimension</code>.
100 *
101 * @return a hash code for this <code>Dimension</code>
102 */
103 public int hashCode() {
104 int sum = width + height;
105 return sum * (sum + 1) / 2 + width;
106 }
107
108 /**
109 * Returns a string representation of the values of this
110 * <code>Dimension</code> object's <code>height</code> and
111 * <code>width</code> fields. This method is intended to be used only
112 * for debugging purposes, and the content and format of the returned
113 * string may vary between implementations. The returned string may be
114 * empty but may not be <code>null</code>.
115 *
116 * @return a string representation of this <code>Dimension</code>
117 * object
118 */
119 public String toString() {
120 return getClass().getName() + "[width=" + width + ",height=" + height + "]";
121 }
122
123 /**
124 * Gets the height.
125 * @return Returns a int
126 */
127 public int getHeight() {
128 return height;
129 }
130
131 /**
132 * Sets the height.
133 * @param height The height to set
134 */
135 public void setHeight(int height) {
136 this.height = height;
137 }
138
139 /**
140 * Gets the width.
141 * @return Returns a int
142 */
143 public int getWidth() {
144 return width;
145 }
146
147 /**
148 * Sets the width.
149 * @param width The width to set
150 */
151 public void setWidth(int width) {
152 this.width = width;
153 }
154
155 }
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;
32
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.Comparator;
36
37 import org.lwjgl.LWJGLException;
38 import org.lwjgl.LWJGLUtil;
39 import org.lwjgl.opengl.DisplayMode;
40
41 /**
42 * Display initialization utility, that can be used to find display modes and pick
43 * 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 $
47 */
48 public final class Display {
49
50 private static final boolean DEBUG = false;
51
52 /**
53 * Determine the available display modes that match the specified minimum and maximum criteria.
54 * If any given criterium is specified as -1 then it is ignored.
55 *
56 * @param minWidth the minimum display resolution in pixels
57 * @param minHeight the minimum display resolution in pixels
58 * @param maxWidth the maximum display resolution in pixels
59 * @param maxHeight the maximum display resolution in pixels
60 * @param minBPP the minimum bit depth per pixel
61 * @param maxBPP the maximum bit depth per pixel
62 * @param minFreq the minimum display frequency in Hz
63 * @param maxFreq the maximum display frequency in Hz
64 * @return an array of matching display modes
65 */
66 public static DisplayMode[] getAvailableDisplayModes(int minWidth, int minHeight, int maxWidth, int maxHeight, int minBPP, int maxBPP,
67 int minFreq, int maxFreq) throws LWJGLException
68 {
69 // First get the available display modes
70 DisplayMode[] modes = org.lwjgl.opengl.Display.getAvailableDisplayModes();
71
72 if (LWJGLUtil.DEBUG || DEBUG) {
73 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);
80
81 for (int i = 0; i < modes.length; i ++) {
82 assert modes[i] != null : ""+i+" "+modes.length;
83 if (minWidth != -1 && modes[i].getWidth() < minWidth)
84 continue;
85 if (maxWidth != -1 && modes[i].getWidth() > maxWidth)
86 continue;
87 if (minHeight != -1 && modes[i].getHeight() < minHeight)
88 continue;
89 if (maxHeight != -1 && modes[i].getHeight() > maxHeight)
90 continue;
91 if (minBPP != -1 && modes[i].getBitsPerPixel() < minBPP)
92 continue;
93 if (maxBPP != -1 && modes[i].getBitsPerPixel() > maxBPP)
94 continue;
95 //if (modes[i].bpp == 24)
96 // continue;
97 if (modes[i].getFrequency() != 0) {
98 if (minFreq != -1 && modes[i].getFrequency() < minFreq)
99 continue;
100 if (maxFreq != -1 && modes[i].getFrequency() > maxFreq)
101 continue;
102 }
103 matches.add(modes[i]);
104 }
105
106 DisplayMode[] ret = new DisplayMode[matches.size()];
107 matches.toArray(ret);
108 if (LWJGLUtil.DEBUG && DEBUG) {
109 System.out.println("Filtered screen modes:");
110 for (int i = 0; i < ret.length; i ++) {
111 System.out.println(ret[i]);
112 }
113 }
114
115 return ret;
116 }
117
118 /**
119 * Create the display by choosing from a list of display modes based on an order of preference.
120 * You must supply a list of allowable display modes, probably by calling getAvailableDisplayModes(),
121 * and an array with the order in which you would like them sorted in descending order.
122 * This method attempts to create the topmost display mode; if that fails, it will try the next one,
123 * and so on, until there are no modes left. If no mode is set at the end, an exception is thrown.
124 * @param dm a list of display modes to choose from
125 * @param param the names of the DisplayMode fields in the order in which you would like them sorted.
126 * @return the chosen display mode
127 * @throws NoSuchFieldException if one of the params is not a field in DisplayMode
128 * @throws Exception if no display mode could be set
129 * @see org.lwjgl.opengl.DisplayMode
130 */
131 public static DisplayMode setDisplayMode(DisplayMode[] dm, final String[] param) throws Exception {
132
133 class FieldAccessor {
134 final String fieldName;
135 final int order;
136 final int preferred;
137 final boolean usePreferred;
138 FieldAccessor(String fieldName, int order, int preferred, boolean usePreferred) {
139 this.fieldName = fieldName;
140 this.order = order;
141 this.preferred = preferred;
142 this.usePreferred = usePreferred;
143 }
144 int getInt(DisplayMode mode) {
145 if ("width".equals(fieldName)) {
146 return mode.getWidth();
147 }
148 if ("height".equals(fieldName)) {
149 return mode.getHeight();
150 }
151 if ("freq".equals(fieldName)) {
152 return mode.getFrequency();
153 }
154 if ("bpp".equals(fieldName)) {
155 return mode.getBitsPerPixel();
156 }
157 throw new IllegalArgumentException("Unknown field "+fieldName);
158 }
159 }
160
161 class Sorter implements Comparator {
162
163 final FieldAccessor[] field;
164
165 Sorter() {
166 field = new FieldAccessor[param.length];
167 for (int i = 0; i < field.length; i ++) {
168 int idx = param[i].indexOf('=');
169 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);
171 } else if (param[i].charAt(0) == '-') {
172 field[i] = new FieldAccessor(param[i].substring(1), -1, 0, false);
173 } else {
174 field[i] = new FieldAccessor(param[i], 1, 0, false);
175 }
176 }
177 }
178
179 /**
180 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
181 */
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)
192 return -1;
193 else if (f2 == field[i].preferred)
194 return 1;
195 else {
196 // 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)
200 return -1;
201 else if (absf1 > absf2)
202 return 1;
203 else
204 continue;
205 }
206 } else if (f1 < f2)
207 return field[i].order;
208 else if (f1 == f2)
209 continue;
210 else
211 return -field[i].order;
212 }
213
214 return 0;
215 }
216 }
217
218 // Sort the display modes
219 Arrays.sort(dm, new Sorter());
220
221 // Try them out in the appropriate order
222 if (LWJGLUtil.DEBUG || DEBUG) {
223 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 ++) {
229 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];
234 } catch (Exception e) {
235 if (LWJGLUtil.DEBUG || DEBUG) {
236 System.out.println("Failed to set display mode to "+dm[i]);
237 e.printStackTrace();
238 }
239 }
240 }
241
242 throw new Exception("Failed to set display mode.");
243 }
244
245 }
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;
32
33 import java.io.Serializable;
34
35 /**
36 * A 2D integer point class, which looks remarkably like an AWT one.
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Point.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public final class Point implements ReadablePoint, WritablePoint, Serializable {
42
43 static final long serialVersionUID = 1L;
44
45 /** The location */
46 private int x, y;
47
48 /**
49 * Constructor for Point.
50 */
51 public Point() {
52 super();
53 }
54
55 /**
56 * Constructor for Point.
57 */
58 public Point(int x, int y) {
59 setLocation(x, y);
60 }
61
62 /**
63 * Constructor for Point.
64 */
65 public Point(ReadablePoint p) {
66 setLocation(p);
67 }
68
69 public void setLocation(int x, int y) {
70 this.x = x;
71 this.y = y;
72 }
73
74 public void setLocation(ReadablePoint p) {
75 this.x = p.getX();
76 this.y = p.getY();
77 }
78
79 public void setX(int x) {
80 this.x = x;
81 }
82
83 public void setY(int y) {
84 this.y = y;
85 }
86
87 /**
88 * Translate a point.
89 * @param dx The translation to apply
90 * @param dy The translation to apply
91 */
92 public void translate(int dx, int dy) {
93 this.x += dx;
94 this.y += dy;
95 }
96
97 /**
98 * Translate a point.
99 * @param p The translation to apply
100 */
101 public void translate(ReadablePoint p) {
102 this.x += p.getX();
103 this.y += p.getY();
104 }
105
106 /**
107 * Un-translate a point.
108 * @param p The translation to apply
109 */
110 public void untranslate(ReadablePoint p) {
111 this.x -= p.getX();
112 this.y -= p.getY();
113 }
114
115 /**
116 * Determines whether an instance of <code>Point2D</code> is equal
117 * to this point. Two instances of <code>Point2D</code> are equal if
118 * the values of their <code>x</code> and <code>y</code> member
119 * fields, representing their position in the coordinate space, are
120 * the same.
121 * @param obj an object to be compared with this point
122 * @return <code>true</code> if the object to be compared is
123 * an instance of <code>Point</code> and has
124 * the same values; <code>false</code> otherwise
125 */
126 public boolean equals(Object obj) {
127 if (obj instanceof Point) {
128 Point pt = (Point) obj;
129 return (x == pt.x) && (y == pt.y);
130 }
131 return super.equals(obj);
132 }
133
134 /**
135 * Returns a string representation of this point and its location
136 * in the (<i>x</i>,&nbsp;<i>y</i>) coordinate space. This method is
137 * intended to be used only for debugging purposes, and the content
138 * and format of the returned string may vary between implementations.
139 * The returned string may be empty but may not be <code>null</code>.
140 *
141 * @return a string representation of this point
142 */
143 public String toString() {
144 return getClass().getName() + "[x=" + x + ",y=" + y + "]";
145 }
146
147 /**
148 * Returns the hash code for this <code>Point</code>.
149 *
150 * @return a hash code for this <code>Point</code>
151 */
152 public int hashCode() {
153 int sum = x + y;
154 return sum * (sum + 1) / 2 + x;
155 }
156
157 public int getX() {
158 return x;
159 }
160
161 public int getY() {
162 return y;
163 }
164
165 public void getLocation(WritablePoint dest) {
166 dest.setLocation(x, y);
167 }
168
169 }
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;
32
33 import java.nio.ByteBuffer;
34
35 /**
36 * Readonly interface for Colors
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: ReadableColor.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public interface ReadableColor {
42
43 /**
44 * Return the red component (0..255)
45 * @return int
46 */
47 public int getRed();
48
49 /**
50 * Return the red component (0..255)
51 * @return int
52 */
53 public int getGreen();
54
55 /**
56 * Return the red component (0..255)
57 * @return int
58 */
59 public int getBlue();
60
61 /**
62 * Return the red component (0..255)
63 * @return int
64 */
65 public int getAlpha();
66
67 /**
68 * Return the red component
69 * @return int
70 */
71 public byte getRedByte();
72
73 /**
74 * Return the red component
75 * @return int
76 */
77 public byte getGreenByte();
78
79 /**
80 * Return the red component
81 * @return int
82 */
83 public byte getBlueByte();
84
85 /**
86 * Return the red component
87 * @return int
88 */
89 public byte getAlphaByte();
90
91 /**
92 * Write the RGBA color directly out to a ByteBuffer
93 * @param dest the buffer to write to
94 */
95 public void writeRGBA(ByteBuffer dest);
96
97 /**
98 * Write the RGB color directly out to a ByteBuffer
99 * @param dest the buffer to write to
100 */
101 public void writeRGB(ByteBuffer dest);
102
103 /**
104 * Write the ABGR color directly out to a ByteBuffer
105 * @param dest the buffer to write to
106 */
107 public void writeABGR(ByteBuffer dest);
108
109 /**
110 * Write the BGR color directly out to a ByteBuffer
111 * @param dest the buffer to write to
112 */
113 public void writeBGR(ByteBuffer dest);
114
115 /**
116 * Write the BGRA color directly out to a ByteBuffer
117 * @param dest the buffer to write to
118 */
119 public void writeBGRA(ByteBuffer dest);
120
121 /**
122 * Write the ARGB color directly out to a ByteBuffer
123 * @param dest the buffer to write to
124 */
125 public void writeARGB(ByteBuffer dest);
126
127 /*
128 * Some standard colors
129 */
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);
142
143
144
145 }
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;
32
33 /**
34 * Readonly interface for Dimensions
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadableDimension.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface ReadableDimension {
40
41 /**
42 * Get the width
43 * @return int
44 */
45 public int getWidth();
46
47 /**
48 * Get the height
49 * @return int
50 */
51 public int getHeight();
52
53 /**
54 * Copy this ReadableDimension into a destination Dimension
55 * @param dest The destination
56 */
57 public void getSize(WritableDimension dest);
58
59 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util;
32
33 /**
34 * Readonly interface for Points
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadablePoint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface ReadablePoint {
40
41 /**
42 * @return int
43 */
44 public int getX();
45
46 /**
47 * @return int
48 */
49 public int getY();
50
51 /**
52 * Copy this ReadablePoint into a destination Point
53 * @param dest The destination Point, or null, to create a new Point
54 */
55 public void getLocation(WritablePoint dest);
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;
32
33 /**
34 * Readonly interface for Rectangles
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadableRectangle.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface ReadableRectangle extends ReadableDimension, ReadablePoint {
40
41 /**
42 * Copy this readable rectangle's bounds into a destination Rectangle
43 * @param dest The destination Rectangle, or null, to create a new Rectangle
44 */
45 public void getBounds(WritableRectangle dest);
46
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;
32
33 import java.io.Serializable;
34
35 /**
36 * A 2D integer Rectangle class which looks remarkably like an AWT one.
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Rectangle.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public final class Rectangle implements ReadableRectangle, WritableRectangle, Serializable {
42
43 static final long serialVersionUID = 1L;
44
45 /** Rectangle's bounds */
46 private int x, y, width, height;
47
48 /**
49 * Constructor for Rectangle.
50 */
51 public Rectangle() {
52 super();
53 }
54 /**
55 * Constructor for Rectangle.
56 */
57 public Rectangle(int x, int y, int w, int h) {
58 this.x = x;
59 this.y = y;
60 this.width = w;
61 this.height = h;
62 }
63 /**
64 * Constructor for Rectangle.
65 */
66 public Rectangle(ReadablePoint p, ReadableDimension d) {
67 x = p.getX();
68 y = p.getY();
69 width = d.getWidth();
70 height = d.getHeight();
71 }
72 /**
73 * Constructor for Rectangle.
74 */
75 public Rectangle(ReadableRectangle r) {
76 x = r.getX();
77 y = r.getY();
78 width = r.getWidth();
79 height = r.getHeight();
80 }
81
82 public void setLocation(int x, int y) {
83 this.x = x;
84 this.y = y;
85 }
86
87 public void setLocation(ReadablePoint p) {
88 this.x = p.getX();
89 this.y = p.getY();
90 }
91
92 public void setSize(int w, int h) {
93 this.width = w;
94 this.height = h;
95 }
96
97 public void setSize(ReadableDimension d) {
98 this.width = d.getWidth();
99 this.height = d.getHeight();
100 }
101
102 public void setBounds(int x, int y, int w, int h) {
103 this.x = x;
104 this.y = y;
105 this.width = w;
106 this.height = h;
107 }
108
109 public void setBounds(ReadablePoint p, ReadableDimension d) {
110 x = p.getX();
111 y = p.getY();
112 width = d.getWidth();
113 height = d.getHeight();
114 }
115
116 public void setBounds(ReadableRectangle r) {
117 x = r.getX();
118 y = r.getY();
119 width = r.getWidth();
120 height = r.getHeight();
121 }
122
123 /* (Overrides)
124 * @see com.shavenpuppy.jglib.ReadableRectangle#getBounds(com.shavenpuppy.jglib.Rectangle)
125 */
126 public void getBounds(WritableRectangle dest) {
127 dest.setBounds(x, y, width, height);
128 }
129
130 /* (Overrides)
131 * @see com.shavenpuppy.jglib.ReadablePoint#getLocation(com.shavenpuppy.jglib.Point)
132 */
133 public void getLocation(WritablePoint dest) {
134 dest.setLocation(x, y);
135 }
136
137 /* (Overrides)
138 * @see com.shavenpuppy.jglib.ReadableDimension#getSize(com.shavenpuppy.jglib.Dimension)
139 */
140 public void getSize(WritableDimension dest) {
141 dest.setSize(width, height);
142 }
143
144 /**
145 * Translate the rectangle by an amount.
146 * @param x The translation amount on the x axis
147 * @param y The translation amount on the y axis
148 */
149 public void translate(int x, int y) {
150 this.x += x;
151 this.y += y;
152 }
153
154 /**
155 * Translate the rectangle by an amount.
156 * @param point The translation amount
157 */
158 public void translate(ReadablePoint point) {
159 this.x += point.getX();
160 this.y += point.getY();
161 }
162
163 /**
164 * Un-translate the rectangle by an amount.
165 * @param point The translation amount
166 */
167 public void untranslate(ReadablePoint point) {
168 this.x -= point.getX();
169 this.y -= point.getY();
170 }
171
172 /**
173 * Checks whether or not this <code>Rectangle</code> contains the
174 * specified <code>Point</code>.
175 * @param p the <code>Point</code> to test
176 * @return <code>true</code> if the <code>Point</code>
177 * (<i>x</i>,&nbsp;<i>y</i>) is inside this
178 * <code>Rectangle</code>;
179 * <code>false</code> otherwise.
180 */
181 public boolean contains(ReadablePoint p) {
182 return contains(p.getX(), p.getY());
183 }
184
185 /**
186 * Checks whether or not this <code>Rectangle</code> contains the
187 * point at the specified location
188 * (<i>x</i>,&nbsp;<i>y</i>).
189 * @param X the specified x coordinate
190 * @param Y the specified y coordinate
191 * @return <code>true</code> if the point
192 * (<i>x</i>,&nbsp;<i>y</i>) is inside this
193 * <code>Rectangle</code>;
194 * <code>false</code> otherwise.
195 */
196 public boolean contains(int X, int Y) {
197 int w = this.width;
198 int h = this.height;
199 if ((w | h) < 0) {
200 // At least one of the dimensions is negative...
201 return false;
202 }
203 // Note: if either dimension is zero, tests below must return false...
204 int x = this.x;
205 int y = this.y;
206 if (X < x || Y < y) {
207 return false;
208 }
209 w += x;
210 h += y;
211 // overflow || intersect
212 return ((w < x || w > X) && (h < y || h > Y));
213 }
214
215 /**
216 * Checks whether or not this <code>Rectangle</code> entirely contains
217 * the specified <code>Rectangle</code>.
218 * @param r the specified <code>Rectangle</code>
219 * @return <code>true</code> if the <code>Rectangle</code>
220 * is contained entirely inside this <code>Rectangle</code>;
221 * <code>false</code> otherwise.
222 */
223 public boolean contains(ReadableRectangle r) {
224 return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
225 }
226
227 /**
228 * Checks whether this <code>Rectangle</code> entirely contains
229 * the <code>Rectangle</code>
230 * at the specified location (<i>X</i>,&nbsp;<i>Y</i>) with the
231 * specified dimensions (<i>W</i>,&nbsp;<i>H</i>).
232 * @param X the specified x coordinate
233 * @param Y the specified y coordinate
234 * @param W the width of the <code>Rectangle</code>
235 * @param H the height of the <code>Rectangle</code>
236 * @return <code>true</code> if the <code>Rectangle</code> specified by
237 * (<i>X</i>,&nbsp;<i>Y</i>,&nbsp;<i>W</i>,&nbsp;<i>H</i>)
238 * is entirely enclosed inside this <code>Rectangle</code>;
239 * <code>false</code> otherwise.
240 */
241 public boolean contains(int X, int Y, int W, int H) {
242 int w = this.width;
243 int h = this.height;
244 if ((w | h | W | H) < 0) {
245 // At least one of the dimensions is negative...
246 return false;
247 }
248 // Note: if any dimension is zero, tests below must return false...
249 int x = this.x;
250 int y = this.y;
251 if (X < x || Y < y) {
252 return false;
253 }
254 w += x;
255 W += X;
256 if (W <= X) {
257 // X+W overflowed or W was zero, return false if...
258 // either original w or W was zero or
259 // x+w did not overflow or
260 // the overflowed x+w is smaller than the overflowed X+W
261 if (w >= x || W > w)
262 return false;
263 } else {
264 // X+W did not overflow and W was not zero, return false if...
265 // original w was zero or
266 // x+w did not overflow and x+w is smaller than X+W
267 if (w >= x && W > w)
268 return false;
269 }
270 h += y;
271 H += Y;
272 if (H <= Y) {
273 if (h >= y || H > h)
274 return false;
275 } else {
276 if (h >= y && H > h)
277 return false;
278 }
279 return true;
280 }
281
282 /**
283 * Determines whether or not this <code>Rectangle</code> and the specified
284 * <code>Rectangle</code> intersect. Two rectangles intersect if
285 * their intersection is nonempty.
286 *
287 * @param r the specified <code>Rectangle</code>
288 * @return <code>true</code> if the specified <code>Rectangle</code>
289 * and this <code>Rectangle</code> intersect;
290 * <code>false</code> otherwise.
291 */
292 public boolean intersects(ReadableRectangle r) {
293 int tw = this.width;
294 int th = this.height;
295 int rw = r.getWidth();
296 int rh = r.getHeight();
297 if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
298 return false;
299 }
300 int tx = this.x;
301 int ty = this.y;
302 int rx = r.getX();
303 int ry = r.getY();
304 rw += rx;
305 rh += ry;
306 tw += tx;
307 th += ty;
308 // overflow || intersect
309 return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry));
310 }
311
312 /**
313 * Computes the intersection of this <code>Rectangle</code> with the
314 * specified <code>Rectangle</code>. Returns a new <code>Rectangle</code>
315 * that represents the intersection of the two rectangles.
316 * If the two rectangles do not intersect, the result will be
317 * an empty rectangle.
318 *
319 * @param r the specified <code>Rectangle</code>
320 * @return the largest <code>Rectangle</code> contained in both the
321 * specified <code>Rectangle</code> and in
322 * this <code>Rectangle</code>; or if the rectangles
323 * do not intersect, an empty rectangle.
324 */
325 public Rectangle intersection(ReadableRectangle r, Rectangle dest) {
326 int tx1 = this.x;
327 int ty1 = this.y;
328 int rx1 = r.getX();
329 int ry1 = r.getY();
330 long tx2 = tx1;
331 tx2 += this.width;
332 long ty2 = ty1;
333 ty2 += this.height;
334 long rx2 = rx1;
335 rx2 += r.getWidth();
336 long ry2 = ry1;
337 ry2 += r.getHeight();
338 if (tx1 < rx1)
339 tx1 = rx1;
340 if (ty1 < ry1)
341 ty1 = ry1;
342 if (tx2 > rx2)
343 tx2 = rx2;
344 if (ty2 > ry2)
345 ty2 = ry2;
346 tx2 -= tx1;
347 ty2 -= ty1;
348 // tx2,ty2 will never overflow (they will never be
349 // larger than the smallest of the two source w,h)
350 // they might underflow, though...
351 if (tx2 < Integer.MIN_VALUE)
352 tx2 = Integer.MIN_VALUE;
353 if (ty2 < Integer.MIN_VALUE)
354 ty2 = Integer.MIN_VALUE;
355 if (dest == null)
356 dest = new Rectangle(tx1, ty1, (int) tx2, (int) ty2);
357 else
358 dest.setBounds(tx1, ty1, (int) tx2, (int) ty2);
359 return dest;
360
361 }
362
363 /**
364 * Computes the union of this <code>Rectangle</code> with the
365 * specified <code>Rectangle</code>. Returns a new
366 * <code>Rectangle</code> that
367 * represents the union of the two rectangles
368 * @param r the specified <code>Rectangle</code>
369 * @return the smallest <code>Rectangle</code> containing both
370 * the specified <code>Rectangle</code> and this
371 * <code>Rectangle</code>.
372 */
373 public WritableRectangle union(ReadableRectangle r, WritableRectangle dest) {
374 int x1 = Math.min(x, r.getX());
375 int x2 = Math.max(x + width, r.getX() + r.getWidth());
376 int y1 = Math.min(y, r.getY());
377 int y2 = Math.max(y + height, r.getY() + r.getHeight());
378 dest.setBounds(x1, y1, x2 - x1, y2 - y1);
379 return dest;
380 }
381
382 /**
383 * Adds a point, specified by the integer arguments <code>newx</code>
384 * and <code>newy</code>, to this <code>Rectangle</code>. The
385 * resulting <code>Rectangle</code> is
386 * the smallest <code>Rectangle</code> that contains both the
387 * original <code>Rectangle</code> and the specified point.
388 * <p>
389 * After adding a point, a call to <code>contains</code> with the
390 * added point as an argument does not necessarily return
391 * <code>true</code>. The <code>contains</code> method does not
392 * return <code>true</code> for points on the right or bottom
393 * edges of a <code>Rectangle</code>. Therefore, if the added point
394 * falls on the right or bottom edge of the enlarged
395 * <code>Rectangle</code>, <code>contains</code> returns
396 * <code>false</code> for that point.
397 * @param newx the x coordinates of the new point
398 * @param newy the y coordinates of the new point
399 */
400 public void add(int newx, int newy) {
401 int x1 = Math.min(x, newx);
402 int x2 = Math.max(x + width, newx);
403 int y1 = Math.min(y, newy);
404 int y2 = Math.max(y + height, newy);
405 x = x1;
406 y = y1;
407 width = x2 - x1;
408 height = y2 - y1;
409 }
410
411 /**
412 * Adds the specified <code>Point</code> to this
413 * <code>Rectangle</code>. The resulting <code>Rectangle</code>
414 * is the smallest <code>Rectangle</code> that contains both the
415 * original <code>Rectangle</code> and the specified
416 * <code>Point</code>.
417 * <p>
418 * After adding a <code>Point</code>, a call to <code>contains</code>
419 * with the added <code>Point</code> as an argument does not
420 * necessarily return <code>true</code>. The <code>contains</code>
421 * method does not return <code>true</code> for points on the right
422 * or bottom edges of a <code>Rectangle</code>. Therefore if the added
423 * <code>Point</code> falls on the right or bottom edge of the
424 * enlarged <code>Rectangle</code>, <code>contains</code> returns
425 * <code>false</code> for that <code>Point</code>.
426 * @param pt the new <code>Point</code> to add to this
427 * <code>Rectangle</code>
428 */
429 public void add(ReadablePoint pt) {
430 add(pt.getX(), pt.getY());
431 }
432
433 /**
434 * Adds a <code>Rectangle</code> to this <code>Rectangle</code>.
435 * The resulting <code>Rectangle</code> is the union of the two
436 * rectangles.
437 * @param r the specified <code>Rectangle</code>
438 */
439 public void add(ReadableRectangle r) {
440 int x1 = Math.min(x, r.getX());
441 int x2 = Math.max(x + width, r.getX() + r.getWidth());
442 int y1 = Math.min(y, r.getY());
443 int y2 = Math.max(y + height, r.getY() + r.getHeight());
444 x = x1;
445 y = y1;
446 width = x2 - x1;
447 height = y2 - y1;
448 }
449
450 /**
451 * Resizes the <code>Rectangle</code> both horizontally and vertically.
452 * <p>
453 * This method modifies the <code>Rectangle</code> so that it is
454 * <code>h</code> units larger on both the left and right side,
455 * and <code>v</code> units larger at both the top and bottom.
456 * <p>
457 * The new <code>Rectangle</code> has (<code>x&nbsp;-&nbsp;h</code>,
458 * <code>y&nbsp;-&nbsp;v</code>) as its top-left corner, a
459 * width of
460 * <code>width</code>&nbsp;<code>+</code>&nbsp;<code>2h</code>,
461 * and a height of
462 * <code>height</code>&nbsp;<code>+</code>&nbsp;<code>2v</code>.
463 * <p>
464 * If negative values are supplied for <code>h</code> and
465 * <code>v</code>, the size of the <code>Rectangle</code>
466 * decreases accordingly.
467 * The <code>grow</code> method does not check whether the resulting
468 * values of <code>width</code> and <code>height</code> are
469 * non-negative.
470 * @param h the horizontal expansion
471 * @param v the vertical expansion
472 */
473 public void grow(int h, int v) {
474 x -= h;
475 y -= v;
476 width += h * 2;
477 height += v * 2;
478 }
479
480 /**
481 * Determines whether or not this <code>Rectangle</code> is empty. A
482 * <code>Rectangle</code> is empty if its width or its height is less
483 * than or equal to zero.
484 * @return <code>true</code> if this <code>Rectangle</code> is empty;
485 * <code>false</code> otherwise.
486 */
487 public boolean isEmpty() {
488 return (width <= 0) || (height <= 0);
489 }
490 /**
491 * Checks whether two rectangles are equal.
492 * <p>
493 * The result is <code>true</code> if and only if the argument is not
494 * <code>null</code> and is a <code>Rectangle</code> object that has the
495 * same top-left corner, width, and height as this <code>Rectangle</code>.
496 * @param obj the <code>Object</code> to compare with
497 * this <code>Rectangle</code>
498 * @return <code>true</code> if the objects are equal;
499 * <code>false</code> otherwise.
500 */
501 public boolean equals(Object obj) {
502 if (obj instanceof Rectangle) {
503 Rectangle r = (Rectangle) obj;
504 return ((x == r.x) && (y == r.y) && (width == r.width) && (height == r.height));
505 }
506 return super.equals(obj);
507 }
508
509 /**
510 * Debugging
511 * @return a String
512 */
513 public String toString() {
514 return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "]";
515 }
516 /**
517 * Gets the height.
518 * @return Returns a int
519 */
520 public int getHeight() {
521 return height;
522 }
523
524 /**
525 * Sets the height.
526 * @param height The height to set
527 */
528 public void setHeight(int height) {
529 this.height = height;
530 }
531
532 /**
533 * Gets the width.
534 * @return Returns a int
535 */
536 public int getWidth() {
537 return width;
538 }
539
540 /**
541 * Sets the width.
542 * @param width The width to set
543 */
544 public void setWidth(int width) {
545 this.width = width;
546 }
547
548 /**
549 * Gets the x.
550 * @return Returns a int
551 */
552 public int getX() {
553 return x;
554 }
555
556 /**
557 * Sets the x.
558 * @param x The x to set
559 */
560 public void setX(int x) {
561 this.x = x;
562 }
563
564 /**
565 * Gets the y.
566 * @return Returns a int
567 */
568 public int getY() {
569 return y;
570 }
571
572 /**
573 * Sets the y.
574 * @param y The y to set
575 */
576 public void setY(int y) {
577 this.y = y;
578 }
579
580 }
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;
32
33 /**
34 *
35 * 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 $
40 */
41 public interface Renderable {
42
43 /**
44 * "Render" this thing. This will involve calls to the GL.
45 */
46 public void render();
47
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;
32
33 import org.lwjgl.Sys;
34
35 /**
36 *
37 * A hires timer. This measures time in seconds as floating point values.
38 * All Timers created are updated simultaneously by calling the static method
39 * tick(). This ensures that within a single iteration of a game loop that
40 * all timers are updated consistently with each other.
41 *
42 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 2983 $
44 * $Id: Timer.java 2983 2008-04-07 18:36:09Z matzon $
45 */
46 public class Timer {
47
48 // Record the timer resolution on classload
49 private static long resolution = Sys.getTimerResolution();
50
51 // Every so often we will re-query the timer resolution
52 private static final int QUERY_INTERVAL = 50; // in calls to tick()
53 private static int queryCount = 0;
54
55 // Globally keeps track of time for all instances of Timer
56 private static long currentTime;
57
58 // When the timer was started
59 private long startTime;
60
61 // The last time recorded by getTime()
62 private long lastTime;
63
64 // Whether the timer is paused
65 private boolean paused;
66
67 static {
68 tick();
69 }
70
71 /**
72 * Constructs a timer. The timer will be reset to 0.0 and resumed immediately.
73 */
74 public Timer() {
75 reset();
76 resume();
77 }
78
79 /**
80 * @return the time in seconds, as a float
81 */
82 public float getTime() {
83 if (!paused) {
84 lastTime = currentTime - startTime;
85 }
86
87 return (float) ((double) lastTime / (double) resolution);
88 }
89 /**
90 * @return whether this timer is paused
91 */
92 public boolean isPaused() {
93 return paused;
94 }
95
96 /**
97 * Pause the timer. Whilst paused the time will not change for this timer
98 * when tick() is called.
99 *
100 * @see #resume()
101 */
102 public void pause() {
103 paused = true;
104 }
105
106 /**
107 * Reset the timer. Equivalent to set(0.0f);
108 * @see #set(float)
109 */
110 public void reset() {
111 set(0.0f);
112 }
113
114 /**
115 * Resume the timer.
116 * @see #pause()
117 */
118 public void resume() {
119 paused = false;
120 startTime = currentTime - lastTime;
121 }
122
123 /**
124 * Set the time of this timer
125 * @param newTime the new time, in seconds
126 */
127 public void set(float newTime) {
128 long newTimeInTicks = (long) ((double) newTime * (double) resolution);
129 startTime = currentTime - newTimeInTicks;
130 lastTime = newTimeInTicks;
131 }
132
133 /**
134 * Get the next time update from the system's hires timer. This method should
135 * be called once per main loop iteration; all timers are updated simultaneously
136 * from it.
137 */
138 public static void tick() {
139 currentTime = Sys.getTime();
140
141 // Periodically refresh the timer resolution:
142 queryCount ++;
143 if (queryCount > QUERY_INTERVAL) {
144 queryCount = 0;
145 resolution = Sys.getTimerResolution();
146 }
147 }
148
149 /**
150 * Debug output.
151 */
152 public String toString() {
153 return "Timer[Time=" + getTime() + ", Paused=" + paused + "]";
154 }
155 }
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;
32
33 import java.io.BufferedInputStream;
34 import java.io.ByteArrayInputStream;
35 import java.io.IOException;
36 import java.io.InputStream;
37 import java.net.URL;
38 import java.nio.ByteBuffer;
39 import java.nio.ByteOrder;
40 import java.nio.ShortBuffer;
41
42 import javax.sound.sampled.AudioFormat;
43 import javax.sound.sampled.AudioInputStream;
44 import javax.sound.sampled.AudioSystem;
45
46 import org.lwjgl.openal.AL10;
47
48 /**
49 *
50 * Utitlity class for loading wavefiles.
51 *
52 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 3274 $
54 * $Id: WaveData.java 3274 2010-02-20 10:43:22Z matzon $
55 */
56 public class WaveData {
57 /** actual wave data */
58 public final ByteBuffer data;
59
60 /** format type of data */
61 public final int format;
62
63 /** sample rate of data */
64 public final int samplerate;
65
66 /**
67 * Creates a new WaveData
68 *
69 * @param data actual wavedata
70 * @param format format of wave data
71 * @param samplerate sample rate of data
72 */
73 private WaveData(ByteBuffer data, int format, int samplerate) {
74 this.data = data;
75 this.format = format;
76 this.samplerate = samplerate;
77 }
78
79 /**
80 * Disposes the wavedata
81 */
82 public void dispose() {
83 data.clear();
84 }
85
86 /**
87 * Creates a WaveData container from the specified url
88 *
89 * @param path URL to file
90 * @return WaveData containing data, or null if a failure occured
91 */
92 public static WaveData create(URL path) {
93 try {
94 return create(
95 AudioSystem.getAudioInputStream(
96 new BufferedInputStream(path.openStream())));
97 } catch (Exception e) {
98 org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
99 return null;
100 }
101 }
102
103 /**
104 * Creates a WaveData container from the specified in the classpath
105 *
106 * @param path path to file (relative, and in classpath)
107 * @return WaveData containing data, or null if a failure occured
108 */
109 public static WaveData create(String path) {
110 return create(WaveData.class.getClassLoader().getResource(path));
111 }
112
113 /**
114 * Creates a WaveData container from the specified inputstream
115 *
116 * @param is InputStream to read from
117 * @return WaveData containing data, or null if a failure occured
118 */
119 public static WaveData create(InputStream is) {
120 try {
121 return create(
122 AudioSystem.getAudioInputStream(is));
123 } catch (Exception e) {
124 org.lwjgl.LWJGLUtil.log("Unable to create from inputstream, " + e.getMessage());
125 return null;
126 }
127 }
128
129 /**
130 * Creates a WaveData container from the specified bytes
131 *
132 * @param buffer array of bytes containing the complete wave file
133 * @return WaveData containing data, or null if a failure occured
134 */
135 public static WaveData create(byte[] buffer) {
136 try {
137 return create(
138 AudioSystem.getAudioInputStream(
139 new BufferedInputStream(new ByteArrayInputStream(buffer))));
140 } catch (Exception e) {
141 org.lwjgl.LWJGLUtil.log("Unable to create from byte array, " + e.getMessage());
142 return null;
143 }
144 }
145
146 /**
147 * Creates a WaveData container from the specified ByetBuffer.
148 * If the buffer is backed by an array, it will be used directly,
149 * else the contents of the buffer will be copied using get(byte[]).
150 *
151 * @param buffer ByteBuffer containing sound file
152 * @return WaveData containing data, or null if a failure occured
153 */
154 public static WaveData create(ByteBuffer buffer) {
155 try {
156 byte[] bytes = null;
157
158 if(buffer.hasArray()) {
159 bytes = buffer.array();
160 } else {
161 bytes = new byte[buffer.capacity()];
162 buffer.get(bytes);
163 }
164 return create(bytes);
165 } catch (Exception e) {
166 org.lwjgl.LWJGLUtil.log("Unable to create from ByteBuffer, " + e.getMessage());
167 return null;
168 }
169 }
170
171 /**
172 * Creates a WaveData container from the specified stream
173 *
174 * @param ais AudioInputStream to read from
175 * @return WaveData containing data, or null if a failure occured
176 */
177 public static WaveData create(AudioInputStream ais) {
178 //get format of data
179 AudioFormat audioformat = ais.getFormat();
180
181 // get channels
182 int channels = 0;
183 if (audioformat.getChannels() == 1) {
184 if (audioformat.getSampleSizeInBits() == 8) {
185 channels = AL10.AL_FORMAT_MONO8;
186 } else if (audioformat.getSampleSizeInBits() == 16) {
187 channels = AL10.AL_FORMAT_MONO16;
188 } else {
189 assert false : "Illegal sample size";
190 }
191 } else if (audioformat.getChannels() == 2) {
192 if (audioformat.getSampleSizeInBits() == 8) {
193 channels = AL10.AL_FORMAT_STEREO8;
194 } else if (audioformat.getSampleSizeInBits() == 16) {
195 channels = AL10.AL_FORMAT_STEREO16;
196 } else {
197 assert false : "Illegal sample size";
198 }
199 } else {
200 assert false : "Only mono or stereo is supported";
201 }
202
203 //read data into buffer
204 ByteBuffer buffer = null;
205 try {
206 int available = ais.available();
207 if(available <= 0) {
208 available = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8;
209 }
210 byte[] buf = new byte[ais.available()];
211 int read = 0, total = 0;
212 while ((read = ais.read(buf, total, buf.length - total)) != -1
213 && total < buf.length) {
214 total += read;
215 }
216 buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16);
217 } catch (IOException ioe) {
218 return null;
219 }
220
221
222 //create our result
223 WaveData wavedata =
224 new WaveData(buffer, channels, (int) audioformat.getSampleRate());
225
226 //close stream
227 try {
228 ais.close();
229 } catch (IOException ioe) {
230 }
231
232 return wavedata;
233 }
234
235 private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) {
236 ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
237 dest.order(ByteOrder.nativeOrder());
238 ByteBuffer src = ByteBuffer.wrap(audio_bytes);
239 src.order(ByteOrder.LITTLE_ENDIAN);
240 if (two_bytes_data) {
241 ShortBuffer dest_short = dest.asShortBuffer();
242 ShortBuffer src_short = src.asShortBuffer();
243 while (src_short.hasRemaining())
244 dest_short.put(src_short.get());
245 } else {
246 while (src.hasRemaining())
247 dest.put(src.get());
248 }
249 dest.rewind();
250 return dest;
251 }
252 }
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;
32
33 import java.nio.ByteBuffer;
34
35 /**
36 * Write interface for Colors
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: WritableColor.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41 public interface WritableColor {
42 /**
43 * Set a color
44 */
45 public void set(int r, int g, int b, int a);
46 /**
47 * Set a color
48 */
49 public void set(byte r, byte g, byte b, byte a);
50 /**
51 * Set a color
52 */
53 public void set(int r, int g, int b);
54 /**
55 * Set a color
56 */
57 public void set(byte r, byte g, byte b);
58 /**
59 * Set the Red component
60 */
61 public void setRed(int red);
62 /**
63 * Set the Green component
64 */
65 public void setGreen(int green);
66 /**
67 * Set the Blue component
68 */
69 public void setBlue(int blue);
70 /**
71 * Set the Alpha component
72 */
73 public void setAlpha(int alpha);
74 /**
75 * Set the Red component
76 */
77 public void setRed(byte red);
78 /**
79 * Set the Green component
80 */
81 public void setGreen(byte green);
82 /**
83 * Set the Blue component
84 */
85 public void setBlue(byte blue);
86 /**
87 * Set the Alpha component
88 */
89 public void setAlpha(byte alpha);
90 /**
91 * Read a color from a byte buffer
92 * @param src The source buffer
93 */
94 public void readRGBA(ByteBuffer src);
95 /**
96 * Read a color from a byte buffer
97 * @param src The source buffer
98 */
99 public void readRGB(ByteBuffer src);
100 /**
101 * Read a color from a byte buffer
102 * @param src The source buffer
103 */
104 public void readARGB(ByteBuffer src);
105 /**
106 * Read a color from a byte buffer
107 * @param src The source buffer
108 */
109 public void readBGRA(ByteBuffer src);
110 /**
111 * Read a color from a byte buffer
112 * @param src The source buffer
113 */
114 public void readBGR(ByteBuffer src);
115 /**
116 * Read a color from a byte buffer
117 * @param src The source buffer
118 */
119 public void readABGR(ByteBuffer src);
120 /**
121 * Set this color's color by copying another color
122 * @param src The source color
123 */
124 public void setColor(ReadableColor src);
125 }
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;
32
33 /**
34 * Write interface for Dimensions
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritableDimension.java 2983 2008-04-07 18:36:09Z matzon $
38
39 */
40 public interface WritableDimension {
41 public void setSize(int w, int h);
42 public void setSize(ReadableDimension d);
43 /**
44 * Sets the height.
45 * @param height The height to set
46 */
47 public void setHeight(int height);
48 /**
49 * Sets the width.
50 * @param width The width to set
51 */
52 public void setWidth(int width);
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.util;
32
33 /**
34 * Write interface for Points
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritablePoint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 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);
44 }
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;
32
33 /**
34 * Write interface for Rectangles
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritableRectangle.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface WritableRectangle extends WritablePoint, WritableDimension {
40
41 /**
42 * Sets the bounds of the rectangle
43 * @param x Position of rectangle on x axis
44 * @param y Position of rectangle on y axis
45 * @param width Width of rectangle
46 * @param height Height of rectangle
47 */
48 public void setBounds(int x, int y, int width, int height);
49
50 /**
51 * Sets the bounds of the rectangle
52 * @param location
53 * @param size
54 */
55 public void setBounds(ReadablePoint location, ReadableDimension size);
56
57 /**
58 * Sets the bounds of the rectangle
59 * @param src
60 */
61 public void setBounds(ReadableRectangle src);
62 }
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;
32
33 import java.io.BufferedOutputStream;
34 import java.io.File;
35 import java.io.FileInputStream;
36 import java.io.FileOutputStream;
37 import java.io.IOException;
38 import java.io.InputStream;
39 import java.io.InputStreamReader;
40 import java.io.LineNumberReader;
41 import java.util.HashMap;
42 import java.util.StringTokenizer;
43
44 /**
45 * <p>
46 * NOTE: This simple XPM reader does not support extensions nor hotspots
47 * </p>
48 *
49 * @author Brian Matzon <brian@matzon.dk>
50 * @author Jos Hirth
51 * @version $Revision$
52 * $Id$
53 */
54
55 public class XPMFile {
56
57 /** 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;
67
68 private static int[] format = new int[4];
69
70 /*
71 * Private constructor, use load(String filename)
72 */
73 private XPMFile() {
74 }
75
76 /**
77 * Loads the XPM file
78 *
79 * @param file
80 * path to file
81 * @return XPMFile loaded, or exception
82 * @throws IOException
83 * If any IO exceptions occurs while reading file
84 */
85 public static XPMFile load(String file) throws IOException {
86 return load(new FileInputStream(new File(file)));
87 }
88
89 /**
90 * Loads the XPM file
91 *
92 * @param is
93 * InputStream to read file from
94 * @return XPMFile loaded, or exception
95 */
96 public static XPMFile load(InputStream is) {
97 XPMFile xFile = new XPMFile();
98 xFile.readImage(is);
99 return xFile;
100 }
101
102 /**
103 * @return the height of the image.
104 */
105 public int getHeight() {
106 return format[HEIGHT];
107 }
108
109 /**
110 * @return the width of the image.
111 */
112 public int getWidth() {
113 return format[WIDTH];
114 }
115
116 /**
117 * @return The data of the image.
118 */
119 public byte[] getBytes() {
120 return bytes;
121 }
122
123 /**
124 * Read the image from the specified file.
125 */
126 private void readImage(InputStream is) {
127 try {
128 LineNumberReader reader = new LineNumberReader(
129 new InputStreamReader(is));
130 HashMap colors = new HashMap();
131
132 format = parseFormat(nextLineOfInterest(reader));
133
134 // setup color mapping
135 for (int i = 0; i < format[NUMBER_OF_COLORS]; i++) {
136 Object[] colorDefinition = parseColor(nextLineOfInterest(reader));
137 colors.put(colorDefinition[0], colorDefinition[1]);
138 }
139
140 // read actual image (convert to RGBA)
141 bytes = new byte[format[WIDTH] * format[HEIGHT] * 4];
142 for (int i = 0; i < format[HEIGHT]; i++) {
143 parseImageLine(nextLineOfInterest(reader), format, colors, i);
144 }
145 } catch (Exception e) {
146 e.printStackTrace();
147 throw new IllegalArgumentException("Unable to parse XPM File");
148 }
149 }
150
151 /**
152 * Finds the next interesting line of text.
153 *
154 * @param reader
155 * The LineNumberReader to read from
156 * @return The next interesting String (with stripped quotes)
157 * @throws IOException
158 * If any IO exceptions occurs while reading file
159 */
160 private String nextLineOfInterest(LineNumberReader reader)
161 throws IOException {
162 String ret;
163 do {
164 ret = reader.readLine();
165 } while (!ret.startsWith("\""));
166 // lacks sanity check
167 return ret.substring(1, ret.lastIndexOf('\"'));
168 }
169
170 /**
171 * Parses the format of the xpm file given a format string
172 *
173 * @param format
174 * String to parse
175 * @return Array specifying width, height, colors, characters per pixel
176 */
177 private int[] parseFormat(String format) {
178 // format should look like this:
179 // 16 16 122 2
180
181 // tokenize it
182 StringTokenizer st = new StringTokenizer(format);
183
184 return new int[] { Integer.parseInt(st.nextToken()), /* width */
185 Integer.parseInt(st.nextToken()), /* height */
186 Integer.parseInt(st.nextToken()), /* colors */
187 Integer.parseInt(st.nextToken()) /* chars per pixel */
188 };
189 }
190
191 /**
192 * Given a line defining a color/pixel, parses this into an array containing
193 * a key and a color
194 *
195 * @param line
196 * Line to parse
197 * @return Array containing a key (String) and a color (Integer)
198 */
199 private Object[] parseColor(String line) {
200 // line should look like this:
201 // # c #0A0A0A
202
203 // NOTE: will break if the color is something like "black" or "gray50"
204 // etc (instead of #rrggbb).
205
206 String key = line.substring(0, format[CHARACTERS_PER_PIXEL]);
207 // since we always assume color as type we dont need to read it
208 // String type = line.substring(format[CHARACTERS_PER_PIXEL] + 1,
209 // format[CHARACTERS_PER_PIXEL] + 2);
210 String color = line.substring(format[CHARACTERS_PER_PIXEL] + 4);
211
212 // we always assume type is color, and supplied as #<r><g><b>
213 return new Object[] { key, new Integer(Integer.parseInt(color, 16)) };
214 }
215
216 /**
217 * Parses an Image line into its byte values
218 *
219 * @param line
220 * Line of chars to parse
221 * @param format
222 * Format to expext it in
223 * @param colors
224 * Colors to lookup
225 * @param index
226 * current index into lines, we've reached
227 */
228 private void parseImageLine(String line, int[] format, HashMap colors,
229 int index) {
230 // offset for next line
231 int offset = index * 4 * format[WIDTH];
232
233 // read <format[CHARACTERS_PER_PIXEL]> characters <format[WIDTH]> times,
234 // each iteration equals one pixel
235 for (int i = 0; i < format[WIDTH]; i++) {
236 String key = line
237 .substring(
238 i * format[CHARACTERS_PER_PIXEL],
239 (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
244 // better
245 // :)
246 bytes[offset + ((i * 4) + 3)] = (byte) 0xff; // always 0xff alpha
247 }
248 }
249
250 /**
251 * @param args
252 */
253 public static void main(String[] args) {
254 if (args.length != 1) {
255 System.out.println("usage:\nXPMFile <file>");
256 }
257
258 try {
259 String out = args[0].substring(0, args[0].indexOf(".")) + ".raw";
260 XPMFile file = XPMFile.load(args[0]);
261 BufferedOutputStream bos = new BufferedOutputStream(
262 new FileOutputStream(new File(out)));
263 bos.write(file.getBytes());
264 bos.close();
265
266 // showResult(file.getBytes());
267 } catch (Exception e) {
268 e.printStackTrace();
269 }
270 }
271 /*
272 private static void showResult(byte[] bytes) {
273 final BufferedImage i = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
274 int c = 0;
275 for (int y = 0; y < 16; y++) {
276 for (int x = 0; x < 16; x++) {
277 i.setRGB(x, y, (bytes[c] << 16) + (bytes[c + 1] << 8) + (bytes[c + 2] << 0) + (bytes[c + 3] << 24));//+(128<<24));//
278 c += 4;
279 }
280 }
281
282 final Frame frame = new Frame("XPM Result");
283 frame.add(new Canvas() {
284
285 public void paint(Graphics g) {
286 g.drawImage(i, 0, 0, frame);
287 }
288 });
289
290 frame.addWindowListener(new WindowAdapter() {
291
292 public void windowClosing(WindowEvent e) {
293 frame.dispose();
294 }
295
296 });
297
298 frame.setSize(100, 100);
299 frame.setVisible(true);
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.util.applet;
32
33 import java.applet.Applet;
34 import java.applet.AppletStub;
35 import java.awt.BorderLayout;
36 import java.awt.Color;
37 import java.awt.FontMetrics;
38 import java.awt.Graphics;
39 import java.awt.Image;
40 import java.awt.MediaTracker;
41 import java.io.DataInputStream;
42 import java.io.DataOutputStream;
43 import java.io.File;
44 import java.io.FileInputStream;
45 import java.io.FileOutputStream;
46 import java.io.FilePermission;
47 import java.io.IOException;
48 import java.io.InputStream;
49 import java.io.OutputStream;
50 import java.io.PrintWriter;
51 import java.io.StringWriter;
52 import java.io.Writer;
53 import java.lang.reflect.Constructor;
54 import java.lang.reflect.Field;
55 import java.lang.reflect.Method;
56 import java.net.HttpURLConnection;
57 import java.net.JarURLConnection;
58 import java.net.SocketPermission;
59 import java.net.URL;
60 import java.net.URLClassLoader;
61 import java.net.URLConnection;
62 import java.security.AccessControlException;
63 import java.security.AccessController;
64 import java.security.CodeSource;
65 import java.security.PermissionCollection;
66 import java.security.PrivilegedExceptionAction;
67 import java.security.SecureClassLoader;
68 import java.security.cert.Certificate;
69 import java.util.Enumeration;
70 import java.util.StringTokenizer;
71 import java.util.Vector;
72 import java.util.jar.JarEntry;
73 import java.util.jar.JarFile;
74 import java.util.jar.JarOutputStream;
75 import java.util.jar.Pack200;
76
77 import sun.security.util.SecurityConstants;
78
79 /**
80 * <p>
81 * The AppletLoader enables deployment of LWJGL to applets in an easy
82 * and polished way. The loader will display a configurable logo and progressbar
83 * while the relevant jars (generic and native) are downloaded from a specified source.
84 * </p>
85 * <p>
86 * The downloaded jars are extracted to the users temporary directory - and if enabled, cached for
87 * faster loading in future uses.
88 * </p>
89 * <p>
90 * The following applet parameters are required:
91 * <ul>
92 * <li>al_main - [String] Full package and class the applet to instantiate and display when loaded.</li>
93 * <li>al_logo - [String Path of of the logo resource to paint while loading.</li>
94 * <li>al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.</li>
95 * <li>al_jars - [String] Comma seperated list of jars to download.</li>
96 * <li>al_windows - [String] Jar containing native files for windows.</li>
97 * <li>al_linux - [String] Jar containing native files for linux.</li>
98 * <li>al_mac - [String] Jar containing native files for mac.</li>
99 * <li>al_solaris - [String] Jar containing native files for solaris.</li>
100 * <li>al_freebsd - [String] Jar containing native files for freebsd.</li>
101 * </ul>
102 * </p>
103 * <p>
104 * Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader.
105 * <ul>
106 * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
107 * reused if the version matches. If version doesn't match all of the files are reloaded.</li>
108 * <li>al_bgcolor - [String] Hex formated color to use as background. <i>Default: ffffff</i>.</li>
109 * <li>al_fgcolor - [String] Hex formated color to use as foreground. <i>Default: 000000</i>.</li>
110 * <li>al_errorcolor - [String] Hex formated color to use as foreground color on error. <i>Default: ff0000</i>.</li>
111 * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
112 * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li>
113 * </ul>
114 * </p>
115 * @author kappaOne
116 * @author Brian Matzon <brian@matzon.dk>
117 * @version $Revision$
118 * $Id$
119 */
120 public class AppletLoader extends Applet implements Runnable, AppletStub {
121
122 /** initializing */
123 public static final int STATE_INIT = 1;
124
125 /** determining which packages that are required */
126 public static final int STATE_DETERMINING_PACKAGES = 2;
127
128 /** checking for already downloaded files */
129 public static final int STATE_CHECKING_CACHE = 3;
130
131 /** downloading packages */
132 public static final int STATE_DOWNLOADING = 4;
133
134 /** extracting packages */
135 public static final int STATE_EXTRACTING_PACKAGES = 5;
136
137 /** updating the classpath */
138 public static final int STATE_UPDATING_CLASSPATH = 6;
139
140 /** switching to real applet */
141 public static final int STATE_SWITCHING_APPLET = 7;
142
143 /** initializing real applet */
144 public static final int STATE_INITIALIZE_REAL_APPLET = 8;
145
146 /** stating real applet */
147 public static final int STATE_START_REAL_APPLET = 9;
148
149 /** done */
150 public static final int STATE_DONE = 10;
151
152 /** used to calculate length of progress bar */
153 protected int percentage;
154
155 /** current size of download in bytes */
156 protected int currentSizeDownload;
157
158 /** total size of download in bytes */
159 protected int totalSizeDownload;
160
161 /** current size of extracted in bytes */
162 protected int currentSizeExtract;
163
164 /** total size of extracted in bytes */
165 protected int totalSizeExtract;
166
167 /** logo to be shown while loading */
168 protected Image logo;
169
170 /** progressbar to render while loading */
171 protected Image progressbar;
172
173 /** offscreen image used */
174 protected Image offscreen;
175
176 /** background color of applet */
177 protected Color bgColor = Color.white;
178
179 /** Color to write errors in */
180 protected Color errorColor = Color.red;
181
182 /** color to write foreground in */
183 protected Color fgColor = Color.black;
184
185 /** urls of the jars to download */
186 protected URL[] urlList;
187
188 /** classLoader used to add downloaded jars to the classpath */
189 protected ClassLoader classLoader;
190
191 /** actual thread that does the loading */
192 protected Thread loaderThread;
193
194 /** animation thread that renders our load screen while loading */
195 protected Thread animationThread;
196
197 /** applet to load after all downloads are complete */
198 protected Applet lwjglApplet;
199
200 /** whether a fatal error occured */
201 protected boolean fatalError;
202
203 /** fatal error that occured */
204 protected String fatalErrorDescription;
205
206 /** whether we're running in debug mode */
207 protected boolean debugMode;
208
209 /** whether to prepend host to cache path */
210 protected boolean prependHost;
211
212 /** String to display as a subtask */
213 protected String subtaskMessage = "";
214
215 /** state of applet loader */
216 protected int state = STATE_INIT;
217
218 /** whether lzma is supported */
219 protected boolean lzmaSupported = false;
220
221 /** whether pack200 is supported */
222 protected boolean pack200Supported = false;
223
224 /** generic error message to display on error */
225 protected String[] genericErrorMessage = { "An error occured while loading the applet.",
226 "Please contact support to resolve this issue.",
227 "<placeholder for error message>"};
228
229 /** whether a certificate refused error occured */
230 protected boolean certificateRefused;
231
232 /** error message to display if user refuses to accept certicate*/
233 protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.",
234 "Please accept the permissions dialog to allow",
235 "the applet to continue the loading process."};
236
237 /** have natives been loaded by another instance of this applet */
238 static protected boolean natives_loaded = false;
239
240 /*
241 * @see java.applet.Applet#init()
242 */
243 public void init() {
244 state = STATE_INIT;
245
246 // sanity check
247 String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"};
248 for(int i=0; i<requiredArgs.length; i++) {
249 if(getParameter(requiredArgs[i]) == null) {
250 fatalErrorOccured("missing required applet parameter: " + requiredArgs[i], null);
251 return;
252 }
253 }
254
255 // whether to run in debug mode
256 debugMode = getBooleanParameter("al_debug", false);
257
258 // whether to prepend host to cache path
259 prependHost = getBooleanParameter("al_prepend_host", true);
260
261 // get colors of applet
262 bgColor = getColor("al_bgcolor", Color.white);
263 setBackground(bgColor);
264
265 fgColor = getColor("al_fgcolor", Color.black);
266 errorColor = getColor("al_errorcolor", Color.red);
267
268 // load logos
269 logo = getImage(getParameter("al_logo"));
270 progressbar = getImage(getParameter("al_progressbar"));
271
272 //sanity check
273 if(logo == null || progressbar == null) {
274 fatalErrorOccured("Unable to load logo and progressbar images", null);
275 }
276
277 // check for lzma support
278 try {
279 Class.forName("LZMA.LzmaInputStream");
280 lzmaSupported = true;
281 } catch (Throwable e) {
282 /* no lzma support */
283 }
284
285 // check pack200 support
286 try {
287 java.util.jar.Pack200.class.getSimpleName();
288 pack200Supported = true;
289 } catch (Throwable e) {
290 /* no pack200 support */
291 }
292 }
293
294 /**
295 * Generates a stacktrace in the form of a string
296 * @param exception Exception to make stacktrace of
297 * @return Stacktrace of exception in the form of a string
298 */
299 private String generateStacktrace(Exception exception) {
300 Writer result = new StringWriter();
301 PrintWriter printWriter = new PrintWriter(result);
302 exception.printStackTrace(printWriter);
303 return result.toString();
304 }
305
306 /*
307 * @see java.applet.Applet#start()
308 */
309 public void start() {
310 if (lwjglApplet != null) {
311 lwjglApplet.start();
312 }
313 else {
314 if(loaderThread == null && !fatalError) {
315 loaderThread = new Thread(this);
316 loaderThread.setName("AppletLoader.loaderThread");
317 loaderThread.start();
318
319 animationThread = new Thread() {
320 public void run() {
321 while(loaderThread != null) {
322 repaint();
323 AppletLoader.this.sleep(100);
324 }
325 animationThread = null;
326 }
327 };
328 animationThread.setName("AppletLoader.animationthread");
329 animationThread.start();
330 }
331 }
332 }
333
334 /*
335 * @see java.applet.Applet#stop()
336 */
337 public void stop() {
338 if (lwjglApplet != null) {
339 lwjglApplet.stop();
340 }
341 super.stop();
342 }
343
344 /*
345 * @see java.applet.Applet#destroy()
346 */
347 public void destroy() {
348 if (lwjglApplet != null) {
349 lwjglApplet.destroy();
350 }
351
352 progressbar = null;
353 logo = null;
354
355 super.destroy();
356 }
357
358 /**
359 * Retrieves the applet that has been loaded. Useful for liveconnect.
360 */
361 public Applet getApplet() {
362 return lwjglApplet;
363 }
364
365 /**
366 * Transfers the call of AppletResize from the stub to the lwjglApplet.
367 */
368 public void appletResize(int width, int height) {
369 resize(width, height);
370 }
371
372 /*
373 * @see java.awt.Container#update(java.awt.Graphics)
374 */
375 public final void update(Graphics g) {
376 paint(g);
377 }
378
379 /*
380 * @see java.awt.Container#paint(java.awt.Graphics)
381 */
382 public void paint(Graphics g) {
383
384 // don't paint loader if applet loaded
385 if(state == STATE_DONE) {
386 return;
387 }
388
389 // create offscreen if missing
390 if (offscreen == null) {
391 offscreen = createImage(getWidth(), getHeight());
392 }
393
394 // draw everything onto an image before drawing to avoid flicker
395 Graphics og = offscreen.getGraphics();
396 FontMetrics fm = og.getFontMetrics();
397
398 // set background color
399 og.setColor(bgColor);
400 og.fillRect(0, 0, getWidth(), getHeight());
401
402 // get logo position so its in the middle of applet
403 int x = 0, y = 0;
404
405 if(logo != null && !fatalError) {
406 x = (getWidth() - logo.getWidth(this)) / 2;
407 y = (getHeight() - logo.getHeight(this)) / 2;
408 }
409
410 og.setColor(fgColor);
411 String message = getDescriptionForState();
412
413 // if we had a failure of some sort, notify the user
414 if (fatalError) {
415 String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;
416
417 if (!certificateRefused) {
418 errorMessage[errorMessage.length-1] = fatalErrorDescription;
419 }
420
421 for(int i=0; i<errorMessage.length; i++) {
422 if(errorMessage[i] != null) {
423 int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2;
424 int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2;
425
426 og.setColor(errorColor);
427 og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
428 }
429 }
430 } else {
431 og.setColor(fgColor);
432
433 // draw logo
434 og.drawImage(logo, x, y, null);
435
436 // draw message
437 int messageX = (getWidth() - fm.stringWidth(message)) / 2;
438 int messageY = y + logo.getHeight(null) + 20;
439 og.drawString(message, messageX, messageY);
440
441 // draw subtaskmessage, if any
442 if(subtaskMessage.length() > 0) {
443 messageX = (getWidth() - fm.stringWidth(subtaskMessage)) / 2;
444 og.drawString(subtaskMessage, messageX, messageY+20);
445 }
446
447 // draw loading bar, clipping it depending on percentage done
448 int barSize = (progressbar.getWidth(this) * percentage) / 100;
449 og.clipRect(0, 0, x + barSize, getHeight());
450 og.drawImage(progressbar, x, y, null);
451 }
452
453 og.dispose();
454
455 // finally draw it all
456 g.drawImage(offscreen, 0, 0, null);
457 }
458
459 /**
460 * @return string describing the state of the loader
461 */
462 protected String getDescriptionForState() {
463 switch (state) {
464 case STATE_INIT:
465 return "Initializing loader";
466 case STATE_DETERMINING_PACKAGES:
467 return "Determining packages to load";
468 case STATE_CHECKING_CACHE:
469 return "Checking cache for existing files";
470 case STATE_DOWNLOADING:
471 return "Downloading packages";
472 case STATE_EXTRACTING_PACKAGES:
473 return "Extracting downloaded packages";
474 case STATE_UPDATING_CLASSPATH:
475 return "Updating classpath";
476 case STATE_SWITCHING_APPLET:
477 return "Switching applet";
478 case STATE_INITIALIZE_REAL_APPLET:
479 return "Initializing real applet";
480 case STATE_START_REAL_APPLET:
481 return "Starting real applet";
482 case STATE_DONE:
483 return "Done loading";
484 default:
485 return "unknown state";
486 }
487 }
488
489 /**
490 * Trims the passed file string based on the available capabilities
491 * @param file string of files to be trimmed
492 * @return trimmed string based on capabilities of client
493 */
494 protected String trimExtensionByCapabilities(String file) {
495 if (!pack200Supported) {
496 file = file.replaceAll(".pack", "");
497 }
498
499 if (!lzmaSupported) {
500 file = file.replaceAll(".lzma", "");
501 }
502 return file;
503 }
504
505 /**
506 * Reads list of jars to download and adds the urls to urlList
507 * also finds out which OS you are on and adds appropriate native
508 * jar to the urlList
509 */
510 protected void loadJarURLs() throws Exception {
511 state = STATE_DETERMINING_PACKAGES;
512
513 // jars to load
514 String jarList = getParameter("al_jars");
515
516 jarList = trimExtensionByCapabilities(jarList);
517
518 StringTokenizer jar = new StringTokenizer(jarList, ", ");
519
520 int jarCount = jar.countTokens() + 1;
521
522 urlList = new URL[jarCount];
523
524 URL path = getCodeBase();
525
526 // set jars urls
527 for (int i = 0; i < jarCount - 1; i++) {
528 urlList[i] = new URL(path, jar.nextToken());
529 }
530
531 // native jar url
532 String osName = System.getProperty("os.name");
533 String nativeJar = null;
534
535 if (osName.startsWith("Win")) {
536 nativeJar = getParameter("al_windows");
537 } else if (osName.startsWith("Linux")) {
538 nativeJar = getParameter("al_linux");
539 } else if (osName.startsWith("Mac")) {
540 nativeJar = getParameter("al_mac");
541 } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
542 nativeJar = getParameter("al_solaris");
543 } else if (osName.startsWith("FreeBSD")) {
544 nativeJar = getParameter("al_freebsd");
545 } else {
546 fatalErrorOccured("OS (" + osName + ") not supported", null);
547 }
548
549 if (nativeJar == null) {
550 fatalErrorOccured("no lwjgl natives files found", null);
551 } else {
552 nativeJar = trimExtensionByCapabilities(nativeJar);
553 urlList[jarCount - 1] = new URL(path, nativeJar);
554 }
555 }
556
557 /**
558 * 4 steps
559 *
560 * 1) check version of applet and decide whether to download jars
561 * 2) download the jars
562 * 3) extract natives
563 * 4) add to jars to class path
564 * 5) switch applets
565 */
566 public void run() {
567 state = STATE_CHECKING_CACHE;
568
569 percentage = 5;
570
571 try {
572 debug_sleep(2000);
573
574 // parse the urls for the jars into the url list
575 loadJarURLs();
576
577 // get path where applet will be stored
578 String path = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() {
579 public Object run() throws Exception {
580
581 // we append the code base to avoid naming collisions with al_title
582 String codebase = "";
583 if(prependHost) {
584 codebase = getCodeBase().getHost();
585 if(codebase == null || codebase.length() == 0) {
586 codebase = "localhost";
587 }
588 codebase += File.separator;
589 }
590 return System.getProperty("java.io.tmpdir") + File.separator + codebase + getParameter("al_title") + File.separator;
591 }
592 });
593
594 File dir = new File(path);
595
596 // create directory
597 if (!dir.exists()) {
598 dir.mkdirs();
599 }
600 dir = new File(dir, "version");
601
602 // if applet already available don't download anything
603 boolean cacheAvailable = false;
604
605 // version of applet
606 String version = getParameter("al_version");
607 float latestVersion = 0;
608
609 // if applet version specifed, check if you have latest version of applet
610 if (version != null) {
611
612 latestVersion = Float.parseFloat(version);
613
614 // if version file exists
615 if (dir.exists()) {
616 // compare to new version
617 if (latestVersion <= readVersionFile(dir)) {
618 cacheAvailable = true;
619 percentage = 90;
620
621 if(debugMode) {
622 System.out.println("Loading Cached Applet Version " + latestVersion);
623 }
624 debug_sleep(2000);
625 }
626 }
627 }
628
629 // if jars not available or need updating download them
630 if (!cacheAvailable) {
631 // downloads jars from the server
632 downloadJars(path); // 10-55%
633
634 // Extract Pack and LZMA files
635 extractJars(path); // 55-65%
636
637 // Extracts Native Files
638 extractNatives(path); // 65-85%
639
640 // add version information once jars downloaded successfully
641 if (version != null) {
642 percentage = 90;
643 writeVersionFile(dir, latestVersion);
644 }
645 }
646
647 // add the downloaded jars and natives to classpath
648 updateClassPath(path);
649
650 // switch to LWJGL Applet
651 switchApplet();
652
653 state = STATE_DONE;
654 } catch (AccessControlException ace) {
655 fatalErrorOccured(ace.getMessage(), ace);
656 certificateRefused = true;
657 } catch (Exception e) {
658 fatalErrorOccured(e.getMessage(), e);
659 } finally {
660 loaderThread = null;
661 }
662 }
663
664 /**
665 * read the current version file
666 *
667 * @param file the file to read
668 * @return the version value of saved file
669 * @throws Exception if it fails to read value
670 */
671 protected float readVersionFile(File file) throws Exception {
672 DataInputStream dis = new DataInputStream(new FileInputStream(file));
673 float version = dis.readFloat();
674 dis.close();
675 return version;
676 }
677
678 /**
679 * write out version file of applet
680 *
681 * @param file the file to write out to
682 * @param version the version of the applet as a float
683 * @throws Exception if it fails to write file
684 */
685 protected void writeVersionFile(File file, float version) throws Exception {
686 DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
687 dos.writeFloat(version);
688 dos.close();
689 }
690
691 /**
692 * Edits the ClassPath at runtime to include the jars
693 * that have just been downloaded and then adds the
694 * lwjgl natives folder property.
695 *
696 * @param path location where applet is stored
697 * @throws Exception if it fails to add classpath
698 */
699 protected void updateClassPath(String path) throws Exception {
700
701 state = STATE_UPDATING_CLASSPATH;
702
703 percentage = 95;
704
705 URL[] urls = new URL[urlList.length];
706
707 for (int i = 0; i < urlList.length; i++) {
708 urls[i] = new URL("file:" + path + getJarName(urlList[i]));
709 }
710
711 // add downloaded jars to the classpath with required permissions
712 classLoader = new URLClassLoader(urls) {
713 protected PermissionCollection getPermissions (CodeSource codesource) {
714 PermissionCollection perms = null;
715
716 try {
717 // getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed
718 Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class });
719 method.setAccessible(true);
720 perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource});
721
722 String host = getCodeBase().getHost();
723
724 if (host != null && (host.length() > 0)) {
725 // add permission for downloaded jars to access host they were from
726 perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
727 }
728 else if (codesource.getLocation().getProtocol().equals("file")) {
729 // if running locally add file permission
730 String path = codesource.getLocation().getFile().replace('/', File.separatorChar);
731 perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION));
732 }
733
734 } catch (Exception e) {
735 e.printStackTrace();
736 }
737
738 return perms;
739 }
740 };
741
742 debug_sleep(2000);
743
744 // unload natives loaded by a previous instance of this lwjgl applet
745 unloadNatives(path);
746
747 // add natives files path to native class path
748 System.setProperty("org.lwjgl.librarypath", path + "natives");
749
750 // Make sure jinput knows about the new path too
751 System.setProperty("net.java.games.input.librarypath", path + "natives");
752
753 // mark natives as loaded
754 natives_loaded = true;
755 }
756
757 /**
758 * Unload natives loaded by a different classloader.
759 *
760 * Due to limitations of the jvm, native files can only
761 * be loaded once and only be used by the classloader
762 * they were loaded from.
763 *
764 * Due to the way applets on plugin1 work, one jvm must
765 * be used for all applets. We need to use multiple
766 * classloaders in the same jvm due to LWJGL's static
767 * nature. I order to solver this we simply remove the
768 * natives from a previous classloader allowing a new
769 * classloader to use those natives in the same jvm.
770 *
771 * This method will only attempt to unload natives from a
772 * previous classloader if it detects that the natives have
773 * been loaded in the same jvm.
774 *
775 * @param nativePath directory where natives are stored
776 */
777 private void unloadNatives(String nativePath) {
778
779 // check whether natives have been loaded into this jvm
780 if (!natives_loaded) {
781 return;
782 }
783
784 try {
785 Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames");
786 field.setAccessible(true);
787 Vector libs = (Vector) field.get(getClass().getClassLoader());
788
789 String path = new File(nativePath).getCanonicalPath();
790
791 for (int i = 0; i < libs.size(); i++) {
792 String s = (String) libs.get(i);
793
794 // if a native from the nativePath directory is loaded, unload it
795 if (s.startsWith(path)) {
796 libs.remove(i);
797 i--;
798 }
799 }
800 } catch (Exception e) {
801 e.printStackTrace();
802 }
803 }
804
805 /**
806 * replace the current applet with the lwjgl applet
807 * using AppletStub and initialise and start it
808 */
809 protected void switchApplet() throws Exception {
810
811 state = STATE_SWITCHING_APPLET;
812 percentage = 100;
813
814 debug_sleep(2000);
815
816 Class appletClass = classLoader.loadClass(getParameter("al_main"));
817 lwjglApplet = (Applet) appletClass.newInstance();
818
819 lwjglApplet.setStub(this);
820 lwjglApplet.setSize(getWidth(), getHeight());
821
822 setLayout(new BorderLayout());
823 add(lwjglApplet);
824 validate();
825
826 state = STATE_INITIALIZE_REAL_APPLET;
827 lwjglApplet.init();
828
829 state = STATE_START_REAL_APPLET;
830 lwjglApplet.start();
831 }
832
833 /**
834 * Will download the jars from the server using the list of urls
835 * in urlList, while at the same time updating progress bar
836 *
837 * @param path location of the directory to save to
838 * @throws Exception if download fails
839 */
840 protected void downloadJars(String path) throws Exception {
841
842 state = STATE_DOWNLOADING;
843
844 URLConnection urlconnection;
845
846 // store file sizes, used for download verification
847 int[] fileSizes = new int[urlList.length];
848
849 // calculate total size of jars to download
850 for (int i = 0; i < urlList.length; i++) {
851 urlconnection = urlList[i].openConnection();
852 urlconnection.setDefaultUseCaches(false);
853 if (urlconnection instanceof HttpURLConnection) {
854 ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
855 }
856 fileSizes[i] = urlconnection.getContentLength();
857 totalSizeDownload += fileSizes[i];
858 }
859
860 int initialPercentage = percentage = 10;
861
862 // download each jar
863 byte buffer[] = new byte[65536];
864 for (int i = 0; i < urlList.length; i++) {
865
866 int unsuccessfulAttempts = 0;
867 int maxUnsuccessfulAttempts = 3;
868 boolean downloadFile = true;
869
870 // download the jar a max of 3 times
871 while(downloadFile) {
872 downloadFile = false;
873
874 debug_sleep(2000);
875
876 urlconnection = urlList[i].openConnection();
877
878 if (urlconnection instanceof HttpURLConnection) {
879 urlconnection.setRequestProperty("Cache-Control", "no-cache");
880 urlconnection.connect();
881 }
882
883 String currentFile = getFileName(urlList[i]);
884 InputStream inputstream = getJarInputStream(currentFile, urlconnection);
885 FileOutputStream fos = new FileOutputStream(path + currentFile);
886
887
888 int bufferSize;
889 long downloadStartTime = System.currentTimeMillis();
890 int downloadedAmount = 0;
891 int fileSize = 0;
892 String downloadSpeedMessage = "";
893
894 while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
895 debug_sleep(10);
896 fos.write(buffer, 0, bufferSize);
897 currentSizeDownload += bufferSize;
898 fileSize += bufferSize;
899 percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
900 subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
901
902 downloadedAmount += bufferSize;
903 long timeLapse = System.currentTimeMillis() - downloadStartTime;
904 // update only if a second or more has passed
905 if (timeLapse >= 1000) {
906 // get kb/s, nice that bytes/millis is same as kilobytes/seconds
907 float downloadSpeed = (float) downloadedAmount / timeLapse;
908 // round to two decimal places
909 downloadSpeed = ((int)(downloadSpeed*100))/100f;
910 // set current speed message
911 downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec";
912 // reset downloaded amount
913 downloadedAmount = 0;
914 // reset start time
915 downloadStartTime = System.currentTimeMillis();
916 }
917
918 subtaskMessage += downloadSpeedMessage;
919 }
920
921 inputstream.close();
922 fos.close();
923
924 // download complete, verify if it was successful
925 if (urlconnection instanceof HttpURLConnection) {
926 if (fileSize == fileSizes[i]) {
927 // successful download
928 }
929 else if (fileSizes[i] <= 0) {
930 // If contentLength for fileSizes[i] <= 0, we don't know if the download
931 // is complete. We're going to guess the download is complete.
932 }
933 else {
934 unsuccessfulAttempts++;
935 // download failed try again
936 if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
937 downloadFile = true;
938 currentSizeDownload -= fileSize; // reset progress bar
939 }
940 else {
941 // retry attempts exhasted, download failed
942 throw new Exception("failed to download " + currentFile);
943 }
944 }
945 }
946 }
947 }
948 subtaskMessage = "";
949 }
950
951 /**
952 * Retrieves a jar files input stream. This method exists primarily to fix an Opera hang in getInputStream
953 * @param urlconnection connection to get input stream from
954 * @return InputStream or null if not possible
955 */
956 protected InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception {
957 final InputStream[] is = new InputStream[1];
958
959 // try to get the input stream 3 times.
960 // Wait at most 5 seconds before interrupting the thread
961 for (int j = 0; j < 3 && is[0] == null; j++) {
962 Thread t = new Thread() {
963 public void run() {
964 try {
965 is[0] = urlconnection.getInputStream();
966 } catch (IOException e) {
967 /* ignored */
968 }
969 }
970 };
971 t.setName("JarInputStreamThread");
972 t.start();
973
974 int iterationCount = 0;
975 while(is[0] == null && iterationCount++ < 5) {
976 try {
977 t.join(1000);
978 } catch (InterruptedException inte) {
979 /* ignored */
980 }
981 }
982
983 if(is[0] == null) {
984 try {
985 t.interrupt();
986 t.join();
987 } catch (InterruptedException inte) {
988 /* ignored */
989 }
990 }
991 }
992
993 if(is[0] == null) {
994 throw new Exception("Unable to get input stream for " + currentFile);
995 }
996
997
998 return is[0];
999 }
1000
1001 /**
1002 * Extract LZMA File
1003 * @param in Input path to pack file
1004 * @param out output path to resulting file
1005 * @throws exception if any errors occur
1006 */
1007 protected void extractLZMA(String in, String out) throws Exception {
1008
1009 File f = new File(in);
1010 FileInputStream fileInputHandle = new FileInputStream(f);
1011
1012 // use reflection to avoid hard dependency
1013 Class clazz = Class.forName( "LZMA.LzmaInputStream" );
1014 Constructor constructor = clazz.getDeclaredConstructor( new Class[] {InputStream.class} );
1015 InputStream inputHandle = (InputStream) constructor.newInstance( new Object[] {fileInputHandle} );
1016
1017 OutputStream outputHandle;
1018 outputHandle = new FileOutputStream(out);
1019
1020 byte [] buffer = new byte [1<<14];
1021
1022 int ret = inputHandle.read(buffer);
1023 while (ret >= 1) {
1024 outputHandle.write(buffer,0,ret);
1025 ret = inputHandle.read(buffer);
1026 }
1027
1028 inputHandle.close();
1029 outputHandle.close();
1030
1031 outputHandle = null;
1032 inputHandle = null;
1033
1034 // delete LZMA file, as it is no longer needed
1035 f.delete();
1036 }
1037
1038 /**
1039 * Extract Pack File
1040 * @param in Input path to pack file
1041 * @param out output path to resulting file
1042 * @throws exception if any errors occur
1043 */
1044 protected void extractPack(String in, String out) throws Exception {
1045 File f = new File(in);
1046 FileOutputStream fostream = new FileOutputStream(out);
1047 JarOutputStream jostream = new JarOutputStream(fostream);
1048
1049 Pack200.Unpacker unpacker = Pack200.newUnpacker();
1050 unpacker.unpack(f, jostream);
1051 jostream.close();
1052
1053 // delete pack file as its no longer needed
1054 f.delete();
1055 }
1056
1057 /**
1058 * Extract all jars from any lzma/pack files
1059 *
1060 * @param path output path
1061 * @throws exception if any errors occur
1062 */
1063 protected void extractJars(String path) throws Exception {
1064 state = STATE_EXTRACTING_PACKAGES;
1065
1066 float increment = (float) 10.0 / urlList.length;
1067 // extract all lzma and pack.lzma files
1068 for (int i = 0; i < urlList.length; i++) {
1069 percentage = 55 + (int) (increment * (i+1));
1070 String filename = getFileName(urlList[i]);
1071
1072 if (filename.endsWith(".pack.lzma")) {
1073 subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", "");
1074 debug_sleep(1000);
1075 extractLZMA(path + filename, path + filename.replaceAll(".lzma", ""));
1076
1077 subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", "");
1078 debug_sleep(1000);
1079 extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", ""));
1080 }
1081 else if (filename.endsWith(".pack")) {
1082 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", "");
1083 debug_sleep(1000);
1084 extractPack(path + filename, path + filename.replace(".pack", ""));
1085 }
1086 else if (filename.endsWith(".lzma")) {
1087 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".lzma", "");
1088 debug_sleep(1000);
1089 extractLZMA(path + filename, path + filename.replace(".lzma", ""));
1090 }
1091 }
1092 }
1093
1094 /**
1095 * This method will extract all file from the native jar and extract them
1096 * to the subdirectory called "natives" in the local path, will also check
1097 * to see if the native jar files is signed properly
1098 *
1099 * @param path base folder containing all downloaded jars
1100 * @throws Exception if it fails to extract files
1101 */
1102 protected void extractNatives(String path) throws Exception {
1103
1104 state = STATE_EXTRACTING_PACKAGES;
1105
1106 int initialPercentage = percentage;
1107
1108 // get name of jar file with natives from urlList, it will be the last url
1109 String nativeJar = getJarName(urlList[urlList.length - 1]);
1110
1111 // get the current certificate to compare against native files
1112 Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
1113
1114 // workaround for bug where cached applet loader does not have certificates!?
1115 if (certificate == null) {
1116 URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
1117
1118 // manually load the certificate
1119 JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
1120 jurl.setDefaultUseCaches(true);
1121 certificate = jurl.getCertificates();
1122 }
1123
1124 // create native folder
1125 File nativeFolder = new File(path + "natives");
1126 if (!nativeFolder.exists()) {
1127 nativeFolder.mkdir();
1128 }
1129
1130 // open jar file
1131 JarFile jarFile = new JarFile(path + nativeJar, true);
1132
1133 // get list of files in jar
1134 Enumeration entities = jarFile.entries();
1135
1136 totalSizeExtract = 0;
1137
1138 // calculate the size of the files to extract for progress bar
1139 while (entities.hasMoreElements()) {
1140 JarEntry entry = (JarEntry) entities.nextElement();
1141
1142 // skip directories and anything in directories
1143 // conveniently ignores the manifest
1144 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1145 continue;
1146 }
1147 totalSizeExtract += entry.getSize();
1148 }
1149
1150 currentSizeExtract = 0;
1151
1152 // reset point to begining by getting list of file again
1153 entities = jarFile.entries();
1154
1155 // extract all files from the jar
1156 while (entities.hasMoreElements()) {
1157 JarEntry entry = (JarEntry) entities.nextElement();
1158
1159 // skip directories and anything in directories
1160 // conveniently ignores the manifest
1161 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1162 continue;
1163 }
1164
1165 // check if native file already exists if so delete it to make room for new one
1166 // useful when using the reload button on the browser
1167 File f = new File(path + "natives" + File.separator + entry.getName());
1168 if (f.exists()) {
1169 if (!f.delete()) {
1170 continue; // unable to delete file, it is in use, skip extracting it
1171 }
1172 }
1173
1174 debug_sleep(1000);
1175
1176 InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
1177 OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
1178
1179 int bufferSize;
1180 byte buffer[] = new byte[65536];
1181
1182 while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
1183 debug_sleep(10);
1184 out.write(buffer, 0, bufferSize);
1185 currentSizeExtract += bufferSize;
1186
1187 // update progress bar
1188 percentage = initialPercentage + ((currentSizeExtract * 20) / totalSizeExtract);
1189 subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
1190 }
1191
1192 // validate if the certificate for native file is correct
1193 validateCertificateChain(certificate, entry.getCertificates());
1194
1195 in.close();
1196 out.close();
1197 }
1198 subtaskMessage = "";
1199
1200 jarFile.close();
1201
1202 // delete native jar as it is no longer needed
1203 File f = new File(path + nativeJar);
1204 f.delete();
1205 }
1206
1207 /**
1208 * Validates the certificate chain for a single file
1209 *
1210 * @param ownCerts Chain of certificates to check against
1211 * @param native_certs Chain of certificates to check
1212 */
1213 protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) throws Exception {
1214 if (native_certs == null)
1215 throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all");
1216
1217 if (ownCerts.length != native_certs.length)
1218 throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]");
1219
1220 for (int i = 0; i < ownCerts.length; i++) {
1221 if (!ownCerts[i].equals(native_certs[i])) {
1222 throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]);
1223 }
1224 }
1225 }
1226
1227 /**
1228 * Get Image from path provided
1229 *
1230 * @param s location of the image
1231 * @return the Image file
1232 */
1233 protected Image getImage(String s) {
1234 try {
1235 URL url = AppletLoader.class.getResource("/"+s);
1236
1237 // if image not found in jar, look outside it
1238 if (url == null) {
1239 url = new URL(getCodeBase(), s);
1240 }
1241
1242 Image image = super.getImage(url);
1243
1244 // wait for image to load
1245 MediaTracker tracker = new MediaTracker(this);
1246 tracker.addImage(image, 0);
1247 tracker.waitForAll();
1248
1249 return image;
1250 } catch (Exception e) {
1251 /* */
1252 }
1253 return null;
1254 }
1255
1256
1257 /**
1258 * Get jar name from URL.
1259 *
1260 * @param url Get jar file name from this url
1261 * @return file name as string
1262 */
1263 protected String getJarName(URL url) {
1264 String fileName = url.getFile();
1265
1266 if (fileName.endsWith(".pack.lzma")) {
1267 fileName = fileName.replaceAll(".pack.lzma", "");
1268 } else if (fileName.endsWith(".pack")) {
1269 fileName = fileName.replaceAll(".pack", "");
1270 } else if (fileName.endsWith(".lzma")) {
1271 fileName = fileName.replaceAll(".lzma", "");
1272 }
1273
1274 return fileName.substring(fileName.lastIndexOf('/') + 1);
1275 }
1276
1277 /**
1278 * Get file name portion of URL.
1279 *
1280 * @param url Get file name from this url
1281 * @return file name as string
1282 */
1283 protected String getFileName(URL url) {
1284 String fileName = url.getFile();
1285 return fileName.substring(fileName.lastIndexOf('/') + 1);
1286 }
1287
1288 /**
1289 * Retrieves the color
1290 *
1291 * @param color Color to load
1292 * @param defaultColor Default color to use if no color to load
1293 * @return Color to use
1294 */
1295 protected Color getColor(String color, Color defaultColor) {
1296 String param_color = getParameter(color);
1297 if (param_color != null) {
1298 return new Color(Integer.parseInt(param_color, 16));
1299 }
1300 return defaultColor;
1301 }
1302
1303 /**
1304 * Retrieves the boolean value for the applet
1305 * @param name Name of parameter
1306 * @param defaultValue default value to return if no such parameter
1307 * @return value of parameter or defaultValue
1308 */
1309 protected boolean getBooleanParameter(String name, boolean defaultValue) {
1310 String parameter = getParameter(name);
1311 if(parameter != null) {
1312 return Boolean.parseBoolean(parameter);
1313 }
1314 return defaultValue;
1315 }
1316
1317 /**
1318 * Sets the state of the loaded and prints some debug information
1319 *
1320 * @param error Error message to print
1321 */
1322 protected void fatalErrorOccured(String error, Exception e) {
1323 fatalError = true;
1324 fatalErrorDescription = "Fatal error occured (" + state + "): " + error;
1325 System.out.println(fatalErrorDescription);
1326 if(e != null) {
1327 System.out.println(generateStacktrace(e));
1328 }
1329 repaint();
1330 }
1331
1332 /**
1333 * Utility method for sleeping
1334 * Will only really sleep if debug has been enabled
1335 * @param ms milliseconds to sleep
1336 */
1337 protected void debug_sleep(long ms) {
1338 if(debugMode) {
1339 sleep(ms);
1340 }
1341 }
1342
1343 /**
1344 * Utility method for sleeping
1345 * @param ms milliseconds to sleep
1346 */
1347 protected void sleep(long ms) {
1348 try {
1349 Thread.sleep(ms);
1350 } catch (Exception e) {
1351 /* ignored */
1352 }
1353 }
1354
1355
1356 }
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;
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 com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
47 import java.util.*;
48 import java.nio.*;
49
50 public class ALTypeMap implements TypeMap {
51 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
52
53 static {
54 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
55 native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN);
56 native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE);
57 native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT);
58 native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT);
59 native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE);
60 native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT);
61 native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT);
62 native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT);
63 native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE);
64 native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT);
65 native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE);
66 }
67
68 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
69 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
70 if (kind == null)
71 throw new RuntimeException("Unsupported type " + native_type);
72 return kind;
73 }
74
75 public Signedness getSignednessFromType(Class type) {
76 if (ALuint.class.equals(type))
77 return Signedness.UNSIGNED;
78 else if (ALint.class.equals(type))
79 return Signedness.SIGNED;
80 else if (ALshort.class.equals(type))
81 return Signedness.SIGNED;
82 else if (ALbyte.class.equals(type))
83 return Signedness.SIGNED;
84 else
85 return Signedness.NONE;
86 }
87
88 public String translateAnnotation(Class annotation_type) {
89 if (annotation_type.equals(ALuint.class))
90 return "i";
91 else if (annotation_type.equals(ALint.class))
92 return "i";
93 else if (annotation_type.equals(ALshort.class))
94 return "s";
95 else if (annotation_type.equals(ALbyte.class))
96 return "b";
97 else if (annotation_type.equals(ALfloat.class))
98 return "f";
99 else if (annotation_type.equals(ALdouble.class))
100 return "d";
101 else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class))
102 return "";
103 else
104 throw new RuntimeException(annotation_type + " is not allowed");
105 }
106
107 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
108 Class type;
109 switch (kind) {
110 case INT:
111 type = ALint.class;
112 break;
113 case FLOAT:
114 type = ALfloat.class;
115 break;
116 case DOUBLE:
117 type = ALdouble.class;
118 break;
119 case SHORT:
120 type = ALshort.class;
121 break;
122 case BYTE:
123 type = ALbyte.class;
124 break;
125 case BOOLEAN:
126 type = ALboolean.class;
127 break;
128 default:
129 throw new RuntimeException(kind + " is not allowed");
130 }
131 return type;
132 }
133
134 private static Class[] getValidBufferTypes(Class type) {
135 if (type.equals(IntBuffer.class))
136 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
137 else if (type.equals(FloatBuffer.class))
138 return new Class[]{ALfloat.class};
139 else if (type.equals(ByteBuffer.class))
140 return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class};
141 else if (type.equals(ShortBuffer.class))
142 return new Class[]{ALshort.class};
143 else if (type.equals(DoubleBuffer.class))
144 return new Class[]{ALdouble.class};
145 else
146 return new Class[]{};
147 }
148
149 private static Class[] getValidPrimitiveTypes(Class type) {
150 if (type.equals(int.class))
151 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
152 else if (type.equals(double.class))
153 return new Class[]{ALdouble.class};
154 else if (type.equals(float.class))
155 return new Class[]{ALfloat.class};
156 else if (type.equals(short.class))
157 return new Class[]{ALshort.class};
158 else if (type.equals(byte.class))
159 return new Class[]{ALbyte.class};
160 else if (type.equals(boolean.class))
161 return new Class[]{ALboolean.class};
162 else if (type.equals(void.class))
163 return new Class[]{ALvoid.class};
164 else
165 return new Class[]{};
166 }
167
168 public String getErrorCheckMethodName() {
169 return "Util.checkALError()";
170 }
171
172 public String getRegisterNativesFunctionName() {
173 return "extal_InitializeClass";
174 }
175
176 public String getTypedefPrefix() {
177 return "ALAPIENTRY";
178 }
179
180 public void printNativeIncludes(PrintWriter writer) {
181 writer.println("#include \"extal.h\"");
182 }
183
184 public Class getStringElementType() {
185 return ALubyte.class;
186 }
187
188 public Class[] getValidAnnotationTypes(Class type) {
189 Class[] valid_types;
190 if (Buffer.class.isAssignableFrom(type))
191 valid_types = getValidBufferTypes(type);
192 else if (type.isPrimitive())
193 valid_types = getValidPrimitiveTypes(type);
194 else if (type.equals(String.class))
195 valid_types = new Class[]{ALubyte.class};
196 else
197 valid_types = new Class[]{};
198 return valid_types;
199 }
200
201 public Class getVoidType() {
202 return ALvoid.class;
203 }
204
205 public Class getInverseType(Class type) {
206 if (ALuint.class.equals(type))
207 return ALint.class;
208 else if (ALint.class.equals(type))
209 return ALuint.class;
210 else
211 return null;
212 }
213
214 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
215 return null;
216 }
217 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALboolean {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALbyte {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALdouble {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALenum {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALfloat {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALint {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALshort {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALsizei {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALubyte {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALuint {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface ALvoid {
46 }
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 * When a method is annonated with @Alternate, no native stub will be created and the Java method will be renamed to value().
38 * This can be useful when we want to provide an alternate GL call with different arguments (created by different annotations)
39 *
40 * @author spasi <spasi@users.sourceforge.net>
41 */
42 @Target({ ElementType.METHOD })
43 public @interface Alternate {
44
45 /** This must match an existing GL method name. */
46 String value();
47
48 /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */
49 boolean nativeAlt() default false;
50
51 /** If true, the alternate method's name will be used for the Java call. */
52 boolean javaAlt() default false;
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.util.generator;
32
33 /**
34 *
35 * AutoType and AutoSize is annotated with @Auto.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 * $Id: Auto.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @Target(ElementType.ANNOTATION_TYPE)
46 public @interface Auto {
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 *
35 * AutoResultSize specifies the size of a returned Buffer
36 * as an expression.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: AutoResultSize.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.METHOD)
47 public @interface AutoResultSize {
48 String value(); // The size as a java expression
49 }
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 * AutoSize specifies that a parameter should be pre-computed
36 * according to the remaining() of a Buffer parameter.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: AutoSize.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Auto
47 @Target(ElementType.PARAMETER)
48 public @interface AutoSize {
49 String value(); // The name of the Buffer parameter
50 String expression() default ""; // This value is added after the argument
51 }
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 * Indicates that a parameter should be pre-computed according
36 * to the type of a Buffer parameter.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: AutoType.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Auto
47 @Target(ElementType.PARAMETER)
48 public @interface AutoType {
49 String value(); // The parameter to get the type from
50 }
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 elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3279 $
37 * $Id: BufferKind.java 3279 2010-03-11 21:06:49Z spasi $
38 */
39
40 public enum BufferKind {
41 UnpackPBO,
42 PackPBO,
43 ElementVBO,
44 ArrayVBO,
45 IndirectBO
46 }
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 * This annotation implies that a Buffer parameter can be an
36 * integer VBO/PBO offset.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: BufferObject.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.PARAMETER)
47 public @interface BufferObject {
48 BufferKind value();
49 }
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 * This annotation indicates that a buffer parameter is cached by
36 * OpenGL.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: CachedReference.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.PARAMETER)
47 public @interface CachedReference {
48 /** If set then this will be used as array index for accessing the stored reference. */
49 String index() default "";
50
51 /** If set then this name will be used for the reference and the reference field will not be auto generated in References. */
52 String name() default "";
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.util.generator;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3262 $
37 * $Id: CachedResult.java 3262 2010-01-04 18:47:49Z spasi $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.METHOD)
44 public @interface CachedResult {
45 boolean isRange() default false;
46 }
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 elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Check.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.PARAMETER)
44 public @interface Check {
45 String value() default "";
46 boolean canBeNull() default false;
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 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Code.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.METHOD)
44 public @interface Code {
45 String value();
46 }
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 elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Const.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target({ElementType.PARAMETER, ElementType.METHOD})
44 public @interface Const {
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 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3287 $
37 * $Id: Constant.java 3287 2010-03-14 23:24:40Z spasi $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.PARAMETER)
44 public @interface Constant {
45 String value();
46 /** If true, the original parameter will not be removed from the method. */
47 boolean keepParam() default false;
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;
33
34 import java.io.PrintWriter;
35 import java.util.Arrays;
36 import java.util.Collection;
37 import java.util.EnumSet;
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.type.InterfaceType;
43
44 /**
45 * Generator visitor for the context capabilities generator tool
46 *
47 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3316 $
49 * $Id: ContextCapabilitiesGenerator.java 3316 2010-04-09 23:57:40Z spasi $
50 */
51 public class ContextCapabilitiesGenerator {
52
53 private final static String STUBS_LOADED_NAME = "loaded_stubs";
54 private final static String ALL_INIT_METHOD_NAME = "initAllStubs";
55 private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses";
56 private final static String CACHED_EXTS_VAR_NAME = "supported_extensions";
57 private final static String PROFILE_MASK_VAR_NAME = "profileMask";
58 private final static String EXTENSION_PREFIX = "GL_";
59 private final static String CORE_PREFIX = "Open";
60
61 public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
62 writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
63 writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
64 writer.println("\tfinal StateTracker tracker = new StateTracker();");
65 writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);");
66 writer.println();
67 if ( !context_specific ) {
68 writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;");
69 }
70 }
71
72 public static void generateInitializerPrologue(PrintWriter writer) {
73 writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCompatible) throws LWJGLException {");
74 writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);");
75 }
76
77 private static String translateFieldName(String interface_name) {
78 if ( interface_name.startsWith("GL") )
79 return CORE_PREFIX + interface_name;
80 else
81 return EXTENSION_PREFIX + interface_name;
82 }
83
84 public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) {
85 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
86 if ( super_interfaces.size() > 1 )
87 throw new RuntimeException(d + " extends more than one other interface");
88 if ( super_interfaces.size() == 1 ) {
89 InterfaceType super_interface = super_interfaces.iterator().next();
90 writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
91 writer.println(translateFieldName(d.getSimpleName()) + "\"))");
92 writer.print("\t\t\t");
93 generateAddExtension(writer, super_interface.getDeclaration());
94 }
95 }
96
97 public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) {
98 String translated_field_name = translateFieldName(d.getSimpleName());
99 writer.print("\t\tthis." + translated_field_name + " = ");
100 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
101 writer.print(translated_field_name + "\")");
102 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
103 if ( super_interfaces.size() > 1 )
104 throw new RuntimeException(d + " extends more than one other interface");
105 if ( super_interfaces.size() == 1 ) {
106 InterfaceType super_interface = super_interfaces.iterator().next();
107 writer.println();
108 writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
109 writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")");
110 }
111 writer.println(";");
112 }
113
114 private static String getAddressesInitializerName(String class_name) {
115 return class_name + POINTER_INITIALIZER_POSTFIX;
116 }
117
118 public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) {
119 writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {");
120
121 // Load the basic pointers we need to detect OpenGL version and supported extensions.
122 writer.println("\t\tGL11_glGetError_pointer = GLContext.getFunctionAddress(\"glGetError\");");
123 writer.println("\t\tGL11_glGetString_pointer = GLContext.getFunctionAddress(\"glGetString\");");
124
125 // Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context.
126 // (they will be used in GLContext.getSupportedExtensions)
127 writer.println("\t\tGL11_glGetIntegerv_pointer = GLContext.getFunctionAddress(\"glGetIntegerv\");");
128 writer.println("\t\tGL30_glGetStringi_pointer = GLContext.getFunctionAddress(\"glGetStringi\");");
129
130 // Get the supported extensions set.
131 writer.println("\t\tGLContext.setCapabilities(this);");
132 writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);");
133 writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");");
134
135 // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available.
136 writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )");
137 writer.println("\t\t\tforwardCompatible = true;");
138
139 if ( !context_specific ) {
140 writer.println("\t\tif (" + STUBS_LOADED_NAME + ")");
141 writer.println("\t\t\treturn GLContext.getSupportedExtensions();");
142 writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();");
143 } else {
144 writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCompatible))");
145 writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");");
146 }
147 }
148
149 public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) {
150 if ( !context_specific ) {
151 writer.println("\t\t" + STUBS_LOADED_NAME + " = true;");
152 }
153 writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";");
154 writer.println("\t}");
155 }
156
157 public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) {
158 if ( d.getMethods().size() > 0 ) {
159 writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d));
160 writer.println(".class);");
161 }
162 }
163
164 public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) {
165 if ( d.getMethods().size() > 0 ) {
166 if ( context_specific ) {
167 if ( d.getAnnotation(ForceInit.class) != null )
168 writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");");
169 writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
170 writer.print(translateFieldName(d.getSimpleName()) + "\")");
171 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "(");
172 if ( d.getAnnotation(DeprecatedGL.class) != null )
173 writer.print("forwardCompatible");
174 if ( d.getAnnotation(Dependent.class) != null ) {
175 if ( d.getAnnotation(DeprecatedGL.class) != null )
176 writer.print(",");
177 writer.print("supported_extensions");
178 }
179 writer.println("))");
180 //writer.print("\t\t\t" + CACHED_EXTS_VAR_NAME + ".remove(\"");
181 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
182 writer.println(translateFieldName(d.getSimpleName()) + "\");");
183 } else {
184 writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
185 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");");
186 }
187 }
188 }
189
190 private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) {
191 writer.print(CACHED_EXTS_VAR_NAME + ".add(\"");
192 writer.println(translateFieldName(d.getSimpleName()) + "\");");
193 }
194
195 public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) {
196 Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
197 if ( !methods.hasNext() )
198 return;
199
200 writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "(");
201
202 boolean optional;
203 boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null;
204 Dependent dependent = d.getAnnotation(Dependent.class);
205 if ( deprecated )
206 writer.print("boolean forwardCompatible");
207 if ( dependent != null ) {
208 if ( deprecated )
209 writer.print(",");
210 writer.print("Set supported_extensions");
211 }
212
213 writer.println(") {");
214 writer.println("\t\treturn ");
215
216 boolean first = true;
217 while ( methods.hasNext() ) {
218 MethodDeclaration method = methods.next();
219 if ( method.getAnnotation(Alternate.class) != null )
220 continue;
221
222 if ( !first )
223 writer.println(" &");
224 else
225 first = false;
226
227 optional = method.getAnnotation(Optional.class) != null;
228 deprecated = method.getAnnotation(DeprecatedGL.class) != null;
229 dependent = method.getAnnotation(Dependent.class);
230
231 writer.print("\t\t\t(");
232 if ( optional )
233 writer.print('(');
234 if ( deprecated )
235 writer.print("forwardCompatible || ");
236 if ( dependent != null ) {
237 if ( dependent.value().indexOf(',') == -1 )
238 writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || ");
239 else {
240 writer.print("!(false");
241 for ( String extension : dependent.value().split(",") )
242 writer.print(" || supported_extensions.contains(\"" + extension + "\")");
243 writer.print(") || ");
244 }
245 }
246 if ( deprecated || dependent != null )
247 writer.print('(');
248 writer.print(Utils.getFunctionAddressName(d, method) + " = ");
249 PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class);
250 if ( platform_dependent != null ) {
251 EnumSet<Platform> platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value()));
252 writer.print("GLContext.getPlatformSpecificFunctionAddress(\"");
253 writer.print(Platform.ALL.getPrefix() + "\", ");
254 writer.print("new String[]{");
255 Iterator<Platform> platforms = platform_set.iterator();
256 while ( platforms.hasNext() ) {
257 writer.print("\"" + platforms.next().getOSPrefix() + "\"");
258 if ( platforms.hasNext() )
259 writer.print(", ");
260 }
261 writer.print("}, new String[]{");
262 platforms = platform_set.iterator();
263 while ( platforms.hasNext() ) {
264 writer.print("\"" + platforms.next().getPrefix() + "\"");
265 if ( platforms.hasNext() )
266 writer.print(", ");
267 }
268 writer.print("}, ");
269 } else
270 writer.print("GLContext.getFunctionAddress(");
271 writer.print("\"" + method.getSimpleName() + "\")) != 0");
272 if ( deprecated || dependent != null )
273 writer.print(')');
274 if ( optional )
275 writer.print(" || true)");
276 }
277 writer.println(";");
278 writer.println("\t}");
279 writer.println();
280 }
281
282 public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
283 for ( MethodDeclaration method : d.getMethods() ) {
284 if ( method.getAnnotation(Alternate.class) == null )
285 writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";");
286 }
287 }
288
289 public static void generateField(PrintWriter writer, InterfaceDeclaration d) {
290 writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";");
291 }
292 }
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;
33
34 import static java.util.Collections.unmodifiableCollection;
35
36 import java.io.File;
37 import java.io.IOException;
38 import java.io.PrintWriter;
39 import java.util.Arrays;
40 import java.util.Collection;
41 import java.util.Map;
42 import java.util.Set;
43
44 import com.sun.mirror.apt.AnnotationProcessor;
45 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
46 import com.sun.mirror.apt.AnnotationProcessorFactory;
47 import com.sun.mirror.apt.AnnotationProcessors;
48 import com.sun.mirror.apt.Filer;
49 import com.sun.mirror.apt.RoundCompleteEvent;
50 import com.sun.mirror.apt.RoundCompleteListener;
51 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
52 import com.sun.mirror.declaration.InterfaceDeclaration;
53 import com.sun.mirror.declaration.TypeDeclaration;
54 import com.sun.mirror.util.DeclarationFilter;
55
56 /**
57 *
58 * Generator tool for creating the ContexCapabilities class
59 *
60 * @author elias_naur <elias_naur@users.sourceforge.net>
61 * @version $Revision: 3316 $
62 * $Id: ContextGeneratorProcessorFactory.java 3316 2010-04-09 23:57:40Z spasi $
63 */
64 public class ContextGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
65 private static boolean first_round = true;
66
67 // Process any set of annotations
68 private static final Collection<String> supportedAnnotations =
69 unmodifiableCollection(Arrays.asList("*"));
70
71 public Collection<String> supportedAnnotationTypes() {
72 return supportedAnnotations;
73 }
74
75 public Collection<String> supportedOptions() {
76 return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks"));
77 }
78
79 public void roundComplete(RoundCompleteEvent event) {
80 first_round = false;
81 }
82
83 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
84 // Only process the initial types, not the generated ones
85 if (first_round) {
86 env.addListener(this);
87 return new GeneratorProcessor(env);
88 } else
89 return AnnotationProcessors.NO_OP;
90 }
91
92 private static class GeneratorProcessor implements AnnotationProcessor {
93 private final AnnotationProcessorEnvironment env;
94
95 GeneratorProcessor(AnnotationProcessorEnvironment env) {
96 this.env = env;
97 }
98
99 public void process() {
100 Map<String, String> options = env.getOptions();
101 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
102 boolean context_specific = options.containsKey("-Acontextspecific");
103 try {
104 generateContextCapabilitiesSource(context_specific, generate_error_checks);
105 } catch (IOException e) {
106 throw new RuntimeException(e);
107 }
108 }
109
110 private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException {
111 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null);
112 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
113 writer.println();
114 writer.println("package org.lwjgl.opengl;");
115 writer.println();
116 writer.println("import org.lwjgl.LWJGLException;");
117 writer.println("import org.lwjgl.LWJGLUtil;");
118 writer.println("import org.lwjgl.BufferUtils;");
119 writer.println("import java.util.Set;");
120 writer.println("import java.util.HashSet;");
121 writer.println("import java.nio.IntBuffer;");
122 writer.println();
123 ContextCapabilitiesGenerator.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 ContextCapabilitiesGenerator.generateField(writer, interface_decl);
130 }
131 writer.println();
132 for (TypeDeclaration typedecl : interface_decls) {
133 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
134 ContextCapabilitiesGenerator.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 ContextCapabilitiesGenerator.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 ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
151 for (TypeDeclaration typedecl : interface_decls) {
152 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
153 ContextCapabilitiesGenerator.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 (simple_name.equals("GL11"))
159 continue;
160 ContextCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific);
161 }
162 ContextCapabilitiesGenerator.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 ContextCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl);
171 }
172 writer.println("\t\tloaded_stubs = false;");
173 }
174 writer.println("\t}");
175 writer.println();
176 ContextCapabilitiesGenerator.generateInitializerPrologue(writer);
177 for (TypeDeclaration typedecl : interface_decls) {
178 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
179 if (Utils.isFinal(interface_decl))
180 ContextCapabilitiesGenerator.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 package org.lwjgl.util.generator;
32
33 /**
34 * Use this annotation on extensions with functionality that depends on the presence of other extensions.
35 * Functions in such extensions marked with this annotation will only be loaded if the specified extension is present.
36 *
37 * @author spasi <spasi@users.sourceforge.net>
38 */
39
40 import java.lang.annotation.ElementType;
41 import java.lang.annotation.Target;
42
43 @Target({ ElementType.TYPE, ElementType.METHOD })
44 public @interface Dependent {
45 String value() default "";
46 }
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 * Use this annotation on extensions with deprecated functionality.
35 * Functions in such extensions marked with this annotation will not be loaded in a forward compatible context.
36 *
37 * @author spasi <spasi@users.sourceforge.net>
38 */
39
40 import java.lang.annotation.ElementType;
41 import java.lang.annotation.Target;
42
43 @Target({ ElementType.TYPE, ElementType.METHOD })
44 public @interface DeprecatedGL {
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 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Extension.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.TYPE)
44 public @interface Extension {
45 String className() default "";
46 boolean isFinal() default true;
47 String postfix();
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;
33
34 import com.sun.mirror.declaration.*;
35 import com.sun.mirror.type.*;
36
37 import java.io.*;
38 import java.util.*;
39
40 public class FieldsGenerator {
41 private static void validateField(FieldDeclaration field) {
42 Collection<Modifier> modifiers = field.getModifiers();
43 if (modifiers.size() != 3 || !modifiers.contains(Modifier.PUBLIC) || !modifiers.contains(Modifier.STATIC) ||
44 !modifiers.contains(Modifier.FINAL))
45 throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
46 TypeMirror field_type = field.getType();
47 if (!(field_type instanceof PrimitiveType))
48 throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type");
49 PrimitiveType field_type_prim = (PrimitiveType)field_type;
50 if (field_type_prim.getKind() != PrimitiveType.Kind.INT && field_type_prim.getKind() != PrimitiveType.Kind.LONG)
51 throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int' or 'long'");
52 Object field_value = field.getConstantValue();
53 if (field_value == null)
54 throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value");
55 }
56
57 private static void generateField(PrintWriter writer, FieldDeclaration field) {
58 validateField(field);
59
60 Object value = field.getConstantValue();
61 String field_value_string;
62 if ( value.getClass().equals(Integer.class) )
63 field_value_string = Integer.toHexString((Integer)field.getConstantValue());
64 else
65 field_value_string = Long.toHexString((Long)field.getConstantValue()) + 'l';
66
67 Utils.printDocComment(writer, field);
68 // Print field declaration
69 writer.println("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = 0x" + field_value_string + ";");
70 }
71
72 public static void generateFields(PrintWriter writer, Collection<FieldDeclaration> fields) {
73 for (FieldDeclaration field : fields)
74 generateField(writer, field);
75 }
76
77 }
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 * Extensions marked with ForceInit will be initialized by LWJGL even if not exposed in the GL_EXTENSIONS string.
35 *
36 * @author spasi
37 */
38
39 import java.lang.annotation.ElementType;
40 import java.lang.annotation.Target;
41
42 @Target({ ElementType.TYPE })
43 public @interface ForceInit {
44 }
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;
33
34 /**
35 *
36 * OpenGL sepcific generator behaviour
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3287 $
40 * $Id: GLTypeMap.java 3287 2010-03-14 23:24:40Z spasi $
41 */
42
43 import org.lwjgl.opengl.PointerWrapper;
44
45 import java.io.PrintWriter;
46 import java.nio.*;
47 import java.util.HashMap;
48 import java.util.Map;
49
50 import com.sun.mirror.declaration.AnnotationMirror;
51 import com.sun.mirror.type.PrimitiveType;
52
53 public class GLTypeMap implements TypeMap {
54
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(GLbitfield.class, PrimitiveType.Kind.INT);
60 native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE);
61 native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT);
62 native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT);
63 native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT);
64 native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT);
65 native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG);
66 native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT);
67 native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN);
68 native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE);
69 native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE);
70 native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT);
71 native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG);
72 native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT);
73 native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT);
74 native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE);
75 native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE);
76 native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT);
77 native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT);
78 native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG);
79 native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG);
80 native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE);
81 native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE);
82 native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG);
83 native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG);
84 native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG);
85 native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG);
86 }
87
88 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
89 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
90 if ( kind == null )
91 throw new RuntimeException("Unsupported type " + native_type);
92 return kind;
93 }
94
95 public String getErrorCheckMethodName() {
96 return "Util.checkGLError()";
97 }
98
99 public String getRegisterNativesFunctionName() {
100 return "extgl_InitializeClass";
101 }
102
103 public Signedness getSignednessFromType(Class type) {
104 if ( GLuint.class.equals(type) )
105 return Signedness.UNSIGNED;
106 else if ( GLint.class.equals(type) )
107 return Signedness.SIGNED;
108 else if ( GLushort.class.equals(type) )
109 return Signedness.UNSIGNED;
110 else if ( GLshort.class.equals(type) )
111 return Signedness.SIGNED;
112 else if ( GLubyte.class.equals(type) )
113 return Signedness.UNSIGNED;
114 else if ( GLbyte.class.equals(type) )
115 return Signedness.SIGNED;
116 else if ( GLuint64EXT.class.equals(type) )
117 return Signedness.UNSIGNED;
118 else if ( GLint64EXT.class.equals(type) )
119 return Signedness.SIGNED;
120 else if ( GLuint64.class.equals(type) )
121 return Signedness.UNSIGNED;
122 else if ( GLint64.class.equals(type) )
123 return Signedness.SIGNED;
124 else
125 return Signedness.NONE;
126 }
127
128 public String translateAnnotation(Class annotation_type) {
129 if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) )
130 return "i";
131 else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) )
132 return "s";
133 else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) )
134 return "b";
135 else if ( annotation_type.equals(GLfloat.class) )
136 return "f";
137 else if ( annotation_type.equals(GLdouble.class) )
138 return "d";
139 else if ( annotation_type.equals(GLhalf.class) )
140 return "h";
141 else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) )
142 return "i64";
143 else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) )
144 return "";
145 else
146 throw new RuntimeException(annotation_type + " is not allowed");
147 }
148
149 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
150 Class type;
151 switch ( kind ) {
152 case INT:
153 type = GLint.class;
154 break;
155 case DOUBLE:
156 type = GLdouble.class;
157 break;
158 case FLOAT:
159 type = GLfloat.class;
160 break;
161 case SHORT:
162 type = GLshort.class;
163 break;
164 case BYTE:
165 type = GLbyte.class;
166 break;
167 case LONG:
168 type = GLint64EXT.class;
169 break;
170 case BOOLEAN:
171 type = GLboolean.class;
172 break;
173 default:
174 throw new RuntimeException(kind + " is not allowed");
175 }
176 return type;
177 }
178
179 public Class getVoidType() {
180 return GLvoid.class;
181 }
182
183 public Class getStringElementType() {
184 return GLubyte.class;
185 }
186
187 private static Class[] getValidBufferTypes(Class type) {
188 if ( type.equals(IntBuffer.class) )
189 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class,
190 GLsizei.class, GLuint.class, GLvoid.class };
191 else if ( type.equals(FloatBuffer.class) )
192 return new Class[] { GLclampf.class, GLfloat.class };
193 else if ( type.equals(ByteBuffer.class) )
194 return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class };
195 else if ( type.equals(ShortBuffer.class) )
196 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
197 else if ( type.equals(DoubleBuffer.class) )
198 return new Class[] { GLclampd.class, GLdouble.class };
199 else if ( type.equals(LongBuffer.class) )
200 return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
201 else
202 return new Class[] { };
203 }
204
205 private static Class[] getValidPrimitiveTypes(Class type) {
206 if ( type.equals(long.class) )
207 return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
208 else if ( type.equals(int.class) )
209 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class,
210 GLsizei.class };
211 else if ( type.equals(double.class) )
212 return new Class[] { GLclampd.class, GLdouble.class };
213 else if ( type.equals(float.class) )
214 return new Class[] { GLclampf.class, GLfloat.class };
215 else if ( type.equals(short.class) )
216 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
217 else if ( type.equals(byte.class) )
218 return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class };
219 else if ( type.equals(boolean.class) )
220 return new Class[] { GLboolean.class };
221 else if ( type.equals(void.class) )
222 return new Class[] { GLvoid.class, GLreturn.class };
223 else
224 return new Class[] { };
225 }
226
227 public String getTypedefPrefix() {
228 return "APIENTRY";
229 }
230
231 public void printNativeIncludes(PrintWriter writer) {
232 writer.println("#include \"extgl.h\"");
233 }
234
235 public Class[] getValidAnnotationTypes(Class type) {
236 Class[] valid_types;
237 if ( Buffer.class.isAssignableFrom(type) )
238 valid_types = getValidBufferTypes(type);
239 else if ( type.isPrimitive() )
240 valid_types = getValidPrimitiveTypes(type);
241 else if ( String.class.equals(type) )
242 valid_types = new Class[] { GLubyte.class };
243 else if ( PointerWrapper.class.isAssignableFrom(type) )
244 valid_types = new Class[] { GLpointer.class };
245 else if (void.class.equals(type) )
246 valid_types = new Class[] { GLreturn.class };
247 else
248 valid_types = new Class[] { };
249 return valid_types;
250 }
251
252 public Class getInverseType(Class type) {
253 if ( GLuint.class.equals(type) )
254 return GLint.class;
255 else if ( GLint.class.equals(type) )
256 return GLuint.class;
257 else if ( GLushort.class.equals(type) )
258 return GLshort.class;
259 else if ( GLshort.class.equals(type) )
260 return GLushort.class;
261 else if ( GLubyte.class.equals(type) )
262 return GLbyte.class;
263 else if ( GLbyte.class.equals(type) )
264 return GLubyte.class;
265 else if ( GLuint64EXT.class.equals(type) )
266 return GLint64EXT.class;
267 else if ( GLint64EXT.class.equals(type) )
268 return GLuint64EXT.class;
269 else if ( GLuint64.class.equals(type) )
270 return GLint64.class;
271 else if ( GLint64.class.equals(type) )
272 return GLuint64.class;
273 else
274 return null;
275 }
276
277 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
278 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
279 if ( annotation_class.equals(GLint.class) )
280 return "GL11.GL_INT";
281 else if ( annotation_class.equals(GLbyte.class) )
282 return "GL11.GL_BYTE";
283 else if ( annotation_class.equals(GLshort.class) )
284 return "GL11.GL_SHORT";
285 if ( annotation_class.equals(GLuint.class) )
286 return "GL11.GL_UNSIGNED_INT";
287 else if ( annotation_class.equals(GLubyte.class) )
288 return "GL11.GL_UNSIGNED_BYTE";
289 else if ( annotation_class.equals(GLushort.class) )
290 return "GL11.GL_UNSIGNED_SHORT";
291 else if ( annotation_class.equals(GLfloat.class) )
292 return "GL11.GL_FLOAT";
293 else if ( annotation_class.equals(GLdouble.class) )
294 return "GL11.GL_DOUBLE";
295 else
296 return null;
297 }
298 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLbitfield {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLboolean {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLbyte {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLchar {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLcharARB {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLclampd {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLclampf {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLdouble {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLenum {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLfloat {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLhalf {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLhandleARB {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLint {
46 }
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.Target;
34 import java.lang.annotation.ElementType;
35
36 @NativeType
37 @Target({ElementType.PARAMETER, ElementType.METHOD})
38 public @interface GLint64 {
39 }
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.Target;
34 import java.lang.annotation.ElementType;
35
36 @NativeType
37 @Target({ElementType.PARAMETER, ElementType.METHOD})
38 public @interface GLint64EXT {
39 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLintptr {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLintptrARB {
46 }
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 GLpointer {
41 String value(); // The native pointer type.
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 package org.lwjgl.util.generator;
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 java.lang.annotation.ElementType;
41 import java.lang.annotation.Target;
42
43 @NativeType
44 @Target({ ElementType.METHOD })
45 public @interface GLreturn {
46 /** The Buffer parameter to use as the method result. */
47 String value();
48 /** The argument that specifies the maximum number of bytes that may be read (String results only). */
49 String maxLength() default "";
50 /** If true, the maxLength value is going to be used when creating the String. */
51 boolean forceMaxLength() default false;
52 ///** If we use the byte buffer for another parameter, an offset must be used. */
53 //String offset() default "";
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator;
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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLshort {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLsizei {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLsizeiptr {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLsizeiptrARB {
46 }
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 * 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 java.lang.annotation.ElementType;
41 import java.lang.annotation.Target;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLtime {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLubyte {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLuint {
46 }
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.Target;
34 import java.lang.annotation.ElementType;
35
36 @NativeType
37 @Target({ElementType.PARAMETER, ElementType.METHOD})
38 public @interface GLuint64 {
39 }
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.Target;
34 import java.lang.annotation.ElementType;
35
36 @NativeType
37 @Target({ElementType.PARAMETER, ElementType.METHOD})
38 public @interface GLuint64EXT {
39 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @NativeType
44 @Target({ElementType.PARAMETER, ElementType.METHOD})
45 public @interface GLushort {
46 }
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 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 java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 import com.sun.mirror.type.PrimitiveType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLvoid {
48 PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
49 }
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 elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GenerateAutos.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
42
43 @Target(ElementType.METHOD)
44 public @interface GenerateAutos {
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
32 package org.lwjgl.util.generator;
33
34 import com.sun.mirror.apt.*;
35 import com.sun.mirror.declaration.*;
36
37 import java.io.File;
38 import java.io.FileFilter;
39 import java.util.Collection;
40 import java.util.Set;
41 import java.util.Map;
42 import java.util.Arrays;
43
44 import static java.util.Collections.*;
45 import static com.sun.mirror.util.DeclarationVisitors.*;
46
47 /**
48 *
49 * Generator tool for creating the java classes and native code
50 * from an annotated template java interface.
51 *
52 * @author elias_naur <elias_naur@users.sourceforge.net>
53 * @version $Revision: 3289 $
54 * $Id: GeneratorProcessorFactory.java 3289 2010-03-16 19:05:19Z spasi $
55 */
56 public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
57 private static boolean first_round = true;
58
59 // Process any set of annotations
60 private static final Collection<String> supportedAnnotations =
61 unmodifiableCollection(Arrays.asList("*"));
62
63 private static final Collection<String> supportedOptions =
64 unmodifiableCollection(Arrays.asList("-Atypemap", "-Ageneratechecks", "-Acontextspecific"));
65
66 public Collection<String> supportedAnnotationTypes() {
67 return supportedAnnotations;
68 }
69
70 public Collection<String> supportedOptions() {
71 return supportedOptions;
72 }
73
74 public void roundComplete(RoundCompleteEvent event) {
75 first_round = false;
76 }
77
78 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
79 // Only process the initial types, not the generated ones
80 if (first_round) {
81 env.addListener(this);
82 return new GeneratorProcessor(env);
83 } else
84 return AnnotationProcessors.NO_OP;
85 }
86
87 private static class GeneratorProcessor implements AnnotationProcessor {
88 private final AnnotationProcessorEnvironment env;
89
90 GeneratorProcessor(AnnotationProcessorEnvironment env) {
91 this.env = env;
92 }
93
94 public void process() {
95 Map<String, String> options = env.getOptions();
96 String typemap_classname = null;
97 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
98 boolean context_specific = options.containsKey("-Acontextspecific");
99 for (String k : options.keySet()) {
100 int delimiter = k.indexOf('=');
101 if (delimiter != -1) {
102 if (k.startsWith("-Atypemap")) {
103 typemap_classname = k.substring(delimiter + 1);
104 }
105 }
106 }
107 if (typemap_classname == null)
108 throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>");
109
110 TypeDeclaration lastFile = null;
111 try {
112 long generatorLM = getGeneratorLastModified();
113 TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
114 for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) {
115 lastFile = typedecl;
116 typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP));
117 }
118 } catch (Exception e) {
119 if ( lastFile == null )
120 throw new RuntimeException(e);
121 else
122 throw new RuntimeException("\n-- Failed to process template: " + lastFile.getQualifiedName() + " --", e);
123 }
124 }
125
126 /**
127 * Gets the time of the latest change on the Generator classes.
128 *
129 * @return time of the latest change
130 */
131 private static long getGeneratorLastModified() {
132 final File pck = new File(System.getProperty("user.dir") + "/bin/org/lwjgl/util/generator");
133 if ( !pck.exists() || !pck.isDirectory() )
134 return Long.MAX_VALUE;
135
136 final File[] classes = pck.listFiles(new FileFilter() {
137 public boolean accept(final File pathname) {
138 return pathname.isFile() && pathname.getName().endsWith(".class");
139 }
140 });
141
142 if ( classes == null || classes.length == 0 )
143 return Long.MAX_VALUE;
144
145 long lastModified = 0;
146
147 for ( File clazz : classes ) {
148 long lm = clazz.lastModified();
149 if ( lastModified < lm )
150 lastModified = lm;
151 }
152
153 return lastModified;
154 }
155 }
156 }
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;
33
34 import com.sun.mirror.apt.*;
35 import com.sun.mirror.declaration.*;
36 import com.sun.mirror.type.*;
37 import com.sun.mirror.util.*;
38
39 import java.util.*;
40
41 import java.io.PrintWriter;
42 import java.io.IOException;
43 import java.io.File;
44
45 import java.nio.*;
46
47 /**
48 *
49 * Generator visitor for the generator tool
50 *
51 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 3299 $
53 * $Id: GeneratorVisitor.java 3299 2010-03-31 15:46:16Z spasi $
54 */
55 public class GeneratorVisitor extends SimpleDeclarationVisitor {
56 private final AnnotationProcessorEnvironment env;
57 private final TypeMap type_map;
58 private final boolean generate_error_checks;
59 private final boolean context_specific;
60 private final long generatorLM;
61
62 public GeneratorVisitor(AnnotationProcessorEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) {
63 this.env = env;
64 this.type_map = type_map;
65 this.generate_error_checks = generate_error_checks;
66 this.context_specific = context_specific;
67 this.generatorLM = generatorLM;
68 }
69
70 private void validateMethods(InterfaceDeclaration d) {
71 for (MethodDeclaration method : d.getMethods())
72 validateMethod(method);
73 }
74
75 private void validateMethod(MethodDeclaration method) {
76 if (method.isVarArgs())
77 throw new RuntimeException("Method " + method.getSimpleName() + " is variadic");
78 Collection<Modifier> modifiers = method.getModifiers();
79 if (!modifiers.contains(Modifier.PUBLIC))
80 throw new RuntimeException("Method " + method.getSimpleName() + " is not public");
81 if (method.getThrownTypes().size() > 0)
82 throw new RuntimeException("Method " + method.getSimpleName() + " throws checked exceptions");
83 validateParameters(method);
84 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
85 if (strip_annotation != null && method.getAnnotation(Alternate.class) == null) {
86 String postfix_param_name = strip_annotation.value();
87 ParameterDeclaration postfix_param = Utils.findParameter(method, postfix_param_name);
88 if (Utils.isParameterMultiTyped(postfix_param))
89 throw new RuntimeException("Postfix parameter can't be the same as a multityped parameter in method " + method);
90 if (Utils.getNIOBufferType(postfix_param.getType()) == null)
91 throw new RuntimeException("Postfix parameter type must be a nio Buffer");
92 }
93 if (Utils.getResultParameter(method) != null && !method.getReturnType().equals(env.getTypeUtils().getVoidType()))
94 throw new RuntimeException(method + " return type is not void but a parameter is annotated with Result");
95 if (method.getAnnotation(CachedResult.class) != null) {
96 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null)
97 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");
100 }
101 validateTypes(method, method.getAnnotationMirrors(), method.getReturnType());
102 }
103
104 private void validateType(MethodDeclaration method, Class annotation_type, Class type) {
105 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))
108 return;
109 throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type +
110 " in method " + method);
111 }
112
113 private void validateTypes(MethodDeclaration method, Collection<AnnotationMirror> annotations, TypeMirror type_mirror) {
114 for (AnnotationMirror annotation : annotations) {
115 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
116 if (native_type_annotation != null) {
117 Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
118 Class type = Utils.getJavaType(type_mirror);
119 if (Buffer.class.equals(type))
120 continue;
121 validateType(method, annotation_type, type);
122 }
123 }
124 }
125
126 private void validateParameters(MethodDeclaration method) {
127 for (ParameterDeclaration param : method.getParameters()) {
128 validateTypes(method, param.getAnnotationMirrors(), param.getType());
129 Class<?> param_type = Utils.getJavaType(param.getType());
130 if (Utils.getNIOBufferType(param.getType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class) {
131 Check parameter_check_annotation = param.getAnnotation(Check.class);
132 NullTerminated null_terminated_annotation = param.getAnnotation(NullTerminated.class);
133 if (parameter_check_annotation == null && null_terminated_annotation == null) {
134 boolean found_auto_size_param = false;
135 for (ParameterDeclaration inner_param : method.getParameters()) {
136 AutoSize auto_size_annotation = inner_param.getAnnotation(AutoSize.class);
137 if (auto_size_annotation != null &&
138 auto_size_annotation.value().equals(param.getSimpleName())) {
139 found_auto_size_param = true;
140 break;
141 }
142 }
143 if (!found_auto_size_param
144 && param.getAnnotation(Result.class) == null
145 && param.getAnnotation(Constant.class) == null
146 && !Utils.isReturnParameter(method, param)
147 )
148 throw new RuntimeException(param + " has no Check, Result nor Constant annotation, is not the return parameter and no other parameter has" +
149 " an @AutoSize annotation on it in method " + method);
150 }
151 if (param.getAnnotation(CachedReference.class) != null && param.getAnnotation(Result.class) != null)
152 throw new RuntimeException(param + " can't be annotated with both CachedReference and Result");
153 if (param.getAnnotation(BufferObject.class) != null && param.getAnnotation(Result.class) != null)
154 throw new RuntimeException(param + " can't be annotated with both BufferObject and Result");
155 //if (param.getAnnotation(Constant.class) != null)
156 //throw new RuntimeException("Buffer parameter " + param + " cannot be Constant");
157 } else {
158 if (param.getAnnotation(BufferObject.class) != null)
159 throw new RuntimeException(param + " type is not a buffer, but annotated as a BufferObject");
160 if (param.getAnnotation(CachedReference.class) != null)
161 throw new RuntimeException(param + " type is not a buffer, but annotated as a CachedReference");
162 }
163 }
164 }
165
166 private static void generateMethodsNativePointers(PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
167 for (MethodDeclaration method : methods) {
168 if ( method.getAnnotation(Alternate.class) == null )
169 generateMethodNativePointers(writer, method);
170 }
171 }
172
173 private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) {
174 writer.println("static " + Utils.getTypedefName(method) + " " + method.getSimpleName() + ";");
175 }
176
177 private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException {
178 java_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
179 java_writer.println();
180 java_writer.println("package " + d.getPackage().getQualifiedName() + ";");
181 java_writer.println();
182 java_writer.println("import org.lwjgl.LWJGLException;");
183 java_writer.println("import org.lwjgl.BufferChecks;");
184 // DISABLED: indirect buffer support
185 //java_writer.println("import org.lwjgl.NondirectBufferWrapper;");
186 java_writer.println("import java.nio.*;");
187 java_writer.println();
188 Utils.printDocComment(java_writer, d);
189 java_writer.print("public ");
190 boolean is_final = Utils.isFinal(d);
191 if (is_final)
192 java_writer.write("final ");
193 java_writer.print("class " + Utils.getSimpleClassName(d));
194 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
195 if (super_interfaces.size() > 1)
196 throw new RuntimeException(d + " extends more than one interface");
197 if (super_interfaces.size() == 1) {
198 InterfaceDeclaration super_interface = super_interfaces.iterator().next().getDeclaration();
199 java_writer.print(" extends " + Utils.getSimpleClassName(super_interface));
200 }
201 java_writer.println(" {");
202 FieldsGenerator.generateFields(java_writer, d.getFields());
203 java_writer.println();
204 if (is_final) {
205 // Write private constructor to avoid instantiation
206 java_writer.println("\tprivate " + Utils.getSimpleClassName(d) + "() {");
207 java_writer.println("\t}");
208 java_writer.println();
209 }
210 if (d.getMethods().size() > 0 && !context_specific)
211 java_writer.println("\tstatic native void " + Utils.STUB_INITIALIZER_NAME + "() throws LWJGLException;");
212 JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific);
213 java_writer.println("}");
214 java_writer.close();
215 String qualified_interface_name = Utils.getQualifiedClassName(d);
216 env.getMessager().printNotice("Generated class " + qualified_interface_name);
217 }
218
219 private void generateNativeSource(InterfaceDeclaration d) throws IOException {
220 String qualified_interface_name = Utils.getQualifiedClassName(d);
221 String qualified_native_name = Utils.getNativeQualifiedName(qualified_interface_name)+ ".c";
222 PrintWriter native_writer = env.getFiler().createTextFile(Filer.Location.CLASS_TREE, "", new File(qualified_native_name), "UTF-8");
223 native_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
224 native_writer.println();
225 native_writer.println("#include <jni.h>");
226 type_map.printNativeIncludes(native_writer);
227 native_writer.println();
228 TypedefsGenerator.generateNativeTypedefs(type_map, native_writer, d.getMethods());
229 native_writer.println();
230 if (!context_specific) {
231 generateMethodsNativePointers(native_writer, d.getMethods());
232 native_writer.println();
233 }
234 NativeMethodStubsGenerator.generateNativeMethodStubs(env, type_map, native_writer, d, generate_error_checks, context_specific);
235 if (!context_specific) {
236 native_writer.print("JNIEXPORT void JNICALL " + Utils.getQualifiedNativeMethodName(qualified_interface_name, Utils.STUB_INITIALIZER_NAME));
237 native_writer.println("(JNIEnv *env, jclass clazz) {");
238 native_writer.println("\tJavaMethodAndExtFunction functions[] = {");
239 RegisterStubsGenerator.generateMethodsNativeStubBind(native_writer, d, generate_error_checks, context_specific);
240 native_writer.println("\t};");
241 native_writer.println("\tint num_functions = NUMFUNCTIONS(functions);");
242 native_writer.print("\t");
243 native_writer.print(type_map.getRegisterNativesFunctionName());
244 native_writer.println("(env, clazz, num_functions, functions);");
245 native_writer.println("}");
246 }
247 native_writer.close();
248 env.getMessager().printNotice("Generated C source " + qualified_interface_name);
249 }
250
251 public void visitInterfaceDeclaration(InterfaceDeclaration d) {
252 File input = d.getPosition().file();
253 File output = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java");
254
255 PrintWriter java_writer = null;
256
257 try {
258 // Skip this class if the output exists and the input has not been modified.
259 if ( output.exists() && Math.max(input.lastModified(), generatorLM) < output.lastModified() )
260 return;
261
262 if (d.getMethods().size() > 0 || d.getFields().size() > 0) {
263 validateMethods(d);
264 java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
265 generateJavaSource(d, java_writer);
266 }
267 if (d.getMethods().size() > 0)
268 generateNativeSource(d);
269 } catch (Exception e) {
270 // If anything goes wrong mid-gen, delete output to allow regen next time we run.
271 if ( java_writer != null ) java_writer.close();
272 if ( output.exists() ) output.delete();
273
274 throw new RuntimeException(e);
275 }
276 }
277 }
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 * Implies that a parameter is indirect, and forces the native
36 * stub to use the indirection operator '&' on it.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: Indirect.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.PARAMETER)
47 public @interface Indirect {
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;
33
34 import com.sun.mirror.type.*;
35 import com.sun.mirror.util.*;
36
37 /**
38 *
39 * A TypeVisitor that translates TypeMirrors to JNI
40 * type strings.
41 *
42 * @author elias_naur <elias_naur@users.sourceforge.net>
43 * @version $Revision: 3281 $
44 * $Id: JNITypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
45 */
46 public class JNITypeTranslator implements TypeVisitor {
47 private final StringBuilder signature = new StringBuilder();
48
49 public String getSignature() {
50 return signature.toString();
51 }
52
53 public void visitAnnotationType(AnnotationType t) {
54 throw new RuntimeException(t + " is not allowed");
55 }
56
57 public void visitArrayType(ArrayType t) {
58 if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) )
59 signature.append("jobject");
60 else
61 throw new RuntimeException(t + " is not allowed");
62 }
63
64 public void visitClassType(ClassType t) {
65 signature.append("jobject");
66 }
67
68 public void visitDeclaredType(DeclaredType t) {
69 throw new RuntimeException(t + " is not allowed");
70 }
71
72 public void visitEnumType(EnumType t) {
73 throw new RuntimeException(t + " is not allowed");
74 }
75
76 public void visitInterfaceType(InterfaceType t) {
77 throw new RuntimeException(t + " is not allowed");
78 }
79
80 public void visitPrimitiveType(PrimitiveType t) {
81 String type;
82 switch (t.getKind()) {
83 case LONG:
84 type = "jlong";
85 break;
86 case INT:
87 type = "jint";
88 break;
89 case FLOAT:
90 type = "jfloat";
91 break;
92 case SHORT:
93 type = "jshort";
94 break;
95 case BYTE:
96 type = "jbyte";
97 break;
98 case DOUBLE:
99 type = "jdouble";
100 break;
101 case BOOLEAN:
102 type = "jboolean";
103 break;
104 default:
105 throw new RuntimeException(t + " is not allowed");
106 }
107 signature.append(type);
108 }
109
110 public void visitReferenceType(ReferenceType t) {
111 throw new RuntimeException(t + " is not allowed");
112 }
113
114 public void visitTypeMirror(TypeMirror t) {
115 throw new RuntimeException(t + " is not allowed");
116 }
117
118 public void visitTypeVariable(TypeVariable t) {
119 throw new RuntimeException(t + " is not allowed");
120 }
121
122 public void visitVoidType(VoidType t) {
123 signature.append(t.toString());
124 }
125
126 public void visitWildcardType(WildcardType t) {
127 throw new RuntimeException(t + " is not allowed");
128 }
129 }
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;
33
34 /**
35 *
36 * This class generates the methods in the generated java source files.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3293 $
40 * $Id: JavaMethodsGenerator.java 3293 2010-03-23 12:43:44Z spasi $
41 */
42
43 import com.sun.mirror.apt.*;
44 import com.sun.mirror.declaration.*;
45 import com.sun.mirror.type.*;
46
47 import java.io.*;
48 import java.util.*;
49 import java.nio.*;
50
51 public class JavaMethodsGenerator {
52 private final static String SAVED_PARAMETER_POSTFIX = "_saved";
53
54 public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) {
55 for (MethodDeclaration method : interface_decl.getMethods())
56 generateMethodJava(env, type_map, writer, interface_decl, method, generate_error_checks, context_specific);
57 }
58
59 private static void generateMethodJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
60 writer.println();
61 if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) {
62 if (method.getAnnotation(GenerateAutos.class) != null) {
63 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.AUTOS, generate_error_checks, context_specific);
64 }
65 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product = TypeInfo.getTypeInfoCrossProduct(type_map, method);
66 for (Map<ParameterDeclaration, TypeInfo> typeinfos_instance : cross_product) {
67 printMethodWithMultiType(env, type_map, writer, interface_decl, method, typeinfos_instance, Mode.NORMAL, generate_error_checks, context_specific);
68 }
69 }
70 if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) {
71 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific);
72 }
73 Alternate alt_annotation = method.getAnnotation(Alternate.class);
74 if ( alt_annotation == null || alt_annotation.nativeAlt() ) {
75 if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) )
76 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);
78 if (Utils.hasMethodBufferObjectParameter(method)) {
79 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);
81 }
82 }
83 }
84
85 private static void printJavaNativeStub(PrintWriter writer, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
86 if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) {
87 writer.print("\tprivate static native ");
88 } else {
89 Utils.printDocComment(writer, method);
90 writer.print("\tpublic static native ");
91 }
92 printResultType(writer, method, true);
93 writer.print(" " + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
94 if (mode == Mode.BUFFEROBJECT)
95 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
96 writer.print("(");
97 boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, mode);
98 if (context_specific) {
99 if (!first_parameter)
100 writer.print(", ");
101 writer.print("long " + Utils.FUNCTION_POINTER_VAR_NAME);
102 }
103 writer.println(");");
104 }
105
106 private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance,
107 boolean native_stub, Mode mode) {
108 boolean first_parameter = true;
109 for (ParameterDeclaration param : method.getParameters()) {
110 AnnotationMirror auto_annotation_mirror = Utils.getParameterAutoAnnotation(param);
111 boolean hide_auto_parameter = mode == Mode.NORMAL && !native_stub && auto_annotation_mirror != null;
112 if (hide_auto_parameter) {
113 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
114 if (auto_type_annotation != null) {
115 ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
116 TypeInfo auto_param_type_info = typeinfos_instance.get(auto_parameter);
117 if (auto_param_type_info.getSignedness() == Signedness.BOTH) {
118 if (!first_parameter)
119 writer.print(", ");
120 first_parameter = false;
121 writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME);
122 }
123 }
124 } else if (
125 param.getAnnotation(Result.class) == null
126 && (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);
132 }
133 }
134 CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
135 TypeMirror result_type = Utils.getMethodReturnType(method);
136 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);
142 }
143 }
144 if (cached_result_annotation != null) {
145 if (!first_parameter)
146 writer.print(", ");
147
148 if ( mode == Mode.CACHEDRESULT )
149 writer.print("long " + Utils.CACHED_BUFFER_LENGTH_NAME + ", ");
150
151 first_parameter = false;
152 printResultType(writer, method, native_stub);
153 writer.print(" " + Utils.CACHED_BUFFER_NAME);
154 }
155 return first_parameter;
156 }
157
158 private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, boolean first_parameter, Mode mode) {
159 Class buffer_type = Utils.getNIOBufferType(param.getType());
160 if (!first_parameter)
161 writer.print(", ");
162 BufferObject bo_annotation = param.getAnnotation(BufferObject.class);
163 if (bo_annotation != null && mode == Mode.BUFFEROBJECT) {
164 if (buffer_type == null)
165 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);
167 } else {
168 if ( native_stub && param.getAnnotation(GLpointer.class) != null )
169 writer.print("long");
170 else {
171 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());
178 if ( native_stub && buffer_type != null )
179 writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX);
180 }
181 return false;
182 }
183
184 private static void printBufferObjectCheck(PrintWriter writer, BufferKind kind, Mode mode) {
185 String bo_check_method_name = kind.toString();
186 writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".ensure" + bo_check_method_name);
187 if (mode == Mode.BUFFEROBJECT)
188 writer.print("enabled");
189 else
190 writer.print("disabled");
191 writer.println("(caps);");
192 }
193
194 private static void printBufferObjectChecks(PrintWriter writer, MethodDeclaration method, Mode mode) {
195 EnumSet<BufferKind> check_set = EnumSet.noneOf(BufferKind.class);
196 for (ParameterDeclaration param : method.getParameters()) {
197 BufferObject bo_annotation = param.getAnnotation(BufferObject.class);
198 if (bo_annotation != null)
199 check_set.add(bo_annotation.value());
200 }
201 for (BufferKind kind : check_set)
202 printBufferObjectCheck(writer, kind, mode);
203 }
204
205 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) {
206 Utils.printDocComment(writer, method);
207 writer.print("\tpublic static ");
208 printResultType(writer, method, false);
209 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
210 String method_name;
211 Alternate alt_annotation = method.getAnnotation(Alternate.class);
212 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value();
213 if (strip_annotation != null && mode == Mode.NORMAL)
214 method_name = getPostfixStrippedName(type_map, interface_decl, method);
215 writer.print(" " + method_name + "(");
216 generateParametersJava(writer, method, typeinfos_instance, false, mode);
217 TypeMirror result_type = Utils.getMethodReturnType(method);
218 writer.println(") {");
219 if (context_specific) {
220 writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
221 writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps.");
222 writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";");
223 writer.print("\t\tBufferChecks.checkFunctionAddress(");
224 writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
225 }
226 Code code_annotation = method.getAnnotation(Code.class);
227 if (code_annotation != null)
228 writer.println(code_annotation.value());
229 printBufferObjectChecks(writer, method, mode);
230 printParameterChecks(writer, method, typeinfos_instance, mode);
231 printParameterCaching(writer, interface_decl, method, mode);
232 writer.print("\t\t");
233 boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType());
234 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 ) {
242 has_result = true;
243 Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class));
244 }
245 writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
246 if (mode == Mode.BUFFEROBJECT)
247 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
248 writer.print("(");
249 boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode);
250 if (context_specific) {
251 if (!first_parameter)
252 writer.print(", ");
253 writer.print(Utils.FUNCTION_POINTER_VAR_NAME);
254 }
255 if ( has_result && method.getAnnotation(GLpointer.class) != null )
256 writer.print(")");
257 writer.println(");");
258 if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null)
259 writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";");
260 // DISABLED: indirect buffer support
261 //printNondirectParameterCopies(writer, method, mode);
262 if (has_result) {
263 if ( method.getAnnotation(GLreturn.class) == null )
264 writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";");
265 else
266 Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class));
267 }
268 writer.println("\t}");
269 }
270
271 private static String getExtensionPostfix(InterfaceDeclaration interface_decl) {
272 String interface_simple_name = interface_decl.getSimpleName();
273 Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
274 if (extension_annotation == null) {
275 int underscore_index = interface_simple_name.indexOf("_");
276 if (underscore_index != -1)
277 return interface_simple_name.substring(0, underscore_index);
278 else
279 return "";
280 } else
281 return extension_annotation.postfix();
282 }
283
284 private static ParameterDeclaration getAutoTypeParameter(MethodDeclaration method, ParameterDeclaration target_parameter) {
285 for (ParameterDeclaration param : method.getParameters()) {
286 AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param);
287 if (auto_annotation != null) {
288 Class annotation_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType());
289 String parameter_name;
290 if (annotation_type.equals(AutoType.class))
291 parameter_name = param.getAnnotation(AutoType.class).value();
292 else if (annotation_type.equals(AutoSize.class))
293 parameter_name = param.getAnnotation(AutoSize.class).value();
294 else
295 throw new RuntimeException("Unkown annotation type " + annotation_type);
296 if (target_parameter.getSimpleName().equals(parameter_name))
297 return param;
298 }
299 }
300 return null;
301 }
302
303 private static boolean hasAnyParameterAutoTypeAnnotation(MethodDeclaration method, ParameterDeclaration target_param) {
304 for (ParameterDeclaration param : method.getParameters()) {
305 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
306 if (auto_type_annotation != null) {
307 ParameterDeclaration type_target_param = Utils.findParameter(method, auto_type_annotation.value());
308 if (target_param.equals(type_target_param))
309 return true;
310 }
311 }
312 return false;
313 }
314
315 private static String getPostfixStrippedName(TypeMap type_map, InterfaceDeclaration interface_decl, MethodDeclaration method) {
316 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
317 ParameterDeclaration postfix_parameter = Utils.findParameter(method, strip_annotation.value());
318 String postfix = strip_annotation.postfix();
319 if ( "NULL".equals(postfix) ) {
320 PostfixTranslator translator = new PostfixTranslator(type_map, postfix_parameter);
321 postfix_parameter.getType().accept(translator);
322 postfix = translator.getSignature();
323 }
324 String method_name;
325 Alternate alt_annotation = method.getAnnotation(Alternate.class);
326 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value();
327
328 String extension_postfix = "NULL".equals(strip_annotation.extension()) ? getExtensionPostfix(interface_decl) : strip_annotation.extension();
329 String result;
330
331 if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "v" + extension_postfix))
332 result = method_name.substring(0, method_name.length() - (postfix.length() + 1 + extension_postfix.length()));
333 else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + extension_postfix))
334 result = method_name.substring(0, method_name.length() - (postfix.length() + extension_postfix.length()));
335 else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "i_v" + extension_postfix) )
336 result = method_name.substring(0, method_name.length() - (postfix.length() + 3 + extension_postfix.length()));
337 else if ( method_name.endsWith("i_v" + extension_postfix) )
338 result = method_name.substring(0, method_name.length() - (3 + extension_postfix.length()));
339 else if (method_name.endsWith("v" + extension_postfix))
340 result = method_name.substring(0, method_name.length() - (1 + extension_postfix.length()));
341 else
342 throw new RuntimeException(method + " is specified as being postfix stripped on parameter " + postfix_parameter + ", but it's postfix is not '" + postfix + "' nor 'v'");
343
344 return result + extension_postfix;
345 }
346
347 private static int getBufferElementSizeExponent(Class c) {
348 if (IntBuffer.class.equals(c))
349 return 2;
350 else if (LongBuffer.class.equals(c))
351 return 3;
352 else if (DoubleBuffer.class.equals(c))
353 return 3;
354 else if (ShortBuffer.class.equals(c))
355 return 1;
356 else if (ByteBuffer.class.equals(c))
357 return 0;
358 else if (FloatBuffer.class.equals(c))
359 return 2;
360 else
361 throw new RuntimeException(c + " is not allowed");
362 }
363
364 private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter) {
365 if (!first_parameter)
366 writer.print(", ");
367 AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param);
368 Constant constant_annotation = param.getAnnotation(Constant.class);
369 if (constant_annotation != null) {
370 writer.print(constant_annotation.value());
371 } else if (auto_annotation != null && mode == Mode.NORMAL) {
372 Class param_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType());
373 if (AutoType.class.equals(param_type)) {
374 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
375 String auto_parameter_name = auto_type_annotation.value();
376 ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_parameter_name);
377 String auto_type = typeinfos_instance.get(auto_parameter).getAutoType();
378 if (auto_type == null)
379 throw new RuntimeException("No auto type for parameter " + param.getSimpleName() + " in method " + method);
380 writer.print(auto_type);
381 } else if (AutoSize.class.equals(param_type)) {
382 AutoSize auto_type_annotation = param.getAnnotation(AutoSize.class);
383 String auto_parameter_name = auto_type_annotation.value();
384 ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
385 TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
386 writer.print("(" + auto_parameter_name + ".remaining()");
387 // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
388 boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
389 if (shift_remaining) {
390 int shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
391 if (shifting > 0)
392 writer.print(" << " + shifting);
393 }
394 writer.print(")");
395 writer.print(auto_type_annotation.expression());
396 } else
397 throw new RuntimeException("Unknown auto annotation " + param_type);
398 } else {
399 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
400 writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
401 } else {
402 Class type = typeinfos_instance.get(param).getType();
403 boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null;
404 if (hide_buffer)
405 writer.print("null");
406 else {
407 if ( type == CharSequence.class || type == CharSequence[].class ) {
408 final String offset = Utils.getStringOffset(method, param);
409
410 writer.print("APIUtils.getBuffer");
411 if ( param.getAnnotation(NullTerminated.class) != null )
412 writer.print("NT");
413 writer.print("(" + param.getSimpleName());
414 if ( offset != null )
415 writer.print(", " + offset);
416 writer.print(")");
417 hide_buffer = true;
418 } else
419 writer.print(param.getSimpleName());
420 }
421 Class buffer_type = Utils.getNIOBufferType(param.getType());
422 if (buffer_type != null) {
423 writer.print(", ");
424 if (!hide_buffer) {
425 TypeInfo type_info = typeinfos_instance.get(param);
426 Check check_annotation = param.getAnnotation(Check.class);
427 int shifting;
428 if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class))
429 shifting = getBufferElementSizeExponent(type_info.getType());
430 else
431 shifting = 0;
432 writer.print(param.getSimpleName());
433 if (check_annotation != null && check_annotation.canBeNull())
434 writer.print(" != null ? " + param.getSimpleName());
435 writer.print(".position()");
436 if (shifting > 0)
437 writer.print(" << " + shifting);
438 if (check_annotation != null && check_annotation.canBeNull())
439 writer.print(" : 0");
440 } else if ( type == CharSequence.class || type == CharSequence[].class ) {
441 final String offset = Utils.getStringOffset(method, param);
442 writer.print(offset == null ? "0" : offset);
443 } else
444 writer.print("0");
445 } else if ( param.getAnnotation(GLpointer.class) != null ) {
446 writer.print(".getPointer()");
447 }
448 }
449 }
450 return false;
451 }
452
453 private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) {
454 boolean first_parameter = true;
455 for (ParameterDeclaration param : method.getParameters())
456 if (param.getAnnotation(Result.class) == null) {
457 first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter);
458 }
459 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) {
460 if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) {
461 first_parameter = false;
462 Utils.printExtraCallArguments(writer, method, "");
463 } else {
464 if (!first_parameter)
465 writer.print(", ");
466 first_parameter = false;
467
468 String result_size_expression;
469 if ( mode == Mode.CACHEDRESULT )
470 result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME;
471 else {
472 AutoResultSize auto_result_size_annotation = method.getAnnotation(AutoResultSize.class);
473 if (auto_result_size_annotation == null)
474 result_size_expression = Utils.RESULT_SIZE_NAME;
475 else
476 result_size_expression = auto_result_size_annotation.value();
477 }
478 Utils.printExtraCallArguments(writer, method, result_size_expression);
479 }
480 }
481 return first_parameter;
482 }
483
484 private static void printParameterCaching(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Mode mode) {
485 for (ParameterDeclaration param : method.getParameters()) {
486 Class java_type = Utils.getJavaType(param.getType());
487 CachedReference cachedReference = param.getAnnotation(CachedReference.class);
488 if (Buffer.class.isAssignableFrom(java_type) &&
489 cachedReference != null &&
490 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
491 param.getAnnotation(Result.class) == null) {
492 writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences(caps).");
493 if(cachedReference.name().length() > 0) {
494 writer.print(cachedReference.name());
495 } else {
496 writer.print(Utils.getReferenceName(interface_decl, method, param));
497 }
498 if(cachedReference.index().length() > 0) {
499 writer.print("[" + cachedReference.index() + "]");
500 }
501 writer.println(" = " + param.getSimpleName() + ";");
502 }
503 }
504 }
505
506 private static void printNondirectParameterCopies(PrintWriter writer, MethodDeclaration method, Mode mode) {
507 for (ParameterDeclaration param : method.getParameters()) {
508 Class java_type = Utils.getJavaType(param.getType());
509 if (Utils.isAddressableType(java_type) &&
510 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
511 (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) &&
512 param.getAnnotation(Result.class) == null) {
513 if (Buffer.class.isAssignableFrom(java_type)) {
514 boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
515 if (out_parameter)
516 writer.println("\t\tNondirectBufferWrapper.copy(" + param.getSimpleName() + ", " + param.getSimpleName() + SAVED_PARAMETER_POSTFIX + ");");
517 }
518 }
519 }
520 }
521
522 private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode) {
523 for (ParameterDeclaration param : method.getParameters()) {
524 Class java_type = Utils.getJavaType(param.getType());
525 if (Utils.isAddressableType(java_type) &&
526 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
527 (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) &&
528 param.getAnnotation(Result.class) == null &&
529 !Utils.isReturnParameter(method, param) ) {
530 String check_value = null;
531 boolean can_be_null = false;
532 Check check_annotation = param.getAnnotation(Check.class);
533 if (check_annotation != null) {
534 check_value = check_annotation.value();
535 can_be_null = check_annotation.canBeNull();
536 }
537 NullTerminated null_terminated = param.getAnnotation(NullTerminated.class);
538 if (Buffer.class.isAssignableFrom(java_type) && param.getAnnotation(Constant.class) == null) {
539 boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support
540 boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
541 TypeInfo typeinfo = typeinfos.get(param);
542 printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter);
543 } else if ( String.class.equals(java_type)) {
544 if (!can_be_null)
545 writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");");
546 }
547 }
548 }
549 if (method.getAnnotation(CachedResult.class) != null)
550 printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false);
551 }
552
553 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) {
554 if (indirect_buffer_allowed && out_parameter) {
555 writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";");
556 }
557 if (can_be_null) {
558 writer.println("\t\tif (" + name + " != null)");
559 writer.print("\t");
560 }
561 if (indirect_buffer_allowed) {
562 writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap");
563 if (out_parameter)
564 writer.print("NoCopy");
565 } else
566 writer.print("\t\tBufferChecks.check");
567 if (check_value != null && !"".equals(check_value) ) {
568 writer.print("Buffer(" + name + ", " + check_value);
569 } else {
570 writer.print("Direct(" + name);
571 }
572 writer.println(");");
573 if (null_terminated != null) {
574 writer.print("\t\tBufferChecks.checkNullTerminated(");
575 writer.print(name);
576 if ( null_terminated.value().length() > 0 ) {
577 writer.print(", ");
578 writer.print(null_terminated.value());
579 }
580 writer.println(");");
581 }
582 }
583
584 private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) {
585 if ( native_stub && method.getAnnotation(GLpointer.class) != null )
586 writer.print("long");
587 else if ( !native_stub && method.getAnnotation(GLreturn.class) != null )
588 writer.print(Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false));
589 else
590 writer.print(Utils.getMethodReturnType(method).toString());
591 }
592 }
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;
33
34 import com.sun.mirror.type.*;
35 import com.sun.mirror.util.*;
36
37 /**
38 *
39 * A TypeVisitor that translates (annotated) TypeMirrors to
40 * java types (represented by a Class)
41 *
42 * @author elias_naur <elias_naur@users.sourceforge.net>
43 * @version $Revision: 3287 $
44 * $Id: JavaTypeTranslator.java 3287 2010-03-14 23:24:40Z spasi $
45 */
46 public class JavaTypeTranslator implements TypeVisitor {
47 private Class type;
48
49 public Class getType() {
50 return type;
51 }
52
53 public void visitAnnotationType(AnnotationType t) {
54 throw new RuntimeException(t + " is not allowed");
55 }
56
57 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");
62 }
63
64 public static Class getPrimitiveClassFromKind(PrimitiveType.Kind kind) {
65 switch ( kind ) {
66 case LONG:
67 return long.class;
68 case INT:
69 return int.class;
70 case DOUBLE:
71 return double.class;
72 case FLOAT:
73 return float.class;
74 case SHORT:
75 return short.class;
76 case BYTE:
77 return byte.class;
78 case BOOLEAN:
79 return boolean.class;
80 default:
81 throw new RuntimeException(kind + " is not allowed");
82 }
83 }
84
85 public void visitPrimitiveType(PrimitiveType t) {
86 type = getPrimitiveClassFromKind(t.getKind());
87 }
88
89 public void visitDeclaredType(DeclaredType t) {
90 throw new RuntimeException(t + " is not allowed");
91 }
92
93 public void visitEnumType(EnumType t) {
94 throw new RuntimeException(t + " is not allowed");
95 }
96
97 public void visitClassType(ClassType t) {
98 type = NativeTypeTranslator.getClassFromType(t);
99 }
100
101 public void visitInterfaceType(InterfaceType t) {
102 type = NativeTypeTranslator.getClassFromType(t);
103 }
104
105 public void visitReferenceType(ReferenceType t) {
106 throw new RuntimeException(t + " is not allowed");
107 }
108
109 public void visitTypeMirror(TypeMirror t) {
110 throw new RuntimeException(t + " is not allowed");
111 }
112
113 public void visitTypeVariable(TypeVariable t) {
114 throw new RuntimeException(t + " is not allowed");
115 }
116
117 public void visitVoidType(VoidType t) {
118 type = void.class;
119 }
120
121 public void visitWildcardType(WildcardType t) {
122 throw new RuntimeException(t + " is not allowed");
123 }
124 }
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 public enum Mode {
34 BUFFEROBJECT,
35 AUTOS,
36 CACHEDRESULT, // Used for generating a CachedResult method with an explicit length argument.
37 NORMAL
38 }
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;
33
34 /**
35 *
36 * This class generates the functions in the native source files.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3289 $
40 * $Id: NativeMethodStubsGenerator.java 3289 2010-03-16 19:05:19Z spasi $
41 */
42
43 import com.sun.mirror.apt.*;
44 import com.sun.mirror.declaration.*;
45 import com.sun.mirror.type.*;
46
47 import java.io.*;
48 import java.util.*;
49 import java.nio.*;
50
51 public class NativeMethodStubsGenerator {
52 private static final String BUFFER_ADDRESS_POSTFIX = "_address";
53 public static final String BUFFER_POSITION_POSTFIX = "_position";
54 private static final String STRING_LIST_POSTFIX = "_str";
55
56 public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) {
57 for (MethodDeclaration method : d.getMethods()) {
58 Alternate alt_annotation = method.getAnnotation(Alternate.class);
59 if ( alt_annotation != null && !alt_annotation.nativeAlt() )
60 continue;
61 generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific);
62 if (Utils.hasMethodBufferObjectParameter(method))
63 generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
64 }
65 }
66
67 private static void generateParameters(PrintWriter writer, Collection<ParameterDeclaration> params, Mode mode) {
68 for (ParameterDeclaration param : params)
69 if (param.getAnnotation(Result.class) == null)
70 generateParameter(writer, param, mode);
71 }
72
73 private static void generateParameter(PrintWriter writer, ParameterDeclaration param, Mode mode) {
74 writer.print(", ");
75 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
76 writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
77 } else if ( param.getAnnotation(GLpointer.class) != null ) {
78 writer.print("jlong " + param.getSimpleName());
79 } else {
80 JNITypeTranslator translator = new JNITypeTranslator();
81 param.getType().accept(translator);
82 writer.print(translator.getSignature() + " " + param.getSimpleName());
83 if (Utils.getNIOBufferType(param.getType()) != null)
84 writer.print(", jint " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
85 }
86 }
87
88 private static void generateMethodStub(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
89 if ( !context_specific && method.getAnnotation(Alternate.class) == null )
90 writer.print("static ");
91 else
92 writer.print("JNIEXPORT ");
93
94 TypeMirror result_type = Utils.getMethodReturnType(method);
95
96 if ( method.getAnnotation(GLpointer.class) != null ) {
97 writer.print("jlong");
98 } else {
99 JNITypeTranslator translator = new JNITypeTranslator();
100 result_type.accept(translator);
101 writer.print(translator.getSignature());
102 }
103 writer.print(" JNICALL ");
104
105 writer.print(Utils.getQualifiedNativeMethodName(interface_name, method, generate_error_checks, context_specific));
106 if (mode == Mode.BUFFEROBJECT)
107 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
108 writer.print("(JNIEnv *env, jclass clazz");
109 generateParameters(writer, method.getParameters(), mode);
110 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())
113 writer.print(", jlong " + Utils.RESULT_SIZE_NAME);
114 if (cached_result_annotation != null)
115 writer.print(", jobject " + Utils.CACHED_BUFFER_NAME);
116 }
117 if (context_specific) {
118 writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME);
119 }
120 writer.println(") {");
121 generateBufferParameterAddresses(type_map, writer, method, mode);
122 Alternate alt_annotation = method.getAnnotation(Alternate.class);
123 if (context_specific) {
124 String typedef_name = Utils.getTypedefName(method);
125 writer.print("\t" + typedef_name + " " + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()));
126 writer.print(" = (" + typedef_name + ")((intptr_t)");
127 writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
128 }
129 generateStringListInits(writer, method.getParameters());
130 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 }
147 writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "(");
148 generateCallParameters(writer, type_map, method.getParameters());
149 writer.print(")");
150 writer.println(";");
151 generateStringDeallocations(writer, method.getParameters());
152 if (!result_type.equals(env.getTypeUtils().getVoidType())) {
153 writer.print("\treturn ");
154 Class java_result_type = Utils.getJavaType(result_type);
155 if (Buffer.class.isAssignableFrom(java_result_type)) {
156 if (method.getAnnotation(CachedResult.class) != null)
157 writer.print("safeNewBufferCached(env, ");
158 else
159 writer.print("safeNewBuffer(env, ");
160 } else if (String.class.equals(java_result_type)) {
161 writer.print("NewStringNativeUnsigned(env, ");
162 } else if ( method.getAnnotation(GLpointer.class) != null ) {
163 writer.print("(intptr_t)");
164 }
165 writer.print(Utils.RESULT_VAR_NAME);
166 if (Buffer.class.isAssignableFrom(java_result_type)) {
167 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);
172 }
173 if (Buffer.class.isAssignableFrom(java_result_type) ||
174 String.class.equals(java_result_type))
175 writer.print(")");
176 writer.println(";");
177 }
178 writer.println("}");
179 writer.println();
180 }
181
182 private static void generateCallParameters(PrintWriter writer, TypeMap type_map, Collection<ParameterDeclaration> params) {
183 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());
189 }
190 }
191 }
192
193 private static void generateCallParameter(PrintWriter writer, TypeMap type_map, ParameterDeclaration param) {
194 boolean is_indirect = param.getAnnotation(Indirect.class) != null;
195 if (is_indirect || param.getAnnotation(StringList.class) != null) {
196 writer.print("(");
197 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
198 param.getType().accept(translator);
199 writer.print(translator.getSignature());
200 writer.print("*)");
201 }
202 if ( param.getAnnotation(GLpointer.class) != null )
203 writer.print("(" + param.getAnnotation(GLpointer.class).value() + ")(intptr_t)");
204 if (param.getAnnotation(Result.class) != null || is_indirect)
205 writer.print("&");
206 if (param.getAnnotation(Result.class) != null) {
207 writer.print(Utils.RESULT_VAR_NAME);
208 } else {
209 writer.print(param.getSimpleName());
210 if ( param.getAnnotation(StringList.class) != null )
211 writer.print(STRING_LIST_POSTFIX);
212 else if (Utils.isAddressableType(param.getType()))
213 writer.print(BUFFER_ADDRESS_POSTFIX);
214 }
215 }
216
217 private static void generateStringDeallocations(PrintWriter writer, Collection<ParameterDeclaration> params) {
218 for (ParameterDeclaration param : params) {
219 if (Utils.getJavaType(param.getType()).equals(String.class) &&
220 param.getAnnotation(Result.class) == null)
221 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 + ");");
224 }
225 }
226
227 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);
236 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());
253 } else {
254 writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName());
255 }
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}");
309 }
310 }
311 }
312
313 }
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 * This annotation indicates that another annotation is
36 * a native type.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: NativeType.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.ANNOTATION_TYPE)
47 public @interface NativeType {
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;
33
34 /**
35 *
36 * A TypeVisitor that translates types (and optional native type
37 * annotations) to the native type string.
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3281 $
41 * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
42 */
43
44 import org.lwjgl.opengl.PointerWrapper;
45
46 import com.sun.mirror.declaration.*;
47 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;
56
57 /**
58 * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
59 *
60 * A TypeVisitor that translates (annotated) TypeMirrors to
61 * native types
62 *
63 * @author elias_naur <elias_naur@users.sourceforge.net>
64 * @version $Revision: 3281 $
65 */
66 public class NativeTypeTranslator implements TypeVisitor {
67 private Collection<Class> native_types;
68 private boolean is_indirect;
69 private final Declaration declaration;
70 private final TypeMap type_map;
71
72 public NativeTypeTranslator(TypeMap type_map, Declaration declaration) {
73 this.declaration = declaration;
74 this.type_map = type_map;
75 }
76
77 public String getSignature() {
78 StringBuilder signature = new StringBuilder();
79 if (declaration.getAnnotation(Const.class) != null)
80 signature.append("const ");
81
82 if ( declaration.getAnnotation(GLpointer.class) != null ) {
83 signature.append(declaration.getAnnotation(GLpointer.class).value());
84 } else {
85 // Use the name of the native type annotation as the C type name
86 signature.append(getAnnotationType().getSimpleName());
87 }
88
89 if (is_indirect)
90 signature.append(" *");
91 return signature.toString();
92 }
93
94 public Class getAnnotationType() {
95 if (native_types.size() != 1)
96 throw new RuntimeException("Expected only one native type for declaration " + declaration +
97 ", but got " + native_types.size());
98 return native_types.iterator().next();
99 }
100
101 public void visitAnnotationType(AnnotationType t) {
102 throw new RuntimeException(t + " is not allowed");
103 }
104
105 public void visitArrayType(ArrayType t) {
106 if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) {
107 is_indirect = true;
108 native_types = new ArrayList<Class>();
109 native_types.add(GLchar.class);
110 } else
111 throw new RuntimeException(t + " is not allowed");
112 }
113
114 public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
115 if (IntBuffer.class.equals(c))
116 return PrimitiveType.Kind.INT;
117 else if (DoubleBuffer.class.equals(c))
118 return PrimitiveType.Kind.DOUBLE;
119 else if (ShortBuffer.class.equals(c))
120 return PrimitiveType.Kind.SHORT;
121 else if (ByteBuffer.class.equals(c))
122 return PrimitiveType.Kind.BYTE;
123 else if (FloatBuffer.class.equals(c))
124 return PrimitiveType.Kind.FLOAT;
125 else if (LongBuffer.class.equals(c))
126 return PrimitiveType.Kind.LONG;
127 else
128 throw new RuntimeException(c + " is not allowed");
129 }
130
131 public static Class<?> getClassFromType(DeclaredType t) {
132 try {
133 return Class.forName(t.getDeclaration().getQualifiedName());
134 } catch (ClassNotFoundException e) {
135 throw new RuntimeException(e);
136 }
137 }
138
139 private void getNativeTypeFromAnnotatedPrimitiveType(PrimitiveType.Kind kind) {
140 native_types = translateAnnotations();
141 if (native_types.size() == 0)
142 native_types.add(type_map.getNativeTypeFromPrimitiveType(kind));
143 }
144
145 public void visitClassType(ClassType t) {
146 is_indirect = true;
147
148 Class<?> c = getClassFromType(t);
149 if (String.class.equals(c)) {
150 native_types = new ArrayList<Class>();
151 native_types.add(type_map.getStringElementType());
152 } else if (Buffer.class.equals(c)) {
153 native_types = new ArrayList<Class>();
154 native_types.add(type_map.getVoidType());
155 } else if (Buffer.class.isAssignableFrom(c)) {
156 PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
157 getNativeTypeFromAnnotatedPrimitiveType(kind);
158 } else if ( PointerWrapper.class.isAssignableFrom(c) ) {
159 native_types = new ArrayList<Class>();
160 native_types.add(GLpointer.class);
161
162 is_indirect = false;
163 } else
164 throw new RuntimeException(t + " is not allowed");
165 }
166
167 public void visitPrimitiveType(PrimitiveType t) {
168 getNativeTypeFromAnnotatedPrimitiveType(t.getKind());
169 }
170
171 public void visitDeclaredType(DeclaredType t) {
172 throw new RuntimeException(t + " is not allowed");
173 }
174
175 public void visitEnumType(EnumType t) {
176 throw new RuntimeException(t + " is not allowed");
177 }
178
179 public void visitInterfaceType(InterfaceType t) {
180 throw new RuntimeException(t + " is not allowed");
181 }
182
183 // Check if the annotation is itself annotated with a certain annotation type
184 public static <T extends Annotation> T getAnnotation(AnnotationMirror annotation, Class<T> type) {
185 return annotation.getAnnotationType().getDeclaration().getAnnotation(type);
186 }
187
188 private static Class translateAnnotation(AnnotationMirror annotation) {
189 NativeType native_type = getAnnotation(annotation, NativeType.class);
190 if (native_type != null) {
191 return getClassFromType(annotation.getAnnotationType());
192 } else
193 return null;
194 }
195
196 private Collection<Class> translateAnnotations() {
197 Collection<Class> result = new ArrayList<Class>();
198 for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors())) {
199 Class translated_result = translateAnnotation(annotation);
200 if (translated_result != null) {
201 result.add(translated_result);
202 }
203 }
204 return result;
205 }
206
207 public void visitReferenceType(ReferenceType t) {
208 throw new RuntimeException(t + " is not allowed");
209 }
210
211 public void visitTypeMirror(TypeMirror t) {
212 throw new RuntimeException(t + " is not allowed");
213 }
214
215 public void visitTypeVariable(TypeVariable t) {
216 throw new RuntimeException(t + " is not allowed");
217 }
218
219 public void visitVoidType(VoidType t) {
220 native_types = translateAnnotations();
221 if (native_types.size() == 0)
222 native_types.add(void.class);
223 }
224
225 public void visitWildcardType(WildcardType t) {
226 throw new RuntimeException(t + " is not allowed");
227 }
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 package org.lwjgl.util.generator;
32
33 /**
34 *
35 * This annotation implies that a method should not include
36 * error checking even if it is enabled.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: NoErrorCheck.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.METHOD)
47 public @interface NoErrorCheck {
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;
32
33 /**
34 *
35 * This annotation implies that a Buffer argument should be
36 * checked for a trailing '\0'
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3260 $
40 * $Id: NullTerminated.java 3260 2009-12-04 04:49:19Z spasi $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.PARAMETER)
47 public @interface NullTerminated {
48 String value() default "";
49 }
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 * A function annotated with @Optional will allow the extension to be available even if the driver does not expose that function.
35 * This is useful when certain buggy drivers miss some functionality.
36 *
37 * @author spasi <spasi@users.sourceforge.net>
38 */
39
40 import java.lang.annotation.ElementType;
41 import java.lang.annotation.Target;
42
43 @Target(ElementType.METHOD)
44 public @interface Optional {
45 String reason(); // No default value to force documentation
46 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator;
32
33 /**
34 * This annotation indicates that a parameter is written,
35 * not read.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2286 $
39 * $Id: Check.java 2286 2006-03-23 19:32:21Z matzon $
40 */
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @Target(ElementType.PARAMETER)
46 public @interface OutParameter {
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 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Platform.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import java.io.PrintWriter;
41
42 public enum Platform {
43 WGL,
44 GLX,
45 ALL;
46
47 public void printPrologue(PrintWriter writer) {
48 if (this == ALL)
49 return;
50 writer.print("#ifdef ");
51 switch (this) {
52 case WGL:
53 writer.println("_WIN32");
54 break;
55 case GLX:
56 writer.println("_X11");
57 break;
58 default:
59 throw new RuntimeException(this + " is not supported");
60 }
61 }
62
63 public void printEpilogue(PrintWriter writer) {
64 if (this == ALL)
65 return;
66 writer.println("#endif");
67 }
68
69 public String getOSPrefix() {
70 switch (this) {
71 case WGL:
72 return "Windows";
73 case GLX:
74 return "Linux";
75 default:
76 throw new RuntimeException(this + " has no OS specific prefix");
77 }
78 }
79
80 public String getPrefix() {
81 switch (this) {
82 case WGL:
83 return "wgl";
84 case GLX:
85 return "glX";
86 case ALL:
87 return "gl";
88 default:
89 throw new RuntimeException(this + " is not supported");
90 }
91 }
92 }
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 * This annotation implies that the corresponding native
36 * function symbol is named after the platform specific
37 * window system (glX, wgl, ...)
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 2983 $
41 * $Id: PlatformDependent.java 2983 2008-04-07 18:36:09Z matzon $
42 */
43
44 import java.lang.annotation.Target;
45 import java.lang.annotation.ElementType;
46
47 @Target(ElementType.METHOD)
48 public @interface PlatformDependent {
49 Platform[] value();
50 }
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;
33
34 /**
35 *
36 * A TypeVisitor that translates (annotated) TypeMirrors to
37 * postfixes.
38 *
39 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3287 $
41 * $Id: PostfixTranslator.java 3287 2010-03-14 23:24:40Z spasi $
42 */
43
44 import com.sun.mirror.declaration.*;
45 import com.sun.mirror.type.*;
46 import com.sun.mirror.util.*;
47
48 import java.nio.*;
49
50 public class PostfixTranslator implements TypeVisitor {
51 private final StringBuilder signature = new StringBuilder();
52 private final Declaration declaration;
53 private final TypeMap type_map;
54
55 public PostfixTranslator(TypeMap type_map, Declaration declaration) {
56 this.declaration = declaration;
57 this.type_map = type_map;
58 }
59
60 public String getSignature() {
61 return signature.toString();
62 }
63
64 public void visitAnnotationType(AnnotationType t) {
65 throw new RuntimeException(t + " is not allowed");
66 }
67
68 public void visitArrayType(ArrayType t) {
69 throw new RuntimeException(t + " is not allowed");
70 }
71
72 private static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
73 if (IntBuffer.class.equals(c) || int.class.equals(c) )
74 return PrimitiveType.Kind.INT;
75 else if (DoubleBuffer.class.equals(c) || double.class.equals(c) )
76 return PrimitiveType.Kind.DOUBLE;
77 else if (ShortBuffer.class.equals(c) || short.class.equals(c) )
78 return PrimitiveType.Kind.SHORT;
79 else if (ByteBuffer.class.equals(c) || byte.class.equals(c) )
80 return PrimitiveType.Kind.BYTE;
81 else if (FloatBuffer.class.equals(c) || float.class.equals(c))
82 return PrimitiveType.Kind.FLOAT;
83 else if (LongBuffer.class.equals(c) || long.class.equals(c) )
84 return PrimitiveType.Kind.LONG;
85 else
86 throw new RuntimeException(c + " is not allowed");
87 }
88
89 public void visitClassType(ClassType t) {
90 Class<?> c = NativeTypeTranslator.getClassFromType(t);
91 PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
92 visitPrimitiveTypeKind(kind);
93 }
94
95 public void visitDeclaredType(DeclaredType t) {
96 throw new RuntimeException(t + " is not allowed");
97 }
98
99 public void visitEnumType(EnumType t) {
100 throw new RuntimeException(t + " is not allowed");
101 }
102
103 public void visitInterfaceType(InterfaceType t) {
104 throw new RuntimeException(t + " is not allowed");
105 }
106
107 private boolean translateAnnotation(AnnotationMirror annotation) {
108 NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
109 if (native_type != null) {
110 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
111 signature.append(type_map.translateAnnotation(annotation_class));
112 return true;
113 } else
114 return false;
115 }
116
117 private boolean translateAnnotations() {
118 boolean result = false;
119 for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()))
120 if (translateAnnotation(annotation)) {
121 if (result)
122 throw new RuntimeException("Multiple native types");
123 result = true;
124 }
125 return result;
126 }
127
128 public void visitPrimitiveType(PrimitiveType t) {
129 visitPrimitiveTypeKind(t.getKind());
130 }
131
132 private void visitPrimitiveTypeKind(PrimitiveType.Kind kind) {
133 boolean annotated_translation = translateAnnotations();
134 if (annotated_translation)
135 return;
136 // No annotation type was specified, fall back to default
137 String type;
138 switch (kind) {
139 case INT:
140 type = "i";
141 break;
142 case DOUBLE:
143 type = "d";
144 break;
145 case FLOAT:
146 type = "f";
147 break;
148 case SHORT:
149 type = "s";
150 break;
151 case BYTE:
152 type = "b";
153 break;
154 case LONG:
155 type = "i64";
156 break;
157 default:
158 throw new RuntimeException(kind + " is not allowed");
159 }
160 signature.append(type);
161 }
162
163 public void visitReferenceType(ReferenceType t) {
164 throw new RuntimeException(t + " is not allowed");
165 }
166
167 public void visitTypeMirror(TypeMirror t) {
168 throw new RuntimeException(t + " is not allowed");
169 }
170
171 public void visitTypeVariable(TypeVariable t) {
172 throw new RuntimeException(t + " is not allowed");
173 }
174
175 public void visitVoidType(VoidType t) {
176 }
177
178 public void visitWildcardType(WildcardType t) {
179 throw new RuntimeException(t + " is not allowed");
180 }
181 }
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;
33
34 import static java.util.Collections.emptyList;
35 import static java.util.Collections.unmodifiableCollection;
36
37 import java.io.File;
38 import java.io.IOException;
39 import java.io.PrintWriter;
40 import java.util.Arrays;
41 import java.util.Collection;
42 import java.util.Set;
43
44 import com.sun.mirror.apt.AnnotationProcessor;
45 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
46 import com.sun.mirror.apt.AnnotationProcessorFactory;
47 import com.sun.mirror.apt.AnnotationProcessors;
48 import com.sun.mirror.apt.Filer;
49 import com.sun.mirror.apt.RoundCompleteEvent;
50 import com.sun.mirror.apt.RoundCompleteListener;
51 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
52 import com.sun.mirror.declaration.InterfaceDeclaration;
53 import com.sun.mirror.declaration.MethodDeclaration;
54 import com.sun.mirror.declaration.ParameterDeclaration;
55 import com.sun.mirror.declaration.TypeDeclaration;
56 import com.sun.mirror.util.DeclarationFilter;
57
58 /**
59 *
60 * Generator tool for creating the References class
61 *
62 * @author elias_naur <elias_naur@users.sourceforge.net>
63 * @version $Revision: 3237 $
64 * $Id: ReferencesGeneratorProcessorFactory.java 3237 2009-09-08 15:07:15Z spasi $
65 */
66 public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
67 private final static String REFERENCES_CLASS_NAME = "References";
68 private final static String REFERENCES_PARAMETER_NAME = "references";
69
70 private static boolean first_round = true;
71
72 // Process any set of annotations
73 private static final Collection<String> supportedAnnotations =
74 unmodifiableCollection(Arrays.asList("*"));
75
76 public Collection<String> supportedAnnotationTypes() {
77 return supportedAnnotations;
78 }
79
80 public Collection<String> supportedOptions() {
81 return emptyList();
82 }
83
84 public void roundComplete(RoundCompleteEvent event) {
85 first_round = false;
86 }
87
88 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
89 // Only process the initial types, not the generated ones
90 if (first_round) {
91 env.addListener(this);
92 return new GeneratorProcessor(env);
93 } else
94 return AnnotationProcessors.NO_OP;
95 }
96
97 private static class GeneratorProcessor implements AnnotationProcessor {
98 private final AnnotationProcessorEnvironment env;
99
100 GeneratorProcessor(AnnotationProcessorEnvironment env) {
101 this.env = env;
102 }
103
104 public void process() {
105 try {
106 generateReferencesSource();
107 } catch (IOException e) {
108 throw new RuntimeException(e);
109 }
110 }
111
112 private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
113 for (ParameterDeclaration param : method.getParameters()) {
114 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
115 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
116 Class nio_type = Utils.getNIOBufferType(param.getType());
117 String reference_name = Utils.getReferenceName(interface_decl, method, param);
118 writer.println("\t\tthis." + reference_name + " = null;");
119 }
120 }
121 }
122
123 private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
124 for (ParameterDeclaration param : method.getParameters()) {
125 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
126 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
127 Class nio_type = Utils.getNIOBufferType(param.getType());
128 String reference_name = Utils.getReferenceName(interface_decl, method, param);
129 writer.print("\t\t\tthis." + reference_name + " = ");
130 writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
131 }
132 }
133 }
134
135 private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
136 for (MethodDeclaration method : interface_decl.getMethods()) {
137 generateClearsFromParameters(writer, interface_decl, method);
138 }
139 }
140
141 private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
142 for (MethodDeclaration method : interface_decl.getMethods()) {
143 generateCopiesFromParameters(writer, interface_decl, method);
144 }
145 }
146
147 private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
148 for (ParameterDeclaration param : method.getParameters()) {
149 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
150 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
151 Class nio_type = Utils.getNIOBufferType(param.getType());
152 if (nio_type == null)
153 throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
154 + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
155 writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
156 writer.println(";");
157 }
158 }
159 }
160
161 private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
162 for (MethodDeclaration method : interface_decl.getMethods()) {
163 generateReferencesFromParameters(writer, interface_decl, method);
164 }
165 }
166
167 private void generateReferencesSource() throws IOException {
168 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null);
169 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
170 writer.println();
171 writer.println("package org.lwjgl.opengl;");
172 writer.println();
173 writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {");
174 writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {");
175 writer.println("\t\tsuper(caps);");
176 writer.println("\t}");
177 DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
178 Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
179 for (TypeDeclaration typedecl : interface_decls) {
180 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
181 generateReferencesFromMethods(writer, interface_decl);
182 }
183 writer.println();
184 writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {");
185 writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);");
186 writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {");
187 for (TypeDeclaration typedecl : interface_decls) {
188 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
189 generateCopiesFromMethods(writer, interface_decl);
190 }
191 writer.println("\t\t}");
192 writer.println("\t}");
193 writer.println("\tvoid clear() {");
194 writer.println("\t\tsuper.clear();");
195 for (TypeDeclaration typedecl : interface_decls) {
196 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
197 generateClearsFromMethods(writer, interface_decl);
198 }
199 writer.println("\t}");
200 writer.println("}");
201 writer.close();
202 }
203 }
204 }
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;
33
34 /**
35 *
36 * This class generates the initNatives native function.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3288 $
40 * $Id: RegisterStubsGenerator.java 3288 2010-03-16 17:58:48Z spasi $
41 */
42
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
47 import java.util.*;
48
49 public class RegisterStubsGenerator {
50 public static void generateMethodsNativeStubBind(PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) {
51 Iterator<? extends MethodDeclaration> it = d.getMethods().iterator();
52 while (it.hasNext()) {
53 MethodDeclaration method = it.next();
54 if ( method.getAnnotation(Alternate.class) != null )
55 continue;
56 EnumSet<Platform> platforms;
57 PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class);
58 if (platform_annotation != null)
59 platforms = EnumSet.copyOf(Arrays.asList(platform_annotation.value()));
60 else
61 platforms = EnumSet.of(Platform.ALL);
62 for (Platform platform : platforms) {
63 platform.printPrologue(writer);
64 boolean has_buffer_parameter = Utils.hasMethodBufferObjectParameter(method);
65 printMethodNativeStubBind(writer, d, method, platform, Mode.NORMAL, it.hasNext() || has_buffer_parameter, generate_error_checks, context_specific);
66 if (has_buffer_parameter) {
67 printMethodNativeStubBind(writer, d, method, platform, Mode.BUFFEROBJECT, it.hasNext(), generate_error_checks, context_specific);
68 }
69 platform.printEpilogue(writer);
70 }
71 }
72 writer.println();
73 }
74
75 private static String getTypeSignature(TypeMirror type, boolean add_position_signature) {
76 SignatureTranslator v = new SignatureTranslator(add_position_signature);
77 type.accept(v);
78 return v.getSignature();
79 }
80
81 private static String getMethodSignature(MethodDeclaration method, Mode mode) {
82 Collection<ParameterDeclaration> params = method.getParameters();
83 String signature = "(";
84 for (ParameterDeclaration param : params) {
85 if (param.getAnnotation(Result.class) != null)
86 continue;
87 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
88 signature += "I";
89 } else {
90 signature += getTypeSignature(param.getType(), true);
91 }
92 }
93 TypeMirror result_type = Utils.getMethodReturnType(method);
94 if (Utils.getNIOBufferType(result_type) != null)
95 signature += "I";
96 String result_type_signature = getTypeSignature(result_type, false);
97 if (method.getAnnotation(CachedResult.class) != null)
98 signature += result_type_signature;
99 signature += ")";
100 signature += result_type_signature;
101 return signature;
102 }
103
104 private static void printMethodNativeStubBind(PrintWriter writer, InterfaceDeclaration d, MethodDeclaration method, Platform platform, Mode mode, boolean has_more, boolean generate_error_checks, boolean context_specific) {
105 writer.print("\t\t{\"" + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
106 if (mode == Mode.BUFFEROBJECT)
107 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
108 writer.print("\", \"" + getMethodSignature(method, mode) + "\", (void *)&");
109 writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific));
110 if (mode == Mode.BUFFEROBJECT)
111 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() + "}");
114 if (has_more)
115 writer.println(",");
116 }
117
118 }
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 * This annotation indicates that the method result is in the
36 * specified parameter.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: Result.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.PARAMETER)
47 public @interface Result {
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;
33
34 /**
35 *
36 * A TypeVisitor that translates types to JNI signatures.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: SignatureTranslator.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import com.sun.mirror.type.*;
44 import com.sun.mirror.util.*;
45
46 import java.nio.*;
47
48 class SignatureTranslator implements TypeVisitor {
49 private final boolean add_position_signature;
50 private final StringBuilder signature = new StringBuilder();
51
52 SignatureTranslator(boolean add_position_signature) {
53 this.add_position_signature = add_position_signature;
54 }
55
56 private static String getNativeNameFromClassName(String class_name) {
57 return class_name.replaceAll("\\.", "/");
58 }
59
60 public String getSignature() {
61 return signature.toString();
62 }
63
64 public void visitAnnotationType(AnnotationType t) {
65 throw new RuntimeException(t + " is not allowed");
66 }
67
68 public void visitArrayType(ArrayType t) {
69 throw new RuntimeException(t + " is not allowed");
70 }
71
72 public void visitClassType(ClassType t) {
73 String type_name = getNativeNameFromClassName(t.getDeclaration().getQualifiedName());
74 signature.append("L");
75 signature.append(type_name);
76 signature.append(";");
77 if (add_position_signature && Buffer.class.isAssignableFrom(NativeTypeTranslator.getClassFromType(t))) {
78 signature.append("I");
79 }
80 }
81
82 public void visitDeclaredType(DeclaredType t) {
83 throw new RuntimeException(t + " is not allowed");
84 }
85
86 public void visitEnumType(EnumType t) {
87 throw new RuntimeException(t + " is not allowed");
88 }
89
90 public void visitInterfaceType(InterfaceType t) {
91 throw new RuntimeException(t + " is not allowed");
92 }
93
94 public void visitPrimitiveType(PrimitiveType t) {
95 switch (t.getKind()) {
96 case BOOLEAN:
97 signature.append("Z");
98 break;
99 case INT:
100 signature.append("I");
101 break;
102 case FLOAT:
103 signature.append("F");
104 break;
105 case SHORT:
106 signature.append("S");
107 break;
108 case DOUBLE:
109 signature.append("D");
110 break;
111 case BYTE:
112 signature.append("B");
113 break;
114 case LONG:
115 signature.append("J");
116 break;
117 default:
118 throw new RuntimeException("Unsupported type " + t);
119 }
120 }
121
122 public void visitReferenceType(ReferenceType t) {
123 throw new RuntimeException(t + " is not allowed");
124 }
125
126 public void visitTypeMirror(TypeMirror t) {
127 throw new RuntimeException(t + " is not allowed");
128 }
129
130 public void visitTypeVariable(TypeVariable t) {
131 throw new RuntimeException(t + " is not allowed");
132 }
133
134 public void visitVoidType(VoidType t) {
135 signature.append("V");
136 }
137
138 public void visitWildcardType(WildcardType t) {
139 throw new RuntimeException(t + " is not allowed");
140 }
141 }
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 elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Signedness.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 public enum Signedness {
41 SIGNED,
42 UNSIGNED,
43 NONE,
44 BOTH
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 /**
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 StringList {
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 *
35 * This annotation implies that a method have its postfix stripped
36 * according to a specified Buffer parameter.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3256 $
40 * $Id: StripPostfix.java 3256 2009-12-01 03:37:27Z spasi $
41 */
42
43 import java.lang.annotation.Target;
44 import java.lang.annotation.ElementType;
45
46 @Target(ElementType.METHOD)
47 public @interface StripPostfix {
48 String value(); // The parameter to deduce the postfix from
49 String extension() default "NULL";
50 boolean hasPostfix() default true;
51 String postfix() default "NULL";
52 }
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 * This class represent a parameter configuration. There are multiple
36 * TypeInfos in case of multityped parameters.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3279 $
40 * $Id: TypeInfo.java 3279 2010-03-11 21:06:49Z spasi $
41 */
42
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.util.*;
47 import java.nio.*;
48
49 public class TypeInfo {
50 public static final String UNSIGNED_PARAMETER_NAME = "unsigned";
51
52 private final Signedness signedness;
53 private final Class type;
54 private final String auto_type;
55
56 private TypeInfo(Class type, Signedness signedness, String auto_type) {
57 this.type = type;
58 this.signedness = signedness;
59 this.auto_type = auto_type;
60 }
61
62 public Class getType() {
63 return type;
64 }
65
66 public Signedness getSignedness() {
67 return signedness;
68 }
69
70 public String getAutoType() {
71 if (auto_type == null)
72 throw new RuntimeException("No auto type assigned");
73 return auto_type;
74 }
75
76 private static Class getTypeFromPrimitiveKind(PrimitiveType.Kind kind) {
77 Class type;
78 switch (kind) {
79 case LONG:
80 type = long.class;
81 break;
82 case INT:
83 type = int.class;
84 break;
85 case FLOAT:
86 type = float.class;
87 break;
88 case DOUBLE:
89 type = double.class;
90 break;
91 case SHORT:
92 type = short.class;
93 break;
94 case BYTE:
95 type = byte.class;
96 break;
97 default:
98 throw new RuntimeException(kind + " is not allowed");
99 }
100 return type;
101 }
102
103 private static Class getBufferTypeFromPrimitiveKind(PrimitiveType.Kind kind) {
104 Class type;
105 switch (kind) {
106 case INT:
107 type = IntBuffer.class;
108 break;
109 case FLOAT:
110 type = FloatBuffer.class;
111 break;
112 case DOUBLE:
113 type = DoubleBuffer.class;
114 break;
115 case SHORT:
116 type = ShortBuffer.class;
117 break;
118 case LONG:
119 type = LongBuffer.class;
120 break;
121 case BYTE: /* fall through */
122 case BOOLEAN:
123 type = ByteBuffer.class;
124 break;
125 default:
126 throw new RuntimeException(kind + " is not allowed");
127 }
128 return type;
129 }
130
131 private static TypeInfo getDefaultTypeInfo(TypeMirror t) {
132 Class java_type = Utils.getJavaType(t);
133 return new TypeInfo(java_type, Signedness.NONE, null);
134 }
135
136 public static Map<ParameterDeclaration, TypeInfo> getDefaultTypeInfoMap(MethodDeclaration method) {
137 Map<ParameterDeclaration, TypeInfo> map = new HashMap<ParameterDeclaration, TypeInfo>();
138 for (ParameterDeclaration param : method.getParameters()) {
139 TypeInfo type_info = getDefaultTypeInfo(param.getType());
140 map.put(param, type_info);
141 }
142 return map;
143 }
144
145 private static Collection<TypeInfo> getTypeInfos(TypeMap type_map, Declaration param, TypeMirror decl_type) {
146 Collection<AnnotationMirror> annotations = Utils.getSortedAnnotations(param.getAnnotationMirrors());
147 Map<Class, TypeInfo> types = new HashMap<Class, TypeInfo>();
148 Collection<TypeInfo> multityped_result = new ArrayList<TypeInfo>();
149 boolean add_default_type = true;
150 for (AnnotationMirror annotation : annotations) {
151 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
152 if (native_type_annotation != null) {
153 Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
154 Signedness signedness = type_map.getSignednessFromType(annotation_type);
155 Class inverse_type = type_map.getInverseType(annotation_type);
156 String auto_type = type_map.getAutoTypeFromAnnotation(annotation);
157 if (inverse_type != null) {
158 if (types.containsKey(inverse_type)) {
159 TypeInfo inverse_type_info = types.get(inverse_type);
160 String inverse_auto_type = inverse_type_info.getAutoType();
161 auto_type = signedness == Signedness.UNSIGNED ? auto_type + " : " + inverse_auto_type :
162 inverse_auto_type + " : " + auto_type;
163 auto_type = UNSIGNED_PARAMETER_NAME + " ? " + auto_type;
164 signedness = Signedness.BOTH;
165 types.remove(inverse_type);
166 multityped_result.remove(inverse_type_info);
167 }
168 }
169 Class type;
170 PrimitiveType.Kind kind;
171 GLvoid void_annotation = param.getAnnotation(GLvoid.class);
172 kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
173 if (Utils.getNIOBufferType(decl_type) != null)
174 type = getBufferTypeFromPrimitiveKind(kind);
175 else
176 type = getTypeFromPrimitiveKind(kind);
177 TypeInfo type_info = new TypeInfo(type, signedness, auto_type);
178 types.put(annotation_type, type_info);
179 multityped_result.add(type_info);
180 add_default_type = false;
181 }
182 }
183 if (add_default_type) {
184 TypeInfo default_type_info = getDefaultTypeInfo(decl_type);
185 Collection<TypeInfo> result = new ArrayList<TypeInfo>();
186 result.add(default_type_info);
187 return result;
188 } else
189 return multityped_result;
190 }
191
192 private static Map<ParameterDeclaration, Collection<TypeInfo>> getTypeInfoMap(TypeMap type_map, MethodDeclaration method) {
193 Map<ParameterDeclaration, Collection<TypeInfo>> map = new HashMap<ParameterDeclaration, Collection<TypeInfo>>();
194 for (ParameterDeclaration param : method.getParameters()) {
195 Collection<TypeInfo> types = getTypeInfos(type_map, param, param.getType());
196 map.put(param, types);
197 }
198 return map;
199 }
200
201 public static Collection<Map<ParameterDeclaration, TypeInfo>> getTypeInfoCrossProduct(TypeMap type_map, MethodDeclaration method) {
202 Collection<ParameterDeclaration> parameter_collection = method.getParameters();
203 ParameterDeclaration[] parameters = new ParameterDeclaration[parameter_collection.size()];
204 parameter_collection.toArray(parameters);
205 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product = new ArrayList<Map<ParameterDeclaration, TypeInfo>>();
206 getCrossProductRecursive(0, parameters, getTypeInfoMap(type_map, method),
207 new HashMap<ParameterDeclaration, TypeInfo>(), cross_product);
208 return cross_product;
209 }
210
211 private static void getCrossProductRecursive(int index, ParameterDeclaration[] parameters, Map<ParameterDeclaration,
212 Collection<TypeInfo>> typeinfos_map, Map<ParameterDeclaration, TypeInfo> current_instance,
213 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product) {
214 if (index == parameters.length) {
215 cross_product.add(current_instance);
216 return;
217 }
218 ParameterDeclaration param = parameters[index];
219 Collection<TypeInfo> typeinfos = typeinfos_map.get(param);
220 if (typeinfos != null) {
221 for (TypeInfo typeinfo : typeinfos) {
222 Map<ParameterDeclaration, TypeInfo> instance = new HashMap<ParameterDeclaration, TypeInfo>(current_instance);
223 instance.put(param, typeinfo);
224 getCrossProductRecursive(index + 1, parameters, typeinfos_map, instance, cross_product);
225 }
226 }
227 }
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 package org.lwjgl.util.generator;
33
34 /**
35 *
36 * The interface to the OpenAL/OpenGL specific generator behaviour
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: TypeMap.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
47
48 public interface TypeMap {
49 String getErrorCheckMethodName();
50 String getRegisterNativesFunctionName();
51 PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type);
52 String getTypedefPrefix();
53 void printNativeIncludes(PrintWriter writer);
54 Class getStringElementType();
55 Class[] getValidAnnotationTypes(Class type);
56 Class getVoidType();
57 String translateAnnotation(Class annotation_type);
58 Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind);
59 String getAutoTypeFromAnnotation(AnnotationMirror annotation);
60 Class getInverseType(Class type);
61 Signedness getSignednessFromType(Class type);
62 }
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;
33
34 /**
35 *
36 * A TypeVisitor that generates the native typedefs.
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3281 $
40 * $Id: TypedefsGenerator.java 3281 2010-03-12 21:55:13Z spasi $
41 */
42
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
47 import java.util.*;
48
49 public class TypedefsGenerator {
50 private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) {
51 TypeMirror return_type = method.getReturnType();
52 writer.print("typedef ");
53 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, method);
54 return_type.accept(translator);
55 writer.print(translator.getSignature());
56 writer.print(" (");
57 writer.print(type_map.getTypedefPrefix());
58 writer.print(" *" + Utils.getTypedefName(method) + ") (");
59 generateNativeTypedefsParameters(type_map, writer, method.getParameters());
60 writer.println(");");
61 }
62
63 private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection<ParameterDeclaration> params) {
64 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());
70 }
71 }
72 }
73
74 private static void generateNativeTypedefsParameter(TypeMap type_map, PrintWriter writer, ParameterDeclaration param) {
75 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
76 param.getType().accept(translator);
77 writer.print(translator.getSignature());
78 if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(StringList.class) != null)
79 writer.print("*");
80 writer.print(" " + param.getSimpleName());
81 }
82
83 public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
84 for (MethodDeclaration method : methods) {
85 if ( method.getAnnotation(Alternate.class) == null )
86 generateNativeTypedefs(type_map, writer, method);
87 }
88 }
89
90 }
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 * Various utility methods to the generator.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3299 $
39 * $Id: Utils.java 3299 2010-03-31 15:46:16Z spasi $
40 */
41
42 import java.io.PrintWriter;
43 import java.nio.Buffer;
44 import java.nio.ByteBuffer;
45 import java.util.*;
46
47 import com.sun.mirror.declaration.*;
48 import com.sun.mirror.type.PrimitiveType;
49 import com.sun.mirror.type.TypeMirror;
50
51 public class Utils {
52
53 public static final String TYPEDEF_POSTFIX = "PROC";
54 public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
55 public static final String FUNCTION_POINTER_POSTFIX = "_pointer";
56 public static final String CHECKS_CLASS_NAME = "GLChecks";
57 public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities";
58 public static final String STUB_INITIALIZER_NAME = "initNativeStubs";
59 public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
60 public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
61 public static final String RESULT_SIZE_NAME = "result_size";
62 public static final String RESULT_VAR_NAME = "__result";
63 public static final String CACHED_BUFFER_LENGTH_NAME = "length";
64 public static final String CACHED_BUFFER_NAME = "old_buffer";
65 private static final String OVERLOADED_METHOD_PREFIX = "n";
66
67 public static String getTypedefName(MethodDeclaration method) {
68 Alternate alt_annotation = method.getAnnotation(Alternate.class);
69 return (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + TYPEDEF_POSTFIX;
70 }
71
72 public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method) {
73 return getFunctionAddressName(interface_decl, method, false);
74 }
75
76 public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) {
77 Alternate alt_annotation = method.getAnnotation(Alternate.class);
78 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
79 return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX;
80 else
81 return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX;
82 }
83
84 public static boolean isFinal(InterfaceDeclaration d) {
85 Extension extension_annotation = d.getAnnotation(Extension.class);
86 return extension_annotation == null || extension_annotation.isFinal();
87 }
88
89 private static class AnnotationMirrorComparator implements Comparator<AnnotationMirror> {
90 public int compare(AnnotationMirror a1, AnnotationMirror a2) {
91 String n1 = a1.getAnnotationType().getDeclaration().getQualifiedName();
92 String n2 = a2.getAnnotationType().getDeclaration().getQualifiedName();
93 int result = n1.compareTo(n2);
94 return result;
95 }
96
97 public boolean equals(AnnotationMirror a1, AnnotationMirror a2) {
98 return compare(a1, a2) == 0;
99 }
100 }
101
102 public static Collection<AnnotationMirror> getSortedAnnotations(Collection<AnnotationMirror> annotations) {
103 List<AnnotationMirror> annotation_list = new ArrayList<AnnotationMirror>(annotations);
104 Collections.sort(annotation_list, new AnnotationMirrorComparator());
105 return annotation_list;
106 }
107
108 public static String getReferenceName(InterfaceDeclaration interface_decl, MethodDeclaration method, ParameterDeclaration param) {
109 return interface_decl.getSimpleName() + "_" + method.getSimpleName() + "_" + param.getSimpleName();
110 }
111
112 public static boolean isAddressableType(TypeMirror type) {
113 return isAddressableType(getJavaType(type));
114 }
115
116 public static boolean isAddressableType(Class type) {
117 return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type);
118 }
119
120 public static Class getJavaType(TypeMirror type_mirror) {
121 JavaTypeTranslator translator = new JavaTypeTranslator();
122 type_mirror.accept(translator);
123 return translator.getType();
124 }
125
126 private static boolean hasParameterMultipleTypes(ParameterDeclaration param) {
127 int num_native_annotations = 0;
128 for (AnnotationMirror annotation : param.getAnnotationMirrors())
129 if (NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null)
130 num_native_annotations++;
131 return num_native_annotations > 1;
132 }
133
134 public static boolean isParameterMultiTyped(ParameterDeclaration param) {
135 boolean result = Buffer.class.equals(Utils.getJavaType(param.getType()));
136 if (!result && hasParameterMultipleTypes(param))
137 throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types");
138 return result;
139 }
140
141 public static ParameterDeclaration findParameter(MethodDeclaration method, String name) {
142 for (ParameterDeclaration param : method.getParameters())
143 if (param.getSimpleName().equals(name))
144 return param;
145 throw new RuntimeException("Parameter " + name + " not found");
146 }
147
148 public static void printDocComment(PrintWriter writer, Declaration decl) {
149 String doc_comment = decl.getDocComment();
150 if (doc_comment != null) {
151 String tab = decl instanceof InterfaceDeclaration ? "" : "\t";
152 writer.println(tab + "/**");
153 StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n");
154 while (doc_lines.hasMoreTokens())
155 writer.println(tab + " * " + doc_lines.nextToken());
156 writer.println(tab + " */");
157 } else if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null )
158 writer.println("\t/** Overloads " + decl.getAnnotation(Alternate.class).value() + " */");
159 }
160
161 public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) {
162 for (AnnotationMirror annotation : param.getAnnotationMirrors())
163 if (NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null)
164 return annotation;
165 return null;
166 }
167
168 public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, MethodDeclaration method) {
169 for (ParameterDeclaration param : method.getParameters()) {
170 if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null ||
171 param.getAnnotation(Constant.class) != null)
172 return true;
173 }
174 return hasMethodBufferObjectParameter(method) || method.getAnnotation(Code.class) != null ||
175 method.getAnnotation(CachedResult.class) != null ||
176 (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) ||
177 context_specific;
178 }
179
180 public static String getNativeQualifiedName(String qualified_name) {
181 return qualified_name.replaceAll("\\.", "_");
182 }
183
184 public static String getQualifiedNativeMethodName(String qualified_class_name, String method_name) {
185 return "Java_" + getNativeQualifiedName(qualified_class_name) + "_" + method_name;
186 }
187
188 public static String getQualifiedNativeMethodName(String qualified_class_name, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
189 String method_name = getSimpleNativeMethodName(method, generate_error_checks, context_specific);
190 return getQualifiedNativeMethodName(qualified_class_name, method_name);
191 }
192
193 public static ParameterDeclaration getResultParameter(MethodDeclaration method) {
194 ParameterDeclaration result_param = null;
195 for (ParameterDeclaration param : method.getParameters()) {
196 if (param.getAnnotation(Result.class) != null) {
197 if (result_param != null)
198 throw new RuntimeException("Multiple parameters annotated with Result in method " + method);
199 result_param = param;
200 }
201 }
202 return result_param;
203 }
204
205 public static TypeMirror getMethodReturnType(MethodDeclaration method) {
206 TypeMirror result_type;
207 ParameterDeclaration result_param = getResultParameter(method);
208 if (result_param != null) {
209 result_type = result_param.getType();
210 } else
211 result_type = method.getReturnType();
212 return result_type;
213 }
214
215 public static String getMethodReturnType(MethodDeclaration method, GLreturn return_annotation, boolean buffer) {
216 ParameterDeclaration return_param = null;
217 for ( ParameterDeclaration param : method.getParameters() ) {
218 if ( param.getSimpleName().equals(return_annotation.value()) ) {
219 return_param = param;
220 break;
221 }
222 }
223 if ( return_param == null )
224 throw new RuntimeException("The @GLreturn parameter \"" + return_annotation.value() + "\" could not be found in method: " + method);
225
226 PrimitiveType.Kind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.getType()));
227 if ( return_param.getAnnotation(GLboolean.class) != null )
228 kind = PrimitiveType.Kind.BOOLEAN;
229
230 if ( kind == PrimitiveType.Kind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) )
231 return "String";
232 else {
233 final String type = JavaTypeTranslator.getPrimitiveClassFromKind(kind).getName();
234 return buffer ? Character.toUpperCase(type.charAt(0)) + type.substring(1) : type;
235 }
236 }
237
238 public static boolean needResultSize(MethodDeclaration method) {
239 return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoResultSize.class) == null;
240 }
241
242 public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) {
243 writer.print(size_parameter_name);
244 if (method.getAnnotation(CachedResult.class) != null) {
245 writer.print(", " + CACHED_BUFFER_NAME);
246 }
247 }
248
249 private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) {
250 Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
251 if (extension_annotation != null && !"".equals(extension_annotation.className())) {
252 return extension_annotation.className();
253 }
254 StringBuilder result = new StringBuilder();
255 for (int i = 0; i < opengl_name.length(); i++) {
256 int ch = opengl_name.codePointAt(i);
257 if (ch == '_') {
258 i++;
259 result.appendCodePoint(Character.toUpperCase(opengl_name.codePointAt(i)));
260 } else
261 result.appendCodePoint(ch);
262 }
263 return result.toString();
264 }
265
266 public static boolean hasMethodBufferObjectParameter(MethodDeclaration method) {
267 for (ParameterDeclaration param : method.getParameters()) {
268 if (param.getAnnotation(BufferObject.class) != null) {
269 return true;
270 }
271 }
272 return false;
273 }
274
275 public static String getQualifiedClassName(InterfaceDeclaration interface_decl) {
276 return interface_decl.getPackage().getQualifiedName() + "." + getSimpleClassName(interface_decl);
277 }
278
279 public static String getSimpleClassName(InterfaceDeclaration interface_decl) {
280 return getClassName(interface_decl, interface_decl.getSimpleName());
281 }
282
283 public static Class<?> getNIOBufferType(TypeMirror t) {
284 Class<?> param_type = getJavaType(t);
285 if (Buffer.class.isAssignableFrom(param_type))
286 return param_type;
287 else if ( param_type == CharSequence.class || param_type == CharSequence[].class )
288 return ByteBuffer.class;
289 else
290 return null;
291 }
292
293 public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
294 String method_name;
295 Alternate alt_annotation = method.getAnnotation(Alternate.class);
296 method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value();
297 if (isMethodIndirect(generate_error_checks, context_specific, method))
298 method_name = OVERLOADED_METHOD_PREFIX + method_name;
299 return method_name;
300 }
301
302 static boolean isReturnParameter(MethodDeclaration method, ParameterDeclaration param) {
303 GLreturn string_annotation = method.getAnnotation(GLreturn.class);
304 if ( string_annotation == null || !string_annotation.value().equals(param.getSimpleName()) )
305 return false;
306
307 if ( param.getAnnotation(OutParameter.class) == null )
308 throw new RuntimeException("The parameter specified in @GLreturn is not annotated with @OutParameter in method: " + method);
309
310 if ( param.getAnnotation(Check.class) != null )
311 throw new RuntimeException("The parameter specified in @GLreturn is annotated with @Check in method: " + method);
312
313 if ( param.getAnnotation(GLchar.class) != null && Utils.getJavaType(param.getType()).equals(ByteBuffer.class) && string_annotation.maxLength().length() == 0 )
314 throw new RuntimeException("The @GLreturn annotation is missing a maxLength parameter in method: " + method);
315
316 return true;
317 }
318
319 static String getStringOffset(MethodDeclaration method, ParameterDeclaration param) {
320 String offset = null;
321 for ( ParameterDeclaration p : method.getParameters() ) {
322 if ( param != null && p.getSimpleName().equals(param.getSimpleName()) )
323 break;
324
325 final Class type = Utils.getJavaType(p.getType());
326 if ( type.equals(CharSequence.class) ) {
327 if ( offset == null )
328 offset = p.getSimpleName() + ".length()";
329 else
330 offset += " + " + p.getSimpleName() + ".length()";
331 if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1";
332
333 } else if ( type.equals(CharSequence[].class) ) {
334 if ( offset == null )
335 offset = "APIUtils.getTotalLength(" + p.getSimpleName() + ")";
336 else
337 offset += " + APIUtils.getTotalLength(" + p.getSimpleName() + ")";
338 if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length";
339 }
340
341 }
342 return offset;
343 }
344
345 static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
346 final String return_type = getMethodReturnType(method, return_annotation, true);
347
348 if ( "String".equals(return_type) ) {
349 if ( !return_annotation.forceMaxLength() ) {
350 writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtils.getLengths();");
351 writer.print("\t\t");
352 }
353 writer.print("ByteBuffer " + return_annotation.value() + " = APIUtils.getBufferByte(" + return_annotation.maxLength());
354 /*
355 Params that use the return buffer will advance its position while filling it. When we return, the position will be
356 at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was
357 large enough to hold everything, so that no re-allocations happen while filling.
358 */
359 final String offset = getStringOffset(method, null);
360 if ( offset != null )
361 writer.print(" + " + offset);
362 writer.println(");");
363 } else {
364 final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type;
365 writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtils.getBuffer" + buffer_type + "(");
366 if ( "Byte".equals(buffer_type) )
367 writer.print('1');
368 writer.println(");");
369 }
370
371 writer.print("\t\t");
372 }
373
374 static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
375 final String return_type = getMethodReturnType(method, return_annotation, true);
376
377 if ( "String".equals(return_type) ) {
378 writer.print("\t\t" + return_annotation.value() + ".limit(");
379 final String offset = getStringOffset(method, null);
380 if ( offset != null)
381 writer.print(offset + " + ");
382 if ( return_annotation.forceMaxLength() )
383 writer.print(return_annotation.maxLength());
384 else
385 writer.print(return_annotation.value() + "_length.get(0)");
386 writer.println(");");
387 writer.println("\t\treturn APIUtils.getString(" + return_annotation.value() + ");");
388 } else {
389 writer.print("\t\treturn " + return_annotation.value() + ".get(0)");
390 if ( "Boolean".equals(return_type) )
391 writer.print(" == 1");
392 writer.println(";");
393 }
394 }
395
396 }
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.glu;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * Cylinder.java
37 *
38 *
39 * Created 23-dec-2003
40 * @author Erik Duijs
41 */
42 public class Cylinder extends Quadric {
43
44 /**
45 * Constructor for Cylinder.
46 */
47 public Cylinder() {
48 super();
49 }
50
51 /**
52 * draws a cylinder oriented along the z axis. The base of the
53 * cylinder is placed at z = 0, and the top at z=height. Like a sphere, a
54 * cylinder is subdivided around the z axis into slices, and along the z axis
55 * into stacks.
56 *
57 * Note that if topRadius is set to zero, then this routine will generate a
58 * cone.
59 *
60 * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then
61 * any generated normals point away from the z axis. Otherwise, they point
62 * toward the z axis.
63 *
64 * If texturing is turned on (with glu.quadricTexture), then texture
65 * coordinates are generated so that t ranges linearly from 0.0 at z = 0 to
66 * 1.0 at z = height, and s ranges from 0.0 at the +y axis, to 0.25 at the +x
67 * axis, to 0.5 at the -y axis, to 0.75 at the -x axis, and back to 1.0 at the
68 * +y axis.
69 *
70 * @param baseRadius Specifies the radius of the cylinder at z = 0.
71 * @param topRadius Specifies the radius of the cylinder at z = height.
72 * @param height Specifies the height of the cylinder.
73 * @param slices Specifies the number of subdivisions around the z axis.
74 * @param stacks Specifies the number of subdivisions along the z axis.
75 */
76 public void draw(float baseRadius, float topRadius, float height, int slices, int stacks) {
77
78 float da, r, dr, dz;
79 float x, y, z, nz, nsign;
80 int i, j;
81
82 if (super.orientation == GLU.GLU_INSIDE) {
83 nsign = -1.0f;
84 } else {
85 nsign = 1.0f;
86 }
87
88 da = 2.0f * GLU.PI / slices;
89 dr = (topRadius - baseRadius) / stacks;
90 dz = height / stacks;
91 nz = (baseRadius - topRadius) / height;
92 // Z component of normal vectors
93
94 if (super.drawStyle == GLU.GLU_POINT) {
95 GL11.glBegin(GL11.GL_POINTS);
96 for (i = 0; i < slices; i++) {
97 x = cos((i * da));
98 y = sin((i * da));
99 normal3f(x * nsign, y * nsign, nz * nsign);
100
101 z = 0.0f;
102 r = baseRadius;
103 for (j = 0; j <= stacks; j++) {
104 GL11.glVertex3f((x * r), (y * r), z);
105 z += dz;
106 r += dr;
107 }
108 }
109 GL11.glEnd();
110 } else if (super.drawStyle == GLU.GLU_LINE || super.drawStyle == GLU.GLU_SILHOUETTE) {
111 // Draw rings
112 if (super.drawStyle == GLU.GLU_LINE) {
113 z = 0.0f;
114 r = baseRadius;
115 for (j = 0; j <= stacks; j++) {
116 GL11.glBegin(GL11.GL_LINE_LOOP);
117 for (i = 0; i < slices; i++) {
118 x = cos((i * da));
119 y = sin((i * da));
120 normal3f(x * nsign, y * nsign, nz * nsign);
121 GL11.glVertex3f((x * r), (y * r), z);
122 }
123 GL11.glEnd();
124 z += dz;
125 r += dr;
126 }
127 } else {
128 // draw one ring at each end
129 if (baseRadius != 0.0) {
130 GL11.glBegin(GL11.GL_LINE_LOOP);
131 for (i = 0; i < slices; i++) {
132 x = cos((i * da));
133 y = sin((i * da));
134 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);
139 for (i = 0; i < slices; i++) {
140 x = cos((i * da));
141 y = sin((i * da));
142 normal3f(x * nsign, y * nsign, nz * nsign);
143 GL11.glVertex3f((x * topRadius), (y * topRadius), height);
144 }
145 GL11.glEnd();
146 }
147 }
148 // draw length lines
149 GL11.glBegin(GL11.GL_LINES);
150 for (i = 0; i < slices; i++) {
151 x = cos((i * da));
152 y = sin((i * da));
153 normal3f(x * nsign, y * nsign, nz * nsign);
154 GL11.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
155 GL11.glVertex3f((x * topRadius), (y * topRadius), (height));
156 }
157 GL11.glEnd();
158 } else if (super.drawStyle == GLU.GLU_FILL) {
159 float ds = 1.0f / slices;
160 float dt = 1.0f / stacks;
161 float t = 0.0f;
162 z = 0.0f;
163 r = baseRadius;
164 for (j = 0; j < stacks; j++) {
165 float s = 0.0f;
166 GL11.glBegin(GL11.GL_QUAD_STRIP);
167 for (i = 0; i <= slices; i++) {
168 if (i == slices) {
169 x = sin(0.0f);
170 y = cos(0.0f);
171 } else {
172 x = sin((i * da));
173 y = cos((i * da));
174 }
175 if (nsign == 1.0f) {
176 normal3f((x * nsign), (y * nsign), (nz * nsign));
177 TXTR_COORD(s, t);
178 GL11.glVertex3f((x * r), (y * r), z);
179 normal3f((x * nsign), (y * nsign), (nz * nsign));
180 TXTR_COORD(s, t + dt);
181 GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
182 } else {
183 normal3f(x * nsign, y * nsign, nz * nsign);
184 TXTR_COORD(s, t);
185 GL11.glVertex3f((x * r), (y * r), z);
186 normal3f(x * nsign, y * nsign, nz * nsign);
187 TXTR_COORD(s, t + dt);
188 GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
189 }
190 s += ds;
191 } // for slices
192 GL11.glEnd();
193 r += dr;
194 t += dt;
195 z += dz;
196 } // for stacks
197 }
198 }
199 }
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.glu;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * Disk.java
37 *
38 *
39 * Created 23-dec-2003
40 * @author Erik Duijs
41 */
42 public class Disk extends Quadric {
43
44 /**
45 * Constructor for Disk.
46 */
47 public Disk() {
48 super();
49 }
50
51 /**
52 * renders a disk on the z = 0 plane. The disk has a radius of
53 * outerRadius, and contains a concentric circular hole with a radius of
54 * innerRadius. If innerRadius is 0, then no hole is generated. The disk is
55 * subdivided around the z axis into slices (like pizza slices), and also
56 * about the z axis into rings (as specified by slices and loops,
57 * respectively).
58 *
59 * With respect to orientation, the +z side of the disk is considered to be
60 * "outside" (see glu.quadricOrientation). This means that if the orientation
61 * is set to GLU.OUTSIDE, then any normals generated point along the +z axis.
62 * Otherwise, they point along the -z axis.
63 *
64 * If texturing is turned on (with glu.quadricTexture), texture coordinates are
65 * generated linearly such that where r=outerRadius, the value at (r, 0, 0) is
66 * (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), and at
67 * (0, -r, 0) it is (0.5, 0).
68 */
69 public void draw(float innerRadius, float outerRadius, int slices, int loops)
70 {
71 float da, dr;
72
73 /* 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);
77 }
78 else {
79 GL11.glNormal3f(0.0f, 0.0f, -1.0f);
80 }
81 }
82
83 da = 2.0f * GLU.PI / slices;
84 dr = (outerRadius - innerRadius) / loops;
85
86 switch (super.drawStyle) {
87 case GLU.GLU_FILL:
88 {
89 /* texture of a gluDisk is a cut out of the texture unit square
90 * x, y in [-outerRadius, +outerRadius]; s, t in [0, 1]
91 * (linear mapping)
92 */
93 float dtc = 2.0f * outerRadius;
94 float sa, ca;
95 float r1 = innerRadius;
96 int l;
97 for (l = 0; l < loops; l++) {
98 float r2 = r1 + dr;
99 if (super.orientation == GLU.GLU_OUTSIDE) {
100 int s;
101 GL11.glBegin(GL11.GL_QUAD_STRIP);
102 for (s = 0; s <= slices; s++) {
103 float a;
104 if (s == slices)
105 a = 0.0f;
106 else
107 a = s * da;
108 sa = sin(a);
109 ca = cos(a);
110 TXTR_COORD(0.5f + sa * r2 / dtc, 0.5f + ca * r2 / dtc);
111 GL11.glVertex2f(r2 * sa, r2 * ca);
112 TXTR_COORD(0.5f + sa * r1 / dtc, 0.5f + ca * r1 / dtc);
113 GL11.glVertex2f(r1 * sa, r1 * ca);
114 }
115 GL11.glEnd();
116 }
117 else {
118 int s;
119 GL11.glBegin(GL11.GL_QUAD_STRIP);
120 for (s = slices; s >= 0; s--) {
121 float a;
122 if (s == slices)
123 a = 0.0f;
124 else
125 a = s * da;
126 sa = sin(a);
127 ca = cos(a);
128 TXTR_COORD(0.5f - sa * r2 / dtc, 0.5f + ca * r2 / dtc);
129 GL11.glVertex2f(r2 * sa, r2 * ca);
130 TXTR_COORD(0.5f - sa * r1 / dtc, 0.5f + ca * r1 / dtc);
131 GL11.glVertex2f(r1 * sa, r1 * ca);
132 }
133 GL11.glEnd();
134 }
135 r1 = r2;
136 }
137 break;
138 }
139 case GLU.GLU_LINE:
140 {
141 int l, s;
142 /* draw loops */
143 for (l = 0; l <= loops; l++) {
144 float r = innerRadius + l * dr;
145 GL11.glBegin(GL11.GL_LINE_LOOP);
146 for (s = 0; s < slices; s++) {
147 float a = s * da;
148 GL11.glVertex2f(r * sin(a), r * cos(a));
149 }
150 GL11.glEnd();
151 }
152 /* draw spokes */
153 for (s = 0; s < slices; s++) {
154 float a = s * da;
155 float x = sin(a);
156 float y = cos(a);
157 GL11.glBegin(GL11.GL_LINE_STRIP);
158 for (l = 0; l <= loops; l++) {
159 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:
167 {
168 int s;
169 GL11.glBegin(GL11.GL_POINTS);
170 for (s = 0; s < slices; s++) {
171 float a = s * da;
172 float x = sin(a);
173 float y = cos(a);
174 int l;
175 for (l = 0; l <= loops; l++) {
176 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:
184 {
185 if (innerRadius != 0.0) {
186 float a;
187 GL11.glBegin(GL11.GL_LINE_LOOP);
188 for (a = 0.0f; a < 2.0 * GLU.PI; a += da) {
189 float x = innerRadius * sin(a);
190 float y = innerRadius * cos(a);
191 GL11.glVertex2f(x, y);
192 }
193 GL11.glEnd();
194 }
195 {
196 float a;
197 GL11.glBegin(GL11.GL_LINE_LOOP);
198 for (a = 0; a < 2.0f * GLU.PI; a += da) {
199 float x = outerRadius * sin(a);
200 float y = outerRadius * cos(a);
201 GL11.glVertex2f(x, y);
202 }
203 GL11.glEnd();
204 }
205 break;
206 }
207 default:
208 return;
209 }
210 }
211
212 }
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.glu;
32
33 import java.nio.ByteBuffer;
34 import java.nio.FloatBuffer;
35 import java.nio.IntBuffer;
36
37 import org.lwjgl.opengl.GL11;
38 import org.lwjgl.opengl.Util;
39 import org.lwjgl.util.glu.tessellation.GLUtessellatorImpl;
40
41 /**
42 * GLU.java
43 *
44 *
45 * Created 23-dec-2003
46 * @author Erik Duijs
47 */
48 public class GLU {
49 static final float PI = (float)Math.PI;
50
51 /* Errors: (return value 0 = no error) */
52 public static final int GLU_INVALID_ENUM = 100900;
53 public static final int GLU_INVALID_VALUE = 100901;
54 public static final int GLU_OUT_OF_MEMORY = 100902;
55 public static final int GLU_INCOMPATIBLE_GL_VERSION = 100903;
56
57 /* StringName */
58 public static final int GLU_VERSION = 100800;
59 public static final int GLU_EXTENSIONS = 100801;
60
61 /* Boolean */
62 public static final boolean GLU_TRUE = true;
63 public static final boolean GLU_FALSE = false;
64
65
66 /**** Quadric constants ****/
67
68 /* QuadricNormal */
69 public static final int GLU_SMOOTH = 100000;
70 public static final int GLU_FLAT = 100001;
71 public static final int GLU_NONE = 100002;
72
73 /* QuadricDrawStyle */
74 public static final int GLU_POINT = 100010;
75 public static final int GLU_LINE = 100011;
76 public static final int GLU_FILL = 100012;
77 public static final int GLU_SILHOUETTE = 100013;
78
79 /* QuadricOrientation */
80 public static final int GLU_OUTSIDE = 100020;
81 public static final int GLU_INSIDE = 100021;
82
83 /* Callback types: */
84 /* ERROR = 100103 */
85
86
87 /**** Tesselation constants ****/
88
89 public static final double GLU_TESS_MAX_COORD = 1.0e150;
90 public static final double TESS_MAX_COORD = 1.0e150;
91
92 /* TessProperty */
93 public static final int GLU_TESS_WINDING_RULE = 100140;
94 public static final int GLU_TESS_BOUNDARY_ONLY = 100141;
95 public static final int GLU_TESS_TOLERANCE = 100142;
96
97 /* TessWinding */
98 public static final int GLU_TESS_WINDING_ODD = 100130;
99 public static final int GLU_TESS_WINDING_NONZERO = 100131;
100 public static final int GLU_TESS_WINDING_POSITIVE = 100132;
101 public static final int GLU_TESS_WINDING_NEGATIVE = 100133;
102 public static final int GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
103
104 /* TessCallback */
105 public static final int GLU_TESS_BEGIN = 100100; /* void (CALLBACK*)(GLenum type) */
106 public static final int GLU_TESS_VERTEX = 100101; /* void (CALLBACK*)(void *data) */
107 public static final int GLU_TESS_END = 100102; /* void (CALLBACK*)(void) */
108 public static final int GLU_TESS_ERROR = 100103; /* void (CALLBACK*)(GLenum errno) */
109 public static final int GLU_TESS_EDGE_FLAG = 100104; /* void (CALLBACK*)(GLboolean boundaryEdge) */
110 public static final int GLU_TESS_COMBINE = 100105; /* void (CALLBACK*)(GLdouble coords[3],
111 void *data[4],
112 GLfloat weight[4],
113 void **dataOut) */
114 public static final int GLU_TESS_BEGIN_DATA = 100106; /* void (CALLBACK*)(GLenum type,
115 void *polygon_data) */
116 public static final int GLU_TESS_VERTEX_DATA = 100107; /* void (CALLBACK*)(void *data,
117 void *polygon_data) */
118 public static final int GLU_TESS_END_DATA = 100108; /* void (CALLBACK*)(void *polygon_data) */
119 public static final int GLU_TESS_ERROR_DATA = 100109; /* void (CALLBACK*)(GLenum errno,
120 void *polygon_data) */
121 public static final int GLU_TESS_EDGE_FLAG_DATA = 100110; /* void (CALLBACK*)(GLboolean boundaryEdge,
122 void *polygon_data) */
123 public static final int GLU_TESS_COMBINE_DATA = 100111; /* void (CALLBACK*)(GLdouble coords[3],
124 void *data[4],
125 GLfloat weight[4],
126 void **dataOut,
127 void *polygon_data) */
128
129 /* TessError */
130 public static final int GLU_TESS_ERROR1 = 100151;
131 public static final int GLU_TESS_ERROR2 = 100152;
132 public static final int GLU_TESS_ERROR3 = 100153;
133 public static final int GLU_TESS_ERROR4 = 100154;
134 public static final int GLU_TESS_ERROR5 = 100155;
135 public static final int GLU_TESS_ERROR6 = 100156;
136 public static final int GLU_TESS_ERROR7 = 100157;
137 public static final int GLU_TESS_ERROR8 = 100158;
138
139 public static final int GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
140 public static final int GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
141 public static final int GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
142 public static final int GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
143 public static final int GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
144 public static final int GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
145
146 /**** NURBS constants ****/
147
148 /* NurbsProperty */
149 public static final int GLU_AUTO_LOAD_MATRIX = 100200;
150 public static final int GLU_CULLING = 100201;
151 public static final int GLU_SAMPLING_TOLERANCE = 100203;
152 public static final int GLU_DISPLAY_MODE = 100204;
153 public static final int GLU_PARAMETRIC_TOLERANCE = 100202;
154 public static final int GLU_SAMPLING_METHOD = 100205;
155 public static final int GLU_U_STEP = 100206;
156 public static final int GLU_V_STEP = 100207;
157
158 /* NurbsSampling */
159 public static final int GLU_PATH_LENGTH = 100215;
160 public static final int GLU_PARAMETRIC_ERROR = 100216;
161 public static final int GLU_DOMAIN_DISTANCE = 100217;
162
163
164 /* NurbsTrim */
165 public static final int GLU_MAP1_TRIM_2 = 100210;
166 public static final int GLU_MAP1_TRIM_3 = 100211;
167
168 /* NurbsDisplay */
169 /* FILL = 100012 */
170 public static final int GLU_OUTLINE_POLYGON = 100240;
171 public static final int GLU_OUTLINE_PATCH = 100241;
172
173 /* NurbsCallback */
174 /* ERROR = 100103 */
175
176 /* NurbsErrors */
177 public static final int GLU_NURBS_ERROR1 = 100251;
178 public static final int GLU_NURBS_ERROR2 = 100252;
179 public static final int GLU_NURBS_ERROR3 = 100253;
180 public static final int GLU_NURBS_ERROR4 = 100254;
181 public static final int GLU_NURBS_ERROR5 = 100255;
182 public static final int GLU_NURBS_ERROR6 = 100256;
183 public static final int GLU_NURBS_ERROR7 = 100257;
184 public static final int GLU_NURBS_ERROR8 = 100258;
185 public static final int GLU_NURBS_ERROR9 = 100259;
186 public static final int GLU_NURBS_ERROR10 = 100260;
187 public static final int GLU_NURBS_ERROR11 = 100261;
188 public static final int GLU_NURBS_ERROR12 = 100262;
189 public static final int GLU_NURBS_ERROR13 = 100263;
190 public static final int GLU_NURBS_ERROR14 = 100264;
191 public static final int GLU_NURBS_ERROR15 = 100265;
192 public static final int GLU_NURBS_ERROR16 = 100266;
193 public static final int GLU_NURBS_ERROR17 = 100267;
194 public static final int GLU_NURBS_ERROR18 = 100268;
195 public static final int GLU_NURBS_ERROR19 = 100269;
196 public static final int GLU_NURBS_ERROR20 = 100270;
197 public static final int GLU_NURBS_ERROR21 = 100271;
198 public static final int GLU_NURBS_ERROR22 = 100272;
199 public static final int GLU_NURBS_ERROR23 = 100273;
200 public static final int GLU_NURBS_ERROR24 = 100274;
201 public static final int GLU_NURBS_ERROR25 = 100275;
202 public static final int GLU_NURBS_ERROR26 = 100276;
203 public static final int GLU_NURBS_ERROR27 = 100277;
204 public static final int GLU_NURBS_ERROR28 = 100278;
205 public static final int GLU_NURBS_ERROR29 = 100279;
206 public static final int GLU_NURBS_ERROR30 = 100280;
207 public static final int GLU_NURBS_ERROR31 = 100281;
208 public static final int GLU_NURBS_ERROR32 = 100282;
209 public static final int GLU_NURBS_ERROR33 = 100283;
210 public static final int GLU_NURBS_ERROR34 = 100284;
211 public static final int GLU_NURBS_ERROR35 = 100285;
212 public static final int GLU_NURBS_ERROR36 = 100286;
213 public static final int GLU_NURBS_ERROR37 = 100287;
214
215 /* Contours types -- obsolete! */
216 public static final int GLU_CW = 100120;
217 public static final int GLU_CCW = 100121;
218 public static final int GLU_INTERIOR = 100122;
219 public static final int GLU_EXTERIOR = 100123;
220 public static final int GLU_UNKNOWN = 100124;
221
222 /* Names without "TESS_" prefix */
223 public static final int GLU_BEGIN = GLU_TESS_BEGIN;
224 public static final int GLU_VERTEX = GLU_TESS_VERTEX;
225 public static final int GLU_END = GLU_TESS_END;
226 public static final int GLU_ERROR = GLU_TESS_ERROR;
227 public static final int GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
228
229 /**
230 * Method gluLookAt
231 * @param eyex
232 * @param eyey
233 * @param eyez
234 * @param centerx
235 * @param centery
236 * @param centerz
237 * @param upx
238 * @param upy
239 * @param upz
240 */
241 public static void gluLookAt(
242 float eyex,
243 float eyey,
244 float eyez,
245 float centerx,
246 float centery,
247 float centerz,
248 float upx,
249 float upy,
250 float upz) {
251
252 Project.gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);
253 }
254
255 /**
256 * Method gluOrtho2D
257 * @param left
258 * @param right
259 * @param bottom
260 * @param top
261 */
262 public static void gluOrtho2D(
263 float left,
264 float right,
265 float bottom,
266 float top) {
267
268 GL11.glOrtho(left, right, bottom, top, -1.0, 1.0);
269 }
270
271 /**
272 * Method gluPerspective
273 * @param fovy
274 * @param aspect
275 * @param zNear
276 * @param zFar
277 */
278 public static void gluPerspective(
279 float fovy,
280 float aspect,
281 float zNear,
282 float zFar) {
283
284 Project.gluPerspective(fovy, aspect, zNear, zFar);
285 }
286
287 /**
288 * Method gluProject
289 * @param objx
290 * @param objy
291 * @param objz
292 * @param modelMatrix
293 * @param projMatrix
294 * @param viewport
295 * @param win_pos
296 */
297 public static boolean gluProject(float objx, float objy, float objz,
298 FloatBuffer modelMatrix,
299 FloatBuffer projMatrix,
300 IntBuffer viewport,
301 FloatBuffer win_pos)
302 {
303 return Project.gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, win_pos);
304 }
305
306 /**
307 * Method gluUnproject
308 * @param winx
309 * @param winy
310 * @param winz
311 * @param modelMatrix
312 * @param projMatrix
313 * @param viewport
314 * @param obj_pos
315 */
316 public static boolean gluUnProject(float winx, float winy, float winz,
317 FloatBuffer modelMatrix,
318 FloatBuffer projMatrix,
319 IntBuffer viewport,
320 FloatBuffer obj_pos)
321 {
322 return Project.gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, obj_pos);
323 }
324
325 /**
326 * Method gluPickMatrix
327 * @param x
328 * @param y
329 * @param width
330 * @param height
331 * @param viewport
332 */
333 public static void gluPickMatrix(
334 float x,
335 float y,
336 float width,
337 float height,
338 IntBuffer viewport) {
339
340 Project.gluPickMatrix(x, y, width, height, viewport);
341 }
342
343 /**
344 * Method gluGetString.
345 * @param name
346 * @return String
347 */
348 public static String gluGetString(int name) {
349 return Registry.gluGetString(name);
350 }
351
352 /**
353 * Method gluCheckExtension.
354 * @param extName
355 * @param extString
356 * @return boolean
357 */
358 public static boolean gluCheckExtension(String extName, String extString) {
359 return Registry.gluCheckExtension(extName, extString);
360 }
361
362 /**
363 * Method gluBuild2DMipmaps
364 * @param target
365 * @param components
366 * @param width
367 * @param height
368 * @param format
369 * @param type
370 * @param data
371 * @return int
372 */
373 public static int gluBuild2DMipmaps(
374 int target,
375 int components,
376 int width,
377 int height,
378 int format,
379 int type,
380 ByteBuffer data) {
381
382 return MipMap.gluBuild2DMipmaps(target, components, width, height, format, type, data);
383 }
384
385 /**
386 * Method gluScaleImage.
387 * @param format
388 * @param widthIn
389 * @param heightIn
390 * @param typeIn
391 * @param dataIn
392 * @param widthOut
393 * @param heightOut
394 * @param typeOut
395 * @param dataOut
396 * @return int
397 */
398 public static int gluScaleImage(
399 int format,
400 int widthIn,
401 int heightIn,
402 int typeIn,
403 ByteBuffer dataIn,
404 int widthOut,
405 int heightOut,
406 int typeOut,
407 ByteBuffer dataOut) {
408
409 return MipMap.gluScaleImage(format, widthIn, heightIn, typeIn, dataIn, widthOut, heightOut, typeOut, dataOut);
410 }
411
412 public static String gluErrorString(int error_code) {
413 switch (error_code) {
414 case GLU.GLU_INVALID_ENUM:
415 return "Invalid enum (glu)";
416 case GLU.GLU_INVALID_VALUE:
417 return "Invalid value (glu)";
418 case GLU.GLU_OUT_OF_MEMORY:
419 return "Out of memory (glu)";
420 default:
421 return Util.translateGLErrorString(error_code);
422 }
423 }
424
425 public static GLUtessellator gluNewTess() {
426 return new GLUtessellatorImpl();
427 }
428 }
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.glu;
33
34 public interface GLUtessellator {
35
36 public abstract void gluDeleteTess();
37
38 public abstract void gluTessProperty(int which, double value);
39
40 /* Returns tessellator property */
41 public abstract void gluGetTessProperty(int which, double[] value,
42 int value_offset); /* gluGetTessProperty() */
43
44 public abstract void gluTessNormal(double x, double y, double z);
45
46 public abstract void gluTessCallback(int which,
47 GLUtessellatorCallback aCallback);
48
49 public abstract void gluTessVertex(double[] coords, int coords_offset,
50 Object vertexData);
51
52 public abstract void gluTessBeginPolygon(Object data);
53
54 public abstract void gluTessBeginContour();
55
56 public abstract void gluTessEndContour();
57
58 public abstract void gluTessEndPolygon();
59
60 /*******************************************************/
61
62 /* Obsolete calls -- for backward compatibility */
63
64 public abstract void gluBeginPolygon();
65
66 /*ARGSUSED*/
67 public abstract void gluNextContour(int type);
68
69 public abstract void gluEndPolygon();
70
71 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu;
85
86 /**
87 * <b>GLUtessellatorCallback</b> interface provides methods that the user will
88 * override to define the callbacks for a tessellation object.
89 *
90 * @author Eric Veach, July 1994
91 * @author Java Port: Pepijn Van Eeckhoudt, July 2003
92 * @author Java Port: Nathan Parker Burg, August 2003
93 */
94 public interface GLUtessellatorCallback {
95 /**
96 * The <b>begin</b> callback method is invoked like
97 * {@link javax.media.opengl.GL#glBegin glBegin} to indicate the start of a
98 * (triangle) primitive. The method takes a single argument of type int. If
99 * the <b>GLU_TESS_BOUNDARY_ONLY</b> property is set to <b>GL_FALSE</b>, then
100 * the argument is set to either <b>GL_TRIANGLE_FAN</b>,
101 * <b>GL_TRIANGLE_STRIP</b>, or <b>GL_TRIANGLES</b>. If the
102 * <b>GLU_TESS_BOUNDARY_ONLY</b> property is set to <b>GL_TRUE</b>, then the
103 * argument will be set to <b>GL_LINE_LOOP</b>.
104 *
105 * @param type
106 * Specifics the type of begin/end pair being defined. The following
107 * values are valid: <b>GL_TRIANGLE_FAN</b>, <b>GL_TRIANGLE_STRIP</b>,
108 * <b>GL_TRIANGLES</b> or <b>GL_LINE_LOOP</b>.
109 *
110 * @see GLU#gluTessCallback gluTessCallback
111 * @see #end end
112 * @see #begin begin
113 */
114 public void begin(int type);
115
116 /**
117 * The same as the {@link #begin begin} callback method except that
118 * it takes an additional reference argument. This reference is
119 * identical to the opaque reference provided when {@link
120 * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
121 *
122 * @param type
123 * Specifics the type of begin/end pair being defined. The following
124 * values are valid: <b>GL_TRIANGLE_FAN</b>, <b>GL_TRIANGLE_STRIP</b>,
125 * <b>GL_TRIANGLES</b> or <b>GL_LINE_LOOP</b>.
126 * @param polygonData
127 * Specifics a reference to user-defined data.
128 *
129 * @see GLU#gluTessCallback gluTessCallback
130 * @see #endData endData
131 * @see #begin begin
132 */
133 public void beginData(int type, Object polygonData);
134
135
136 /**
137 * The <b>edgeFlag</b> callback method is similar to
138 * {@link javax.media.opengl.GL#glEdgeFlag glEdgeFlag}. The method takes
139 * a single boolean boundaryEdge that indicates which edges lie on the
140 * polygon boundary. If the boundaryEdge is <b>GL_TRUE</b>, then each vertex
141 * that follows begins an edge that lies on the polygon boundary, that is,
142 * an edge that separates an interior region from an exterior one. If the
143 * boundaryEdge is <b>GL_FALSE</b>, then each vertex that follows begins an
144 * edge that lies in the polygon interior. The edge flag callback (if
145 * defined) is invoked before the first vertex callback.<P>
146 *
147 * Since triangle fans and triangle strips do not support edge flags, the
148 * begin callback is not called with <b>GL_TRIANGLE_FAN</b> or
149 * <b>GL_TRIANGLE_STRIP</b> if a non-null edge flag callback is provided.
150 * (If the callback is initialized to null, there is no impact on
151 * performance). Instead, the fans and strips are converted to independent
152 * triangles.
153 *
154 * @param boundaryEdge
155 * Specifics which edges lie on the polygon boundary.
156 *
157 * @see GLU#gluTessCallback gluTessCallback
158 * @see #edgeFlagData edgeFlagData
159 */
160 public void edgeFlag(boolean boundaryEdge);
161
162
163 /**
164 * The same as the {@link #edgeFlag edgeFlage} callback method
165 * except that it takes an additional reference argument. This
166 * reference is identical to the opaque reference provided when
167 * {@link GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
168 *
169 * @param boundaryEdge
170 * Specifics which edges lie on the polygon boundary.
171 * @param polygonData
172 * Specifics a reference to user-defined data.
173 *
174 * @see GLU#gluTessCallback gluTessCallback
175 * @see #edgeFlag edgeFlag
176 */
177 public void edgeFlagData(boolean boundaryEdge, Object polygonData);
178
179
180 /**
181 * The <b>vertex</b> callback method is invoked between the {@link
182 * #begin begin} and {@link #end end} callback methods. It is
183 * similar to {@link javax.media.opengl.GL#glVertex3f glVertex3f},
184 * and it defines the vertices of the triangles created by the
185 * tessellation process. The method takes a reference as its only
186 * argument. This reference is identical to the opaque reference
187 * provided by the user when the vertex was described (see {@link
188 * GLU#gluTessVertex gluTessVertex}).
189 *
190 * @param vertexData
191 * Specifics a reference to the vertices of the triangles created
192 * byt the tessellatin process.
193 *
194 * @see GLU#gluTessCallback gluTessCallback
195 * @see #vertexData vertexData
196 */
197 public void vertex(Object vertexData);
198
199
200 /**
201 * The same as the {@link #vertex vertex} callback method except
202 * that it takes an additional reference argument. This reference is
203 * identical to the opaque reference provided when {@link
204 * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
205 *
206 * @param vertexData
207 * Specifics a reference to the vertices of the triangles created
208 * byt the tessellatin process.
209 * @param polygonData
210 * Specifics a reference to user-defined data.
211 *
212 * @see GLU#gluTessCallback gluTessCallback
213 * @see #vertex vertex
214 */
215 public void vertexData(Object vertexData, Object polygonData);
216
217
218 /**
219 * The end callback serves the same purpose as
220 * {@link javax.media.opengl.GL#glEnd glEnd}. It indicates the end of a
221 * primitive and it takes no arguments.
222 *
223 * @see GLU#gluTessCallback gluTessCallback
224 * @see #begin begin
225 * @see #endData endData
226 */
227 public void end();
228
229
230 /**
231 * The same as the {@link #end end} callback method except that it
232 * takes an additional reference argument. This reference is
233 * identical to the opaque reference provided when {@link
234 * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
235 *
236 * @param polygonData
237 * Specifics a reference to user-defined data.
238 *
239 * @see GLU#gluTessCallback gluTessCallback
240 * @see #beginData beginData
241 * @see #end end
242 */
243 public void endData(Object polygonData);
244
245
246 /**
247 * The <b>combine</b> callback method is called to create a new vertex when
248 * the tessellation detects an intersection, or wishes to merge features. The
249 * method takes four arguments: an array of three elements each of type
250 * double, an array of four references, an array of four elements each of
251 * type float, and a reference to a reference.<P>
252 *
253 * The vertex is defined as a linear combination of up to four existing
254 * vertices, stored in <i>data</i>. The coefficients of the linear combination
255 * are given by <i>weight</i>; these weights always add up to 1. All vertex
256 * pointers are valid even when some of the weights are 0. <i>coords</i> gives
257 * the location of the new vertex.<P>
258 *
259 * The user must allocate another vertex, interpolate parameters using
260 * <i>data</i> and <i>weight</i>, and return the new vertex pointer in
261 * <i>outData</i>. This handle is supplied during rendering callbacks. The
262 * user is responsible for freeing the memory some time after
263 * {@link GLU#gluTessEndPolygon gluTessEndPolygon} is
264 * called.<P>
265 *
266 * For example, if the polygon lies in an arbitrary plane in 3-space, and a
267 * color is associated with each vertex, the <b>GLU_TESS_COMBINE</b>
268 * callback might look like this:
269 * </UL>
270 * <PRE>
271 * void myCombine(double[] coords, Object[] data,
272 * float[] weight, Object[] outData)
273 * {
274 * MyVertex newVertex = new MyVertex();
275 *
276 * newVertex.x = coords[0];
277 * newVertex.y = coords[1];
278 * newVertex.z = coords[2];
279 * newVertex.r = weight[0]*data[0].r +
280 * weight[1]*data[1].r +
281 * weight[2]*data[2].r +
282 * weight[3]*data[3].r;
283 * newVertex.g = weight[0]*data[0].g +
284 * weight[1]*data[1].g +
285 * weight[2]*data[2].g +
286 * weight[3]*data[3].g;
287 * newVertex.b = weight[0]*data[0].b +
288 * weight[1]*data[1].b +
289 * weight[2]*data[2].b +
290 * weight[3]*data[3].b;
291 * newVertex.a = weight[0]*data[0].a +
292 * weight[1]*data[1].a +
293 * weight[2]*data[2].a +
294 * weight[3]*data[3].a;
295 * outData = newVertex;
296 * }</PRE>
297 *
298 * @param coords
299 * Specifics the location of the new vertex.
300 * @param data
301 * Specifics the vertices used to create the new vertex.
302 * @param weight
303 * Specifics the weights used to create the new vertex.
304 * @param outData
305 * Reference user the put the coodinates of the new vertex.
306 *
307 * @see GLU#gluTessCallback gluTessCallback
308 * @see #combineData combineData
309 */
310 public void combine(double[] coords, Object[] data,
311 float[] weight, Object[] outData);
312
313
314 /**
315 * The same as the {@link #combine combine} callback method except
316 * that it takes an additional reference argument. This reference is
317 * identical to the opaque reference provided when {@link
318 * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
319 *
320 * @param coords
321 * Specifics the location of the new vertex.
322 * @param data
323 * Specifics the vertices used to create the new vertex.
324 * @param weight
325 * Specifics the weights used to create the new vertex.
326 * @param outData
327 * Reference user the put the coodinates of the new vertex.
328 * @param polygonData
329 * Specifics a reference to user-defined data.
330 *
331 * @see GLU#gluTessCallback gluTessCallback
332 * @see #combine combine
333 */
334 public void combineData(double[] coords, Object[] data,
335 float[] weight, Object[] outData,
336 Object polygonData);
337
338
339 /**
340 * The <b>error</b> callback method is called when an error is encountered.
341 * The one argument is of type int; it indicates the specific error that
342 * occurred and will be set to one of <b>GLU_TESS_MISSING_BEGIN_POLYGON</b>,
343 * <b>GLU_TESS_MISSING_END_POLYGON</b>, <b>GLU_TESS_MISSING_BEGIN_CONTOUR</b>,
344 * <b>GLU_TESS_MISSING_END_CONTOUR</b>, <b>GLU_TESS_COORD_TOO_LARGE</b>,
345 * <b>GLU_TESS_NEED_COMBINE_CALLBACK</b> or <b>GLU_OUT_OF_MEMORY</b>.
346 * Character strings describing these errors can be retrieved with the
347 * {@link GLU#gluErrorString gluErrorString} call.<P>
348 *
349 * The GLU library will recover from the first four errors by inserting the
350 * missing call(s). <b>GLU_TESS_COORD_TOO_LARGE</b> indicates that some
351 * vertex coordinate exceeded the predefined constant
352 * <b>GLU_TESS_MAX_COORD</b> in absolute value, and that the value has been
353 * clamped. (Coordinate values must be small enough so that two can be
354 * multiplied together without overflow.)
355 * <b>GLU_TESS_NEED_COMBINE_CALLBACK</b> indicates that the tessellation
356 * detected an intersection between two edges in the input data, and the
357 * <b>GLU_TESS_COMBINE</b> or <b>GLU_TESS_COMBINE_DATA</b> callback was not
358 * provided. No output is generated. <b>GLU_OUT_OF_MEMORY</b> indicates that
359 * there is not enough memory so no output is generated.
360 *
361 * @param errnum
362 * Specifics the error number code.
363 *
364 * @see GLU#gluTessCallback gluTessCallback
365 * @see #errorData errorData
366 */
367 public void error(int errnum);
368
369
370 /**
371 * The same as the {@link #error error} callback method except that
372 * it takes an additional reference argument. This reference is
373 * identical to the opaque reference provided when {@link
374 * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
375 *
376 * @param errnum
377 * Specifics the error number code.
378 * @param polygonData
379 * Specifics a reference to user-defined data.
380 *
381 * @see GLU#gluTessCallback gluTessCallback
382 * @see #error error
383 */
384 public void errorData(int errnum, Object polygonData);
385
386 //void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh);
387 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu;
85
86 /**
87 * The <b>GLUtessellatorCallbackAdapter</b> provides a default implementation of
88 * {@link GLUtessellatorCallback GLUtessellatorCallback}
89 * with empty callback methods. This class can be extended to provide user
90 * defined callback methods.
91 *
92 * @author Eric Veach, July 1994
93 * @author Java Port: Pepijn Van Eechhoudt, July 2003
94 * @author Java Port: Nathan Parker Burg, August 2003
95 */
96
97 public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback {
98 public void begin(int type) {}
99 public void edgeFlag(boolean boundaryEdge) {}
100 public void vertex(Object vertexData) {}
101 public void end() {}
102 // public void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh) {}
103 public void error(int errnum) {}
104 public void combine(double[] coords, Object[] data,
105 float[] weight, Object[] outData) {}
106 public void beginData(int type, Object polygonData) {}
107 public void edgeFlagData(boolean boundaryEdge,
108 Object polygonData) {}
109 public void vertexData(Object vertexData, Object polygonData) {}
110 public void endData(Object polygonData) {}
111 public void errorData(int errnum, Object polygonData) {}
112 public void combineData(double[] coords, Object[] data,
113 float[] weight, Object[] outData,
114 Object polygonData) {}
115 }
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.glu;
32
33 import java.nio.ByteBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.opengl.GL11;
37
38 /**
39 * MipMap.java
40 *
41 *
42 * Created 11-jan-2004
43 * @author Erik Duijs
44 */
45 public class MipMap extends Util {
46
47 /**
48 * Method gluBuild2DMipmaps
49 *
50 * @param target
51 * @param components
52 * @param width
53 * @param height
54 * @param format
55 * @param type
56 * @param data
57 * @return int
58 */
59 public static int gluBuild2DMipmaps(final int target,
60 final int components, final int width, final int height,
61 final int format, final int type, final ByteBuffer data) {
62 if ( width < 1 || height < 1 ) return GLU.GLU_INVALID_VALUE;
63
64 final int bpp = bytesPerPixel(format, type);
65 if ( bpp == 0 )
66 return GLU.GLU_INVALID_ENUM;
67
68 final int maxSize = glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE);
69
70 int w = nearestPower(width);
71 if ( w > maxSize )
72 w = maxSize;
73
74 int h = nearestPower(height);
75 if ( h > maxSize )
76 h = maxSize;
77
78 // Get current glPixelStore state
79 PixelStoreState pss = new PixelStoreState();
80
81 // 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);
86
87 ByteBuffer image;
88 int retVal = 0;
89 boolean done = false;
90
91 if ( w != width || h != height ) {
92 // must rescale image to get "top" mipmap texture image
93 image = BufferUtils.createByteBuffer((w + 4) * h * bpp);
94 int error = gluScaleImage(format, width, height, type, data, w, h, type, image);
95 if ( error != 0 ) {
96 retVal = error;
97 done = true;
98 }
99
100 /* 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);
105 } else {
106 image = data;
107 }
108
109 ByteBuffer bufferA = null;
110 ByteBuffer bufferB = null;
111
112 int level = 0;
113 while ( !done ) {
114 if (image != data) {
115 /* 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);
123
124 if ( w == 1 && h == 1 )
125 break;
126
127 final int newW = (w < 2) ? 1 : w >> 1;
128 final int newH = (h < 2) ? 1 : h >> 1;
129
130 final ByteBuffer newImage;
131
132 if ( bufferA == null )
133 newImage = (bufferA = BufferUtils.createByteBuffer((newW + 4) * newH * bpp));
134 else if ( bufferB == null )
135 newImage = (bufferB = BufferUtils.createByteBuffer((newW + 4) * newH * bpp));
136 else
137 newImage = bufferB;
138
139 int error = gluScaleImage(format, w, h, type, image, newW, newH, type, newImage);
140 if ( error != 0 ) {
141 retVal = error;
142 done = true;
143 }
144
145 image = newImage;
146 if ( bufferB != null )
147 bufferB = bufferA;
148
149 w = newW;
150 h = newH;
151 level++;
152 }
153
154 // Restore original glPixelStore state
155 pss.save();
156
157 return retVal;
158 }
159
160 /**
161 * Method gluScaleImage.
162 * @param format
163 * @param widthIn
164 * @param heightIn
165 * @param typein
166 * @param dataIn
167 * @param widthOut
168 * @param heightOut
169 * @param typeOut
170 * @param dataOut
171 * @return int
172 */
173 public static int gluScaleImage(int format,
174 int widthIn, int heightIn, int typein, ByteBuffer dataIn,
175 int widthOut, int heightOut, int typeOut, ByteBuffer dataOut) {
176
177 final int components = compPerPix(format);
178 if ( components == -1 )
179 return GLU.GLU_INVALID_ENUM;
180
181 int i, j, k;
182 float[] tempIn, tempOut;
183 float sx, sy;
184 int sizein, sizeout;
185 int rowstride, rowlen;
186
187 // temp image data
188 tempIn = new float[widthIn * heightIn * components];
189 tempOut = new float[widthOut * heightOut * components];
190
191 // Determine bytes per input type
192 switch ( typein ) {
193 case GL11.GL_UNSIGNED_BYTE:
194 sizein = 1;
195 break;
196 case GL11.GL_FLOAT:
197 sizein = 4;
198 break;
199 default:
200 return GL11.GL_INVALID_ENUM;
201 }
202
203 // Determine bytes per output type
204 switch ( typeOut ) {
205 case GL11.GL_UNSIGNED_BYTE:
206 sizeout = 1;
207 break;
208 case GL11.GL_FLOAT:
209 sizeout = 4;
210 break;
211 default:
212 return GL11.GL_INVALID_ENUM;
213 }
214
215 // Get glPixelStore state
216 PixelStoreState pss = new PixelStoreState();
217
218 //Unpack the pixel data and convert to floating point
219 if ( pss.unpackRowLength > 0 )
220 rowlen = pss.unpackRowLength;
221 else
222 rowlen = widthIn;
223
224 if ( sizein >= pss.unpackAlignment )
225 rowstride = components * rowlen;
226 else
227 rowstride = pss.unpackAlignment / sizein * ceil(components * rowlen * sizein, pss.unpackAlignment);
228
229 switch ( typein ) {
230 case GL11.GL_UNSIGNED_BYTE:
231 k = 0;
232 dataIn.rewind();
233 for ( i = 0; i < heightIn; i++ ) {
234 int ubptr = i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components;
235 for ( j = 0; j < widthIn * components; j++ ) {
236 tempIn[k++] = dataIn.get(ubptr++) & 0xff;
237 }
238 }
239 break;
240 case GL11.GL_FLOAT:
241 k = 0;
242 dataIn.rewind();
243 for ( i = 0; i < heightIn; i++ )
244 {
245 int fptr = 4 * (i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components);
246 for ( j = 0; j < widthIn * components; j++ )
247 {
248 tempIn[k++] = dataIn.getFloat(fptr);
249 fptr += 4;
250 }
251 }
252 break;
253 default:
254 return GLU.GLU_INVALID_ENUM;
255 }
256
257 // Do scaling
258 sx = (float)widthIn / (float)widthOut;
259 sy = (float)heightIn / (float)heightOut;
260
261 float[] c = new float[components];
262 int src, dst;
263
264 for ( int iy = 0; iy < heightOut; iy++ ) {
265 for ( int ix = 0; ix < widthOut; ix++ ) {
266 int x0 = (int)(ix * sx);
267 int x1 = (int)((ix + 1) * sx);
268 int y0 = (int)(iy * sy);
269 int y1 = (int)((iy + 1) * sy);
270
271 int readPix = 0;
272
273 // reset weighted pixel
274 for ( int ic = 0; ic < components; ic++ ) {
275 c[ic] = 0;
276 }
277
278 // create weighted pixel
279 for ( int ix0 = x0; ix0 < x1; ix0++ ) {
280 for ( int iy0 = y0; iy0 < y1; iy0++ ) {
281
282 src = (iy0 * widthIn + ix0) * components;
283
284 for ( int ic = 0; ic < components; ic++ ) {
285 c[ic] += tempIn[src + ic];
286 }
287
288 readPix++;
289 }
290 }
291
292 // store weighted pixel
293 dst = (iy * widthOut + ix) * components;
294
295 if ( readPix == 0 ) {
296 // Image is sized up, caused by non power of two texture as input
297 src = (y0 * widthIn + x0) * components;
298 for ( int ic = 0; ic < components; ic++ ) {
299 tempOut[dst++] = tempIn[src + ic];
300 }
301 } else {
302 // sized down
303 for ( k = 0; k < components; k++ ) {
304 tempOut[dst++] = c[k] / readPix;
305 }
306 }
307 }
308 }
309
310
311 // Convert temp output
312 if ( pss.packRowLength > 0 )
313 rowlen = pss.packRowLength;
314 else
315 rowlen = widthOut;
316
317 if ( sizeout >= pss.packAlignment )
318 rowstride = components * rowlen;
319 else
320 rowstride = pss.packAlignment / sizeout * ceil(components * rowlen * sizeout, pss.packAlignment);
321
322 switch ( typeOut ) {
323 case GL11.GL_UNSIGNED_BYTE:
324 k = 0;
325 for ( i = 0; i < heightOut; i++ ) {
326 int ubptr = i * rowstride + pss.packSkipRows * rowstride + pss.packSkipPixels * components;
327
328 for ( j = 0; j < widthOut * components; j++ ) {
329 dataOut.put(ubptr++, (byte)tempOut[k++]);
330 }
331 }
332 break;
333 case GL11.GL_FLOAT:
334 k = 0;
335 for ( i = 0; i < heightOut; i++ ) {
336 int fptr = 4 * (i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components);
337
338 for ( j = 0; j < widthOut * components; j++ ) {
339 dataOut.putFloat(fptr, tempOut[k++]);
340 fptr += 4;
341 }
342 }
343 break;
344 default:
345 return GLU.GLU_INVALID_ENUM;
346 }
347
348 return 0;
349 }
350 }
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.glu;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * PartialDisk.java
37 *
38 *
39 * Created 23-dec-2003
40 *
41 * @author Erik Duijs
42 */
43 public class PartialDisk extends Quadric {
44
45 private static final int CACHE_SIZE = 240;
46
47 /**
48 * Constructor for PartialDisk.
49 */
50 public PartialDisk() {
51 super();
52 }
53
54 /**
55 * renders a partial disk on the z=0 plane. A partial disk is similar to a
56 * full disk, except that only the subset of the disk from startAngle
57 * through startAngle + sweepAngle is included (where 0 degrees is along
58 * the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and
59 * 270 along the -x axis).
60 *
61 * The partial disk has a radius of outerRadius, and contains a concentric
62 * circular hole with a radius of innerRadius. If innerRadius is zero, then
63 * no hole is generated. The partial disk is subdivided around the z axis
64 * into slices (like pizza slices), and also about the z axis into rings
65 * (as specified by slices and loops, respectively).
66 *
67 * With respect to orientation, the +z side of the partial disk is
68 * considered to be outside (see gluQuadricOrientation). This means that if
69 * the orientation is set to GLU.GLU_OUTSIDE, then any normals generated point
70 * along the +z axis. Otherwise, they point along the -z axis.
71 *
72 * If texturing is turned on (with gluQuadricTexture), texture coordinates
73 * are generated linearly such that where r=outerRadius, the value at (r, 0, 0)
74 * is (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5),
75 * and at (0, -r, 0) it is (0.5, 0).
76 */
77 public void draw(
78 float innerRadius,
79 float outerRadius,
80 int slices,
81 int loops,
82 float startAngle,
83 float sweepAngle) {
84
85 int i, j;
86 float[] sinCache = new float[CACHE_SIZE];
87 float[] cosCache = new float[CACHE_SIZE];
88 float angle;
89 float sintemp, costemp;
90 float deltaRadius;
91 float radiusLow, radiusHigh;
92 float texLow = 0, texHigh = 0;
93 float angleOffset;
94 int slices2;
95 int finish;
96
97 if (slices >= CACHE_SIZE)
98 slices = CACHE_SIZE - 1;
99 if (slices < 2
100 || loops < 1
101 || outerRadius <= 0.0f
102 || innerRadius < 0.0f
103 || innerRadius > outerRadius) {
104 //gluQuadricError(qobj, GLU.GLU_INVALID_VALUE);
105 System.err.println("PartialDisk: GLU_INVALID_VALUE");
106 return;
107 }
108
109 if (sweepAngle < -360.0f)
110 sweepAngle = 360.0f;
111 if (sweepAngle > 360.0f)
112 sweepAngle = 360.0f;
113 if (sweepAngle < 0) {
114 startAngle += sweepAngle;
115 sweepAngle = -sweepAngle;
116 }
117
118 if (sweepAngle == 360.0f) {
119 slices2 = slices;
120 } else {
121 slices2 = slices + 1;
122 }
123
124 /* Compute length (needed for normal calculations) */
125 deltaRadius = outerRadius - innerRadius;
126
127 /* Cache is the vertex locations cache */
128
129 angleOffset = startAngle / 180.0f * GLU.PI;
130 for (i = 0; i <= slices; i++) {
131 angle = angleOffset + ((GLU.PI * sweepAngle) / 180.0f) * i / slices;
132 sinCache[i] = sin(angle);
133 cosCache[i] = cos(angle);
134 }
135
136 if (sweepAngle == 360.0f) {
137 sinCache[slices] = sinCache[0];
138 cosCache[slices] = cosCache[0];
139 }
140
141 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);
146 } else {
147 GL11.glNormal3f(0.0f, 0.0f, -1.0f);
148 }
149 break;
150 default :
151 case GLU.GLU_NONE :
152 break;
153 }
154
155 switch (super.drawStyle) {
156 case GLU.GLU_FILL :
157 if (innerRadius == .0f) {
158 finish = loops - 1;
159 /* 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);
165 radiusLow = outerRadius - deltaRadius * ((float) (loops - 1) / loops);
166 if (super.textureFlag) {
167 texLow = radiusLow / outerRadius / 2;
168 }
169
170 if (super.orientation == GLU.GLU_OUTSIDE) {
171 for (i = slices; i >= 0; i--) {
172 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);
178 }
179 } else {
180 for (i = 0; i <= slices; i++) {
181 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();
190 } else {
191 finish = loops;
192 }
193 for (j = 0; j < finish; j++) {
194 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
195 radiusHigh = outerRadius - deltaRadius * ((float) (j + 1) / loops);
196 if (super.textureFlag) {
197 texLow = radiusLow / outerRadius / 2;
198 texHigh = radiusHigh / outerRadius / 2;
199 }
200
201 GL11.glBegin(GL11.GL_QUAD_STRIP);
202 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(
213 texHigh * sinCache[i] + 0.5f,
214 texHigh * cosCache[i] + 0.5f);
215 }
216 GL11.glVertex3f(
217 radiusHigh * sinCache[i],
218 radiusHigh * cosCache[i],
219 0.0f);
220 } else {
221 if (super.textureFlag) {
222 GL11.glTexCoord2f(
223 texHigh * sinCache[i] + 0.5f,
224 texHigh * cosCache[i] + 0.5f);
225 }
226 GL11.glVertex3f(
227 radiusHigh * sinCache[i],
228 radiusHigh * cosCache[i],
229 0.0f);
230
231 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);
244 for (i = 0; i < slices2; i++) {
245 sintemp = sinCache[i];
246 costemp = cosCache[i];
247 for (j = 0; j <= loops; j++) {
248 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
249
250 if (super.textureFlag) {
251 texLow = radiusLow / outerRadius / 2;
252
253 GL11.glTexCoord2f(
254 texLow * sinCache[i] + 0.5f,
255 texLow * cosCache[i] + 0.5f);
256 }
257 GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
258 }
259 }
260 GL11.glEnd();
261 break;
262 case GLU.GLU_LINE :
263 if (innerRadius == outerRadius) {
264 GL11.glBegin(GL11.GL_LINE_STRIP);
265
266 for (i = 0; i <= slices; i++) {
267 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();
273 break;
274 }
275 for (j = 0; j <= loops; j++) {
276 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
277 if (super.textureFlag) {
278 texLow = radiusLow / outerRadius / 2;
279 }
280
281 GL11.glBegin(GL11.GL_LINE_STRIP);
282 for (i = 0; i <= slices; i++) {
283 if (super.textureFlag) {
284 GL11.glTexCoord2f(
285 texLow * sinCache[i] + 0.5f,
286 texLow * cosCache[i] + 0.5f);
287 }
288 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
289 }
290 GL11.glEnd();
291 }
292 for (i = 0; i < slices2; i++) {
293 sintemp = sinCache[i];
294 costemp = cosCache[i];
295 GL11.glBegin(GL11.GL_LINE_STRIP);
296 for (j = 0; j <= loops; j++) {
297 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
298 if (super.textureFlag) {
299 texLow = radiusLow / outerRadius / 2;
300 }
301
302 if (super.textureFlag) {
303 GL11.glTexCoord2f(
304 texLow * sinCache[i] + 0.5f,
305 texLow * cosCache[i] + 0.5f);
306 }
307 GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
308 }
309 GL11.glEnd();
310 }
311 break;
312 case GLU.GLU_SILHOUETTE :
313 if (sweepAngle < 360.0f) {
314 for (i = 0; i <= slices; i += slices) {
315 sintemp = sinCache[i];
316 costemp = cosCache[i];
317 GL11.glBegin(GL11.GL_LINE_STRIP);
318 for (j = 0; j <= loops; j++) {
319 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
320
321 if (super.textureFlag) {
322 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();
330 }
331 }
332 for (j = 0; j <= loops; j += loops) {
333 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
334 if (super.textureFlag) {
335 texLow = radiusLow / outerRadius / 2;
336 }
337
338 GL11.glBegin(GL11.GL_LINE_STRIP);
339 for (i = 0; i <= slices; i++) {
340 if (super.textureFlag) {
341 GL11.glTexCoord2f(
342 texLow * sinCache[i] + 0.5f,
343 texLow * cosCache[i] + 0.5f);
344 }
345 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
346 }
347 GL11.glEnd();
348 if (innerRadius == outerRadius)
349 break;
350 }
351 break;
352 default :
353 break;
354 }
355 }
356 }
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.glu;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * PixelStoreState.java
37 *
38 *
39 * Created 11-jan-2004
40 * @author Erik Duijs
41 */
42 class PixelStoreState extends Util {
43
44 public int unpackRowLength;
45 public int unpackAlignment;
46 public int unpackSkipRows;
47 public int unpackSkipPixels;
48 public int packRowLength;
49 public int packAlignment;
50 public int packSkipRows;
51 public int packSkipPixels;
52
53 /**
54 * Constructor for PixelStoreState.
55 */
56 PixelStoreState() {
57 super();
58 load();
59 }
60
61 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);
70 }
71
72 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);
81 }
82
83 }
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.glu;
32
33 import java.nio.FloatBuffer;
34 import java.nio.IntBuffer;
35
36 import org.lwjgl.BufferUtils;
37 import org.lwjgl.opengl.GL11;
38
39 /**
40 * Project.java
41 * <p/>
42 * <p/>
43 * Created 11-jan-2004
44 *
45 * @author Erik Duijs
46 */
47 public class Project extends Util {
48
49 private static final float[] IDENTITY_MATRIX =
50 new float[] {
51 1.0f, 0.0f, 0.0f, 0.0f,
52 0.0f, 1.0f, 0.0f, 0.0f,
53 0.0f, 0.0f, 1.0f, 0.0f,
54 0.0f, 0.0f, 0.0f, 1.0f };
55
56 private static final FloatBuffer matrix = BufferUtils.createFloatBuffer(16);
57 private static final FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16);
58
59 private static final FloatBuffer tempMatrix = BufferUtils.createFloatBuffer(16);
60 private static final float[] in = new float[4];
61 private static final float[] out = new float[4];
62
63 private static final float[] forward = new float[3];
64 private static final float[] side = new float[3];
65 private static final float[] up = new float[3];
66
67 /**
68 * Make matrix an identity matrix
69 */
70 private static void __gluMakeIdentityf(FloatBuffer m) {
71 int oldPos = m.position();
72 m.put(IDENTITY_MATRIX);
73 m.position(oldPos);
74 }
75
76 /**
77 * Method __gluMultMatrixVecf
78 *
79 * @param finalMatrix
80 * @param in
81 * @param out
82 */
83 private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) {
84 for (int i = 0; i < 4; i++) {
85 out[i] =
86 in[0] * m.get(m.position() + 0*4 + i)
87 + in[1] * m.get(m.position() + 1*4 + i)
88 + in[2] * m.get(m.position() + 2*4 + i)
89 + in[3] * m.get(m.position() + 3*4 + i);
90
91 }
92 }
93
94 /**
95 * @param src
96 * @param inverse
97 *
98 * @return
99 */
100 private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
101 int i, j, k, swap;
102 float t;
103 FloatBuffer temp = Project.tempMatrix;
104
105
106 for (i = 0; i < 16; i++) {
107 temp.put(i, src.get(i + src.position()));
108 }
109 __gluMakeIdentityf(inverse);
110
111 for (i = 0; i < 4; i++) {
112 /*
113 * * Look for largest element in column
114 */
115 swap = i;
116 for (j = i + 1; j < 4; j++) {
117 /*
118 * if (fabs(temp[j][i]) > fabs(temp[i][i])) { swap = j;
119 */
120 if (Math.abs(temp.get(j*4 + i)) > Math.abs(temp.get(i* 4 + i))) {
121 swap = j;
122 }
123 }
124
125 if (swap != i) {
126 /*
127 * * Swap rows.
128 */
129 for (k = 0; k < 4; k++) {
130 t = temp.get(i*4 + k);
131 temp.put(i*4 + k, temp.get(swap*4 + k));
132 temp.put(swap*4 + k, t);
133
134 t = inverse.get(i*4 + k);
135 inverse.put(i*4 + k, inverse.get(swap*4 + k));
136 //inverse.put((i << 2) + k, inverse.get((swap << 2) + k));
137 inverse.put(swap*4 + k, t);
138 //inverse.put((swap << 2) + k, t);
139 }
140 }
141
142 if (temp.get(i*4 + i) == 0) {
143 /*
144 * * No non-zero pivot. The matrix is singular, which shouldn't *
145 * happen. This means the user gave us a bad matrix.
146 */
147 return false;
148 }
149
150 t = temp.get(i*4 + i);
151 for (k = 0; k < 4; k++) {
152 temp.put(i*4 + k, temp.get(i*4 + k)/t);
153 inverse.put(i*4 + k, inverse.get(i*4 + k)/t);
154 }
155 for (j = 0; j < 4; j++) {
156 if (j != i) {
157 t = temp.get(j*4 + i);
158 for (k = 0; k < 4; k++) {
159 temp.put(j*4 + k, temp.get(j*4 + k) - temp.get(i*4 + k) * t);
160 inverse.put(j*4 + k, inverse.get(j*4 + k) - inverse.get(i*4 + k) * t);
161 /*inverse.put(
162 (j << 2) + k,
163 inverse.get((j << 2) + k) - inverse.get((i << 2) + k) * t);*/
164 }
165 }
166 }
167 }
168 return true;
169 }
170
171 /**
172 * @param a
173 * @param b
174 * @param r
175 */
176 private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
177 for (int i = 0; i < 4; i++) {
178 for (int j = 0; j < 4; j++) {
179 r.put(r.position() + i*4 + j,
180 a.get(a.position() + i*4 + 0) * b.get(b.position() + 0*4 + j) + a.get(a.position() + i*4 + 1) * b.get(b.position() + 1*4 + j) + a.get(a.position() + i*4 + 2) * b.get(b.position() + 2*4 + j) + a.get(a.position() + i*4 + 3) * b.get(b.position() + 3*4 + j));
181 }
182 }
183 }
184
185 /**
186 * Method gluPerspective.
187 *
188 * @param fovy
189 * @param aspect
190 * @param zNear
191 * @param zFar
192 */
193 public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
194 float sine, cotangent, deltaZ;
195 float radians = fovy / 2 * GLU.PI / 180;
196
197 deltaZ = zFar - zNear;
198 sine = (float) Math.sin(radians);
199
200 if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) {
201 return;
202 }
203
204 cotangent = (float) Math.cos(radians) / sine;
205
206 __gluMakeIdentityf(matrix);
207
208 matrix.put(0 * 4 + 0, cotangent / aspect);
209 matrix.put(1 * 4 + 1, cotangent);
210 matrix.put(2 * 4 + 2, - (zFar + zNear) / deltaZ);
211 matrix.put(2 * 4 + 3, -1);
212 matrix.put(3 * 4 + 2, -2 * zNear * zFar / deltaZ);
213 matrix.put(3 * 4 + 3, 0);
214
215 GL11.glMultMatrix(matrix);
216 }
217
218 /**
219 * Method gluLookAt
220 *
221 * @param eyex
222 * @param eyey
223 * @param eyez
224 * @param centerx
225 * @param centery
226 * @param centerz
227 * @param upx
228 * @param upy
229 * @param upz
230 */
231 public static void gluLookAt(
232 float eyex,
233 float eyey,
234 float eyez,
235 float centerx,
236 float centery,
237 float centerz,
238 float upx,
239 float upy,
240 float upz) {
241 float[] forward = Project.forward;
242 float[] side = Project.side;
243 float[] up = Project.up;
244
245 forward[0] = centerx - eyex;
246 forward[1] = centery - eyey;
247 forward[2] = centerz - eyez;
248
249 up[0] = upx;
250 up[1] = upy;
251 up[2] = upz;
252
253 normalize(forward);
254
255 /* Side = forward x up */
256 cross(forward, up, side);
257 normalize(side);
258
259 /* Recompute up as: up = side x forward */
260 cross(side, forward, up);
261
262 __gluMakeIdentityf(matrix);
263 matrix.put(0 * 4 + 0, side[0]);
264 matrix.put(1 * 4 + 0, side[1]);
265 matrix.put(2 * 4 + 0, side[2]);
266
267 matrix.put(0 * 4 + 1, up[0]);
268 matrix.put(1 * 4 + 1, up[1]);
269 matrix.put(2 * 4 + 1, up[2]);
270
271 matrix.put(0 * 4 + 2, -forward[0]);
272 matrix.put(1 * 4 + 2, -forward[1]);
273 matrix.put(2 * 4 + 2, -forward[2]);
274
275 GL11.glMultMatrix(matrix);
276 GL11.glTranslatef(-eyex, -eyey, -eyez);
277 }
278
279 /**
280 * Method gluProject
281 *
282 * @param objx
283 * @param objy
284 * @param objz
285 * @param modelMatrix
286 * @param projMatrix
287 * @param viewport
288 * @param win_pos
289 */
290 public static boolean gluProject(
291 float objx,
292 float objy,
293 float objz,
294 FloatBuffer modelMatrix,
295 FloatBuffer projMatrix,
296 IntBuffer viewport,
297 FloatBuffer win_pos) {
298
299 float[] in = Project.in;
300 float[] out = Project.out;
301
302 in[0] = objx;
303 in[1] = objy;
304 in[2] = objz;
305 in[3] = 1.0f;
306
307 __gluMultMatrixVecf(modelMatrix, in, out);
308 __gluMultMatrixVecf(projMatrix, out, in);
309
310 if (in[3] == 0.0)
311 return false;
312
313 in[3] = (1.0f / in[3]) * 0.5f;
314
315 // Map x, y and z to range 0-1
316 in[0] = in[0] * in[3] + 0.5f;
317 in[1] = in[1] * in[3] + 0.5f;
318 in[2] = in[2] * in[3] + 0.5f;
319
320 // Map x,y to viewport
321 win_pos.put(0, in[0] * viewport.get(viewport.position() + 2) + viewport.get(viewport.position() + 0));
322 win_pos.put(1, in[1] * viewport.get(viewport.position() + 3) + viewport.get(viewport.position() + 1));
323 win_pos.put(2, in[2]);
324
325 return true;
326 }
327
328 /**
329 * Method gluUnproject
330 *
331 * @param winx
332 * @param winy
333 * @param winz
334 * @param modelMatrix
335 * @param projMatrix
336 * @param viewport
337 * @param obj_pos
338 */
339 public static boolean gluUnProject(
340 float winx,
341 float winy,
342 float winz,
343 FloatBuffer modelMatrix,
344 FloatBuffer projMatrix,
345 IntBuffer viewport,
346 FloatBuffer obj_pos) {
347 float[] in = Project.in;
348 float[] out = Project.out;
349
350 __gluMultMatricesf(modelMatrix, projMatrix, finalMatrix);
351
352 if (!__gluInvertMatrixf(finalMatrix, finalMatrix))
353 return false;
354
355 in[0] = winx;
356 in[1] = winy;
357 in[2] = winz;
358 in[3] = 1.0f;
359
360 // Map x and y from window coordinates
361 in[0] = (in[0] - viewport.get(viewport.position() + 0)) / viewport.get(viewport.position() + 2);
362 in[1] = (in[1] - viewport.get(viewport.position() + 1)) / viewport.get(viewport.position() + 3);
363
364 // Map to range -1 to 1
365 in[0] = in[0] * 2 - 1;
366 in[1] = in[1] * 2 - 1;
367 in[2] = in[2] * 2 - 1;
368
369 __gluMultMatrixVecf(finalMatrix, in, out);
370
371 if (out[3] == 0.0)
372 return false;
373
374 out[3] = 1.0f / out[3];
375
376 obj_pos.put(obj_pos.position() + 0, out[0] * out[3]);
377 obj_pos.put(obj_pos.position() + 1, out[1] * out[3]);
378 obj_pos.put(obj_pos.position() + 2, out[2] * out[3]);
379
380 return true;
381 }
382
383 /**
384 * Method gluPickMatrix
385 *
386 * @param x
387 * @param y
388 * @param deltaX
389 * @param deltaY
390 * @param viewport
391 */
392 public static void gluPickMatrix(
393 float x,
394 float y,
395 float deltaX,
396 float deltaY,
397 IntBuffer viewport) {
398 if (deltaX <= 0 || deltaY <= 0) {
399 return;
400 }
401
402 /* Translate and scale the picked region to the entire window */
403 GL11.glTranslatef(
404 (viewport.get(viewport.position() + 2) - 2 * (x - viewport.get(viewport.position() + 0))) / deltaX,
405 (viewport.get(viewport.position() + 3) - 2 * (y - viewport.get(viewport.position() + 1))) / deltaY,
406 0);
407 GL11.glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f);
408 }
409 }
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.glu;
32
33 import org.lwjgl.opengl.GL11;
34
35 /**
36 * Quadric.java
37 *
38 *
39 * Created 22-dec-2003
40 * @author Erik Duijs
41 */
42 public class Quadric {
43
44 protected int drawStyle;
45 protected int orientation;
46 protected boolean textureFlag;
47 protected int normals;
48
49 /**
50 * Constructor for Quadric.
51 */
52 public Quadric() {
53 super();
54
55 drawStyle = GLU.GLU_FILL;
56 orientation = GLU.GLU_OUTSIDE;
57 textureFlag = false;
58 normals = GLU.GLU_SMOOTH;
59 }
60
61 /**
62 * Call glNormal3f after scaling normal to unit length.
63 *
64 * @param x
65 * @param y
66 * @param z
67 */
68 protected void normal3f(float x, float y, float z) {
69 float mag;
70
71 mag = (float)Math.sqrt(x * x + y * y + z * z);
72 if (mag > 0.00001F) {
73 x /= mag;
74 y /= mag;
75 z /= mag;
76 }
77 GL11.glNormal3f(x, y, z);
78 }
79
80 /**
81 * specifies the draw style for quadrics.
82 *
83 * The legal values are as follows:
84 *
85 * GLU.FILL: Quadrics are rendered with polygon primitives. The polygons
86 * are drawn in a counterclockwise fashion with respect to
87 * their normals (as defined with glu.quadricOrientation).
88 *
89 * GLU.LINE: Quadrics are rendered as a set of lines.
90 *
91 * GLU.SILHOUETTE: Quadrics are rendered as a set of lines, except that edges
92 * separating coplanar faces will not be drawn.
93 *
94 * GLU.POINT: Quadrics are rendered as a set of points.
95 *
96 * @param drawStyle The drawStyle to set
97 */
98 public void setDrawStyle(int drawStyle) {
99 this.drawStyle = drawStyle;
100 }
101
102 /**
103 * specifies what kind of normals are desired for quadrics.
104 * The legal values are as follows:
105 *
106 * GLU.NONE: No normals are generated.
107 *
108 * GLU.FLAT: One normal is generated for every facet of a quadric.
109 *
110 * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This
111 * is the default.
112 *
113 * @param normals The normals to set
114 */
115 public void setNormals(int normals) {
116 this.normals = normals;
117 }
118
119 /**
120 * specifies what kind of orientation is desired for.
121 * The orientation values are as follows:
122 *
123 * GLU.OUTSIDE: Quadrics are drawn with normals pointing outward.
124 *
125 * GLU.INSIDE: Normals point inward. The default is GLU.OUTSIDE.
126 *
127 * Note that the interpretation of outward and inward depends on the quadric
128 * being drawn.
129 *
130 * @param orientation The orientation to set
131 */
132 public void setOrientation(int orientation) {
133 this.orientation = orientation;
134 }
135
136 /**
137 * specifies if texture coordinates should be generated for
138 * quadrics rendered with qobj. If the value of textureCoords is true,
139 * then texture coordinates are generated, and if textureCoords is false,
140 * they are not.. The default is false.
141 *
142 * The manner in which texture coordinates are generated depends upon the
143 * specific quadric rendered.
144 *
145 * @param textureFlag The textureFlag to set
146 */
147 public void setTextureFlag(boolean textureFlag) {
148 this.textureFlag = textureFlag;
149 }
150
151
152 /**
153 * Returns the drawStyle.
154 * @return int
155 */
156 public int getDrawStyle() {
157 return drawStyle;
158 }
159
160 /**
161 * Returns the normals.
162 * @return int
163 */
164 public int getNormals() {
165 return normals;
166 }
167
168 /**
169 * Returns the orientation.
170 * @return int
171 */
172 public int getOrientation() {
173 return orientation;
174 }
175
176 /**
177 * Returns the textureFlag.
178 * @return boolean
179 */
180 public boolean getTextureFlag() {
181 return textureFlag;
182 }
183
184 protected void TXTR_COORD(float x, float y) {
185 if (textureFlag) GL11.glTexCoord2f(x,y);
186 }
187
188
189 protected float sin(float r) {
190 return (float)Math.sin(r);
191 }
192
193 protected float cos(float r) {
194 return (float)Math.cos(r);
195 }
196
197 }
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.glu;
32
33 /**
34 * Registry.java
35 *
36 *
37 * Created 11-jan-2004
38 * @author Erik Duijs
39 */
40 public class Registry extends Util {
41
42 private static final String versionString = "1.3";
43 private static final String extensionString =
44 "GLU_EXT_nurbs_tessellator " + "GLU_EXT_object_space_tess ";
45
46 /**
47 * Method gluGetString
48 * @param name
49 * @return String
50 */
51 public static String gluGetString(int name) {
52
53 if (name == GLU.GLU_VERSION) {
54 return versionString;
55 } else if (name == GLU.GLU_EXTENSIONS) {
56 return extensionString;
57 }
58 return null;
59 }
60
61 /**
62 * Method gluCheckExtension
63 *
64 * @param extName is an extension name.
65 * @param extString is a string of extensions separated by blank(s). There may or
66 * may not be leading or trailing blank(s) in extString.
67 * This works in cases of extensions being prefixes of another like
68 * GL_EXT_texture and GL_EXT_texture3D.
69 * @return boolean true if extName is found otherwise it returns false.
70 */
71 public static boolean gluCheckExtension(String extName, String extString) {
72 if (extString == null || extName == null)
73 return false;
74
75 return extString.indexOf(extName) != -1;
76 }
77 }
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.glu;
32
33
34 import org.lwjgl.opengl.GL11;
35
36 /**
37 * Sphere.java
38 *
39 *
40 * Created 23-dec-2003
41 * @author Erik Duijs
42 */
43 public class Sphere extends Quadric {
44
45 /**
46 * Constructor
47 */
48 public Sphere() {
49 super();
50 }
51
52 /**
53 * draws a sphere of the given radius centered around the origin.
54 * The sphere is subdivided around the z axis into slices and along the z axis
55 * into stacks (similar to lines of longitude and latitude).
56 *
57 * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then
58 * any normals generated point away from the center of the sphere. Otherwise,
59 * they point toward the center of the sphere.
60
61 * If texturing is turned on (with glu.quadricTexture), then texture
62 * coordinates are generated so that t ranges from 0.0 at z=-radius to 1.0 at
63 * z=radius (t increases linearly along longitudinal lines), and s ranges from
64 * 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75
65 * at the -x axis, and back to 1.0 at the +y axis.
66 */
67 public void draw(float radius, int slices, int stacks) {
68 // TODO
69
70 float rho, drho, theta, dtheta;
71 float x, y, z;
72 float s, t, ds, dt;
73 int i, j, imin, imax;
74 boolean normals;
75 float nsign;
76
77 normals = super.normals != GLU.GLU_NONE;
78
79 if (super.orientation == GLU.GLU_INSIDE) {
80 nsign = -1.0f;
81 } else {
82 nsign = 1.0f;
83 }
84
85 drho = GLU.PI / stacks;
86 dtheta = 2.0f * GLU.PI / slices;
87
88 if (super.drawStyle == GLU.GLU_FILL) {
89 if (!super.textureFlag) {
90 // 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);
94 for (j = 0; j <= slices; j++) {
95 theta = (j == slices) ? 0.0f : j * dtheta;
96 x = -sin(theta) * sin(drho);
97 y = cos(theta) * sin(drho);
98 z = nsign * cos(drho);
99 if (normals) {
100 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
101 }
102 GL11.glVertex3f(x * radius, y * radius, z * radius);
103 }
104 GL11.glEnd();
105 }
106
107 ds = 1.0f / slices;
108 dt = 1.0f / stacks;
109 t = 1.0f; // because loop now runs from 0
110 if (super.textureFlag) {
111 imin = 0;
112 imax = stacks;
113 } else {
114 imin = 1;
115 imax = stacks - 1;
116 }
117
118 // draw intermediate stacks as quad strips
119 for (i = imin; i < imax; i++) {
120 rho = i * drho;
121 GL11.glBegin(GL11.GL_QUAD_STRIP);
122 s = 0.0f;
123 for (j = 0; j <= slices; j++) {
124 theta = (j == slices) ? 0.0f : j * dtheta;
125 x = -sin(theta) * sin(rho);
126 y = cos(theta) * sin(rho);
127 z = nsign * cos(rho);
128 if (normals) {
129 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
130 }
131 TXTR_COORD(s, t);
132 GL11.glVertex3f(x * radius, y * radius, z * radius);
133 x = -sin(theta) * sin(rho + drho);
134 y = cos(theta) * sin(rho + drho);
135 z = nsign * cos(rho + drho);
136 if (normals) {
137 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
138 }
139 TXTR_COORD(s, t - dt);
140 s += ds;
141 GL11.glVertex3f(x * radius, y * radius, z * radius);
142 }
143 GL11.glEnd();
144 t -= dt;
145 }
146
147 if (!super.textureFlag) {
148 // 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;
153 s = 1.0f;
154 for (j = slices; j >= 0; j--) {
155 theta = (j == slices) ? 0.0f : j * dtheta;
156 x = -sin(theta) * sin(rho);
157 y = cos(theta) * sin(rho);
158 z = nsign * cos(rho);
159 if (normals)
160 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
161 s -= ds;
162 GL11.glVertex3f(x * radius, y * radius, z * radius);
163 }
164 GL11.glEnd();
165 }
166 } else if (
167 super.drawStyle == GLU.GLU_LINE
168 || super.drawStyle == GLU.GLU_SILHOUETTE) {
169 // draw stack lines
170 for (i = 1;
171 i < stacks;
172 i++) { // stack line at i==stacks-1 was missing here
173 rho = i * drho;
174 GL11.glBegin(GL11.GL_LINE_LOOP);
175 for (j = 0; j < slices; j++) {
176 theta = j * dtheta;
177 x = cos(theta) * sin(rho);
178 y = sin(theta) * sin(rho);
179 z = cos(rho);
180 if (normals)
181 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
182 GL11.glVertex3f(x * radius, y * radius, z * radius);
183 }
184 GL11.glEnd();
185 }
186 // draw slice lines
187 for (j = 0; j < slices; j++) {
188 theta = j * dtheta;
189 GL11.glBegin(GL11.GL_LINE_STRIP);
190 for (i = 0; i <= stacks; i++) {
191 rho = i * drho;
192 x = cos(theta) * sin(rho);
193 y = sin(theta) * sin(rho);
194 z = cos(rho);
195 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) {
202 // top and bottom-most points
203 GL11.glBegin(GL11.GL_POINTS);
204 if (normals)
205 GL11.glNormal3f(0.0f, 0.0f, nsign);
206 GL11.glVertex3f(0.0f, 0.0f, radius);
207 if (normals)
208 GL11.glNormal3f(0.0f, 0.0f, -nsign);
209 GL11.glVertex3f(0.0f, 0.0f, -radius);
210
211 // loop over stacks
212 for (i = 1; i < stacks - 1; i++) {
213 rho = i * drho;
214 for (j = 0; j < slices; j++) {
215 theta = j * dtheta;
216 x = cos(theta) * sin(rho);
217 y = sin(theta) * sin(rho);
218 z = cos(rho);
219 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();
225 }
226 }
227
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 package org.lwjgl.util.glu;
32
33 import java.nio.IntBuffer;
34
35 import org.lwjgl.BufferUtils;
36 import org.lwjgl.opengl.GL11;
37 import org.lwjgl.opengl.GL12;
38
39 /**
40 * Util.java
41 * <p/>
42 * <p/>
43 * Created 7-jan-2004
44 *
45 * @author Erik Duijs
46 */
47 public class Util {
48
49 /**
50 * temp IntBuffer of one for getting an int from some GL functions
51 */
52 private static IntBuffer scratch = BufferUtils.createIntBuffer(16);
53
54 /**
55 * Return ceiling of integer division
56 *
57 * @param a
58 * @param b
59 *
60 * @return int
61 */
62 protected static int ceil(int a, int b) {
63 return (a % b == 0 ? a / b : a / b + 1);
64 }
65
66 /**
67 * Normalize vector
68 *
69 * @param v
70 *
71 * @return float[]
72 */
73 protected static float[] normalize(float[] v) {
74 float r;
75
76 r = (float)Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
77 if ( r == 0.0 )
78 return v;
79
80 r = 1.0f / r;
81
82 v[0] *= r;
83 v[1] *= r;
84 v[2] *= r;
85
86 return v;
87 }
88
89 /**
90 * Calculate cross-product
91 *
92 * @param v1
93 * @param v2
94 * @param result
95 */
96 protected static void cross(float[] v1, float[] v2, float[] result) {
97 result[0] = v1[1] * v2[2] - v1[2] * v2[1];
98 result[1] = v1[2] * v2[0] - v1[0] * v2[2];
99 result[2] = v1[0] * v2[1] - v1[1] * v2[0];
100 }
101
102 /**
103 * Method compPerPix.
104 *
105 * @param format
106 *
107 * @return int
108 */
109 protected static int compPerPix(int format) {
110 /* Determine number of components per pixel */
111 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:
120 return 1;
121 case GL11.GL_LUMINANCE_ALPHA:
122 return 2;
123 case GL11.GL_RGB:
124 case GL12.GL_BGR:
125 return 3;
126 case GL11.GL_RGBA:
127 case GL12.GL_BGRA:
128 return 4;
129 default :
130 return -1;
131 }
132 }
133
134 /**
135 * Method nearestPower.
136 * <p/>
137 * Compute the nearest power of 2 number. This algorithm is a little strange, but it works quite well.
138 *
139 * @param value
140 *
141 * @return int
142 */
143 protected static int nearestPower(int value) {
144 int i;
145
146 i = 1;
147
148 /* Error! */
149 if ( value == 0 )
150 return -1;
151
152 for ( ; ; ) {
153 if ( value == 1 ) {
154 return i;
155 } else if ( value == 3 ) {
156 return i << 2;
157 }
158 value >>= 1;
159 i <<= 1;
160 }
161 }
162
163 /**
164 * Method bytesPerPixel.
165 *
166 * @param format
167 * @param type
168 *
169 * @return int
170 */
171 protected static int bytesPerPixel(int format, int type) {
172 int n, m;
173
174 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:
183 n = 1;
184 break;
185 case GL11.GL_LUMINANCE_ALPHA:
186 n = 2;
187 break;
188 case GL11.GL_RGB:
189 case GL12.GL_BGR:
190 n = 3;
191 break;
192 case GL11.GL_RGBA:
193 case GL12.GL_BGRA:
194 n = 4;
195 break;
196 default :
197 n = 0;
198 }
199
200 switch ( type ) {
201 case GL11.GL_UNSIGNED_BYTE:
202 m = 1;
203 break;
204 case GL11.GL_BYTE:
205 m = 1;
206 break;
207 case GL11.GL_BITMAP:
208 m = 1;
209 break;
210 case GL11.GL_UNSIGNED_SHORT:
211 m = 2;
212 break;
213 case GL11.GL_SHORT:
214 m = 2;
215 break;
216 case GL11.GL_UNSIGNED_INT:
217 m = 4;
218 break;
219 case GL11.GL_INT:
220 m = 4;
221 break;
222 case GL11.GL_FLOAT:
223 m = 4;
224 break;
225 default :
226 m = 0;
227 }
228
229 return n * m;
230 }
231
232 /**
233 * Convenience method for returning an int, rather than getting it out of a buffer yourself.
234 *
235 * @param what
236 *
237 * @return int
238 */
239 protected static int glGetIntegerv(int what) {
240 scratch.rewind();
241 GL11.glGetInteger(what, scratch);
242 return scratch.get();
243 }
244
245 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class ActiveRegion {
87 GLUhalfEdge eUp; /* upper edge, directed right to left */
88 DictNode nodeUp; /* dictionary node corresponding to eUp */
89 int windingNumber; /* used to determine which regions are
90 * inside the polygon */
91 boolean inside; /* is this region inside the polygon? */
92 boolean sentinel; /* marks fake edges at t = +/-infinity */
93 boolean dirty; /* marks regions where the upper or lower
94 * edge has changed, but we haven't checked
95 * whether they intersect yet */
96 boolean fixUpperEdge; /* marks temporary edges introduced when
97 * we process a "right vertex" (one without
98 * any edges leaving to the right) */
99 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class CachedVertex {
87 public double[] coords = new double[3];
88 public Object data;
89 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class Dict {
87 DictNode head;
88 Object frame;
89 DictLeq leq;
90
91 private Dict() {
92 }
93
94 static Dict dictNewDict(Object frame, DictLeq leq) {
95 Dict dict = new Dict();
96 dict.head = new DictNode();
97
98 dict.head.key = null;
99 dict.head.next = dict.head;
100 dict.head.prev = dict.head;
101
102 dict.frame = frame;
103 dict.leq = leq;
104
105 return dict;
106 }
107
108 static void dictDeleteDict(Dict dict) {
109 dict.head = null;
110 dict.frame = null;
111 dict.leq = null;
112 }
113
114 static DictNode dictInsert(Dict dict, Object key) {
115 return dictInsertBefore(dict, dict.head, key);
116 }
117
118 static DictNode dictInsertBefore(Dict dict, DictNode node, Object key) {
119 do {
120 node = node.prev;
121 } while (node.key != null && !dict.leq.leq(dict.frame, node.key, key));
122
123 DictNode newNode = new DictNode();
124 newNode.key = key;
125 newNode.next = node.next;
126 node.next.prev = newNode;
127 newNode.prev = node;
128 node.next = newNode;
129
130 return newNode;
131 }
132
133 static Object dictKey(DictNode aNode) {
134 return aNode.key;
135 }
136
137 static DictNode dictSucc(DictNode aNode) {
138 return aNode.next;
139 }
140
141 static DictNode dictPred(DictNode aNode) {
142 return aNode.prev;
143 }
144
145 static DictNode dictMin(Dict aDict) {
146 return aDict.head.next;
147 }
148
149 static DictNode dictMax(Dict aDict) {
150 return aDict.head.prev;
151 }
152
153 static void dictDelete(Dict dict, DictNode node) {
154 node.next.prev = node.prev;
155 node.prev.next = node.next;
156 }
157
158 static DictNode dictSearch(Dict dict, Object key) {
159 DictNode node = dict.head;
160
161 do {
162 node = node.next;
163 } while (node.key != null && !(dict.leq.leq(dict.frame, key, node.key)));
164
165 return node;
166 }
167
168 public interface DictLeq {
169 boolean leq(Object frame, Object key1, Object key2);
170 }
171 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class DictNode {
87 Object key;
88 DictNode next;
89 DictNode prev;
90 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class GLUface {
87 public GLUface next; /* next face (never NULL) */
88 public GLUface prev; /* previous face (never NULL) */
89 public GLUhalfEdge anEdge; /* a half edge with this left face */
90 public Object data; /* room for client's data */
91
92 /* Internal data (keep hidden) */
93 public GLUface trail; /* "stack" for conversion to strips */
94 public boolean marked; /* flag for conversion to strips */
95 public boolean inside; /* this face is in the polygon interior */
96 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86
87
88 class GLUhalfEdge {
89 public GLUhalfEdge next; /* doubly-linked list (prev==Sym->next) */
90 public GLUhalfEdge Sym; /* same edge, opposite direction */
91 public GLUhalfEdge Onext; /* next edge CCW around origin */
92 public GLUhalfEdge Lnext; /* next edge CCW around left face */
93 public GLUvertex Org; /* origin vertex (Overtex too long) */
94 public GLUface Lface; /* left face */
95
96 /* Internal data (keep hidden) */
97 public ActiveRegion activeRegion; /* a region with this upper edge (sweep.c) */
98 public int winding; /* change in winding number when crossing */
99 public boolean first;
100
101 public GLUhalfEdge(boolean first) {
102 this.first = first;
103 }
104 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86
87
88 class GLUmesh {
89 GLUvertex vHead = new GLUvertex(); /* dummy header for vertex list */
90 GLUface fHead = new GLUface(); /* dummy header for face list */
91 GLUhalfEdge eHead = new GLUhalfEdge(true); /* dummy header for edge list */
92 GLUhalfEdge eHeadSym = new GLUhalfEdge(false); /* and its symmetric counterpart */
93 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 import org.lwjgl.util.glu.GLU;
87 import org.lwjgl.util.glu.GLUtessellator;
88 import org.lwjgl.util.glu.GLUtessellatorCallback;
89 import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
90
91 public class GLUtessellatorImpl implements GLUtessellator {
92 public static final int TESS_MAX_CACHE = 100;
93
94 private int state; /* what begin/end calls have we seen? */
95
96 private GLUhalfEdge lastEdge; /* lastEdge->Org is the most recent vertex */
97 GLUmesh mesh; /* stores the input contours, and eventually
98 the tessellation itself */
99
100 /*** state needed for projecting onto the sweep plane ***/
101
102 double[] normal = new double[3]; /* user-specified normal (if provided) */
103 double[] sUnit = new double[3]; /* unit vector in s-direction (debugging) */
104 double[] tUnit = new double[3]; /* unit vector in t-direction (debugging) */
105
106 /*** state needed for the line sweep ***/
107
108 private double relTolerance; /* tolerance for merging features */
109 int windingRule; /* rule for determining polygon interior */
110 boolean fatalError; /* fatal error: needed combine callback */
111
112 Dict dict; /* edge dictionary for sweep line */
113 PriorityQ pq; /* priority queue of vertex events */
114 GLUvertex event; /* current sweep event being processed */
115
116 /*** state needed for rendering callbacks (see render.c) ***/
117
118 boolean flagBoundary; /* mark boundary edges (use EdgeFlag) */
119 boolean boundaryOnly; /* Extract contours, not triangles */
120 GLUface lonelyTriList;
121 /* list of triangles which could not be rendered as strips or fans */
122
123
124
125 /*** state needed to cache single-contour polygons for renderCache() */
126
127 private boolean flushCacheOnNextVertex; /* empty cache on next vertex() call */
128 int cacheCount; /* number of cached vertices */
129 CachedVertex[] cache = new CachedVertex[TESS_MAX_CACHE]; /* the vertex data */
130
131 /*** rendering callbacks that also pass polygon data ***/
132 private Object polygonData; /* client data for current polygon */
133
134 private GLUtessellatorCallback callBegin;
135 private GLUtessellatorCallback callEdgeFlag;
136 private GLUtessellatorCallback callVertex;
137 private GLUtessellatorCallback callEnd;
138 // private GLUtessellatorCallback callMesh;
139 private GLUtessellatorCallback callError;
140 private GLUtessellatorCallback callCombine;
141
142 private GLUtessellatorCallback callBeginData;
143 private GLUtessellatorCallback callEdgeFlagData;
144 private GLUtessellatorCallback callVertexData;
145 private GLUtessellatorCallback callEndData;
146 // private GLUtessellatorCallback callMeshData;
147 private GLUtessellatorCallback callErrorData;
148 private GLUtessellatorCallback callCombineData;
149
150 private static final double GLU_TESS_DEFAULT_TOLERANCE = 0.0;
151 // private static final int GLU_TESS_MESH = 100112; /* void (*)(GLUmesh *mesh) */
152 private static GLUtessellatorCallback NULL_CB = new GLUtessellatorCallbackAdapter();
153
154 // #define MAX_FAST_ALLOC (MAX(sizeof(EdgePair), \
155 // MAX(sizeof(GLUvertex),sizeof(GLUface))))
156
157 public GLUtessellatorImpl() {
158 state = TessState.T_DORMANT;
159
160 normal[0] = 0;
161 normal[1] = 0;
162 normal[2] = 0;
163
164 relTolerance = GLU_TESS_DEFAULT_TOLERANCE;
165 windingRule = GLU.GLU_TESS_WINDING_ODD;
166 flagBoundary = false;
167 boundaryOnly = false;
168
169 callBegin = NULL_CB;
170 callEdgeFlag = NULL_CB;
171 callVertex = NULL_CB;
172 callEnd = NULL_CB;
173 callError = NULL_CB;
174 callCombine = NULL_CB;
175 // callMesh = NULL_CB;
176
177 callBeginData = NULL_CB;
178 callEdgeFlagData = NULL_CB;
179 callVertexData = NULL_CB;
180 callEndData = NULL_CB;
181 callErrorData = NULL_CB;
182 callCombineData = NULL_CB;
183
184 polygonData = null;
185
186 for (int i = 0; i < cache.length; i++) {
187 cache[i] = new CachedVertex();
188 }
189 }
190
191 static public GLUtessellator gluNewTess()
192 {
193 return new GLUtessellatorImpl();
194 }
195
196
197 private void makeDormant() {
198 /* Return the tessellator to its original dormant state. */
199
200 if (mesh != null) {
201 Mesh.__gl_meshDeleteMesh(mesh);
202 }
203 state = TessState.T_DORMANT;
204 lastEdge = null;
205 mesh = null;
206 }
207
208 private void requireState(int newState) {
209 if (state != newState) gotoState(newState);
210 }
211
212 private void gotoState(int newState) {
213 while (state != newState) {
214 /* We change the current state one level at a time, to get to
215 * the desired state.
216 */
217 if (state < newState) {
218 if (state == TessState.T_DORMANT) {
219 callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_POLYGON);
220 gluTessBeginPolygon(null);
221 } else if (state == TessState.T_IN_POLYGON) {
222 callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_CONTOUR);
223 gluTessBeginContour();
224 }
225 } else {
226 if (state == TessState.T_IN_CONTOUR) {
227 callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_CONTOUR);
228 gluTessEndContour();
229 } else if (state == TessState.T_IN_POLYGON) {
230 callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_POLYGON);
231 /* gluTessEndPolygon( tess ) is too much work! */
232 makeDormant();
233 }
234 }
235 }
236 }
237
238 public void gluDeleteTess() {
239 requireState(TessState.T_DORMANT);
240 }
241
242 public void gluTessProperty(int which, double value) {
243 switch (which) {
244 case GLU.GLU_TESS_TOLERANCE:
245 if (value < 0.0 || value > 1.0) break;
246 relTolerance = value;
247 return;
248
249 case GLU.GLU_TESS_WINDING_RULE:
250 int windingRule = (int) value;
251 if (windingRule != value) break; /* not an integer */
252
253 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:
259 this.windingRule = windingRule;
260 return;
261 default:
262 break;
263 }
264
265 case GLU.GLU_TESS_BOUNDARY_ONLY:
266 boundaryOnly = (value != 0);
267 return;
268
269 default:
270 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
271 return;
272 }
273 callErrorOrErrorData(GLU.GLU_INVALID_VALUE);
274 }
275
276 /* Returns tessellator property */
277 public void gluGetTessProperty(int which, double[] value, int value_offset) {
278 switch (which) {
279 case GLU.GLU_TESS_TOLERANCE:
280 /* tolerance should be in range [0..1] */
281 assert (0.0 <= relTolerance && relTolerance <= 1.0);
282 value[value_offset] = relTolerance;
283 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);
290 value[value_offset] = windingRule;
291 break;
292 case GLU.GLU_TESS_BOUNDARY_ONLY:
293 assert (boundaryOnly == true || boundaryOnly == false);
294 value[value_offset] = boundaryOnly ? 1 : 0;
295 break;
296 default:
297 value[value_offset] = 0.0;
298 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
299 break;
300 }
301 } /* gluGetTessProperty() */
302
303 public void gluTessNormal(double x, double y, double z) {
304 normal[0] = x;
305 normal[1] = y;
306 normal[2] = z;
307 }
308
309 public void gluTessCallback(int which, GLUtessellatorCallback aCallback) {
310 switch (which) {
311 case GLU.GLU_TESS_BEGIN:
312 callBegin = aCallback == null ? NULL_CB : aCallback;
313 return;
314 case GLU.GLU_TESS_BEGIN_DATA:
315 callBeginData = aCallback == null ? NULL_CB : aCallback;
316 return;
317 case GLU.GLU_TESS_EDGE_FLAG:
318 callEdgeFlag = aCallback == null ? NULL_CB : aCallback;
319 /* If the client wants boundary edges to be flagged,
320 * we render everything as separate triangles (no strips or fans).
321 */
322 flagBoundary = aCallback != null;
323 return;
324 case GLU.GLU_TESS_EDGE_FLAG_DATA:
325 callEdgeFlagData = callBegin = aCallback == null ? NULL_CB : aCallback;
326 /* If the client wants boundary edges to be flagged,
327 * we render everything as separate triangles (no strips or fans).
328 */
329 flagBoundary = (aCallback != null);
330 return;
331 case GLU.GLU_TESS_VERTEX:
332 callVertex = aCallback == null ? NULL_CB : aCallback;
333 return;
334 case GLU.GLU_TESS_VERTEX_DATA:
335 callVertexData = aCallback == null ? NULL_CB : aCallback;
336 return;
337 case GLU.GLU_TESS_END:
338 callEnd = aCallback == null ? NULL_CB : aCallback;
339 return;
340 case GLU.GLU_TESS_END_DATA:
341 callEndData = aCallback == null ? NULL_CB : aCallback;
342 return;
343 case GLU.GLU_TESS_ERROR:
344 callError = aCallback == null ? NULL_CB : aCallback;
345 return;
346 case GLU.GLU_TESS_ERROR_DATA:
347 callErrorData = aCallback == null ? NULL_CB : aCallback;
348 return;
349 case GLU.GLU_TESS_COMBINE:
350 callCombine = aCallback == null ? NULL_CB : aCallback;
351 return;
352 case GLU.GLU_TESS_COMBINE_DATA:
353 callCombineData = aCallback == null ? NULL_CB : aCallback;
354 return;
355 // case GLU_TESS_MESH:
356 // callMesh = aCallback == null ? NULL_CB : aCallback;
357 // return;
358 default:
359 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
360 return;
361 }
362 }
363
364 private boolean addVertex(double[] coords, Object vertexData) {
365 GLUhalfEdge e;
366
367 e = lastEdge;
368 if (e == null) {
369 /* Make a self-loop (one vertex, one edge). */
370
371 e = Mesh.__gl_meshMakeEdge(mesh);
372 if (e == null) return false;
373 if (!Mesh.__gl_meshSplice(e, e.Sym)) return false;
374 } else {
375 /* Create a new vertex and edge which immediately follow e
376 * in the ordering around the left face.
377 */
378 if (Mesh.__gl_meshSplitEdge(e) == null) return false;
379 e = e.Lnext;
380 }
381
382 /* The new vertex is now e.Org. */
383 e.Org.data = vertexData;
384 e.Org.coords[0] = coords[0];
385 e.Org.coords[1] = coords[1];
386 e.Org.coords[2] = coords[2];
387
388 /* The winding of an edge says how the winding number changes as we
389 * cross from the edge''s right face to its left face. We add the
390 * vertices in such an order that a CCW contour will add +1 to
391 * the winding number of the region inside the contour.
392 */
393 e.winding = 1;
394 e.Sym.winding = -1;
395
396 lastEdge = e;
397
398 return true;
399 }
400
401 private void cacheVertex(double[] coords, Object vertexData) {
402 if (cache[cacheCount] == null) {
403 cache[cacheCount] = new CachedVertex();
404 }
405
406 CachedVertex v = cache[cacheCount];
407
408 v.data = vertexData;
409 v.coords[0] = coords[0];
410 v.coords[1] = coords[1];
411 v.coords[2] = coords[2];
412 ++cacheCount;
413 }
414
415
416 private boolean flushCache() {
417 CachedVertex[] v = cache;
418
419 mesh = Mesh.__gl_meshNewMesh();
420 if (mesh == null) return false;
421
422 for (int i = 0; i < cacheCount; i++) {
423 CachedVertex vertex = v[i];
424 if (!addVertex(vertex.coords, vertex.data)) return false;
425 }
426 cacheCount = 0;
427 flushCacheOnNextVertex = false;
428
429 return true;
430 }
431
432 public void gluTessVertex(double[] coords, int coords_offset, Object vertexData) {
433 int i;
434 boolean tooLarge = false;
435 double x;
436 double[] clamped = new double[3];
437
438 requireState(TessState.T_IN_CONTOUR);
439
440 if (flushCacheOnNextVertex) {
441 if (!flushCache()) {
442 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
443 return;
444 }
445 lastEdge = null;
446 }
447 for (i = 0; i < 3; ++i) {
448 x = coords[i+coords_offset];
449 if (x < -GLU.GLU_TESS_MAX_COORD) {
450 x = -GLU.GLU_TESS_MAX_COORD;
451 tooLarge = true;
452 }
453 if (x > GLU.GLU_TESS_MAX_COORD) {
454 x = GLU.GLU_TESS_MAX_COORD;
455 tooLarge = true;
456 }
457 clamped[i] = x;
458 }
459 if (tooLarge) {
460 callErrorOrErrorData(GLU.GLU_TESS_COORD_TOO_LARGE);
461 }
462
463 if (mesh == null) {
464 if (cacheCount < TESS_MAX_CACHE) {
465 cacheVertex(clamped, vertexData);
466 return;
467 }
468 if (!flushCache()) {
469 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
470 return;
471 }
472 }
473
474 if (!addVertex(clamped, vertexData)) {
475 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
476 }
477 }
478
479
480 public void gluTessBeginPolygon(Object data) {
481 requireState(TessState.T_DORMANT);
482
483 state = TessState.T_IN_POLYGON;
484 cacheCount = 0;
485 flushCacheOnNextVertex = false;
486 mesh = null;
487
488 polygonData = data;
489 }
490
491
492 public void gluTessBeginContour() {
493 requireState(TessState.T_IN_POLYGON);
494
495 state = TessState.T_IN_CONTOUR;
496 lastEdge = null;
497 if (cacheCount > 0) {
498 /* Just set a flag so we don't get confused by empty contours
499 * -- these can be generated accidentally with the obsolete
500 * NextContour() interface.
501 */
502 flushCacheOnNextVertex = true;
503 }
504 }
505
506
507 public void gluTessEndContour() {
508 requireState(TessState.T_IN_CONTOUR);
509 state = TessState.T_IN_POLYGON;
510 }
511
512 public void gluTessEndPolygon() {
513 GLUmesh mesh;
514
515 try {
516 requireState(TessState.T_IN_POLYGON);
517 state = TessState.T_DORMANT;
518
519 if (this.mesh == null) {
520 if (!flagBoundary /*&& callMesh == NULL_CB*/) {
521
522 /* Try some special code to make the easy cases go quickly
523 * (eg. convex polygons). This code does NOT handle multiple contours,
524 * intersections, edge flags, and of course it does not generate
525 * an explicit mesh either.
526 */
527 if (Render.__gl_renderCache(this)) {
528 polygonData = null;
529 return;
530 }
531 }
532 if (!flushCache()) throw new RuntimeException(); /* could've used a label*/
533 }
534
535 /* Determine the polygon normal and project vertices onto the plane
536 * of the polygon.
537 */
538 Normal.__gl_projectPolygon(this);
539
540 /* __gl_computeInterior( tess ) computes the planar arrangement specified
541 * by the given contours, and further subdivides this arrangement
542 * into regions. Each region is marked "inside" if it belongs
543 * to the polygon, according to the rule given by windingRule.
544 * Each interior region is guaranteed be monotone.
545 */
546 if (!Sweep.__gl_computeInterior(this)) {
547 throw new RuntimeException(); /* could've used a label */
548 }
549
550 mesh = this.mesh;
551 if (!fatalError) {
552 boolean rc = true;
553
554 /* If the user wants only the boundary contours, we throw away all edges
555 * except those which separate the interior from the exterior.
556 * Otherwise we tessellate all the regions marked "inside".
557 */
558 if (boundaryOnly) {
559 rc = TessMono.__gl_meshSetWindingNumber(mesh, 1, true);
560 } else {
561 rc = TessMono.__gl_meshTessellateInterior(mesh);
562 }
563 if (!rc) throw new RuntimeException(); /* could've used a label */
564
565 Mesh.__gl_meshCheckMesh(mesh);
566
567 if (callBegin != NULL_CB || callEnd != NULL_CB
568 || callVertex != NULL_CB || callEdgeFlag != NULL_CB
569 || callBeginData != NULL_CB
570 || callEndData != NULL_CB
571 || callVertexData != NULL_CB
572 || callEdgeFlagData != NULL_CB) {
573 if (boundaryOnly) {
574 Render.__gl_renderBoundary(this, mesh); /* output boundary contours */
575 } else {
576 Render.__gl_renderMesh(this, mesh); /* output strips and fans */
577 }
578 }
579 // if (callMesh != NULL_CB) {
580 //
581 ///* Throw away the exterior faces, so that all faces are interior.
582 // * This way the user doesn't have to check the "inside" flag,
583 // * and we don't need to even reveal its existence. It also leaves
584 // * the freedom for an implementation to not generate the exterior
585 // * faces in the first place.
586 // */
587 // TessMono.__gl_meshDiscardExterior(mesh);
588 // callMesh.mesh(mesh); /* user wants the mesh itself */
589 // mesh = null;
590 // polygonData = null;
591 // return;
592 // }
593 }
594 Mesh.__gl_meshDeleteMesh(mesh);
595 polygonData = null;
596 mesh = null;
597 } catch (Exception e) {
598 e.printStackTrace();
599 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
600 }
601 }
602
603 /*******************************************************/
604
605 /* Obsolete calls -- for backward compatibility */
606
607 public void gluBeginPolygon() {
608 gluTessBeginPolygon(null);
609 gluTessBeginContour();
610 }
611
612
613 /*ARGSUSED*/
614 public void gluNextContour(int type) {
615 gluTessEndContour();
616 gluTessBeginContour();
617 }
618
619
620 public void gluEndPolygon() {
621 gluTessEndContour();
622 gluTessEndPolygon();
623 }
624
625 void callBeginOrBeginData(int a) {
626 if (callBeginData != NULL_CB)
627 callBeginData.beginData(a, polygonData);
628 else
629 callBegin.begin(a);
630 }
631
632 void callVertexOrVertexData(Object a) {
633 if (callVertexData != NULL_CB)
634 callVertexData.vertexData(a, polygonData);
635 else
636 callVertex.vertex(a);
637 }
638
639 void callEdgeFlagOrEdgeFlagData(boolean a) {
640 if (callEdgeFlagData != NULL_CB)
641 callEdgeFlagData.edgeFlagData(a, polygonData);
642 else
643 callEdgeFlag.edgeFlag(a);
644 }
645
646 void callEndOrEndData() {
647 if (callEndData != NULL_CB)
648 callEndData.endData(polygonData);
649 else
650 callEnd.end();
651 }
652
653 void callCombineOrCombineData(double[] coords, Object[] vertexData, float[] weights, Object[] outData) {
654 if (callCombineData != NULL_CB)
655 callCombineData.combineData(coords, vertexData, weights, outData, polygonData);
656 else
657 callCombine.combine(coords, vertexData, weights, outData);
658 }
659
660 void callErrorOrErrorData(int a) {
661 if (callErrorData != NULL_CB)
662 callErrorData.errorData(a, polygonData);
663 else
664 callError.error(a);
665 }
666
667 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class GLUvertex {
87 public GLUvertex next; /* next vertex (never NULL) */
88 public GLUvertex prev; /* previous vertex (never NULL) */
89 public GLUhalfEdge anEdge; /* a half-edge with this origin */
90 public Object data; /* client's data */
91
92 /* Internal data (keep hidden) */
93 public double[] coords = new double[3]; /* vertex location in 3D */
94 public double s, t; /* projection onto the sweep plane */
95 public int pqHandle; /* to allow deletion from priority queue */
96 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class Geom {
87 private Geom() {
88 }
89
90 /* Given three vertices u,v,w such that VertLeq(u,v) && VertLeq(v,w),
91 * evaluates the t-coord of the edge uw at the s-coord of the vertex v.
92 * Returns v->t - (uw)(v->s), ie. the signed distance from uw to v.
93 * If uw is vertical (and thus passes thru v), the result is zero.
94 *
95 * The calculation is extremely accurate and stable, even when v
96 * is very close to u or w. In particular if we set v->t = 0 and
97 * let r be the negated result (this evaluates (uw)(v->s)), then
98 * r is guaranteed to satisfy MIN(u->t,w->t) <= r <= MAX(u->t,w->t).
99 */
100 static double EdgeEval(GLUvertex u, GLUvertex v, GLUvertex w) {
101 double gapL, gapR;
102
103 assert (VertLeq(u, v) && VertLeq(v, w));
104
105 gapL = v.s - u.s;
106 gapR = w.s - v.s;
107
108 if (gapL + gapR > 0) {
109 if (gapL < gapR) {
110 return (v.t - u.t) + (u.t - w.t) * (gapL / (gapL + gapR));
111 } else {
112 return (v.t - w.t) + (w.t - u.t) * (gapR / (gapL + gapR));
113 }
114 }
115 /* vertical line */
116 return 0;
117 }
118
119 static double EdgeSign(GLUvertex u, GLUvertex v, GLUvertex w) {
120 double gapL, gapR;
121
122 assert (VertLeq(u, v) && VertLeq(v, w));
123
124 gapL = v.s - u.s;
125 gapR = w.s - v.s;
126
127 if (gapL + gapR > 0) {
128 return (v.t - w.t) * gapL + (v.t - u.t) * gapR;
129 }
130 /* vertical line */
131 return 0;
132 }
133
134
135 /***********************************************************************
136 * Define versions of EdgeSign, EdgeEval with s and t transposed.
137 */
138
139 static double TransEval(GLUvertex u, GLUvertex v, GLUvertex w) {
140 /* Given three vertices u,v,w such that TransLeq(u,v) && TransLeq(v,w),
141 * evaluates the t-coord of the edge uw at the s-coord of the vertex v.
142 * Returns v->s - (uw)(v->t), ie. the signed distance from uw to v.
143 * If uw is vertical (and thus passes thru v), the result is zero.
144 *
145 * The calculation is extremely accurate and stable, even when v
146 * is very close to u or w. In particular if we set v->s = 0 and
147 * let r be the negated result (this evaluates (uw)(v->t)), then
148 * r is guaranteed to satisfy MIN(u->s,w->s) <= r <= MAX(u->s,w->s).
149 */
150 double gapL, gapR;
151
152 assert (TransLeq(u, v) && TransLeq(v, w));
153
154 gapL = v.t - u.t;
155 gapR = w.t - v.t;
156
157 if (gapL + gapR > 0) {
158 if (gapL < gapR) {
159 return (v.s - u.s) + (u.s - w.s) * (gapL / (gapL + gapR));
160 } else {
161 return (v.s - w.s) + (w.s - u.s) * (gapR / (gapL + gapR));
162 }
163 }
164 /* vertical line */
165 return 0;
166 }
167
168 static double TransSign(GLUvertex u, GLUvertex v, GLUvertex w) {
169 /* Returns a number whose sign matches TransEval(u,v,w) but which
170 * is cheaper to evaluate. Returns > 0, == 0 , or < 0
171 * as v is above, on, or below the edge uw.
172 */
173 double gapL, gapR;
174
175 assert (TransLeq(u, v) && TransLeq(v, w));
176
177 gapL = v.t - u.t;
178 gapR = w.t - v.t;
179
180 if (gapL + gapR > 0) {
181 return (v.s - w.s) * gapL + (v.s - u.s) * gapR;
182 }
183 /* vertical line */
184 return 0;
185 }
186
187
188 static boolean VertCCW(GLUvertex u, GLUvertex v, GLUvertex w) {
189 /* For almost-degenerate situations, the results are not reliable.
190 * Unless the floating-point arithmetic can be performed without
191 * rounding errors, *any* implementation will give incorrect results
192 * on some degenerate inputs, so the client must have some way to
193 * handle this situation.
194 */
195 return (u.s * (v.t - w.t) + v.s * (w.t - u.t) + w.s * (u.t - v.t)) >= 0;
196 }
197
198 /* Given parameters a,x,b,y returns the value (b*x+a*y)/(a+b),
199 * or (x+y)/2 if a==b==0. It requires that a,b >= 0, and enforces
200 * this in the rare case that one argument is slightly negative.
201 * The implementation is extremely stable numerically.
202 * In particular it guarantees that the result r satisfies
203 * MIN(x,y) <= r <= MAX(x,y), and the results are very accurate
204 * even when a and b differ greatly in magnitude.
205 */
206 static double Interpolate(double a, double x, double b, double y) {
207 a = (a < 0) ? 0 : a;
208 b = (b < 0) ? 0 : b;
209 if (a <= b) {
210 if (b == 0) {
211 return (x + y) / 2.0;
212 } else {
213 return (x + (y - x) * (a / (a + b)));
214 }
215 } else {
216 return (y + (x - y) * (b / (a + b)));
217 }
218 }
219
220 static void EdgeIntersect(GLUvertex o1, GLUvertex d1,
221 GLUvertex o2, GLUvertex d2,
222 GLUvertex v)
223 /* Given edges (o1,d1) and (o2,d2), compute their point of intersection.
224 * The computed point is guaranteed to lie in the intersection of the
225 * bounding rectangles defined by each edge.
226 */ {
227 double z1, z2;
228
229 /* This is certainly not the most efficient way to find the intersection
230 * of two line segments, but it is very numerically stable.
231 *
232 * Strategy: find the two middle vertices in the VertLeq ordering,
233 * and interpolate the intersection s-value from these. Then repeat
234 * using the TransLeq ordering to find the intersection t-value.
235 */
236
237 if (!VertLeq(o1, d1)) {
238 GLUvertex temp = o1;
239 o1 = d1;
240 d1 = temp;
241 }
242 if (!VertLeq(o2, d2)) {
243 GLUvertex temp = o2;
244 o2 = d2;
245 d2 = temp;
246 }
247 if (!VertLeq(o1, o2)) {
248 GLUvertex temp = o1;
249 o1 = o2;
250 o2 = temp;
251 temp = d1;
252 d1 = d2;
253 d2 = temp;
254 }
255
256 if (!VertLeq(o2, d1)) {
257 /* Technically, no intersection -- do our best */
258 v.s = (o2.s + d1.s) / 2.0;
259 } else if (VertLeq(d1, d2)) {
260 /* Interpolate between o2 and d1 */
261 z1 = EdgeEval(o1, o2, d1);
262 z2 = EdgeEval(o2, d1, d2);
263 if (z1 + z2 < 0) {
264 z1 = -z1;
265 z2 = -z2;
266 }
267 v.s = Interpolate(z1, o2.s, z2, d1.s);
268 } else {
269 /* Interpolate between o2 and d2 */
270 z1 = EdgeSign(o1, o2, d1);
271 z2 = -EdgeSign(o1, d2, d1);
272 if (z1 + z2 < 0) {
273 z1 = -z1;
274 z2 = -z2;
275 }
276 v.s = Interpolate(z1, o2.s, z2, d2.s);
277 }
278
279 /* Now repeat the process for t */
280
281 if (!TransLeq(o1, d1)) {
282 GLUvertex temp = o1;
283 o1 = d1;
284 d1 = temp;
285 }
286 if (!TransLeq(o2, d2)) {
287 GLUvertex temp = o2;
288 o2 = d2;
289 d2 = temp;
290 }
291 if (!TransLeq(o1, o2)) {
292 GLUvertex temp = o2;
293 o2 = o1;
294 o1 = temp;
295 temp = d2;
296 d2 = d1;
297 d1 = temp;
298 }
299
300 if (!TransLeq(o2, d1)) {
301 /* Technically, no intersection -- do our best */
302 v.t = (o2.t + d1.t) / 2.0;
303 } else if (TransLeq(d1, d2)) {
304 /* Interpolate between o2 and d1 */
305 z1 = TransEval(o1, o2, d1);
306 z2 = TransEval(o2, d1, d2);
307 if (z1 + z2 < 0) {
308 z1 = -z1;
309 z2 = -z2;
310 }
311 v.t = Interpolate(z1, o2.t, z2, d1.t);
312 } else {
313 /* Interpolate between o2 and d2 */
314 z1 = TransSign(o1, o2, d1);
315 z2 = -TransSign(o1, d2, d1);
316 if (z1 + z2 < 0) {
317 z1 = -z1;
318 z2 = -z2;
319 }
320 v.t = Interpolate(z1, o2.t, z2, d2.t);
321 }
322 }
323
324 static boolean VertEq(GLUvertex u, GLUvertex v) {
325 return u.s == v.s && u.t == v.t;
326 }
327
328 static boolean VertLeq(GLUvertex u, GLUvertex v) {
329 return u.s < v.s || (u.s == v.s && u.t <= v.t);
330 }
331
332 /* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
333
334 static boolean TransLeq(GLUvertex u, GLUvertex v) {
335 return u.t < v.t || (u.t == v.t && u.s <= v.s);
336 }
337
338 static boolean EdgeGoesLeft(GLUhalfEdge e) {
339 return VertLeq(e.Sym.Org, e.Org);
340 }
341
342 static boolean EdgeGoesRight(GLUhalfEdge e) {
343 return VertLeq(e.Org, e.Sym.Org);
344 }
345
346 static double VertL1dist(GLUvertex u, GLUvertex v) {
347 return Math.abs(u.s - v.s) + Math.abs(u.t - v.t);
348 }
349 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class Mesh {
87 private Mesh() {
88 }
89
90 /************************ Utility Routines ************************/
91 /* MakeEdge creates a new pair of half-edges which form their own loop.
92 * No vertex or face structures are allocated, but these must be assigned
93 * before the current edge operation is completed.
94 */
95 static GLUhalfEdge MakeEdge(GLUhalfEdge eNext) {
96 GLUhalfEdge e;
97 GLUhalfEdge eSym;
98 GLUhalfEdge ePrev;
99
100 // EdgePair * pair = (EdgePair *)
101 // memAlloc(sizeof(EdgePair));
102 // if (pair == NULL) return NULL;
103 //
104 // e = &pair - > e;
105 e = new GLUhalfEdge(true);
106 // eSym = &pair - > eSym;
107 eSym = new GLUhalfEdge(false);
108
109
110 /* Make sure eNext points to the first edge of the edge pair */
111 if (!eNext.first) {
112 eNext = eNext.Sym;
113 }
114
115 /* Insert in circular doubly-linked list before eNext.
116 * Note that the prev pointer is stored in Sym->next.
117 */
118 ePrev = eNext.Sym.next;
119 eSym.next = ePrev;
120 ePrev.Sym.next = e;
121 e.next = eNext;
122 eNext.Sym.next = eSym;
123
124 e.Sym = eSym;
125 e.Onext = e;
126 e.Lnext = eSym;
127 e.Org = null;
128 e.Lface = null;
129 e.winding = 0;
130 e.activeRegion = null;
131
132 eSym.Sym = e;
133 eSym.Onext = eSym;
134 eSym.Lnext = e;
135 eSym.Org = null;
136 eSym.Lface = null;
137 eSym.winding = 0;
138 eSym.activeRegion = null;
139
140 return e;
141 }
142
143 /* Splice( a, b ) is best described by the Guibas/Stolfi paper or the
144 * CS348a notes (see mesh.h). Basically it modifies the mesh so that
145 * a->Onext and b->Onext are exchanged. This can have various effects
146 * depending on whether a and b belong to different face or vertex rings.
147 * For more explanation see __gl_meshSplice() below.
148 */
149 static void Splice(GLUhalfEdge a, GLUhalfEdge b) {
150 GLUhalfEdge aOnext = a.Onext;
151 GLUhalfEdge bOnext = b.Onext;
152
153 aOnext.Sym.Lnext = b;
154 bOnext.Sym.Lnext = a;
155 a.Onext = bOnext;
156 b.Onext = aOnext;
157 }
158
159 /* MakeVertex( newVertex, eOrig, vNext ) attaches a new vertex and makes it the
160 * origin of all edges in the vertex loop to which eOrig belongs. "vNext" gives
161 * a place to insert the new vertex in the global vertex list. We insert
162 * the new vertex *before* vNext so that algorithms which walk the vertex
163 * list will not see the newly created vertices.
164 */
165 static void MakeVertex(GLUvertex newVertex,
166 GLUhalfEdge eOrig, GLUvertex vNext) {
167 GLUhalfEdge e;
168 GLUvertex vPrev;
169 GLUvertex vNew = newVertex;
170
171 assert (vNew != null);
172
173 /* insert in circular doubly-linked list before vNext */
174 vPrev = vNext.prev;
175 vNew.prev = vPrev;
176 vPrev.next = vNew;
177 vNew.next = vNext;
178 vNext.prev = vNew;
179
180 vNew.anEdge = eOrig;
181 vNew.data = null;
182 /* leave coords, s, t undefined */
183
184 /* fix other edges on this vertex loop */
185 e = eOrig;
186 do {
187 e.Org = vNew;
188 e = e.Onext;
189 } while (e != eOrig);
190 }
191
192 /* MakeFace( newFace, eOrig, fNext ) attaches a new face and makes it the left
193 * face of all edges in the face loop to which eOrig belongs. "fNext" gives
194 * a place to insert the new face in the global face list. We insert
195 * the new face *before* fNext so that algorithms which walk the face
196 * list will not see the newly created faces.
197 */
198 static void MakeFace(GLUface newFace, GLUhalfEdge eOrig, GLUface fNext) {
199 GLUhalfEdge e;
200 GLUface fPrev;
201 GLUface fNew = newFace;
202
203 assert (fNew != null);
204
205 /* insert in circular doubly-linked list before fNext */
206 fPrev = fNext.prev;
207 fNew.prev = fPrev;
208 fPrev.next = fNew;
209 fNew.next = fNext;
210 fNext.prev = fNew;
211
212 fNew.anEdge = eOrig;
213 fNew.data = null;
214 fNew.trail = null;
215 fNew.marked = false;
216
217 /* The new face is marked "inside" if the old one was. This is a
218 * convenience for the common case where a face has been split in two.
219 */
220 fNew.inside = fNext.inside;
221
222 /* fix other edges on this face loop */
223 e = eOrig;
224 do {
225 e.Lface = fNew;
226 e = e.Lnext;
227 } while (e != eOrig);
228 }
229
230 /* KillEdge( eDel ) destroys an edge (the half-edges eDel and eDel->Sym),
231 * and removes from the global edge list.
232 */
233 static void KillEdge(GLUhalfEdge eDel) {
234 GLUhalfEdge ePrev, eNext;
235
236 /* Half-edges are allocated in pairs, see EdgePair above */
237 if (!eDel.first) {
238 eDel = eDel.Sym;
239 }
240
241 /* delete from circular doubly-linked list */
242 eNext = eDel.next;
243 ePrev = eDel.Sym.next;
244 eNext.Sym.next = ePrev;
245 ePrev.Sym.next = eNext;
246 }
247
248
249 /* KillVertex( vDel ) destroys a vertex and removes it from the global
250 * vertex list. It updates the vertex loop to point to a given new vertex.
251 */
252 static void KillVertex(GLUvertex vDel, GLUvertex newOrg) {
253 GLUhalfEdge e, eStart = vDel.anEdge;
254 GLUvertex vPrev, vNext;
255
256 /* change the origin of all affected edges */
257 e = eStart;
258 do {
259 e.Org = newOrg;
260 e = e.Onext;
261 } while (e != eStart);
262
263 /* delete from circular doubly-linked list */
264 vPrev = vDel.prev;
265 vNext = vDel.next;
266 vNext.prev = vPrev;
267 vPrev.next = vNext;
268 }
269
270 /* KillFace( fDel ) destroys a face and removes it from the global face
271 * list. It updates the face loop to point to a given new face.
272 */
273 static void KillFace(GLUface fDel, GLUface newLface) {
274 GLUhalfEdge e, eStart = fDel.anEdge;
275 GLUface fPrev, fNext;
276
277 /* change the left face of all affected edges */
278 e = eStart;
279 do {
280 e.Lface = newLface;
281 e = e.Lnext;
282 } while (e != eStart);
283
284 /* delete from circular doubly-linked list */
285 fPrev = fDel.prev;
286 fNext = fDel.next;
287 fNext.prev = fPrev;
288 fPrev.next = fNext;
289 }
290
291
292 /****************** Basic Edge Operations **********************/
293
294 /* __gl_meshMakeEdge creates one edge, two vertices, and a loop (face).
295 * The loop consists of the two new half-edges.
296 */
297 public static GLUhalfEdge __gl_meshMakeEdge(GLUmesh mesh) {
298 GLUvertex newVertex1 = new GLUvertex();
299 GLUvertex newVertex2 = new GLUvertex();
300 GLUface newFace = new GLUface();
301 GLUhalfEdge e;
302
303 e = MakeEdge(mesh.eHead);
304 if (e == null) return null;
305
306 MakeVertex(newVertex1, e, mesh.vHead);
307 MakeVertex(newVertex2, e.Sym, mesh.vHead);
308 MakeFace(newFace, e, mesh.fHead);
309 return e;
310 }
311
312
313 /* __gl_meshSplice( eOrg, eDst ) is the basic operation for changing the
314 * mesh connectivity and topology. It changes the mesh so that
315 * eOrg->Onext <- OLD( eDst->Onext )
316 * eDst->Onext <- OLD( eOrg->Onext )
317 * where OLD(...) means the value before the meshSplice operation.
318 *
319 * This can have two effects on the vertex structure:
320 * - if eOrg->Org != eDst->Org, the two vertices are merged together
321 * - if eOrg->Org == eDst->Org, the origin is split into two vertices
322 * In both cases, eDst->Org is changed and eOrg->Org is untouched.
323 *
324 * Similarly (and independently) for the face structure,
325 * - if eOrg->Lface == eDst->Lface, one loop is split into two
326 * - if eOrg->Lface != eDst->Lface, two distinct loops are joined into one
327 * In both cases, eDst->Lface is changed and eOrg->Lface is unaffected.
328 *
329 * Some special cases:
330 * If eDst == eOrg, the operation has no effect.
331 * If eDst == eOrg->Lnext, the new face will have a single edge.
332 * If eDst == eOrg->Lprev, the old face will have a single edge.
333 * If eDst == eOrg->Onext, the new vertex will have a single edge.
334 * If eDst == eOrg->Oprev, the old vertex will have a single edge.
335 */
336 public static boolean __gl_meshSplice(GLUhalfEdge eOrg, GLUhalfEdge eDst) {
337 boolean joiningLoops = false;
338 boolean joiningVertices = false;
339
340 if (eOrg == eDst) return true;
341
342 if (eDst.Org != eOrg.Org) {
343 /* We are merging two disjoint vertices -- destroy eDst->Org */
344 joiningVertices = true;
345 KillVertex(eDst.Org, eOrg.Org);
346 }
347 if (eDst.Lface != eOrg.Lface) {
348 /* We are connecting two disjoint loops -- destroy eDst.Lface */
349 joiningLoops = true;
350 KillFace(eDst.Lface, eOrg.Lface);
351 }
352
353 /* Change the edge structure */
354 Splice(eDst, eOrg);
355
356 if (!joiningVertices) {
357 GLUvertex newVertex = new GLUvertex();
358
359 /* We split one vertex into two -- the new vertex is eDst.Org.
360 * Make sure the old vertex points to a valid half-edge.
361 */
362 MakeVertex(newVertex, eDst, eOrg.Org);
363 eOrg.Org.anEdge = eOrg;
364 }
365 if (!joiningLoops) {
366 GLUface newFace = new GLUface();
367
368 /* We split one loop into two -- the new loop is eDst.Lface.
369 * Make sure the old face points to a valid half-edge.
370 */
371 MakeFace(newFace, eDst, eOrg.Lface);
372 eOrg.Lface.anEdge = eOrg;
373 }
374
375 return true;
376 }
377
378
379 /* __gl_meshDelete( eDel ) removes the edge eDel. There are several cases:
380 * if (eDel.Lface != eDel.Rface), we join two loops into one; the loop
381 * eDel.Lface is deleted. Otherwise, we are splitting one loop into two;
382 * the newly created loop will contain eDel.Dst. If the deletion of eDel
383 * would create isolated vertices, those are deleted as well.
384 *
385 * This function could be implemented as two calls to __gl_meshSplice
386 * plus a few calls to memFree, but this would allocate and delete
387 * unnecessary vertices and faces.
388 */
389 static boolean __gl_meshDelete(GLUhalfEdge eDel) {
390 GLUhalfEdge eDelSym = eDel.Sym;
391 boolean joiningLoops = false;
392
393 /* First step: disconnect the origin vertex eDel.Org. We make all
394 * changes to get a consistent mesh in this "intermediate" state.
395 */
396 if (eDel.Lface != eDel.Sym.Lface) {
397 /* We are joining two loops into one -- remove the left face */
398 joiningLoops = true;
399 KillFace(eDel.Lface, eDel.Sym.Lface);
400 }
401
402 if (eDel.Onext == eDel) {
403 KillVertex(eDel.Org, null);
404 } else {
405 /* Make sure that eDel.Org and eDel.Sym.Lface point to valid half-edges */
406 eDel.Sym.Lface.anEdge = eDel.Sym.Lnext;
407 eDel.Org.anEdge = eDel.Onext;
408
409 Splice(eDel, eDel.Sym.Lnext);
410 if (!joiningLoops) {
411 GLUface newFace = new GLUface();
412
413 /* We are splitting one loop into two -- create a new loop for eDel. */
414 MakeFace(newFace, eDel, eDel.Lface);
415 }
416 }
417
418 /* Claim: the mesh is now in a consistent state, except that eDel.Org
419 * may have been deleted. Now we disconnect eDel.Dst.
420 */
421 if (eDelSym.Onext == eDelSym) {
422 KillVertex(eDelSym.Org, null);
423 KillFace(eDelSym.Lface, null);
424 } else {
425 /* Make sure that eDel.Dst and eDel.Lface point to valid half-edges */
426 eDel.Lface.anEdge = eDelSym.Sym.Lnext;
427 eDelSym.Org.anEdge = eDelSym.Onext;
428 Splice(eDelSym, eDelSym.Sym.Lnext);
429 }
430
431 /* Any isolated vertices or faces have already been freed. */
432 KillEdge(eDel);
433
434 return true;
435 }
436
437
438 /******************** Other Edge Operations **********************/
439
440 /* All these routines can be implemented with the basic edge
441 * operations above. They are provided for convenience and efficiency.
442 */
443
444
445 /* __gl_meshAddEdgeVertex( eOrg ) creates a new edge eNew such that
446 * eNew == eOrg.Lnext, and eNew.Dst is a newly created vertex.
447 * eOrg and eNew will have the same left face.
448 */
449 static GLUhalfEdge __gl_meshAddEdgeVertex(GLUhalfEdge eOrg) {
450 GLUhalfEdge eNewSym;
451 GLUhalfEdge eNew = MakeEdge(eOrg);
452
453 eNewSym = eNew.Sym;
454
455 /* Connect the new edge appropriately */
456 Splice(eNew, eOrg.Lnext);
457
458 /* Set the vertex and face information */
459 eNew.Org = eOrg.Sym.Org;
460 {
461 GLUvertex newVertex = new GLUvertex();
462
463 MakeVertex(newVertex, eNewSym, eNew.Org);
464 }
465 eNew.Lface = eNewSym.Lface = eOrg.Lface;
466
467 return eNew;
468 }
469
470
471 /* __gl_meshSplitEdge( eOrg ) splits eOrg into two edges eOrg and eNew,
472 * such that eNew == eOrg.Lnext. The new vertex is eOrg.Sym.Org == eNew.Org.
473 * eOrg and eNew will have the same left face.
474 */
475 public static GLUhalfEdge __gl_meshSplitEdge(GLUhalfEdge eOrg) {
476 GLUhalfEdge eNew;
477 GLUhalfEdge tempHalfEdge = __gl_meshAddEdgeVertex(eOrg);
478
479 eNew = tempHalfEdge.Sym;
480
481 /* Disconnect eOrg from eOrg.Sym.Org and connect it to eNew.Org */
482 Splice(eOrg.Sym, eOrg.Sym.Sym.Lnext);
483 Splice(eOrg.Sym, eNew);
484
485 /* Set the vertex and face information */
486 eOrg.Sym.Org = eNew.Org;
487 eNew.Sym.Org.anEdge = eNew.Sym; /* may have pointed to eOrg.Sym */
488 eNew.Sym.Lface = eOrg.Sym.Lface;
489 eNew.winding = eOrg.winding; /* copy old winding information */
490 eNew.Sym.winding = eOrg.Sym.winding;
491
492 return eNew;
493 }
494
495
496 /* __gl_meshConnect( eOrg, eDst ) creates a new edge from eOrg.Sym.Org
497 * to eDst.Org, and returns the corresponding half-edge eNew.
498 * If eOrg.Lface == eDst.Lface, this splits one loop into two,
499 * and the newly created loop is eNew.Lface. Otherwise, two disjoint
500 * loops are merged into one, and the loop eDst.Lface is destroyed.
501 *
502 * If (eOrg == eDst), the new face will have only two edges.
503 * If (eOrg.Lnext == eDst), the old face is reduced to a single edge.
504 * If (eOrg.Lnext.Lnext == eDst), the old face is reduced to two edges.
505 */
506 static GLUhalfEdge __gl_meshConnect(GLUhalfEdge eOrg, GLUhalfEdge eDst) {
507 GLUhalfEdge eNewSym;
508 boolean joiningLoops = false;
509 GLUhalfEdge eNew = MakeEdge(eOrg);
510
511 eNewSym = eNew.Sym;
512
513 if (eDst.Lface != eOrg.Lface) {
514 /* We are connecting two disjoint loops -- destroy eDst.Lface */
515 joiningLoops = true;
516 KillFace(eDst.Lface, eOrg.Lface);
517 }
518
519 /* Connect the new edge appropriately */
520 Splice(eNew, eOrg.Lnext);
521 Splice(eNewSym, eDst);
522
523 /* Set the vertex and face information */
524 eNew.Org = eOrg.Sym.Org;
525 eNewSym.Org = eDst.Org;
526 eNew.Lface = eNewSym.Lface = eOrg.Lface;
527
528 /* Make sure the old face points to a valid half-edge */
529 eOrg.Lface.anEdge = eNewSym;
530
531 if (!joiningLoops) {
532 GLUface newFace = new GLUface();
533
534 /* We split one loop into two -- the new loop is eNew.Lface */
535 MakeFace(newFace, eNew, eOrg.Lface);
536 }
537 return eNew;
538 }
539
540
541 /******************** Other Operations **********************/
542
543 /* __gl_meshZapFace( fZap ) destroys a face and removes it from the
544 * global face list. All edges of fZap will have a null pointer as their
545 * left face. Any edges which also have a null pointer as their right face
546 * are deleted entirely (along with any isolated vertices this produces).
547 * An entire mesh can be deleted by zapping its faces, one at a time,
548 * in any order. Zapped faces cannot be used in further mesh operations!
549 */
550 static void __gl_meshZapFace(GLUface fZap) {
551 GLUhalfEdge eStart = fZap.anEdge;
552 GLUhalfEdge e, eNext, eSym;
553 GLUface fPrev, fNext;
554
555 /* walk around face, deleting edges whose right face is also null */
556 eNext = eStart.Lnext;
557 do {
558 e = eNext;
559 eNext = e.Lnext;
560
561 e.Lface = null;
562 if (e.Sym.Lface == null) {
563 /* delete the edge -- see __gl_MeshDelete above */
564
565 if (e.Onext == e) {
566 KillVertex(e.Org, null);
567 } else {
568 /* Make sure that e.Org points to a valid half-edge */
569 e.Org.anEdge = e.Onext;
570 Splice(e, e.Sym.Lnext);
571 }
572 eSym = e.Sym;
573 if (eSym.Onext == eSym) {
574 KillVertex(eSym.Org, null);
575 } else {
576 /* Make sure that eSym.Org points to a valid half-edge */
577 eSym.Org.anEdge = eSym.Onext;
578 Splice(eSym, eSym.Sym.Lnext);
579 }
580 KillEdge(e);
581 }
582 } while (e != eStart);
583
584 /* delete from circular doubly-linked list */
585 fPrev = fZap.prev;
586 fNext = fZap.next;
587 fNext.prev = fPrev;
588 fPrev.next = fNext;
589 }
590
591
592 /* __gl_meshNewMesh() creates a new mesh with no edges, no vertices,
593 * and no loops (what we usually call a "face").
594 */
595 public static GLUmesh __gl_meshNewMesh() {
596 GLUvertex v;
597 GLUface f;
598 GLUhalfEdge e;
599 GLUhalfEdge eSym;
600 GLUmesh mesh = new GLUmesh();
601
602 v = mesh.vHead;
603 f = mesh.fHead;
604 e = mesh.eHead;
605 eSym = mesh.eHeadSym;
606
607 v.next = v.prev = v;
608 v.anEdge = null;
609 v.data = null;
610
611 f.next = f.prev = f;
612 f.anEdge = null;
613 f.data = null;
614 f.trail = null;
615 f.marked = false;
616 f.inside = false;
617
618 e.next = e;
619 e.Sym = eSym;
620 e.Onext = null;
621 e.Lnext = null;
622 e.Org = null;
623 e.Lface = null;
624 e.winding = 0;
625 e.activeRegion = null;
626
627 eSym.next = eSym;
628 eSym.Sym = e;
629 eSym.Onext = null;
630 eSym.Lnext = null;
631 eSym.Org = null;
632 eSym.Lface = null;
633 eSym.winding = 0;
634 eSym.activeRegion = null;
635
636 return mesh;
637 }
638
639
640 /* __gl_meshUnion( mesh1, mesh2 ) forms the union of all structures in
641 * both meshes, and returns the new mesh (the old meshes are destroyed).
642 */
643 static GLUmesh __gl_meshUnion(GLUmesh mesh1, GLUmesh mesh2) {
644 GLUface f1 = mesh1.fHead;
645 GLUvertex v1 = mesh1.vHead;
646 GLUhalfEdge e1 = mesh1.eHead;
647 GLUface f2 = mesh2.fHead;
648 GLUvertex v2 = mesh2.vHead;
649 GLUhalfEdge e2 = mesh2.eHead;
650
651 /* Add the faces, vertices, and edges of mesh2 to those of mesh1 */
652 if (f2.next != f2) {
653 f1.prev.next = f2.next;
654 f2.next.prev = f1.prev;
655 f2.prev.next = f1;
656 f1.prev = f2.prev;
657 }
658
659 if (v2.next != v2) {
660 v1.prev.next = v2.next;
661 v2.next.prev = v1.prev;
662 v2.prev.next = v1;
663 v1.prev = v2.prev;
664 }
665
666 if (e2.next != e2) {
667 e1.Sym.next.Sym.next = e2.next;
668 e2.next.Sym.next = e1.Sym.next;
669 e2.Sym.next.Sym.next = e1;
670 e1.Sym.next = e2.Sym.next;
671 }
672
673 return mesh1;
674 }
675
676
677 /* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh.
678 */
679 static void __gl_meshDeleteMeshZap(GLUmesh mesh) {
680 GLUface fHead = mesh.fHead;
681
682 while (fHead.next != fHead) {
683 __gl_meshZapFace(fHead.next);
684 }
685 assert (mesh.vHead.next == mesh.vHead);
686 }
687
688 /* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh.
689 */
690 public static void __gl_meshDeleteMesh(GLUmesh mesh) {
691 GLUface f, fNext;
692 GLUvertex v, vNext;
693 GLUhalfEdge e, eNext;
694
695 for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) {
696 fNext = f.next;
697 }
698
699 for (v = mesh.vHead.next; v != mesh.vHead; v = vNext) {
700 vNext = v.next;
701 }
702
703 for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) {
704 /* One call frees both e and e.Sym (see EdgePair above) */
705 eNext = e.next;
706 }
707 }
708
709 /* __gl_meshCheckMesh( mesh ) checks a mesh for self-consistency.
710 */
711 public static void __gl_meshCheckMesh(GLUmesh mesh) {
712 GLUface fHead = mesh.fHead;
713 GLUvertex vHead = mesh.vHead;
714 GLUhalfEdge eHead = mesh.eHead;
715 GLUface f, fPrev;
716 GLUvertex v, vPrev;
717 GLUhalfEdge e, ePrev;
718
719 fPrev = fHead;
720 for (fPrev = fHead; (f = fPrev.next) != fHead; fPrev = f) {
721 assert (f.prev == fPrev);
722 e = f.anEdge;
723 do {
724 assert (e.Sym != e);
725 assert (e.Sym.Sym == e);
726 assert (e.Lnext.Onext.Sym == e);
727 assert (e.Onext.Sym.Lnext == e);
728 assert (e.Lface == f);
729 e = e.Lnext;
730 } while (e != f.anEdge);
731 }
732 assert (f.prev == fPrev && f.anEdge == null && f.data == null);
733
734 vPrev = vHead;
735 for (vPrev = vHead; (v = vPrev.next) != vHead; vPrev = v) {
736 assert (v.prev == vPrev);
737 e = v.anEdge;
738 do {
739 assert (e.Sym != e);
740 assert (e.Sym.Sym == e);
741 assert (e.Lnext.Onext.Sym == e);
742 assert (e.Onext.Sym.Lnext == e);
743 assert (e.Org == v);
744 e = e.Onext;
745 } while (e != v.anEdge);
746 }
747 assert (v.prev == vPrev && v.anEdge == null && v.data == null);
748
749 ePrev = eHead;
750 for (ePrev = eHead; (e = ePrev.next) != eHead; ePrev = e) {
751 assert (e.Sym.next == ePrev.Sym);
752 assert (e.Sym != e);
753 assert (e.Sym.Sym == e);
754 assert (e.Org != null);
755 assert (e.Sym.Org != null);
756 assert (e.Lnext.Onext.Sym == e);
757 assert (e.Onext.Sym.Lnext == e);
758 }
759 assert (e.Sym.next == ePrev.Sym
760 && e.Sym == mesh.eHeadSym
761 && e.Sym.Sym == e
762 && e.Org == null && e.Sym.Org == null
763 && e.Lface == null && e.Sym.Lface == null);
764 }
765 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 import org.lwjgl.util.glu.GLU;
87
88 class Normal {
89 private Normal() {
90 }
91
92 static boolean SLANTED_SWEEP = false;
93 static double S_UNIT_X; /* Pre-normalized */
94 static double S_UNIT_Y;
95 private static final boolean TRUE_PROJECT = false;
96
97 static {
98 if (SLANTED_SWEEP) {
99 /* The "feature merging" is not intended to be complete. There are
100 * special cases where edges are nearly parallel to the sweep line
101 * which are not implemented. The algorithm should still behave
102 * robustly (ie. produce a reasonable tesselation) in the presence
103 * of such edges, however it may miss features which could have been
104 * merged. We could minimize this effect by choosing the sweep line
105 * direction to be something unusual (ie. not parallel to one of the
106 * coordinate axes).
107 */
108 S_UNIT_X = 0.50941539564955385; /* Pre-normalized */
109 S_UNIT_Y = 0.86052074622010633;
110 } else {
111 S_UNIT_X = 1.0;
112 S_UNIT_Y = 0.0;
113 }
114 }
115
116 private static double Dot(double[] u, double[] v) {
117 return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]);
118 }
119
120 static void Normalize(double[] v) {
121 double len = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
122
123 assert (len > 0);
124 len = Math.sqrt(len);
125 v[0] /= len;
126 v[1] /= len;
127 v[2] /= len;
128 }
129
130 static int LongAxis(double[] v) {
131 int i = 0;
132
133 if (Math.abs(v[1]) > Math.abs(v[0])) {
134 i = 1;
135 }
136 if (Math.abs(v[2]) > Math.abs(v[i])) {
137 i = 2;
138 }
139 return i;
140 }
141
142 static void ComputeNormal(GLUtessellatorImpl tess, double[] norm) {
143 GLUvertex v, v1, v2;
144 double c, tLen2, maxLen2;
145 double[] maxVal, minVal, d1, d2, tNorm;
146 GLUvertex[] maxVert, minVert;
147 GLUvertex vHead = tess.mesh.vHead;
148 int i;
149
150 maxVal = new double[3];
151 minVal = new double[3];
152 minVert = new GLUvertex[3];
153 maxVert = new GLUvertex[3];
154 d1 = new double[3];
155 d2 = new double[3];
156 tNorm = new double[3];
157
158 maxVal[0] = maxVal[1] = maxVal[2] = -2 * GLU.TESS_MAX_COORD;
159 minVal[0] = minVal[1] = minVal[2] = 2 * GLU.TESS_MAX_COORD;
160
161 for (v = vHead.next; v != vHead; v = v.next) {
162 for (i = 0; i < 3; ++i) {
163 c = v.coords[i];
164 if (c < minVal[i]) {
165 minVal[i] = c;
166 minVert[i] = v;
167 }
168 if (c > maxVal[i]) {
169 maxVal[i] = c;
170 maxVert[i] = v;
171 }
172 }
173 }
174
175 /* Find two vertices separated by at least 1/sqrt(3) of the maximum
176 * distance between any two vertices
177 */
178 i = 0;
179 if (maxVal[1] - minVal[1] > maxVal[0] - minVal[0]) {
180 i = 1;
181 }
182 if (maxVal[2] - minVal[2] > maxVal[i] - minVal[i]) {
183 i = 2;
184 }
185 if (minVal[i] >= maxVal[i]) {
186 /* All vertices are the same -- normal doesn't matter */
187 norm[0] = 0;
188 norm[1] = 0;
189 norm[2] = 1;
190 return;
191 }
192
193 /* Look for a third vertex which forms the triangle with maximum area
194 * (Length of normal == twice the triangle area)
195 */
196 maxLen2 = 0;
197 v1 = minVert[i];
198 v2 = maxVert[i];
199 d1[0] = v1.coords[0] - v2.coords[0];
200 d1[1] = v1.coords[1] - v2.coords[1];
201 d1[2] = v1.coords[2] - v2.coords[2];
202 for (v = vHead.next; v != vHead; v = v.next) {
203 d2[0] = v.coords[0] - v2.coords[0];
204 d2[1] = v.coords[1] - v2.coords[1];
205 d2[2] = v.coords[2] - v2.coords[2];
206 tNorm[0] = d1[1] * d2[2] - d1[2] * d2[1];
207 tNorm[1] = d1[2] * d2[0] - d1[0] * d2[2];
208 tNorm[2] = d1[0] * d2[1] - d1[1] * d2[0];
209 tLen2 = tNorm[0] * tNorm[0] + tNorm[1] * tNorm[1] + tNorm[2] * tNorm[2];
210 if (tLen2 > maxLen2) {
211 maxLen2 = tLen2;
212 norm[0] = tNorm[0];
213 norm[1] = tNorm[1];
214 norm[2] = tNorm[2];
215 }
216 }
217
218 if (maxLen2 <= 0) {
219 /* All points lie on a single line -- any decent normal will do */
220 norm[0] = norm[1] = norm[2] = 0;
221 norm[LongAxis(d1)] = 1;
222 }
223 }
224
225 static void CheckOrientation(GLUtessellatorImpl tess) {
226 double area;
227 GLUface f, fHead = tess.mesh.fHead;
228 GLUvertex v, vHead = tess.mesh.vHead;
229 GLUhalfEdge e;
230
231 /* When we compute the normal automatically, we choose the orientation
232 * so that the the sum of the signed areas of all contours is non-negative.
233 */
234 area = 0;
235 for (f = fHead.next; f != fHead; f = f.next) {
236 e = f.anEdge;
237 if (e.winding <= 0) continue;
238 do {
239 area += (e.Org.s - e.Sym.Org.s) * (e.Org.t + e.Sym.Org.t);
240 e = e.Lnext;
241 } while (e != f.anEdge);
242 }
243 if (area < 0) {
244 /* Reverse the orientation by flipping all the t-coordinates */
245 for (v = vHead.next; v != vHead; v = v.next) {
246 v.t = -v.t;
247 }
248 tess.tUnit[0] = -tess.tUnit[0];
249 tess.tUnit[1] = -tess.tUnit[1];
250 tess.tUnit[2] = -tess.tUnit[2];
251 }
252 }
253
254 /* Determine the polygon normal and project vertices onto the plane
255 * of the polygon.
256 */
257 public static void __gl_projectPolygon(GLUtessellatorImpl tess) {
258 GLUvertex v, vHead = tess.mesh.vHead;
259 double w;
260 double[] norm = new double[3];
261 double[] sUnit, tUnit;
262 int i;
263 boolean computedNormal = false;
264
265 norm[0] = tess.normal[0];
266 norm[1] = tess.normal[1];
267 norm[2] = tess.normal[2];
268 if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) {
269 ComputeNormal(tess, norm);
270 computedNormal = true;
271 }
272 sUnit = tess.sUnit;
273 tUnit = tess.tUnit;
274 i = LongAxis(norm);
275
276 if (TRUE_PROJECT) {
277 /* Choose the initial sUnit vector to be approximately perpendicular
278 * to the normal.
279 */
280 Normalize(norm);
281
282 sUnit[i] = 0;
283 sUnit[(i + 1) % 3] = S_UNIT_X;
284 sUnit[(i + 2) % 3] = S_UNIT_Y;
285
286 /* Now make it exactly perpendicular */
287 w = Dot(sUnit, norm);
288 sUnit[0] -= w * norm[0];
289 sUnit[1] -= w * norm[1];
290 sUnit[2] -= w * norm[2];
291 Normalize(sUnit);
292
293 /* Choose tUnit so that (sUnit,tUnit,norm) form a right-handed frame */
294 tUnit[0] = norm[1] * sUnit[2] - norm[2] * sUnit[1];
295 tUnit[1] = norm[2] * sUnit[0] - norm[0] * sUnit[2];
296 tUnit[2] = norm[0] * sUnit[1] - norm[1] * sUnit[0];
297 Normalize(tUnit);
298 } else {
299 /* Project perpendicular to a coordinate axis -- better numerically */
300 sUnit[i] = 0;
301 sUnit[(i + 1) % 3] = S_UNIT_X;
302 sUnit[(i + 2) % 3] = S_UNIT_Y;
303
304 tUnit[i] = 0;
305 tUnit[(i + 1) % 3] = (norm[i] > 0) ? -S_UNIT_Y : S_UNIT_Y;
306 tUnit[(i + 2) % 3] = (norm[i] > 0) ? S_UNIT_X : -S_UNIT_X;
307 }
308
309 /* Project the vertices onto the sweep plane */
310 for (v = vHead.next; v != vHead; v = v.next) {
311 v.s = Dot(v.coords, sUnit);
312 v.t = Dot(v.coords, tUnit);
313 }
314 if (computedNormal) {
315 CheckOrientation(tess);
316 }
317 }
318 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 abstract class PriorityQ {
87 public static final int INIT_SIZE = 32;
88
89 public static class PQnode {
90 int handle;
91 }
92
93 public static class PQhandleElem {
94 Object key;
95 int node;
96 }
97
98 public static interface Leq {
99 boolean leq(Object key1, Object key2);
100 }
101
102 // #ifdef FOR_TRITE_TEST_PROGRAM
103 // private static boolean LEQ(PriorityQCommon.Leq leq, Object x,Object y) {
104 // return pq.leq.leq(x,y);
105 // }
106 // #else
107 /* Violates modularity, but a little faster */
108 // #include "geom.h"
109 public static boolean LEQ(Leq leq, Object x, Object y) {
110 return Geom.VertLeq((GLUvertex) x, (GLUvertex) y);
111 }
112
113 static PriorityQ pqNewPriorityQ(Leq leq) {
114 return new PriorityQSort(leq);
115 }
116
117 abstract void pqDeletePriorityQ();
118
119 abstract boolean pqInit();
120
121 abstract int pqInsert(Object keyNew);
122
123 abstract Object pqExtractMin();
124
125 abstract void pqDelete(int hCurr);
126
127 abstract Object pqMinimum();
128
129 abstract boolean pqIsEmpty();
130 // #endif
131 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86
87
88 class PriorityQHeap extends PriorityQ {
89 PriorityQ.PQnode[] nodes;
90 PriorityQ.PQhandleElem[] handles;
91 int size, max;
92 int freeList;
93 boolean initialized;
94 PriorityQ.Leq leq;
95
96 /* really __gl_pqHeapNewPriorityQ */
97 public PriorityQHeap(PriorityQ.Leq leq) {
98 size = 0;
99 max = PriorityQ.INIT_SIZE;
100 nodes = new PriorityQ.PQnode[PriorityQ.INIT_SIZE + 1];
101 for (int i = 0; i < nodes.length; i++) {
102 nodes[i] = new PQnode();
103 }
104 handles = new PriorityQ.PQhandleElem[PriorityQ.INIT_SIZE + 1];
105 for (int i = 0; i < handles.length; i++) {
106 handles[i] = new PQhandleElem();
107 }
108 initialized = false;
109 freeList = 0;
110 this.leq = leq;
111
112 nodes[1].handle = 1; /* so that Minimum() returns NULL */
113 handles[1].key = null;
114 }
115
116 /* really __gl_pqHeapDeletePriorityQ */
117 void pqDeletePriorityQ() {
118 handles = null;
119 nodes = null;
120 }
121
122 void FloatDown(int curr) {
123 PriorityQ.PQnode[] n = nodes;
124 PriorityQ.PQhandleElem[] h = handles;
125 int hCurr, hChild;
126 int child;
127
128 hCurr = n[curr].handle;
129 for (; ;) {
130 child = curr << 1;
131 if (child < size && LEQ(leq, h[n[child + 1].handle].key,
132 h[n[child].handle].key)) {
133 ++child;
134 }
135
136 assert (child <= max);
137
138 hChild = n[child].handle;
139 if (child > size || LEQ(leq, h[hCurr].key, h[hChild].key)) {
140 n[curr].handle = hCurr;
141 h[hCurr].node = curr;
142 break;
143 }
144 n[curr].handle = hChild;
145 h[hChild].node = curr;
146 curr = child;
147 }
148 }
149
150
151 void FloatUp(int curr) {
152 PriorityQ.PQnode[] n = nodes;
153 PriorityQ.PQhandleElem[] h = handles;
154 int hCurr, hParent;
155 int parent;
156
157 hCurr = n[curr].handle;
158 for (; ;) {
159 parent = curr >> 1;
160 hParent = n[parent].handle;
161 if (parent == 0 || LEQ(leq, h[hParent].key, h[hCurr].key)) {
162 n[curr].handle = hCurr;
163 h[hCurr].node = curr;
164 break;
165 }
166 n[curr].handle = hParent;
167 h[hParent].node = curr;
168 curr = parent;
169 }
170 }
171
172 /* really __gl_pqHeapInit */
173 boolean pqInit() {
174 int i;
175
176 /* This method of building a heap is O(n), rather than O(n lg n). */
177
178 for (i = size; i >= 1; --i) {
179 FloatDown(i);
180 }
181 initialized = true;
182
183 return true;
184 }
185
186 /* really __gl_pqHeapInsert */
187 /* returns LONG_MAX iff out of memory */
188 int pqInsert(Object keyNew) {
189 int curr;
190 int free;
191
192 curr = ++size;
193 if ((curr * 2) > max) {
194 PriorityQ.PQnode[] saveNodes = nodes;
195 PriorityQ.PQhandleElem[] saveHandles = handles;
196
197 /* If the heap overflows, double its size. */
198 max <<= 1;
199 // pq->nodes = (PQnode *)memRealloc( pq->nodes, (size_t) ((pq->max + 1) * sizeof( pq->nodes[0] )));
200 PriorityQ.PQnode[] pqNodes = new PriorityQ.PQnode[max + 1];
201 System.arraycopy( nodes, 0, pqNodes, 0, nodes.length );
202 for (int i = nodes.length; i < pqNodes.length; i++) {
203 pqNodes[i] = new PQnode();
204 }
205 nodes = pqNodes;
206 if (nodes == null) {
207 nodes = saveNodes; /* restore ptr to free upon return */
208 return Integer.MAX_VALUE;
209 }
210
211 // pq->handles = (PQhandleElem *)memRealloc( pq->handles,(size_t)((pq->max + 1) * sizeof( pq->handles[0] )));
212 PriorityQ.PQhandleElem[] pqHandles = new PriorityQ.PQhandleElem[max + 1];
213 System.arraycopy( handles, 0, pqHandles, 0, handles.length );
214 for (int i = handles.length; i < pqHandles.length; i++) {
215 pqHandles[i] = new PQhandleElem();
216 }
217 handles = pqHandles;
218 if (handles == null) {
219 handles = saveHandles; /* restore ptr to free upon return */
220 return Integer.MAX_VALUE;
221 }
222 }
223
224 if (freeList == 0) {
225 free = curr;
226 } else {
227 free = freeList;
228 freeList = handles[free].node;
229 }
230
231 nodes[curr].handle = free;
232 handles[free].node = curr;
233 handles[free].key = keyNew;
234
235 if (initialized) {
236 FloatUp(curr);
237 }
238 assert (free != Integer.MAX_VALUE);
239 return free;
240 }
241
242 /* really __gl_pqHeapExtractMin */
243 Object pqExtractMin() {
244 PriorityQ.PQnode[] n = nodes;
245 PriorityQ.PQhandleElem[] h = handles;
246 int hMin = n[1].handle;
247 Object min = h[hMin].key;
248
249 if (size > 0) {
250 n[1].handle = n[size].handle;
251 h[n[1].handle].node = 1;
252
253 h[hMin].key = null;
254 h[hMin].node = freeList;
255 freeList = hMin;
256
257 if (--size > 0) {
258 FloatDown(1);
259 }
260 }
261 return min;
262 }
263
264 /* really __gl_pqHeapDelete */
265 void pqDelete(int hCurr) {
266 PriorityQ.PQnode[] n = nodes;
267 PriorityQ.PQhandleElem[] h = handles;
268 int curr;
269
270 assert (hCurr >= 1 && hCurr <= max && h[hCurr].key != null);
271
272 curr = h[hCurr].node;
273 n[curr].handle = n[size].handle;
274 h[n[curr].handle].node = curr;
275
276 if (curr <= --size) {
277 if (curr <= 1 || LEQ(leq, h[n[curr >> 1].handle].key, h[n[curr].handle].key)) {
278 FloatDown(curr);
279 } else {
280 FloatUp(curr);
281 }
282 }
283 h[hCurr].key = null;
284 h[hCurr].node = freeList;
285 freeList = hCurr;
286 }
287
288 Object pqMinimum() {
289 return handles[nodes[1].handle].key;
290 }
291
292 boolean pqIsEmpty() {
293 return size == 0;
294 }
295 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 ** License Applicability. Except to the extent portions of this file are
34 ** made subject to an alternative license as permitted in the SGI Free
35 ** Software License B, Version 1.1 (the "License"), the contents of this
36 ** file are subject only to the provisions of the License. You may not use
37 ** this file except in compliance with the License. You may obtain a copy
38 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
39 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
40 **
41 ** http://oss.sgi.com/projects/FreeB
42 **
43 ** Note that, as provided in the License, the Software is distributed on an
44 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
45 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
46 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
47 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
48 **
49 ** NOTE: The Original Code (as defined below) has been licensed to Sun
50 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
51 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
52 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
53 ** you under an alternative license ("Alternative License"). This
54 ** Alternative License includes all of the provisions of the SGI License
55 ** except that Section 2.2 and 11 are omitted. Any differences between
56 ** the Alternative License and the SGI License are offered solely by Sun
57 ** and not by SGI.
58 **
59 ** Original Code. The Original Code is: OpenGL Sample Implementation,
60 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
61 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
62 ** Copyright in any portions created by third parties is as indicated
63 ** elsewhere herein. All Rights Reserved.
64 **
65 ** Additional Notice Provisions: The application programming interfaces
66 ** established by SGI in conjunction with the Original Code are The
67 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
68 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
69 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
70 ** Window System(R) (Version 1.3), released October 19, 1998. This software
71 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
72 ** published by SGI, but has not been independently verified as being
73 ** compliant with the OpenGL(R) version 1.2.1 Specification.
74 **
75 ** Author: Eric Veach, July 1994
76 ** Java Port: Pepijn Van Eeckhoudt, July 2003
77 ** Java Port: Nathan Parker Burg, August 2003
78 */
79 package org.lwjgl.util.glu.tessellation;
80
81
82
83 class PriorityQSort extends PriorityQ {
84 PriorityQHeap heap;
85 Object[] keys;
86
87 // JAVA: 'order' contains indices into the keys array.
88 // This simulates the indirect pointers used in the original C code
89 // (from Frank Suykens, Luciad.com).
90 int[] order;
91 int size, max;
92 boolean initialized;
93 PriorityQ.Leq leq;
94
95 public PriorityQSort(PriorityQ.Leq leq) {
96 heap = new PriorityQHeap(leq);
97
98 keys = new Object[PriorityQ.INIT_SIZE];
99
100 size = 0;
101 max = PriorityQ.INIT_SIZE;
102 initialized = false;
103 this.leq = leq;
104 }
105
106 /* really __gl_pqSortDeletePriorityQ */
107 void pqDeletePriorityQ() {
108 if (heap != null) heap.pqDeletePriorityQ();
109 order = null;
110 keys = null;
111 }
112
113 private static boolean LT(PriorityQ.Leq leq, Object x, Object y) {
114 return (!PriorityQHeap.LEQ(leq, y, x));
115 }
116
117 private static boolean GT(PriorityQ.Leq leq, Object x, Object y) {
118 return (!PriorityQHeap.LEQ(leq, x, y));
119 }
120
121 private static void Swap(int[] array, int a, int b) {
122 if (true) {
123 int tmp = array[a];
124 array[a] = array[b];
125 array[b] = tmp;
126 } else {
127
128 }
129 }
130
131 private static class Stack {
132 int p, r;
133 }
134
135 /* really __gl_pqSortInit */
136 boolean pqInit() {
137 int p, r, i, j;
138 int piv;
139 Stack[] stack = new Stack[50];
140 for (int k = 0; k < stack.length; k++) {
141 stack[k] = new Stack();
142 }
143 int top = 0;
144
145 int seed = 2016473283;
146
147 /* Create an array of indirect pointers to the keys, so that we
148 * the handles we have returned are still valid.
149 */
150 order = new int[size + 1];
151 /* the previous line is a patch to compensate for the fact that IBM */
152 /* machines return a null on a malloc of zero bytes (unlike SGI), */
153 /* so we have to put in this defense to guard against a memory */
154 /* fault four lines down. from fossum@austin.ibm.com. */
155 p = 0;
156 r = size - 1;
157 for (piv = 0, i = p; i <= r; ++piv, ++i) {
158 // indirect pointers: keep an index into the keys array, not a direct pointer to its contents
159 order[i] = piv;
160 }
161
162 /* Sort the indirect pointers in descending order,
163 * using randomized Quicksort
164 */
165 stack[top].p = p;
166 stack[top].r = r;
167 ++top;
168 while (--top >= 0) {
169 p = stack[top].p;
170 r = stack[top].r;
171 while (r > p + 10) {
172 seed = Math.abs( seed * 1539415821 + 1 );
173 i = p + seed % (r - p + 1);
174 piv = order[i];
175 order[i] = order[p];
176 order[p] = piv;
177 i = p - 1;
178 j = r + 1;
179 do {
180 do {
181 ++i;
182 } while (GT(leq, keys[order[i]], keys[piv]));
183 do {
184 --j;
185 } while (LT(leq, keys[order[j]], keys[piv]));
186 Swap(order, i, j);
187 } while (i < j);
188 Swap(order, i, j); /* Undo last swap */
189 if (i - p < r - j) {
190 stack[top].p = j + 1;
191 stack[top].r = r;
192 ++top;
193 r = i - 1;
194 } else {
195 stack[top].p = p;
196 stack[top].r = i - 1;
197 ++top;
198 p = j + 1;
199 }
200 }
201 /* Insertion sort small lists */
202 for (i = p + 1; i <= r; ++i) {
203 piv = order[i];
204 for (j = i; j > p && LT(leq, keys[order[j - 1]], keys[piv]); --j) {
205 order[j] = order[j - 1];
206 }
207 order[j] = piv;
208 }
209 }
210 max = size;
211 initialized = true;
212 heap.pqInit(); /* always succeeds */
213
214 /* #ifndef NDEBUG
215 p = order;
216 r = p + size - 1;
217 for (i = p; i < r; ++i) {
218 Assertion.doAssert(LEQ( * * (i + 1), **i ));
219 }
220 #endif*/
221
222 return true;
223 }
224
225 /* really __gl_pqSortInsert */
226 /* returns LONG_MAX iff out of memory */
227 int pqInsert(Object keyNew) {
228 int curr;
229
230 if (initialized) {
231 return heap.pqInsert(keyNew);
232 }
233 curr = size;
234 if (++size >= max) {
235 Object[] saveKey = keys;
236
237 /* If the heap overflows, double its size. */
238 max <<= 1;
239 // pq->keys = (PQHeapKey *)memRealloc( pq->keys,(size_t)(pq->max * sizeof( pq->keys[0] )));
240 Object[] pqKeys = new Object[max];
241 System.arraycopy( keys, 0, pqKeys, 0, keys.length );
242 keys = pqKeys;
243 if (keys == null) {
244 keys = saveKey; /* restore ptr to free upon return */
245 return Integer.MAX_VALUE;
246 }
247 }
248 assert curr != Integer.MAX_VALUE;
249 keys[curr] = keyNew;
250
251 /* Negative handles index the sorted array. */
252 return -(curr + 1);
253 }
254
255 /* really __gl_pqSortExtractMin */
256 Object pqExtractMin() {
257 Object sortMin, heapMin;
258
259 if (size == 0) {
260 return heap.pqExtractMin();
261 }
262 sortMin = keys[order[size - 1]];
263 if (!heap.pqIsEmpty()) {
264 heapMin = heap.pqMinimum();
265 if (LEQ(leq, heapMin, sortMin)) {
266 return heap.pqExtractMin();
267 }
268 }
269 do {
270 --size;
271 } while (size > 0 && keys[order[size - 1]] == null);
272 return sortMin;
273 }
274
275 /* really __gl_pqSortMinimum */
276 Object pqMinimum() {
277 Object sortMin, heapMin;
278
279 if (size == 0) {
280 return heap.pqMinimum();
281 }
282 sortMin = keys[order[size - 1]];
283 if (!heap.pqIsEmpty()) {
284 heapMin = heap.pqMinimum();
285 if (PriorityQHeap.LEQ(leq, heapMin, sortMin)) {
286 return heapMin;
287 }
288 }
289 return sortMin;
290 }
291
292 /* really __gl_pqSortIsEmpty */
293 boolean pqIsEmpty() {
294 return (size == 0) && heap.pqIsEmpty();
295 }
296
297 /* really __gl_pqSortDelete */
298 void pqDelete(int curr) {
299 if (curr >= 0) {
300 heap.pqDelete(curr);
301 return;
302 }
303 curr = -(curr + 1);
304 assert curr < max && keys[curr] != null;
305
306 keys[curr] = null;
307 while (size > 0 && keys[order[size - 1]] == null) {
308 --size;
309 }
310 }
311 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 import org.lwjgl.opengl.GL11;
87 import org.lwjgl.util.glu.GLU;
88
89 class Render {
90 private static final boolean USE_OPTIMIZED_CODE_PATH = false;
91
92 private Render() {
93 }
94
95 private static final RenderFan renderFan = new RenderFan();
96 private static final RenderStrip renderStrip = new RenderStrip();
97 private static final RenderTriangle renderTriangle = new RenderTriangle();
98
99 /* This structure remembers the information we need about a primitive
100 * to be able to render it later, once we have determined which
101 * primitive is able to use the most triangles.
102 */
103 private static class FaceCount {
104 public FaceCount() {
105 }
106
107 public FaceCount(long size, GLUhalfEdge eStart, renderCallBack render) {
108 this.size = size;
109 this.eStart = eStart;
110 this.render = render;
111 }
112
113 long size; /* number of triangles used */
114 GLUhalfEdge eStart; /* edge where this primitive starts */
115 renderCallBack render;
116 };
117
118 private static interface renderCallBack {
119 void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size);
120 }
121
122 /************************ Strips and Fans decomposition ******************/
123
124 /* __gl_renderMesh( tess, mesh ) takes a mesh and breaks it into triangle
125 * fans, strips, and separate triangles. A substantial effort is made
126 * to use as few rendering primitives as possible (ie. to make the fans
127 * and strips as large as possible).
128 *
129 * The rendering output is provided as callbacks (see the api).
130 */
131 public static void __gl_renderMesh(GLUtessellatorImpl tess, GLUmesh mesh) {
132 GLUface f;
133
134 /* Make a list of separate triangles so we can render them all at once */
135 tess.lonelyTriList = null;
136
137 for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
138 f.marked = false;
139 }
140 for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
141
142 /* We examine all faces in an arbitrary order. Whenever we find
143 * an unprocessed face F, we output a group of faces including F
144 * whose size is maximum.
145 */
146 if (f.inside && !f.marked) {
147 RenderMaximumFaceGroup(tess, f);
148 assert (f.marked);
149 }
150 }
151 if (tess.lonelyTriList != null) {
152 RenderLonelyTriangles(tess, tess.lonelyTriList);
153 tess.lonelyTriList = null;
154 }
155 }
156
157
158 static void RenderMaximumFaceGroup(GLUtessellatorImpl tess, GLUface fOrig) {
159 /* We want to find the largest triangle fan or strip of unmarked faces
160 * which includes the given face fOrig. There are 3 possible fans
161 * passing through fOrig (one centered at each vertex), and 3 possible
162 * strips (one for each CCW permutation of the vertices). Our strategy
163 * is to try all of these, and take the primitive which uses the most
164 * triangles (a greedy approach).
165 */
166 GLUhalfEdge e = fOrig.anEdge;
167 FaceCount max = new FaceCount();
168 FaceCount newFace = new FaceCount();
169
170 max.size = 1;
171 max.eStart = e;
172 max.render = renderTriangle;
173
174 if (!tess.flagBoundary) {
175 newFace = MaximumFan(e);
176 if (newFace.size > max.size) {
177 max = newFace;
178 }
179 newFace = MaximumFan(e.Lnext);
180 if (newFace.size > max.size) {
181 max = newFace;
182 }
183 newFace = MaximumFan(e.Onext.Sym);
184 if (newFace.size > max.size) {
185 max = newFace;
186 }
187
188 newFace = MaximumStrip(e);
189 if (newFace.size > max.size) {
190 max = newFace;
191 }
192 newFace = MaximumStrip(e.Lnext);
193 if (newFace.size > max.size) {
194 max = newFace;
195 }
196 newFace = MaximumStrip(e.Onext.Sym);
197 if (newFace.size > max.size) {
198 max = newFace;
199 }
200 }
201 max.render.render(tess, max.eStart, max.size);
202 }
203
204
205 /* Macros which keep track of faces we have marked temporarily, and allow
206 * us to backtrack when necessary. With triangle fans, this is not
207 * really necessary, since the only awkward case is a loop of triangles
208 * around a single origin vertex. However with strips the situation is
209 * more complicated, and we need a general tracking method like the
210 * one here.
211 */
212 private static boolean Marked(GLUface f) {
213 return !f.inside || f.marked;
214 }
215
216 private static GLUface AddToTrail(GLUface f, GLUface t) {
217 f.trail = t;
218 f.marked = true;
219 return f;
220 }
221
222 private static void FreeTrail(GLUface t) {
223 if (true) {
224 while (t != null) {
225 t.marked = false;
226 t = t.trail;
227 }
228 } else {
229 /* absorb trailing semicolon */
230 }
231 }
232
233 static FaceCount MaximumFan(GLUhalfEdge eOrig) {
234 /* eOrig.Lface is the face we want to render. We want to find the size
235 * of a maximal fan around eOrig.Org. To do this we just walk around
236 * the origin vertex as far as possible in both directions.
237 */
238 FaceCount newFace = new FaceCount(0, null, renderFan);
239 GLUface trail = null;
240 GLUhalfEdge e;
241
242 for (e = eOrig; !Marked(e.Lface); e = e.Onext) {
243 trail = AddToTrail(e.Lface, trail);
244 ++newFace.size;
245 }
246 for (e = eOrig; !Marked(e.Sym.Lface); e = e.Sym.Lnext) {
247 trail = AddToTrail(e.Sym.Lface, trail);
248 ++newFace.size;
249 }
250 newFace.eStart = e;
251 /*LINTED*/
252 FreeTrail(trail);
253 return newFace;
254 }
255
256
257 private static boolean IsEven(long n) {
258 return (n & 0x1L) == 0;
259 }
260
261 static FaceCount MaximumStrip(GLUhalfEdge eOrig) {
262 /* Here we are looking for a maximal strip that contains the vertices
263 * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
264 * reverse, such that all triangles are oriented CCW).
265 *
266 * Again we walk forward and backward as far as possible. However for
267 * strips there is a twist: to get CCW orientations, there must be
268 * an *even* number of triangles in the strip on one side of eOrig.
269 * We walk the strip starting on a side with an even number of triangles;
270 * if both side have an odd number, we are forced to shorten one side.
271 */
272 FaceCount newFace = new FaceCount(0, null, renderStrip);
273 long headSize = 0, tailSize = 0;
274 GLUface trail = null;
275 GLUhalfEdge e, eTail, eHead;
276
277 for (e = eOrig; !Marked(e.Lface); ++tailSize, e = e.Onext) {
278 trail = AddToTrail(e.Lface, trail);
279 ++tailSize;
280 e = e.Lnext.Sym;
281 if (Marked(e.Lface)) break;
282 trail = AddToTrail(e.Lface, trail);
283 }
284 eTail = e;
285
286 for (e = eOrig; !Marked(e.Sym.Lface); ++headSize, e = e.Sym.Onext.Sym) {
287 trail = AddToTrail(e.Sym.Lface, trail);
288 ++headSize;
289 e = e.Sym.Lnext;
290 if (Marked(e.Sym.Lface)) break;
291 trail = AddToTrail(e.Sym.Lface, trail);
292 }
293 eHead = e;
294
295 newFace.size = tailSize + headSize;
296 if (IsEven(tailSize)) {
297 newFace.eStart = eTail.Sym;
298 } else if (IsEven(headSize)) {
299 newFace.eStart = eHead;
300 } else {
301 /* Both sides have odd length, we must shorten one of them. In fact,
302 * we must start from eHead to guarantee inclusion of eOrig.Lface.
303 */
304 --newFace.size;
305 newFace.eStart = eHead.Onext;
306 }
307 /*LINTED*/
308 FreeTrail(trail);
309 return newFace;
310 }
311
312 private static class RenderTriangle implements renderCallBack {
313 public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) {
314 /* Just add the triangle to a triangle list, so we can render all
315 * the separate triangles at once.
316 */
317 assert (size == 1);
318 tess.lonelyTriList = AddToTrail(e.Lface, tess.lonelyTriList);
319 }
320 }
321
322
323 static void RenderLonelyTriangles(GLUtessellatorImpl tess, GLUface f) {
324 /* Now we render all the separate triangles which could not be
325 * grouped into a triangle fan or strip.
326 */
327 GLUhalfEdge e;
328 int newState;
329 int edgeState = -1; /* force edge state output for first vertex */
330
331 tess.callBeginOrBeginData(GL11.GL_TRIANGLES);
332
333 for (; f != null; f = f.trail) {
334 /* Loop once for each edge (there will always be 3 edges) */
335
336 e = f.anEdge;
337 do {
338 if (tess.flagBoundary) {
339 /* Set the "edge state" to true just before we output the
340 * first vertex of each edge on the polygon boundary.
341 */
342 newState = (!e.Sym.Lface.inside) ? 1 : 0;
343 if (edgeState != newState) {
344 edgeState = newState;
345 tess.callEdgeFlagOrEdgeFlagData( edgeState != 0);
346 }
347 }
348 tess.callVertexOrVertexData( e.Org.data);
349
350 e = e.Lnext;
351 } while (e != f.anEdge);
352 }
353 tess.callEndOrEndData();
354 }
355
356 private static class RenderFan implements renderCallBack {
357 public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) {
358 /* Render as many CCW triangles as possible in a fan starting from
359 * edge "e". The fan *should* contain exactly "size" triangles
360 * (otherwise we've goofed up somewhere).
361 */
362 tess.callBeginOrBeginData(GL11.GL_TRIANGLE_FAN);
363 tess.callVertexOrVertexData( e.Org.data);
364 tess.callVertexOrVertexData( e.Sym.Org.data);
365
366 while (!Marked(e.Lface)) {
367 e.Lface.marked = true;
368 --size;
369 e = e.Onext;
370 tess.callVertexOrVertexData( e.Sym.Org.data);
371 }
372
373 assert (size == 0);
374 tess.callEndOrEndData();
375 }
376 }
377
378 private static class RenderStrip implements renderCallBack {
379 public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) {
380 /* Render as many CCW triangles as possible in a strip starting from
381 * edge "e". The strip *should* contain exactly "size" triangles
382 * (otherwise we've goofed up somewhere).
383 */
384 tess.callBeginOrBeginData(GL11.GL_TRIANGLE_STRIP);
385 tess.callVertexOrVertexData( e.Org.data);
386 tess.callVertexOrVertexData( e.Sym.Org.data);
387
388 while (!Marked(e.Lface)) {
389 e.Lface.marked = true;
390 --size;
391 e = e.Lnext.Sym;
392 tess.callVertexOrVertexData( e.Org.data);
393 if (Marked(e.Lface)) break;
394
395 e.Lface.marked = true;
396 --size;
397 e = e.Onext;
398 tess.callVertexOrVertexData( e.Sym.Org.data);
399 }
400
401 assert (size == 0);
402 tess.callEndOrEndData();
403 }
404 }
405
406 /************************ Boundary contour decomposition ******************/
407
408 /* __gl_renderBoundary( tess, mesh ) takes a mesh, and outputs one
409 * contour for each face marked "inside". The rendering output is
410 * provided as callbacks (see the api).
411 */
412 public static void __gl_renderBoundary(GLUtessellatorImpl tess, GLUmesh mesh) {
413 GLUface f;
414 GLUhalfEdge e;
415
416 for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
417 if (f.inside) {
418 tess.callBeginOrBeginData(GL11.GL_LINE_LOOP);
419 e = f.anEdge;
420 do {
421 tess.callVertexOrVertexData( e.Org.data);
422 e = e.Lnext;
423 } while (e != f.anEdge);
424 tess.callEndOrEndData();
425 }
426 }
427 }
428
429
430 /************************ Quick-and-dirty decomposition ******************/
431
432 private static final int SIGN_INCONSISTENT = 2;
433
434 static int ComputeNormal(GLUtessellatorImpl tess, double[] norm, boolean check)
435 /*
436 * If check==false, we compute the polygon normal and place it in norm[].
437 * If check==true, we check that each triangle in the fan from v0 has a
438 * consistent orientation with respect to norm[]. If triangles are
439 * consistently oriented CCW, return 1; if CW, return -1; if all triangles
440 * are degenerate return 0; otherwise (no consistent orientation) return
441 * SIGN_INCONSISTENT.
442 */ {
443 CachedVertex[] v = tess.cache;
444 // CachedVertex vn = v0 + tess.cacheCount;
445 int vn = tess.cacheCount;
446 // CachedVertex vc;
447 int vc;
448 double dot, xc, yc, zc, xp, yp, zp;
449 double[] n = new double[3];
450 int sign = 0;
451
452 /* Find the polygon normal. It is important to get a reasonable
453 * normal even when the polygon is self-intersecting (eg. a bowtie).
454 * Otherwise, the computed normal could be very tiny, but perpendicular
455 * to the true plane of the polygon due to numerical noise. Then all
456 * the triangles would appear to be degenerate and we would incorrectly
457 * decompose the polygon as a fan (or simply not render it at all).
458 *
459 * We use a sum-of-triangles normal algorithm rather than the more
460 * efficient sum-of-trapezoids method (used in CheckOrientation()
461 * in normal.c). This lets us explicitly reverse the signed area
462 * of some triangles to get a reasonable normal in the self-intersecting
463 * case.
464 */
465 if (!check) {
466 norm[0] = norm[1] = norm[2] = 0.0;
467 }
468
469 vc = 1;
470 xc = v[vc].coords[0] - v[0].coords[0];
471 yc = v[vc].coords[1] - v[0].coords[1];
472 zc = v[vc].coords[2] - v[0].coords[2];
473 while (++vc < vn) {
474 xp = xc;
475 yp = yc;
476 zp = zc;
477 xc = v[vc].coords[0] - v[0].coords[0];
478 yc = v[vc].coords[1] - v[0].coords[1];
479 zc = v[vc].coords[2] - v[0].coords[2];
480
481 /* Compute (vp - v0) cross (vc - v0) */
482 n[0] = yp * zc - zp * yc;
483 n[1] = zp * xc - xp * zc;
484 n[2] = xp * yc - yp * xc;
485
486 dot = n[0] * norm[0] + n[1] * norm[1] + n[2] * norm[2];
487 if (!check) {
488 /* Reverse the contribution of back-facing triangles to get
489 * a reasonable normal for self-intersecting polygons (see above)
490 */
491 if (dot >= 0) {
492 norm[0] += n[0];
493 norm[1] += n[1];
494 norm[2] += n[2];
495 } else {
496 norm[0] -= n[0];
497 norm[1] -= n[1];
498 norm[2] -= n[2];
499 }
500 } else if (dot != 0) {
501 /* Check the new orientation for consistency with previous triangles */
502 if (dot > 0) {
503 if (sign < 0) return SIGN_INCONSISTENT;
504 sign = 1;
505 } else {
506 if (sign > 0) return SIGN_INCONSISTENT;
507 sign = -1;
508 }
509 }
510 }
511 return sign;
512 }
513
514 /* __gl_renderCache( tess ) takes a single contour and tries to render it
515 * as a triangle fan. This handles convex polygons, as well as some
516 * non-convex polygons if we get lucky.
517 *
518 * Returns true if the polygon was successfully rendered. The rendering
519 * output is provided as callbacks (see the api).
520 */
521 public static boolean __gl_renderCache(GLUtessellatorImpl tess) {
522 CachedVertex[] v = tess.cache;
523 // CachedVertex vn = v0 + tess.cacheCount;
524 int vn = tess.cacheCount;
525 // CachedVertex vc;
526 int vc;
527 double[] norm = new double[3];
528 int sign;
529
530 if (tess.cacheCount < 3) {
531 /* Degenerate contour -- no output */
532 return true;
533 }
534
535 norm[0] = tess.normal[0];
536 norm[1] = tess.normal[1];
537 norm[2] = tess.normal[2];
538 if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) {
539 ComputeNormal( tess, norm, false);
540 }
541
542 sign = ComputeNormal( tess, norm, true);
543 if (sign == SIGN_INCONSISTENT) {
544 /* Fan triangles did not have a consistent orientation */
545 return false;
546 }
547 if (sign == 0) {
548 /* All triangles were degenerate */
549 return true;
550 }
551
552 if ( !USE_OPTIMIZED_CODE_PATH ) {
553 return false;
554 } else {
555 /* Make sure we do the right thing for each winding rule */
556 switch (tess.windingRule) {
557 case GLU.GLU_TESS_WINDING_ODD:
558 case GLU.GLU_TESS_WINDING_NONZERO:
559 break;
560 case GLU.GLU_TESS_WINDING_POSITIVE:
561 if (sign < 0) return true;
562 break;
563 case GLU.GLU_TESS_WINDING_NEGATIVE:
564 if (sign > 0) return true;
565 break;
566 case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
567 return true;
568 }
569
570 tess.callBeginOrBeginData( tess.boundaryOnly ? GL11.GL_LINE_LOOP
571 : (tess.cacheCount > 3) ? GL11.GL_TRIANGLE_FAN
572 : GL11.GL_TRIANGLES);
573
574 tess.callVertexOrVertexData( v[0].data);
575 if (sign > 0) {
576 for (vc = 1; vc < vn; ++vc) {
577 tess.callVertexOrVertexData( v[vc].data);
578 }
579 } else {
580 for (vc = vn - 1; vc > 0; --vc) {
581 tess.callVertexOrVertexData( v[vc].data);
582 }
583 }
584 tess.callEndOrEndData();
585 return true;
586 }
587 }
588 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 import org.lwjgl.util.glu.GLU;
87
88 class Sweep {
89 private Sweep() {
90 }
91
92 // #ifdef FOR_TRITE_TEST_PROGRAM
93 // extern void DebugEvent( GLUtessellator *tess );
94 // #else
95 private static void DebugEvent(GLUtessellatorImpl tess) {
96
97 }
98 // #endif
99
100 /*
101 * Invariants for the Edge Dictionary.
102 * - each pair of adjacent edges e2=Succ(e1) satisfies EdgeLeq(e1,e2)
103 * at any valid location of the sweep event
104 * - if EdgeLeq(e2,e1) as well (at any valid sweep event), then e1 and e2
105 * share a common endpoint
106 * - for each e, e.Dst has been processed, but not e.Org
107 * - each edge e satisfies VertLeq(e.Dst,event) && VertLeq(event,e.Org)
108 * where "event" is the current sweep line event.
109 * - no edge e has zero length
110 *
111 * Invariants for the Mesh (the processed portion).
112 * - the portion of the mesh left of the sweep line is a planar graph,
113 * ie. there is *some* way to embed it in the plane
114 * - no processed edge has zero length
115 * - no two processed vertices have identical coordinates
116 * - each "inside" region is monotone, ie. can be broken into two chains
117 * of monotonically increasing vertices according to VertLeq(v1,v2)
118 * - a non-invariant: these chains may intersect (very slightly)
119 *
120 * Invariants for the Sweep.
121 * - if none of the edges incident to the event vertex have an activeRegion
122 * (ie. none of these edges are in the edge dictionary), then the vertex
123 * has only right-going edges.
124 * - if an edge is marked "fixUpperEdge" (it is a temporary edge introduced
125 * by ConnectRightVertex), then it is the only right-going edge from
126 * its associated vertex. (This says that these edges exist only
127 * when it is necessary.)
128 */
129
130 /* When we merge two edges into one, we need to compute the combined
131 * winding of the new edge.
132 */
133 private static void AddWinding(GLUhalfEdge eDst, GLUhalfEdge eSrc) {
134 eDst.winding += eSrc.winding;
135 eDst.Sym.winding += eSrc.Sym.winding;
136 }
137
138
139 private static ActiveRegion RegionBelow(ActiveRegion r) {
140 return ((ActiveRegion) Dict.dictKey(Dict.dictPred(r.nodeUp)));
141 }
142
143 private static ActiveRegion RegionAbove(ActiveRegion r) {
144 return ((ActiveRegion) Dict.dictKey(Dict.dictSucc(r.nodeUp)));
145 }
146
147 static boolean EdgeLeq(GLUtessellatorImpl tess, ActiveRegion reg1, ActiveRegion reg2)
148 /*
149 * Both edges must be directed from right to left (this is the canonical
150 * direction for the upper edge of each region).
151 *
152 * The strategy is to evaluate a "t" value for each edge at the
153 * current sweep line position, given by tess.event. The calculations
154 * are designed to be very stable, but of course they are not perfect.
155 *
156 * Special case: if both edge destinations are at the sweep event,
157 * we sort the edges by slope (they would otherwise compare equally).
158 */ {
159 GLUvertex event = tess.event;
160 GLUhalfEdge e1, e2;
161 double t1, t2;
162
163 e1 = reg1.eUp;
164 e2 = reg2.eUp;
165
166 if (e1.Sym.Org == event) {
167 if (e2.Sym.Org == event) {
168 /* Two edges right of the sweep line which meet at the sweep event.
169 * Sort them by slope.
170 */
171 if (Geom.VertLeq(e1.Org, e2.Org)) {
172 return Geom.EdgeSign(e2.Sym.Org, e1.Org, e2.Org) <= 0;
173 }
174 return Geom.EdgeSign(e1.Sym.Org, e2.Org, e1.Org) >= 0;
175 }
176 return Geom.EdgeSign(e2.Sym.Org, event, e2.Org) <= 0;
177 }
178 if (e2.Sym.Org == event) {
179 return Geom.EdgeSign(e1.Sym.Org, event, e1.Org) >= 0;
180 }
181
182 /* General case - compute signed distance *from* e1, e2 to event */
183 t1 = Geom.EdgeEval(e1.Sym.Org, event, e1.Org);
184 t2 = Geom.EdgeEval(e2.Sym.Org, event, e2.Org);
185 return (t1 >= t2);
186 }
187
188
189 static void DeleteRegion(GLUtessellatorImpl tess, ActiveRegion reg) {
190 if (reg.fixUpperEdge) {
191 /* It was created with zero winding number, so it better be
192 * deleted with zero winding number (ie. it better not get merged
193 * with a real edge).
194 */
195 assert (reg.eUp.winding == 0);
196 }
197 reg.eUp.activeRegion = null;
198 Dict.dictDelete(tess.dict, reg.nodeUp); /* __gl_dictListDelete */
199 }
200
201
202 static boolean FixUpperEdge(ActiveRegion reg, GLUhalfEdge newEdge)
203 /*
204 * Replace an upper edge which needs fixing (see ConnectRightVertex).
205 */ {
206 assert (reg.fixUpperEdge);
207 if (!Mesh.__gl_meshDelete(reg.eUp)) return false;
208 reg.fixUpperEdge = false;
209 reg.eUp = newEdge;
210 newEdge.activeRegion = reg;
211
212 return true;
213 }
214
215 static ActiveRegion TopLeftRegion(ActiveRegion reg) {
216 GLUvertex org = reg.eUp.Org;
217 GLUhalfEdge e;
218
219 /* Find the region above the uppermost edge with the same origin */
220 do {
221 reg = RegionAbove(reg);
222 } while (reg.eUp.Org == org);
223
224 /* If the edge above was a temporary edge introduced by ConnectRightVertex,
225 * now is the time to fix it.
226 */
227 if (reg.fixUpperEdge) {
228 e = Mesh.__gl_meshConnect(RegionBelow(reg).eUp.Sym, reg.eUp.Lnext);
229 if (e == null) return null;
230 if (!FixUpperEdge(reg, e)) return null;
231 reg = RegionAbove(reg);
232 }
233 return reg;
234 }
235
236 static ActiveRegion TopRightRegion(ActiveRegion reg) {
237 GLUvertex dst = reg.eUp.Sym.Org;
238
239 /* Find the region above the uppermost edge with the same destination */
240 do {
241 reg = RegionAbove(reg);
242 } while (reg.eUp.Sym.Org == dst);
243 return reg;
244 }
245
246 static ActiveRegion AddRegionBelow(GLUtessellatorImpl tess,
247 ActiveRegion regAbove,
248 GLUhalfEdge eNewUp)
249 /*
250 * Add a new active region to the sweep line, *somewhere* below "regAbove"
251 * (according to where the new edge belongs in the sweep-line dictionary).
252 * The upper edge of the new region will be "eNewUp".
253 * Winding number and "inside" flag are not updated.
254 */ {
255 ActiveRegion regNew = new ActiveRegion();
256 if (regNew == null) throw new RuntimeException();
257
258 regNew.eUp = eNewUp;
259 /* __gl_dictListInsertBefore */
260 regNew.nodeUp = Dict.dictInsertBefore(tess.dict, regAbove.nodeUp, regNew);
261 if (regNew.nodeUp == null) throw new RuntimeException();
262 regNew.fixUpperEdge = false;
263 regNew.sentinel = false;
264 regNew.dirty = false;
265
266 eNewUp.activeRegion = regNew;
267 return regNew;
268 }
269
270 static boolean IsWindingInside(GLUtessellatorImpl tess, int n) {
271 switch (tess.windingRule) {
272 case GLU.GLU_TESS_WINDING_ODD:
273 return (n & 1) != 0;
274 case GLU.GLU_TESS_WINDING_NONZERO:
275 return (n != 0);
276 case GLU.GLU_TESS_WINDING_POSITIVE:
277 return (n > 0);
278 case GLU.GLU_TESS_WINDING_NEGATIVE:
279 return (n < 0);
280 case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
281 return (n >= 2) || (n <= -2);
282 }
283 /*LINTED*/
284 // assert (false);
285 throw new InternalError();
286 /*NOTREACHED*/
287 }
288
289
290 static void ComputeWinding(GLUtessellatorImpl tess, ActiveRegion reg) {
291 reg.windingNumber = RegionAbove(reg).windingNumber + reg.eUp.winding;
292 reg.inside = IsWindingInside(tess, reg.windingNumber);
293 }
294
295
296 static void FinishRegion(GLUtessellatorImpl tess, ActiveRegion reg)
297 /*
298 * Delete a region from the sweep line. This happens when the upper
299 * and lower chains of a region meet (at a vertex on the sweep line).
300 * The "inside" flag is copied to the appropriate mesh face (we could
301 * not do this before -- since the structure of the mesh is always
302 * changing, this face may not have even existed until now).
303 */ {
304 GLUhalfEdge e = reg.eUp;
305 GLUface f = e.Lface;
306
307 f.inside = reg.inside;
308 f.anEdge = e; /* optimization for __gl_meshTessellateMonoRegion() */
309 DeleteRegion(tess, reg);
310 }
311
312
313 static GLUhalfEdge FinishLeftRegions(GLUtessellatorImpl tess,
314 ActiveRegion regFirst, ActiveRegion regLast)
315 /*
316 * We are given a vertex with one or more left-going edges. All affected
317 * edges should be in the edge dictionary. Starting at regFirst.eUp,
318 * we walk down deleting all regions where both edges have the same
319 * origin vOrg. At the same time we copy the "inside" flag from the
320 * active region to the face, since at this point each face will belong
321 * to at most one region (this was not necessarily true until this point
322 * in the sweep). The walk stops at the region above regLast; if regLast
323 * is null we walk as far as possible. At the same time we relink the
324 * mesh if necessary, so that the ordering of edges around vOrg is the
325 * same as in the dictionary.
326 */ {
327 ActiveRegion reg, regPrev;
328 GLUhalfEdge e, ePrev;
329
330 regPrev = regFirst;
331 ePrev = regFirst.eUp;
332 while (regPrev != regLast) {
333 regPrev.fixUpperEdge = false; /* placement was OK */
334 reg = RegionBelow(regPrev);
335 e = reg.eUp;
336 if (e.Org != ePrev.Org) {
337 if (!reg.fixUpperEdge) {
338 /* Remove the last left-going edge. Even though there are no further
339 * edges in the dictionary with this origin, there may be further
340 * such edges in the mesh (if we are adding left edges to a vertex
341 * that has already been processed). Thus it is important to call
342 * FinishRegion rather than just DeleteRegion.
343 */
344 FinishRegion(tess, regPrev);
345 break;
346 }
347 /* If the edge below was a temporary edge introduced by
348 * ConnectRightVertex, now is the time to fix it.
349 */
350 e = Mesh.__gl_meshConnect(ePrev.Onext.Sym, e.Sym);
351 if (e == null) throw new RuntimeException();
352 if (!FixUpperEdge(reg, e)) throw new RuntimeException();
353 }
354
355 /* Relink edges so that ePrev.Onext == e */
356 if (ePrev.Onext != e) {
357 if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException();
358 if (!Mesh.__gl_meshSplice(ePrev, e)) throw new RuntimeException();
359 }
360 FinishRegion(tess, regPrev); /* may change reg.eUp */
361 ePrev = reg.eUp;
362 regPrev = reg;
363 }
364 return ePrev;
365 }
366
367
368 static void AddRightEdges(GLUtessellatorImpl tess, ActiveRegion regUp,
369 GLUhalfEdge eFirst, GLUhalfEdge eLast, GLUhalfEdge eTopLeft,
370 boolean cleanUp)
371 /*
372 * Purpose: insert right-going edges into the edge dictionary, and update
373 * winding numbers and mesh connectivity appropriately. All right-going
374 * edges share a common origin vOrg. Edges are inserted CCW starting at
375 * eFirst; the last edge inserted is eLast.Sym.Lnext. If vOrg has any
376 * left-going edges already processed, then eTopLeft must be the edge
377 * such that an imaginary upward vertical segment from vOrg would be
378 * contained between eTopLeft.Sym.Lnext and eTopLeft; otherwise eTopLeft
379 * should be null.
380 */ {
381 ActiveRegion reg, regPrev;
382 GLUhalfEdge e, ePrev;
383 boolean firstTime = true;
384
385 /* Insert the new right-going edges in the dictionary */
386 e = eFirst;
387 do {
388 assert (Geom.VertLeq(e.Org, e.Sym.Org));
389 AddRegionBelow(tess, regUp, e.Sym);
390 e = e.Onext;
391 } while (e != eLast);
392
393 /* Walk *all* right-going edges from e.Org, in the dictionary order,
394 * updating the winding numbers of each region, and re-linking the mesh
395 * edges to match the dictionary ordering (if necessary).
396 */
397 if (eTopLeft == null) {
398 eTopLeft = RegionBelow(regUp).eUp.Sym.Onext;
399 }
400 regPrev = regUp;
401 ePrev = eTopLeft;
402 for (; ;) {
403 reg = RegionBelow(regPrev);
404 e = reg.eUp.Sym;
405 if (e.Org != ePrev.Org) break;
406
407 if (e.Onext != ePrev) {
408 /* Unlink e from its current position, and relink below ePrev */
409 if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException();
410 if (!Mesh.__gl_meshSplice(ePrev.Sym.Lnext, e)) throw new RuntimeException();
411 }
412 /* Compute the winding number and "inside" flag for the new regions */
413 reg.windingNumber = regPrev.windingNumber - e.winding;
414 reg.inside = IsWindingInside(tess, reg.windingNumber);
415
416 /* Check for two outgoing edges with same slope -- process these
417 * before any intersection tests (see example in __gl_computeInterior).
418 */
419 regPrev.dirty = true;
420 if (!firstTime && CheckForRightSplice(tess, regPrev)) {
421 AddWinding(e, ePrev);
422 DeleteRegion(tess, regPrev);
423 if (!Mesh.__gl_meshDelete(ePrev)) throw new RuntimeException();
424 }
425 firstTime = false;
426 regPrev = reg;
427 ePrev = e;
428 }
429 regPrev.dirty = true;
430 assert (regPrev.windingNumber - e.winding == reg.windingNumber);
431
432 if (cleanUp) {
433 /* Check for intersections between newly adjacent edges. */
434 WalkDirtyRegions(tess, regPrev);
435 }
436 }
437
438
439 static void CallCombine(GLUtessellatorImpl tess, GLUvertex isect,
440 Object[] data, float[] weights, boolean needed) {
441 double[] coords = new double[3];
442
443 /* Copy coord data in case the callback changes it. */
444 coords[0] = isect.coords[0];
445 coords[1] = isect.coords[1];
446 coords[2] = isect.coords[2];
447
448 Object[] outData = new Object[1];
449 tess.callCombineOrCombineData(coords, data, weights, outData);
450 isect.data = outData[0];
451 if (isect.data == null) {
452 if (!needed) {
453 isect.data = data[0];
454 } else if (!tess.fatalError) {
455 /* The only way fatal error is when two edges are found to intersect,
456 * but the user has not provided the callback necessary to handle
457 * generated intersection points.
458 */
459 tess.callErrorOrErrorData(GLU.GLU_TESS_NEED_COMBINE_CALLBACK);
460 tess.fatalError = true;
461 }
462 }
463 }
464
465 static void SpliceMergeVertices(GLUtessellatorImpl tess, GLUhalfEdge e1,
466 GLUhalfEdge e2)
467 /*
468 * Two vertices with idential coordinates are combined into one.
469 * e1.Org is kept, while e2.Org is discarded.
470 */ {
471 Object[] data = new Object[4];
472 float[] weights = new float[]{0.5f, 0.5f, 0.0f, 0.0f};
473
474 data[0] = e1.Org.data;
475 data[1] = e2.Org.data;
476 CallCombine(tess, e1.Org, data, weights, false);
477 if (!Mesh.__gl_meshSplice(e1, e2)) throw new RuntimeException();
478 }
479
480 static void VertexWeights(GLUvertex isect, GLUvertex org, GLUvertex dst,
481 float[] weights)
482 /*
483 * Find some weights which describe how the intersection vertex is
484 * a linear combination of "org" and "dest". Each of the two edges
485 * which generated "isect" is allocated 50% of the weight; each edge
486 * splits the weight between its org and dst according to the
487 * relative distance to "isect".
488 */ {
489 double t1 = Geom.VertL1dist(org, isect);
490 double t2 = Geom.VertL1dist(dst, isect);
491
492 weights[0] = (float) (0.5 * t2 / (t1 + t2));
493 weights[1] = (float) (0.5 * t1 / (t1 + t2));
494 isect.coords[0] += weights[0] * org.coords[0] + weights[1] * dst.coords[0];
495 isect.coords[1] += weights[0] * org.coords[1] + weights[1] * dst.coords[1];
496 isect.coords[2] += weights[0] * org.coords[2] + weights[1] * dst.coords[2];
497 }
498
499
500 static void GetIntersectData(GLUtessellatorImpl tess, GLUvertex isect,
501 GLUvertex orgUp, GLUvertex dstUp,
502 GLUvertex orgLo, GLUvertex dstLo)
503 /*
504 * We've computed a new intersection point, now we need a "data" pointer
505 * from the user so that we can refer to this new vertex in the
506 * rendering callbacks.
507 */ {
508 Object[] data = new Object[4];
509 float[] weights = new float[4];
510 float[] weights1 = new float[2];
511 float[] weights2 = new float[2];
512
513 data[0] = orgUp.data;
514 data[1] = dstUp.data;
515 data[2] = orgLo.data;
516 data[3] = dstLo.data;
517
518 isect.coords[0] = isect.coords[1] = isect.coords[2] = 0;
519 VertexWeights(isect, orgUp, dstUp, weights1);
520 VertexWeights(isect, orgLo, dstLo, weights2);
521 System.arraycopy(weights1, 0, weights, 0, 2);
522 System.arraycopy(weights2, 0, weights, 2, 2);
523
524 CallCombine(tess, isect, data, weights, true);
525 }
526
527 static boolean CheckForRightSplice(GLUtessellatorImpl tess, ActiveRegion regUp)
528 /*
529 * Check the upper and lower edge of "regUp", to make sure that the
530 * eUp.Org is above eLo, or eLo.Org is below eUp (depending on which
531 * origin is leftmost).
532 *
533 * The main purpose is to splice right-going edges with the same
534 * dest vertex and nearly identical slopes (ie. we can't distinguish
535 * the slopes numerically). However the splicing can also help us
536 * to recover from numerical errors. For example, suppose at one
537 * point we checked eUp and eLo, and decided that eUp.Org is barely
538 * above eLo. Then later, we split eLo into two edges (eg. from
539 * a splice operation like this one). This can change the result of
540 * our test so that now eUp.Org is incident to eLo, or barely below it.
541 * We must correct this condition to maintain the dictionary invariants.
542 *
543 * One possibility is to check these edges for intersection again
544 * (ie. CheckForIntersect). This is what we do if possible. However
545 * CheckForIntersect requires that tess.event lies between eUp and eLo,
546 * so that it has something to fall back on when the intersection
547 * calculation gives us an unusable answer. So, for those cases where
548 * we can't check for intersection, this routine fixes the problem
549 * by just splicing the offending vertex into the other edge.
550 * This is a guaranteed solution, no matter how degenerate things get.
551 * Basically this is a combinatorial solution to a numerical problem.
552 */ {
553 ActiveRegion regLo = RegionBelow(regUp);
554 GLUhalfEdge eUp = regUp.eUp;
555 GLUhalfEdge eLo = regLo.eUp;
556
557 if (Geom.VertLeq(eUp.Org, eLo.Org)) {
558 if (Geom.EdgeSign(eLo.Sym.Org, eUp.Org, eLo.Org) > 0) return false;
559
560 /* eUp.Org appears to be below eLo */
561 if (!Geom.VertEq(eUp.Org, eLo.Org)) {
562 /* Splice eUp.Org into eLo */
563 if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
564 if (!Mesh.__gl_meshSplice(eUp, eLo.Sym.Lnext)) throw new RuntimeException();
565 regUp.dirty = regLo.dirty = true;
566
567 } else if (eUp.Org != eLo.Org) {
568 /* merge the two vertices, discarding eUp.Org */
569 tess.pq.pqDelete(eUp.Org.pqHandle); /* __gl_pqSortDelete */
570 SpliceMergeVertices(tess, eLo.Sym.Lnext, eUp);
571 }
572 } else {
573 if (Geom.EdgeSign(eUp.Sym.Org, eLo.Org, eUp.Org) < 0) return false;
574
575 /* eLo.Org appears to be above eUp, so splice eLo.Org into eUp */
576 RegionAbove(regUp).dirty = regUp.dirty = true;
577 if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
578 if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException();
579 }
580 return true;
581 }
582
583 static boolean CheckForLeftSplice(GLUtessellatorImpl tess, ActiveRegion regUp)
584 /*
585 * Check the upper and lower edge of "regUp", to make sure that the
586 * eUp.Sym.Org is above eLo, or eLo.Sym.Org is below eUp (depending on which
587 * destination is rightmost).
588 *
589 * Theoretically, this should always be true. However, splitting an edge
590 * into two pieces can change the results of previous tests. For example,
591 * suppose at one point we checked eUp and eLo, and decided that eUp.Sym.Org
592 * is barely above eLo. Then later, we split eLo into two edges (eg. from
593 * a splice operation like this one). This can change the result of
594 * the test so that now eUp.Sym.Org is incident to eLo, or barely below it.
595 * We must correct this condition to maintain the dictionary invariants
596 * (otherwise new edges might get inserted in the wrong place in the
597 * dictionary, and bad stuff will happen).
598 *
599 * We fix the problem by just splicing the offending vertex into the
600 * other edge.
601 */ {
602 ActiveRegion regLo = RegionBelow(regUp);
603 GLUhalfEdge eUp = regUp.eUp;
604 GLUhalfEdge eLo = regLo.eUp;
605 GLUhalfEdge e;
606
607 assert (!Geom.VertEq(eUp.Sym.Org, eLo.Sym.Org));
608
609 if (Geom.VertLeq(eUp.Sym.Org, eLo.Sym.Org)) {
610 if (Geom.EdgeSign(eUp.Sym.Org, eLo.Sym.Org, eUp.Org) < 0) return false;
611
612 /* eLo.Sym.Org is above eUp, so splice eLo.Sym.Org into eUp */
613 RegionAbove(regUp).dirty = regUp.dirty = true;
614 e = Mesh.__gl_meshSplitEdge(eUp);
615 if (e == null) throw new RuntimeException();
616 if (!Mesh.__gl_meshSplice(eLo.Sym, e)) throw new RuntimeException();
617 e.Lface.inside = regUp.inside;
618 } else {
619 if (Geom.EdgeSign(eLo.Sym.Org, eUp.Sym.Org, eLo.Org) > 0) return false;
620
621 /* eUp.Sym.Org is below eLo, so splice eUp.Sym.Org into eLo */
622 regUp.dirty = regLo.dirty = true;
623 e = Mesh.__gl_meshSplitEdge(eLo);
624 if (e == null) throw new RuntimeException();
625 if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym)) throw new RuntimeException();
626 e.Sym.Lface.inside = regUp.inside;
627 }
628 return true;
629 }
630
631
632 static boolean CheckForIntersect(GLUtessellatorImpl tess, ActiveRegion regUp)
633 /*
634 * Check the upper and lower edges of the given region to see if
635 * they intersect. If so, create the intersection and add it
636 * to the data structures.
637 *
638 * Returns true if adding the new intersection resulted in a recursive
639 * call to AddRightEdges(); in this case all "dirty" regions have been
640 * checked for intersections, and possibly regUp has been deleted.
641 */ {
642 ActiveRegion regLo = RegionBelow(regUp);
643 GLUhalfEdge eUp = regUp.eUp;
644 GLUhalfEdge eLo = regLo.eUp;
645 GLUvertex orgUp = eUp.Org;
646 GLUvertex orgLo = eLo.Org;
647 GLUvertex dstUp = eUp.Sym.Org;
648 GLUvertex dstLo = eLo.Sym.Org;
649 double tMinUp, tMaxLo;
650 GLUvertex isect = new GLUvertex();
651 GLUvertex orgMin;
652 GLUhalfEdge e;
653
654 assert (!Geom.VertEq(dstLo, dstUp));
655 assert (Geom.EdgeSign(dstUp, tess.event, orgUp) <= 0);
656 assert (Geom.EdgeSign(dstLo, tess.event, orgLo) >= 0);
657 assert (orgUp != tess.event && orgLo != tess.event);
658 assert (!regUp.fixUpperEdge && !regLo.fixUpperEdge);
659
660 if (orgUp == orgLo) return false; /* right endpoints are the same */
661
662 tMinUp = Math.min(orgUp.t, dstUp.t);
663 tMaxLo = Math.max(orgLo.t, dstLo.t);
664 if (tMinUp > tMaxLo) return false; /* t ranges do not overlap */
665
666 if (Geom.VertLeq(orgUp, orgLo)) {
667 if (Geom.EdgeSign(dstLo, orgUp, orgLo) > 0) return false;
668 } else {
669 if (Geom.EdgeSign(dstUp, orgLo, orgUp) < 0) return false;
670 }
671
672 /* At this point the edges intersect, at least marginally */
673 DebugEvent(tess);
674
675 Geom.EdgeIntersect(dstUp, orgUp, dstLo, orgLo, isect);
676 /* The following properties are guaranteed: */
677 assert (Math.min(orgUp.t, dstUp.t) <= isect.t);
678 assert (isect.t <= Math.max(orgLo.t, dstLo.t));
679 assert (Math.min(dstLo.s, dstUp.s) <= isect.s);
680 assert (isect.s <= Math.max(orgLo.s, orgUp.s));
681
682 if (Geom.VertLeq(isect, tess.event)) {
683 /* The intersection point lies slightly to the left of the sweep line,
684 * so move it until it''s slightly to the right of the sweep line.
685 * (If we had perfect numerical precision, this would never happen
686 * in the first place). The easiest and safest thing to do is
687 * replace the intersection by tess.event.
688 */
689 isect.s = tess.event.s;
690 isect.t = tess.event.t;
691 }
692 /* Similarly, if the computed intersection lies to the right of the
693 * rightmost origin (which should rarely happen), it can cause
694 * unbelievable inefficiency on sufficiently degenerate inputs.
695 * (If you have the test program, try running test54.d with the
696 * "X zoom" option turned on).
697 */
698 orgMin = Geom.VertLeq(orgUp, orgLo) ? orgUp : orgLo;
699 if (Geom.VertLeq(orgMin, isect)) {
700 isect.s = orgMin.s;
701 isect.t = orgMin.t;
702 }
703
704 if (Geom.VertEq(isect, orgUp) || Geom.VertEq(isect, orgLo)) {
705 /* Easy case -- intersection at one of the right endpoints */
706 CheckForRightSplice(tess, regUp);
707 return false;
708 }
709
710 if ((!Geom.VertEq(dstUp, tess.event)
711 && Geom.EdgeSign(dstUp, tess.event, isect) >= 0)
712 || (!Geom.VertEq(dstLo, tess.event)
713 && Geom.EdgeSign(dstLo, tess.event, isect) <= 0)) {
714 /* Very unusual -- the new upper or lower edge would pass on the
715 * wrong side of the sweep event, or through it. This can happen
716 * due to very small numerical errors in the intersection calculation.
717 */
718 if (dstLo == tess.event) {
719 /* Splice dstLo into eUp, and process the new region(s) */
720 if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
721 if (!Mesh.__gl_meshSplice(eLo.Sym, eUp)) throw new RuntimeException();
722 regUp = TopLeftRegion(regUp);
723 if (regUp == null) throw new RuntimeException();
724 eUp = RegionBelow(regUp).eUp;
725 FinishLeftRegions(tess, RegionBelow(regUp), regLo);
726 AddRightEdges(tess, regUp, eUp.Sym.Lnext, eUp, eUp, true);
727 return true;
728 }
729 if (dstUp == tess.event) {
730 /* Splice dstUp into eLo, and process the new region(s) */
731 if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
732 if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym.Lnext)) throw new RuntimeException();
733 regLo = regUp;
734 regUp = TopRightRegion(regUp);
735 e = RegionBelow(regUp).eUp.Sym.Onext;
736 regLo.eUp = eLo.Sym.Lnext;
737 eLo = FinishLeftRegions(tess, regLo, null);
738 AddRightEdges(tess, regUp, eLo.Onext, eUp.Sym.Onext, e, true);
739 return true;
740 }
741 /* Special case: called from ConnectRightVertex. If either
742 * edge passes on the wrong side of tess.event, split it
743 * (and wait for ConnectRightVertex to splice it appropriately).
744 */
745 if (Geom.EdgeSign(dstUp, tess.event, isect) >= 0) {
746 RegionAbove(regUp).dirty = regUp.dirty = true;
747 if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
748 eUp.Org.s = tess.event.s;
749 eUp.Org.t = tess.event.t;
750 }
751 if (Geom.EdgeSign(dstLo, tess.event, isect) <= 0) {
752 regUp.dirty = regLo.dirty = true;
753 if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
754 eLo.Org.s = tess.event.s;
755 eLo.Org.t = tess.event.t;
756 }
757 /* leave the rest for ConnectRightVertex */
758 return false;
759 }
760
761 /* General case -- split both edges, splice into new vertex.
762 * When we do the splice operation, the order of the arguments is
763 * arbitrary as far as correctness goes. However, when the operation
764 * creates a new face, the work done is proportional to the size of
765 * the new face. We expect the faces in the processed part of
766 * the mesh (ie. eUp.Lface) to be smaller than the faces in the
767 * unprocessed original contours (which will be eLo.Sym.Lnext.Lface).
768 */
769 if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
770 if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
771 if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException();
772 eUp.Org.s = isect.s;
773 eUp.Org.t = isect.t;
774 eUp.Org.pqHandle = tess.pq.pqInsert(eUp.Org); /* __gl_pqSortInsert */
775 if (eUp.Org.pqHandle == Long.MAX_VALUE) {
776 tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
777 tess.pq = null;
778 throw new RuntimeException();
779 }
780 GetIntersectData(tess, eUp.Org, orgUp, dstUp, orgLo, dstLo);
781 RegionAbove(regUp).dirty = regUp.dirty = regLo.dirty = true;
782 return false;
783 }
784
785 static void WalkDirtyRegions(GLUtessellatorImpl tess, ActiveRegion regUp)
786 /*
787 * When the upper or lower edge of any region changes, the region is
788 * marked "dirty". This routine walks through all the dirty regions
789 * and makes sure that the dictionary invariants are satisfied
790 * (see the comments at the beginning of this file). Of course
791 * new dirty regions can be created as we make changes to restore
792 * the invariants.
793 */ {
794 ActiveRegion regLo = RegionBelow(regUp);
795 GLUhalfEdge eUp, eLo;
796
797 for (; ;) {
798 /* Find the lowest dirty region (we walk from the bottom up). */
799 while (regLo.dirty) {
800 regUp = regLo;
801 regLo = RegionBelow(regLo);
802 }
803 if (!regUp.dirty) {
804 regLo = regUp;
805 regUp = RegionAbove(regUp);
806 if (regUp == null || !regUp.dirty) {
807 /* We've walked all the dirty regions */
808 return;
809 }
810 }
811 regUp.dirty = false;
812 eUp = regUp.eUp;
813 eLo = regLo.eUp;
814
815 if (eUp.Sym.Org != eLo.Sym.Org) {
816 /* Check that the edge ordering is obeyed at the Dst vertices. */
817 if (CheckForLeftSplice(tess, regUp)) {
818
819 /* If the upper or lower edge was marked fixUpperEdge, then
820 * we no longer need it (since these edges are needed only for
821 * vertices which otherwise have no right-going edges).
822 */
823 if (regLo.fixUpperEdge) {
824 DeleteRegion(tess, regLo);
825 if (!Mesh.__gl_meshDelete(eLo)) throw new RuntimeException();
826 regLo = RegionBelow(regUp);
827 eLo = regLo.eUp;
828 } else if (regUp.fixUpperEdge) {
829 DeleteRegion(tess, regUp);
830 if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException();
831 regUp = RegionAbove(regLo);
832 eUp = regUp.eUp;
833 }
834 }
835 }
836 if (eUp.Org != eLo.Org) {
837 if (eUp.Sym.Org != eLo.Sym.Org
838 && !regUp.fixUpperEdge && !regLo.fixUpperEdge
839 && (eUp.Sym.Org == tess.event || eLo.Sym.Org == tess.event)) {
840 /* When all else fails in CheckForIntersect(), it uses tess.event
841 * as the intersection location. To make this possible, it requires
842 * that tess.event lie between the upper and lower edges, and also
843 * that neither of these is marked fixUpperEdge (since in the worst
844 * case it might splice one of these edges into tess.event, and
845 * violate the invariant that fixable edges are the only right-going
846 * edge from their associated vertex).
847 */
848 if (CheckForIntersect(tess, regUp)) {
849 /* WalkDirtyRegions() was called recursively; we're done */
850 return;
851 }
852 } else {
853 /* Even though we can't use CheckForIntersect(), the Org vertices
854 * may violate the dictionary edge ordering. Check and correct this.
855 */
856 CheckForRightSplice(tess, regUp);
857 }
858 }
859 if (eUp.Org == eLo.Org && eUp.Sym.Org == eLo.Sym.Org) {
860 /* A degenerate loop consisting of only two edges -- delete it. */
861 AddWinding(eLo, eUp);
862 DeleteRegion(tess, regUp);
863 if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException();
864 regUp = RegionAbove(regLo);
865 }
866 }
867 }
868
869
870 static void ConnectRightVertex(GLUtessellatorImpl tess, ActiveRegion regUp,
871 GLUhalfEdge eBottomLeft)
872 /*
873 * Purpose: connect a "right" vertex vEvent (one where all edges go left)
874 * to the unprocessed portion of the mesh. Since there are no right-going
875 * edges, two regions (one above vEvent and one below) are being merged
876 * into one. "regUp" is the upper of these two regions.
877 *
878 * There are two reasons for doing this (adding a right-going edge):
879 * - if the two regions being merged are "inside", we must add an edge
880 * to keep them separated (the combined region would not be monotone).
881 * - in any case, we must leave some record of vEvent in the dictionary,
882 * so that we can merge vEvent with features that we have not seen yet.
883 * For example, maybe there is a vertical edge which passes just to
884 * the right of vEvent; we would like to splice vEvent into this edge.
885 *
886 * However, we don't want to connect vEvent to just any vertex. We don''t
887 * want the new edge to cross any other edges; otherwise we will create
888 * intersection vertices even when the input data had no self-intersections.
889 * (This is a bad thing; if the user's input data has no intersections,
890 * we don't want to generate any false intersections ourselves.)
891 *
892 * Our eventual goal is to connect vEvent to the leftmost unprocessed
893 * vertex of the combined region (the union of regUp and regLo).
894 * But because of unseen vertices with all right-going edges, and also
895 * new vertices which may be created by edge intersections, we don''t
896 * know where that leftmost unprocessed vertex is. In the meantime, we
897 * connect vEvent to the closest vertex of either chain, and mark the region
898 * as "fixUpperEdge". This flag says to delete and reconnect this edge
899 * to the next processed vertex on the boundary of the combined region.
900 * Quite possibly the vertex we connected to will turn out to be the
901 * closest one, in which case we won''t need to make any changes.
902 */ {
903 GLUhalfEdge eNew;
904 GLUhalfEdge eTopLeft = eBottomLeft.Onext;
905 ActiveRegion regLo = RegionBelow(regUp);
906 GLUhalfEdge eUp = regUp.eUp;
907 GLUhalfEdge eLo = regLo.eUp;
908 boolean degenerate = false;
909
910 if (eUp.Sym.Org != eLo.Sym.Org) {
911 CheckForIntersect(tess, regUp);
912 }
913
914 /* Possible new degeneracies: upper or lower edge of regUp may pass
915 * through vEvent, or may coincide with new intersection vertex
916 */
917 if (Geom.VertEq(eUp.Org, tess.event)) {
918 if (!Mesh.__gl_meshSplice(eTopLeft.Sym.Lnext, eUp)) throw new RuntimeException();
919 regUp = TopLeftRegion(regUp);
920 if (regUp == null) throw new RuntimeException();
921 eTopLeft = RegionBelow(regUp).eUp;
922 FinishLeftRegions(tess, RegionBelow(regUp), regLo);
923 degenerate = true;
924 }
925 if (Geom.VertEq(eLo.Org, tess.event)) {
926 if (!Mesh.__gl_meshSplice(eBottomLeft, eLo.Sym.Lnext)) throw new RuntimeException();
927 eBottomLeft = FinishLeftRegions(tess, regLo, null);
928 degenerate = true;
929 }
930 if (degenerate) {
931 AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true);
932 return;
933 }
934
935 /* Non-degenerate situation -- need to add a temporary, fixable edge.
936 * Connect to the closer of eLo.Org, eUp.Org.
937 */
938 if (Geom.VertLeq(eLo.Org, eUp.Org)) {
939 eNew = eLo.Sym.Lnext;
940 } else {
941 eNew = eUp;
942 }
943 eNew = Mesh.__gl_meshConnect(eBottomLeft.Onext.Sym, eNew);
944 if (eNew == null) throw new RuntimeException();
945
946 /* Prevent cleanup, otherwise eNew might disappear before we've even
947 * had a chance to mark it as a temporary edge.
948 */
949 AddRightEdges(tess, regUp, eNew, eNew.Onext, eNew.Onext, false);
950 eNew.Sym.activeRegion.fixUpperEdge = true;
951 WalkDirtyRegions(tess, regUp);
952 }
953
954 /* Because vertices at exactly the same location are merged together
955 * before we process the sweep event, some degenerate cases can't occur.
956 * However if someone eventually makes the modifications required to
957 * merge features which are close together, the cases below marked
958 * TOLERANCE_NONZERO will be useful. They were debugged before the
959 * code to merge identical vertices in the main loop was added.
960 */
961 private static final boolean TOLERANCE_NONZERO = false;
962
963 static void ConnectLeftDegenerate(GLUtessellatorImpl tess,
964 ActiveRegion regUp, GLUvertex vEvent)
965 /*
966 * The event vertex lies exacty on an already-processed edge or vertex.
967 * Adding the new vertex involves splicing it into the already-processed
968 * part of the mesh.
969 */ {
970 GLUhalfEdge e, eTopLeft, eTopRight, eLast;
971 ActiveRegion reg;
972
973 e = regUp.eUp;
974 if (Geom.VertEq(e.Org, vEvent)) {
975 /* e.Org is an unprocessed vertex - just combine them, and wait
976 * for e.Org to be pulled from the queue
977 */
978 assert (TOLERANCE_NONZERO);
979 SpliceMergeVertices(tess, e, vEvent.anEdge);
980 return;
981 }
982
983 if (!Geom.VertEq(e.Sym.Org, vEvent)) {
984 /* General case -- splice vEvent into edge e which passes through it */
985 if (Mesh.__gl_meshSplitEdge(e.Sym) == null) throw new RuntimeException();
986 if (regUp.fixUpperEdge) {
987 /* This edge was fixable -- delete unused portion of original edge */
988 if (!Mesh.__gl_meshDelete(e.Onext)) throw new RuntimeException();
989 regUp.fixUpperEdge = false;
990 }
991 if (!Mesh.__gl_meshSplice(vEvent.anEdge, e)) throw new RuntimeException();
992 SweepEvent(tess, vEvent); /* recurse */
993 return;
994 }
995
996 /* vEvent coincides with e.Sym.Org, which has already been processed.
997 * Splice in the additional right-going edges.
998 */
999 assert (TOLERANCE_NONZERO);
1000 regUp = TopRightRegion(regUp);
1001 reg = RegionBelow(regUp);
1002 eTopRight = reg.eUp.Sym;
1003 eTopLeft = eLast = eTopRight.Onext;
1004 if (reg.fixUpperEdge) {
1005 /* Here e.Sym.Org has only a single fixable edge going right.
1006 * We can delete it since now we have some real right-going edges.
1007 */
1008 assert (eTopLeft != eTopRight); /* there are some left edges too */
1009 DeleteRegion(tess, reg);
1010 if (!Mesh.__gl_meshDelete(eTopRight)) throw new RuntimeException();
1011 eTopRight = eTopLeft.Sym.Lnext;
1012 }
1013 if (!Mesh.__gl_meshSplice(vEvent.anEdge, eTopRight)) throw new RuntimeException();
1014 if (!Geom.EdgeGoesLeft(eTopLeft)) {
1015 /* e.Sym.Org had no left-going edges -- indicate this to AddRightEdges() */
1016 eTopLeft = null;
1017 }
1018 AddRightEdges(tess, regUp, eTopRight.Onext, eLast, eTopLeft, true);
1019 }
1020
1021
1022 static void ConnectLeftVertex(GLUtessellatorImpl tess, GLUvertex vEvent)
1023 /*
1024 * Purpose: connect a "left" vertex (one where both edges go right)
1025 * to the processed portion of the mesh. Let R be the active region
1026 * containing vEvent, and let U and L be the upper and lower edge
1027 * chains of R. There are two possibilities:
1028 *
1029 * - the normal case: split R into two regions, by connecting vEvent to
1030 * the rightmost vertex of U or L lying to the left of the sweep line
1031 *
1032 * - the degenerate case: if vEvent is close enough to U or L, we
1033 * merge vEvent into that edge chain. The subcases are:
1034 * - merging with the rightmost vertex of U or L
1035 * - merging with the active edge of U or L
1036 * - merging with an already-processed portion of U or L
1037 */ {
1038 ActiveRegion regUp, regLo, reg;
1039 GLUhalfEdge eUp, eLo, eNew;
1040 ActiveRegion tmp = new ActiveRegion();
1041
1042 /* assert ( vEvent.anEdge.Onext.Onext == vEvent.anEdge ); */
1043
1044 /* Get a pointer to the active region containing vEvent */
1045 tmp.eUp = vEvent.anEdge.Sym;
1046 /* __GL_DICTLISTKEY */ /* __gl_dictListSearch */
1047 regUp = (ActiveRegion) Dict.dictKey(Dict.dictSearch(tess.dict, tmp));
1048 regLo = RegionBelow(regUp);
1049 eUp = regUp.eUp;
1050 eLo = regLo.eUp;
1051
1052 /* Try merging with U or L first */
1053 if (Geom.EdgeSign(eUp.Sym.Org, vEvent, eUp.Org) == 0) {
1054 ConnectLeftDegenerate(tess, regUp, vEvent);
1055 return;
1056 }
1057
1058 /* Connect vEvent to rightmost processed vertex of either chain.
1059 * e.Sym.Org is the vertex that we will connect to vEvent.
1060 */
1061 reg = Geom.VertLeq(eLo.Sym.Org, eUp.Sym.Org) ? regUp : regLo;
1062
1063 if (regUp.inside || reg.fixUpperEdge) {
1064 if (reg == regUp) {
1065 eNew = Mesh.__gl_meshConnect(vEvent.anEdge.Sym, eUp.Lnext);
1066 if (eNew == null) throw new RuntimeException();
1067 } else {
1068 GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(eLo.Sym.Onext.Sym, vEvent.anEdge);
1069 if (tempHalfEdge == null) throw new RuntimeException();
1070
1071 eNew = tempHalfEdge.Sym;
1072 }
1073 if (reg.fixUpperEdge) {
1074 if (!FixUpperEdge(reg, eNew)) throw new RuntimeException();
1075 } else {
1076 ComputeWinding(tess, AddRegionBelow(tess, regUp, eNew));
1077 }
1078 SweepEvent(tess, vEvent);
1079 } else {
1080 /* The new vertex is in a region which does not belong to the polygon.
1081 * We don''t need to connect this vertex to the rest of the mesh.
1082 */
1083 AddRightEdges(tess, regUp, vEvent.anEdge, vEvent.anEdge, null, true);
1084 }
1085 }
1086
1087
1088 static void SweepEvent(GLUtessellatorImpl tess, GLUvertex vEvent)
1089 /*
1090 * Does everything necessary when the sweep line crosses a vertex.
1091 * Updates the mesh and the edge dictionary.
1092 */ {
1093 ActiveRegion regUp, reg;
1094 GLUhalfEdge e, eTopLeft, eBottomLeft;
1095
1096 tess.event = vEvent; /* for access in EdgeLeq() */
1097 DebugEvent(tess);
1098
1099 /* Check if this vertex is the right endpoint of an edge that is
1100 * already in the dictionary. In this case we don't need to waste
1101 * time searching for the location to insert new edges.
1102 */
1103 e = vEvent.anEdge;
1104 while (e.activeRegion == null) {
1105 e = e.Onext;
1106 if (e == vEvent.anEdge) {
1107 /* All edges go right -- not incident to any processed edges */
1108 ConnectLeftVertex(tess, vEvent);
1109 return;
1110 }
1111 }
1112
1113 /* Processing consists of two phases: first we "finish" all the
1114 * active regions where both the upper and lower edges terminate
1115 * at vEvent (ie. vEvent is closing off these regions).
1116 * We mark these faces "inside" or "outside" the polygon according
1117 * to their winding number, and delete the edges from the dictionary.
1118 * This takes care of all the left-going edges from vEvent.
1119 */
1120 regUp = TopLeftRegion(e.activeRegion);
1121 if (regUp == null) throw new RuntimeException();
1122 reg = RegionBelow(regUp);
1123 eTopLeft = reg.eUp;
1124 eBottomLeft = FinishLeftRegions(tess, reg, null);
1125
1126 /* Next we process all the right-going edges from vEvent. This
1127 * involves adding the edges to the dictionary, and creating the
1128 * associated "active regions" which record information about the
1129 * regions between adjacent dictionary edges.
1130 */
1131 if (eBottomLeft.Onext == eTopLeft) {
1132 /* No right-going edges -- add a temporary "fixable" edge */
1133 ConnectRightVertex(tess, regUp, eBottomLeft);
1134 } else {
1135 AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true);
1136 }
1137 }
1138
1139
1140 /* Make the sentinel coordinates big enough that they will never be
1141 * merged with real input features. (Even with the largest possible
1142 * input contour and the maximum tolerance of 1.0, no merging will be
1143 * done with coordinates larger than 3 * GLU_TESS_MAX_COORD).
1144 */
1145 private static final double SENTINEL_COORD = (4.0 * GLU.GLU_TESS_MAX_COORD);
1146
1147 static void AddSentinel(GLUtessellatorImpl tess, double t)
1148 /*
1149 * We add two sentinel edges above and below all other edges,
1150 * to avoid special cases at the top and bottom.
1151 */ {
1152 GLUhalfEdge e;
1153 ActiveRegion reg = new ActiveRegion();
1154 if (reg == null) throw new RuntimeException();
1155
1156 e = Mesh.__gl_meshMakeEdge(tess.mesh);
1157 if (e == null) throw new RuntimeException();
1158
1159 e.Org.s = SENTINEL_COORD;
1160 e.Org.t = t;
1161 e.Sym.Org.s = -SENTINEL_COORD;
1162 e.Sym.Org.t = t;
1163 tess.event = e.Sym.Org; /* initialize it */
1164
1165 reg.eUp = e;
1166 reg.windingNumber = 0;
1167 reg.inside = false;
1168 reg.fixUpperEdge = false;
1169 reg.sentinel = true;
1170 reg.dirty = false;
1171 reg.nodeUp = Dict.dictInsert(tess.dict, reg); /* __gl_dictListInsertBefore */
1172 if (reg.nodeUp == null) throw new RuntimeException();
1173 }
1174
1175
1176 static void InitEdgeDict(final GLUtessellatorImpl tess)
1177 /*
1178 * We maintain an ordering of edge intersections with the sweep line.
1179 * This order is maintained in a dynamic dictionary.
1180 */ {
1181 /* __gl_dictListNewDict */
1182 tess.dict = Dict.dictNewDict(tess, new Dict.DictLeq() {
1183 public boolean leq(Object frame, Object key1, Object key2) {
1184 return EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2);
1185 }
1186 });
1187 if (tess.dict == null) throw new RuntimeException();
1188
1189 AddSentinel(tess, -SENTINEL_COORD);
1190 AddSentinel(tess, SENTINEL_COORD);
1191 }
1192
1193
1194 static void DoneEdgeDict(GLUtessellatorImpl tess) {
1195 ActiveRegion reg;
1196 int fixedEdges = 0;
1197
1198 /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */
1199 while ((reg = (ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))) != null) {
1200 /*
1201 * At the end of all processing, the dictionary should contain
1202 * only the two sentinel edges, plus at most one "fixable" edge
1203 * created by ConnectRightVertex().
1204 */
1205 if (!reg.sentinel) {
1206 assert (reg.fixUpperEdge);
1207 assert (++fixedEdges == 1);
1208 }
1209 assert (reg.windingNumber == 0);
1210 DeleteRegion(tess, reg);
1211 /* __gl_meshDelete( reg.eUp );*/
1212 }
1213 Dict.dictDeleteDict(tess.dict); /* __gl_dictListDeleteDict */
1214 }
1215
1216
1217 static void RemoveDegenerateEdges(GLUtessellatorImpl tess)
1218 /*
1219 * Remove zero-length edges, and contours with fewer than 3 vertices.
1220 */ {
1221 GLUhalfEdge e, eNext, eLnext;
1222 GLUhalfEdge eHead = tess.mesh.eHead;
1223
1224 /*LINTED*/
1225 for (e = eHead.next; e != eHead; e = eNext) {
1226 eNext = e.next;
1227 eLnext = e.Lnext;
1228
1229 if (Geom.VertEq(e.Org, e.Sym.Org) && e.Lnext.Lnext != e) {
1230 /* Zero-length edge, contour has at least 3 edges */
1231
1232 SpliceMergeVertices(tess, eLnext, e); /* deletes e.Org */
1233 if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException(); /* e is a self-loop */
1234 e = eLnext;
1235 eLnext = e.Lnext;
1236 }
1237 if (eLnext.Lnext == e) {
1238 /* Degenerate contour (one or two edges) */
1239
1240 if (eLnext != e) {
1241 if (eLnext == eNext || eLnext == eNext.Sym) {
1242 eNext = eNext.next;
1243 }
1244 if (!Mesh.__gl_meshDelete(eLnext)) throw new RuntimeException();
1245 }
1246 if (e == eNext || e == eNext.Sym) {
1247 eNext = eNext.next;
1248 }
1249 if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException();
1250 }
1251 }
1252 }
1253
1254 static boolean InitPriorityQ(GLUtessellatorImpl tess)
1255 /*
1256 * Insert all vertices into the priority queue which determines the
1257 * order in which vertices cross the sweep line.
1258 */ {
1259 PriorityQ pq;
1260 GLUvertex v, vHead;
1261
1262 /* __gl_pqSortNewPriorityQ */
1263 pq = tess.pq = PriorityQ.pqNewPriorityQ(new PriorityQ.Leq() {
1264 public boolean leq(Object key1, Object key2) {
1265 return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2);
1266 }
1267 });
1268 if (pq == null) return false;
1269
1270 vHead = tess.mesh.vHead;
1271 for (v = vHead.next; v != vHead; v = v.next) {
1272 v.pqHandle = pq.pqInsert(v); /* __gl_pqSortInsert */
1273 if (v.pqHandle == Long.MAX_VALUE) break;
1274 }
1275 if (v != vHead || !pq.pqInit()) { /* __gl_pqSortInit */
1276 tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
1277 tess.pq = null;
1278 return false;
1279 }
1280
1281 return true;
1282 }
1283
1284
1285 static void DonePriorityQ(GLUtessellatorImpl tess) {
1286 tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
1287 }
1288
1289
1290 static boolean RemoveDegenerateFaces(GLUmesh mesh)
1291 /*
1292 * Delete any degenerate faces with only two edges. WalkDirtyRegions()
1293 * will catch almost all of these, but it won't catch degenerate faces
1294 * produced by splice operations on already-processed edges.
1295 * The two places this can happen are in FinishLeftRegions(), when
1296 * we splice in a "temporary" edge produced by ConnectRightVertex(),
1297 * and in CheckForLeftSplice(), where we splice already-processed
1298 * edges to ensure that our dictionary invariants are not violated
1299 * by numerical errors.
1300 *
1301 * In both these cases it is *very* dangerous to delete the offending
1302 * edge at the time, since one of the routines further up the stack
1303 * will sometimes be keeping a pointer to that edge.
1304 */ {
1305 GLUface f, fNext;
1306 GLUhalfEdge e;
1307
1308 /*LINTED*/
1309 for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) {
1310 fNext = f.next;
1311 e = f.anEdge;
1312 assert (e.Lnext != e);
1313
1314 if (e.Lnext.Lnext == e) {
1315 /* A face with only two edges */
1316 AddWinding(e.Onext, e);
1317 if (!Mesh.__gl_meshDelete(e)) return false;
1318 }
1319 }
1320 return true;
1321 }
1322
1323 public static boolean __gl_computeInterior(GLUtessellatorImpl tess)
1324 /*
1325 * __gl_computeInterior( tess ) computes the planar arrangement specified
1326 * by the given contours, and further subdivides this arrangement
1327 * into regions. Each region is marked "inside" if it belongs
1328 * to the polygon, according to the rule given by tess.windingRule.
1329 * Each interior region is guaranteed be monotone.
1330 */ {
1331 GLUvertex v, vNext;
1332
1333 tess.fatalError = false;
1334
1335 /* Each vertex defines an event for our sweep line. Start by inserting
1336 * all the vertices in a priority queue. Events are processed in
1337 * lexicographic order, ie.
1338 *
1339 * e1 < e2 iff e1.x < e2.x || (e1.x == e2.x && e1.y < e2.y)
1340 */
1341 RemoveDegenerateEdges(tess);
1342 if (!InitPriorityQ(tess)) return false; /* if error */
1343 InitEdgeDict(tess);
1344
1345 /* __gl_pqSortExtractMin */
1346 while ((v = (GLUvertex) tess.pq.pqExtractMin()) != null) {
1347 for (; ;) {
1348 vNext = (GLUvertex) tess.pq.pqMinimum(); /* __gl_pqSortMinimum */
1349 if (vNext == null || !Geom.VertEq(vNext, v)) break;
1350
1351 /* Merge together all vertices at exactly the same location.
1352 * This is more efficient than processing them one at a time,
1353 * simplifies the code (see ConnectLeftDegenerate), and is also
1354 * important for correct handling of certain degenerate cases.
1355 * For example, suppose there are two identical edges A and B
1356 * that belong to different contours (so without this code they would
1357 * be processed by separate sweep events). Suppose another edge C
1358 * crosses A and B from above. When A is processed, we split it
1359 * at its intersection point with C. However this also splits C,
1360 * so when we insert B we may compute a slightly different
1361 * intersection point. This might leave two edges with a small
1362 * gap between them. This kind of error is especially obvious
1363 * when using boundary extraction (GLU_TESS_BOUNDARY_ONLY).
1364 */
1365 vNext = (GLUvertex) tess.pq.pqExtractMin(); /* __gl_pqSortExtractMin*/
1366 SpliceMergeVertices(tess, v.anEdge, vNext.anEdge);
1367 }
1368 SweepEvent(tess, v);
1369 }
1370
1371 /* Set tess.event for debugging purposes */
1372 /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */
1373 tess.event = ((ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))).eUp.Org;
1374 DebugEvent(tess);
1375 DoneEdgeDict(tess);
1376 DonePriorityQ(tess);
1377
1378 if (!RemoveDegenerateFaces(tess.mesh)) return false;
1379 Mesh.__gl_meshCheckMesh(tess.mesh);
1380
1381 return true;
1382 }
1383 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class TessMono {
87 /* __gl_meshTessellateMonoRegion( face ) tessellates a monotone region
88 * (what else would it do??) The region must consist of a single
89 * loop of half-edges (see mesh.h) oriented CCW. "Monotone" in this
90 * case means that any vertical line intersects the interior of the
91 * region in a single interval.
92 *
93 * Tessellation consists of adding interior edges (actually pairs of
94 * half-edges), to split the region into non-overlapping triangles.
95 *
96 * The basic idea is explained in Preparata and Shamos (which I don''t
97 * have handy right now), although their implementation is more
98 * complicated than this one. The are two edge chains, an upper chain
99 * and a lower chain. We process all vertices from both chains in order,
100 * from right to left.
101 *
102 * The algorithm ensures that the following invariant holds after each
103 * vertex is processed: the untessellated region consists of two
104 * chains, where one chain (say the upper) is a single edge, and
105 * the other chain is concave. The left vertex of the single edge
106 * is always to the left of all vertices in the concave chain.
107 *
108 * Each step consists of adding the rightmost unprocessed vertex to one
109 * of the two chains, and forming a fan of triangles from the rightmost
110 * of two chain endpoints. Determining whether we can add each triangle
111 * to the fan is a simple orientation test. By making the fan as large
112 * as possible, we restore the invariant (check it yourself).
113 */
114 static boolean __gl_meshTessellateMonoRegion(GLUface face) {
115 GLUhalfEdge up, lo;
116
117 /* All edges are oriented CCW around the boundary of the region.
118 * First, find the half-edge whose origin vertex is rightmost.
119 * Since the sweep goes from left to right, face->anEdge should
120 * be close to the edge we want.
121 */
122 up = face.anEdge;
123 assert (up.Lnext != up && up.Lnext.Lnext != up);
124
125 for (; Geom.VertLeq(up.Sym.Org, up.Org); up = up.Onext.Sym)
126 ;
127 for (; Geom.VertLeq(up.Org, up.Sym.Org); up = up.Lnext)
128 ;
129 lo = up.Onext.Sym;
130
131 while (up.Lnext != lo) {
132 if (Geom.VertLeq(up.Sym.Org, lo.Org)) {
133 /* up.Sym.Org is on the left. It is safe to form triangles from lo.Org.
134 * The EdgeGoesLeft test guarantees progress even when some triangles
135 * are CW, given that the upper and lower chains are truly monotone.
136 */
137 while (lo.Lnext != up && (Geom.EdgeGoesLeft(lo.Lnext)
138 || Geom.EdgeSign(lo.Org, lo.Sym.Org, lo.Lnext.Sym.Org) <= 0)) {
139 GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo);
140 if (tempHalfEdge == null) return false;
141 lo = tempHalfEdge.Sym;
142 }
143 lo = lo.Onext.Sym;
144 } else {
145 /* lo.Org is on the left. We can make CCW triangles from up.Sym.Org. */
146 while (lo.Lnext != up && (Geom.EdgeGoesRight(up.Onext.Sym)
147 || Geom.EdgeSign(up.Sym.Org, up.Org, up.Onext.Sym.Org) >= 0)) {
148 GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(up, up.Onext.Sym);
149 if (tempHalfEdge == null) return false;
150 up = tempHalfEdge.Sym;
151 }
152 up = up.Lnext;
153 }
154 }
155
156 /* Now lo.Org == up.Sym.Org == the leftmost vertex. The remaining region
157 * can be tessellated in a fan from this leftmost vertex.
158 */
159 assert (lo.Lnext != up);
160 while (lo.Lnext.Lnext != up) {
161 GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo);
162 if (tempHalfEdge == null) return false;
163 lo = tempHalfEdge.Sym;
164 }
165
166 return true;
167 }
168
169
170 /* __gl_meshTessellateInterior( mesh ) tessellates each region of
171 * the mesh which is marked "inside" the polygon. Each such region
172 * must be monotone.
173 */
174 public static boolean __gl_meshTessellateInterior(GLUmesh mesh) {
175 GLUface f, next;
176
177 /*LINTED*/
178 for (f = mesh.fHead.next; f != mesh.fHead; f = next) {
179 /* Make sure we don''t try to tessellate the new triangles. */
180 next = f.next;
181 if (f.inside) {
182 if (!__gl_meshTessellateMonoRegion(f)) return false;
183 }
184 }
185
186 return true;
187 }
188
189
190 /* __gl_meshDiscardExterior( mesh ) zaps (ie. sets to NULL) all faces
191 * which are not marked "inside" the polygon. Since further mesh operations
192 * on NULL faces are not allowed, the main purpose is to clean up the
193 * mesh so that exterior loops are not represented in the data structure.
194 */
195 public static void __gl_meshDiscardExterior(GLUmesh mesh) {
196 GLUface f, next;
197
198 /*LINTED*/
199 for (f = mesh.fHead.next; f != mesh.fHead; f = next) {
200 /* Since f will be destroyed, save its next pointer. */
201 next = f.next;
202 if (!f.inside) {
203 Mesh.__gl_meshZapFace(f);
204 }
205 }
206 }
207
208 // private static final int MARKED_FOR_DELETION = 0x7fffffff;
209
210 /* __gl_meshSetWindingNumber( mesh, value, keepOnlyBoundary ) resets the
211 * winding numbers on all edges so that regions marked "inside" the
212 * polygon have a winding number of "value", and regions outside
213 * have a winding number of 0.
214 *
215 * If keepOnlyBoundary is TRUE, it also deletes all edges which do not
216 * separate an interior region from an exterior one.
217 */
218 public static boolean __gl_meshSetWindingNumber(GLUmesh mesh, int value, boolean keepOnlyBoundary) {
219 GLUhalfEdge e, eNext;
220
221 for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) {
222 eNext = e.next;
223 if (e.Sym.Lface.inside != e.Lface.inside) {
224
225 /* This is a boundary edge (one side is interior, one is exterior). */
226 e.winding = (e.Lface.inside) ? value : -value;
227 } else {
228
229 /* Both regions are interior, or both are exterior. */
230 if (!keepOnlyBoundary) {
231 e.winding = 0;
232 } else {
233 if (!Mesh.__gl_meshDelete(e)) return false;
234 }
235 }
236 }
237 return true;
238 }
239
240 }
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 * Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
34 * All rights reserved.
35 */
36
37 /*
38 ** License Applicability. Except to the extent portions of this file are
39 ** made subject to an alternative license as permitted in the SGI Free
40 ** Software License B, Version 1.1 (the "License"), the contents of this
41 ** file are subject only to the provisions of the License. You may not use
42 ** this file except in compliance with the License. You may obtain a copy
43 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
44 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
45 **
46 ** http://oss.sgi.com/projects/FreeB
47 **
48 ** Note that, as provided in the License, the Software is distributed on an
49 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
50 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
51 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
52 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
53 **
54 ** NOTE: The Original Code (as defined below) has been licensed to Sun
55 ** Microsystems, Inc. ("Sun") under the SGI Free Software License B
56 ** (Version 1.1), shown above ("SGI License"). Pursuant to Section
57 ** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
58 ** you under an alternative license ("Alternative License"). This
59 ** Alternative License includes all of the provisions of the SGI License
60 ** except that Section 2.2 and 11 are omitted. Any differences between
61 ** the Alternative License and the SGI License are offered solely by Sun
62 ** and not by SGI.
63 **
64 ** Original Code. The Original Code is: OpenGL Sample Implementation,
65 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
66 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
67 ** Copyright in any portions created by third parties is as indicated
68 ** elsewhere herein. All Rights Reserved.
69 **
70 ** Additional Notice Provisions: The application programming interfaces
71 ** established by SGI in conjunction with the Original Code are The
72 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
73 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
74 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
75 ** Window System(R) (Version 1.3), released October 19, 1998. This software
76 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
77 ** published by SGI, but has not been independently verified as being
78 ** compliant with the OpenGL(R) version 1.2.1 Specification.
79 **
80 ** Author: Eric Veach, July 1994
81 ** Java Port: Pepijn Van Eeckhoudt, July 2003
82 ** Java Port: Nathan Parker Burg, August 2003
83 */
84 package org.lwjgl.util.glu.tessellation;
85
86 class TessState {
87 public static final int T_DORMANT = 0;
88 public static final int T_IN_POLYGON = 1;
89 public static final int T_IN_CONTOUR = 2;
90 }
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.input;
32
33 import org.lwjgl.input.Controller;
34
35 /**
36 * Adapter for the Controller interface. It can be used as placeholder
37 * Controller, which doesn't do anything (eg if Controllers.create() fails and
38 * you don't want to take care of that).
39 *
40 * @author Onyx, Aho and all the other aliases...
41 */
42 public class ControllerAdapter implements Controller {
43
44 /**
45 * Get the name assigned to this controller.
46 *
47 * @return The name assigned to this controller
48 */
49 public String getName() {
50 return "Dummy Controller";
51 }
52
53 /**
54 * Get the index of this controller in the collection
55 *
56 * @return The index of this controller in the collection
57 */
58 public int getIndex() {
59 return 0; //-1 maybe?
60 }
61
62 /**
63 * Retrieve the number of buttons available on this controller
64 *
65 * @return The number of butotns available on this controller
66 */
67 public int getButtonCount() {
68 return 0;
69 }
70
71 /**
72 * Get the name of the specified button. Be warned, often this is as
73 * exciting as "Button X"
74 *
75 * @param index The index of the button whose name should be retrieved
76 * @return The name of the button requested
77 */
78 public String getButtonName(int index) {
79 return "button n/a";
80 }
81
82 /**
83 * Check if a button is currently pressed
84 *
85 * @param index The button to check
86 * @return True if the button is currently pressed
87 */
88 public boolean isButtonPressed(int index) {
89 return false;
90 }
91
92 /**
93 * Poll the controller for new data. This will also update events
94 */
95 public void poll() {
96 }
97
98 /**
99 * Get the X-Axis value of the POV on this controller
100 *
101 * @return The X-Axis value of the POV on this controller
102 */
103 public float getPovX() {
104 return 0f;
105 }
106
107 /**
108 * Get the Y-Axis value of the POV on this controller
109 *
110 * @return The Y-Axis value of the POV on this controller
111 */
112 public float getPovY() {
113 return 0f;
114 }
115
116 /**
117 * Get the dead zone for a specified axis
118 *
119 * @param index The index of the axis for which to retrieve the dead zone
120 * @return The dead zone for the specified axis
121 */
122 public float getDeadZone(int index) {
123 return 0f;
124 }
125
126 /**
127 * Set the dead zone for the specified axis
128 *
129 * @param index The index of hte axis for which to set the dead zone
130 * @param zone The dead zone to use for the specified axis
131 */
132 public void setDeadZone(int index, float zone) {
133 }
134
135 /**
136 * Retrieve the number of axes available on this controller.
137 *
138 * @return The number of axes available on this controller.
139 */
140 public int getAxisCount() {
141 return 0;
142 }
143
144 /**
145 * Get the name that's given to the specified axis
146 *
147 * @param index The index of the axis whose name should be retrieved
148 * @return The name of the specified axis.
149 */
150 public String getAxisName(int index) {
151 return "axis n/a";
152 }
153
154 /**
155 * Retrieve the value thats currently available on a specified axis. The
156 * value will always be between 1.0 and -1.0 and will calibrate as values
157 * are passed read. It may be useful to get the player to wiggle the
158 * joystick from side to side to get the calibration right.
159 *
160 * @param index The index of axis to be read
161 * @return The value from the specified axis.
162 */
163 public float getAxisValue(int index) {
164 return 0f;
165 }
166
167 /**
168 * Get the value from the X axis if there is one. If no X axis is defined a
169 * zero value will be returned.
170 *
171 * @return The value from the X axis
172 */
173 public float getXAxisValue() {
174 return 0f;
175 }
176
177 /**
178 * Get the dead zone for the X axis.
179 *
180 * @return The dead zone for the X axis
181 */
182 public float getXAxisDeadZone() {
183 return 0f;
184 }
185
186 /**
187 * Set the dead zone for the X axis
188 *
189 * @param zone The dead zone to use for the X axis
190 */
191 public void setXAxisDeadZone(float zone) {
192 }
193
194 /**
195 * Get the value from the Y axis if there is one. If no Y axis is defined a
196 * zero value will be returned.
197 *
198 * @return The value from the Y axis
199 */
200 public float getYAxisValue() {
201 return 0f;
202 }
203
204 /**
205 * Get the dead zone for the Y axis.
206 *
207 * @return The dead zone for the Y axis
208 */
209 public float getYAxisDeadZone() {
210 return 0f;
211 }
212
213 /**
214 * Set the dead zone for the Y axis
215 *
216 * @param zone The dead zone to use for the Y axis
217 */
218 public void setYAxisDeadZone(float zone) {
219 }
220
221 /**
222 * Get the value from the Z axis if there is one. If no Z axis is defined a
223 * zero value will be returned.
224 *
225 * @return The value from the Z axis
226 */
227 public float getZAxisValue() {
228 return 0f;
229 }
230
231 /**
232 * Get the dead zone for the Z axis.
233 *
234 * @return The dead zone for the Z axis
235 */
236 public float getZAxisDeadZone() {
237 return 0f;
238 }
239
240 /**
241 * Set the dead zone for the Z axis
242 *
243 * @param zone The dead zone to use for the Z axis
244 */
245 public void setZAxisDeadZone(float zone) {
246 }
247
248 /**
249 * Get the value from the RX axis if there is one. If no RX axis is defined
250 * a zero value will be returned.
251 *
252 * @return The value from the RX axis
253 */
254 public float getRXAxisValue() {
255 return 0f;
256 }
257
258 /**
259 * Get the dead zone for the RX axis.
260 *
261 * @return The dead zone for the RX axis
262 */
263 public float getRXAxisDeadZone() {
264 return 0f;
265 }
266
267 /**
268 * Set the dead zone for the RX axis
269 *
270 * @param zone The dead zone to use for the RX axis
271 */
272 public void setRXAxisDeadZone(float zone) {
273 }
274
275 /**
276 * Get the value from the RY axis if there is one. If no RY axis is defined
277 * a zero value will be returned.
278 *
279 * @return The value from the RY axis
280 */
281 public float getRYAxisValue() {
282 return 0f;
283 }
284
285 /**
286 * Get the dead zone for the RY axis.
287 *
288 * @return The dead zone for the RY axis
289 */
290 public float getRYAxisDeadZone() {
291 return 0f;
292 }
293
294 /**
295 * Set the dead zone for the RY axis
296 *
297 * @param zone The dead zone to use for the RY axis
298 */
299 public void setRYAxisDeadZone(float zone) {
300 }
301
302 /**
303 * Get the value from the RZ axis if there is one. If no RZ axis is defined
304 * a zero value will be returned.
305 *
306 * @return The value from the RZ axis
307 */
308 public float getRZAxisValue() {
309 return 0f;
310 }
311
312 /**
313 * Get the dead zone for the RZ axis.
314 *
315 * @return The dead zone for the RZ axis
316 */
317 public float getRZAxisDeadZone() {
318 return 0f;
319 }
320
321 /**
322 * Set the dead zone for the RZ axis
323 *
324 * @param zone The dead zone to use for the RZ axis
325 */
326 public void setRZAxisDeadZone(float zone) {
327 }
328 }
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.jinput;
32
33 import org.lwjgl.input.Keyboard;
34 import net.java.games.input.Component;
35
36 /**
37 * @author elias
38 */
39 final class KeyMap {
40 public final static Component.Identifier.Key map(int lwjgl_key_code) {
41 switch (lwjgl_key_code) {
42 case Keyboard.KEY_ESCAPE:
43 return Component.Identifier.Key.ESCAPE;
44 case Keyboard.KEY_1:
45 return Component.Identifier.Key._1;
46 case Keyboard.KEY_2:
47 return Component.Identifier.Key._2;
48 case Keyboard.KEY_3:
49 return Component.Identifier.Key._3;
50 case Keyboard.KEY_4:
51 return Component.Identifier.Key._4;
52 case Keyboard.KEY_5:
53 return Component.Identifier.Key._5;
54 case Keyboard.KEY_6:
55 return Component.Identifier.Key._6;
56 case Keyboard.KEY_7:
57 return Component.Identifier.Key._7;
58 case Keyboard.KEY_8:
59 return Component.Identifier.Key._8;
60 case Keyboard.KEY_9:
61 return Component.Identifier.Key._9;
62 case Keyboard.KEY_0:
63 return Component.Identifier.Key._0;
64 case Keyboard.KEY_MINUS:
65 return Component.Identifier.Key.MINUS;
66 case Keyboard.KEY_EQUALS:
67 return Component.Identifier.Key.EQUALS;
68 case Keyboard.KEY_BACK:
69 return Component.Identifier.Key.BACK;
70 case Keyboard.KEY_TAB:
71 return Component.Identifier.Key.TAB;
72 case Keyboard.KEY_Q:
73 return Component.Identifier.Key.Q;
74 case Keyboard.KEY_W:
75 return Component.Identifier.Key.W;
76 case Keyboard.KEY_E:
77 return Component.Identifier.Key.E;
78 case Keyboard.KEY_R:
79 return Component.Identifier.Key.R;
80 case Keyboard.KEY_T:
81 return Component.Identifier.Key.T;
82 case Keyboard.KEY_Y:
83 return Component.Identifier.Key.Y;
84 case Keyboard.KEY_U:
85 return Component.Identifier.Key.U;
86 case Keyboard.KEY_I:
87 return Component.Identifier.Key.I;
88 case Keyboard.KEY_O:
89 return Component.Identifier.Key.O;
90 case Keyboard.KEY_P:
91 return Component.Identifier.Key.P;
92 case Keyboard.KEY_LBRACKET:
93 return Component.Identifier.Key.LBRACKET;
94 case Keyboard.KEY_RBRACKET:
95 return Component.Identifier.Key.RBRACKET;
96 case Keyboard.KEY_RETURN:
97 return Component.Identifier.Key.RETURN;
98 case Keyboard.KEY_LCONTROL:
99 return Component.Identifier.Key.LCONTROL;
100 case Keyboard.KEY_A:
101 return Component.Identifier.Key.A;
102 case Keyboard.KEY_S:
103 return Component.Identifier.Key.S;
104 case Keyboard.KEY_D:
105 return Component.Identifier.Key.D;
106 case Keyboard.KEY_F:
107 return Component.Identifier.Key.F;
108 case Keyboard.KEY_G:
109 return Component.Identifier.Key.G;
110 case Keyboard.KEY_H:
111 return Component.Identifier.Key.H;
112 case Keyboard.KEY_J:
113 return Component.Identifier.Key.J;
114 case Keyboard.KEY_K:
115 return Component.Identifier.Key.K;
116 case Keyboard.KEY_L:
117 return Component.Identifier.Key.L;
118 case Keyboard.KEY_SEMICOLON:
119 return Component.Identifier.Key.SEMICOLON;
120 case Keyboard.KEY_APOSTROPHE:
121 return Component.Identifier.Key.APOSTROPHE;
122 case Keyboard.KEY_GRAVE:
123 return Component.Identifier.Key.GRAVE;
124 case Keyboard.KEY_LSHIFT:
125 return Component.Identifier.Key.LSHIFT;
126 case Keyboard.KEY_BACKSLASH:
127 return Component.Identifier.Key.BACKSLASH;
128 case Keyboard.KEY_Z:
129 return Component.Identifier.Key.Z;
130 case Keyboard.KEY_X:
131 return Component.Identifier.Key.X;
132 case Keyboard.KEY_C:
133 return Component.Identifier.Key.C;
134 case Keyboard.KEY_V:
135 return Component.Identifier.Key.V;
136 case Keyboard.KEY_B:
137 return Component.Identifier.Key.B;
138 case Keyboard.KEY_N:
139 return Component.Identifier.Key.N;
140 case Keyboard.KEY_M:
141 return Component.Identifier.Key.M;
142 case Keyboard.KEY_COMMA:
143 return Component.Identifier.Key.COMMA;
144 case Keyboard.KEY_PERIOD:
145 return Component.Identifier.Key.PERIOD;
146 case Keyboard.KEY_SLASH:
147 return Component.Identifier.Key.SLASH;
148 case Keyboard.KEY_RSHIFT:
149 return Component.Identifier.Key.RSHIFT;
150 case Keyboard.KEY_MULTIPLY:
151 return Component.Identifier.Key.MULTIPLY;
152 case Keyboard.KEY_LMENU:
153 return Component.Identifier.Key.LALT;
154 case Keyboard.KEY_SPACE:
155 return Component.Identifier.Key.SPACE;
156 case Keyboard.KEY_CAPITAL:
157 return Component.Identifier.Key.CAPITAL;
158 case Keyboard.KEY_F1:
159 return Component.Identifier.Key.F1;
160 case Keyboard.KEY_F2:
161 return Component.Identifier.Key.F2;
162 case Keyboard.KEY_F3:
163 return Component.Identifier.Key.F3;
164 case Keyboard.KEY_F4:
165 return Component.Identifier.Key.F4;
166 case Keyboard.KEY_F5:
167 return Component.Identifier.Key.F5;
168 case Keyboard.KEY_F6:
169 return Component.Identifier.Key.F6;
170 case Keyboard.KEY_F7:
171 return Component.Identifier.Key.F7;
172 case Keyboard.KEY_F8:
173 return Component.Identifier.Key.F8;
174 case Keyboard.KEY_F9:
175 return Component.Identifier.Key.F9;
176 case Keyboard.KEY_F10:
177 return Component.Identifier.Key.F10;
178 case Keyboard.KEY_NUMLOCK:
179 return Component.Identifier.Key.NUMLOCK;
180 case Keyboard.KEY_SCROLL:
181 return Component.Identifier.Key.SCROLL;
182 case Keyboard.KEY_NUMPAD7:
183 return Component.Identifier.Key.NUMPAD7;
184 case Keyboard.KEY_NUMPAD8:
185 return Component.Identifier.Key.NUMPAD8;
186 case Keyboard.KEY_NUMPAD9:
187 return Component.Identifier.Key.NUMPAD9;
188 case Keyboard.KEY_SUBTRACT:
189 return Component.Identifier.Key.SUBTRACT;
190 case Keyboard.KEY_NUMPAD4:
191 return Component.Identifier.Key.NUMPAD4;
192 case Keyboard.KEY_NUMPAD5:
193 return Component.Identifier.Key.NUMPAD5;
194 case Keyboard.KEY_NUMPAD6:
195 return Component.Identifier.Key.NUMPAD6;
196 case Keyboard.KEY_ADD:
197 return Component.Identifier.Key.ADD;
198 case Keyboard.KEY_NUMPAD1:
199 return Component.Identifier.Key.NUMPAD1;
200 case Keyboard.KEY_NUMPAD2:
201 return Component.Identifier.Key.NUMPAD2;
202 case Keyboard.KEY_NUMPAD3:
203 return Component.Identifier.Key.NUMPAD3;
204 case Keyboard.KEY_NUMPAD0:
205 return Component.Identifier.Key.NUMPAD0;
206 case Keyboard.KEY_DECIMAL:
207 return Component.Identifier.Key.DECIMAL;
208 case Keyboard.KEY_F11:
209 return Component.Identifier.Key.F11;
210 case Keyboard.KEY_F12:
211 return Component.Identifier.Key.F12;
212 case Keyboard.KEY_F13:
213 return Component.Identifier.Key.F13;
214 case Keyboard.KEY_F14:
215 return Component.Identifier.Key.F14;
216 case Keyboard.KEY_F15:
217 return Component.Identifier.Key.F15;
218 case Keyboard.KEY_KANA:
219 return Component.Identifier.Key.KANA;
220 case Keyboard.KEY_CONVERT:
221 return Component.Identifier.Key.CONVERT;
222 case Keyboard.KEY_NOCONVERT:
223 return Component.Identifier.Key.NOCONVERT;
224 case Keyboard.KEY_YEN:
225 return Component.Identifier.Key.YEN;
226 case Keyboard.KEY_NUMPADEQUALS:
227 return Component.Identifier.Key.NUMPADEQUAL;
228 case Keyboard.KEY_CIRCUMFLEX:
229 return Component.Identifier.Key.CIRCUMFLEX;
230 case Keyboard.KEY_AT:
231 return Component.Identifier.Key.AT;
232 case Keyboard.KEY_COLON:
233 return Component.Identifier.Key.COLON;
234 case Keyboard.KEY_UNDERLINE:
235 return Component.Identifier.Key.UNDERLINE;
236 case Keyboard.KEY_KANJI:
237 return Component.Identifier.Key.KANJI;
238 case Keyboard.KEY_STOP:
239 return Component.Identifier.Key.STOP;
240 case Keyboard.KEY_AX:
241 return Component.Identifier.Key.AX;
242 case Keyboard.KEY_UNLABELED:
243 return Component.Identifier.Key.UNLABELED;
244 case Keyboard.KEY_NUMPADENTER:
245 return Component.Identifier.Key.NUMPADENTER;
246 case Keyboard.KEY_RCONTROL:
247 return Component.Identifier.Key.RCONTROL;
248 case Keyboard.KEY_NUMPADCOMMA:
249 return Component.Identifier.Key.NUMPADCOMMA;
250 case Keyboard.KEY_DIVIDE:
251 return Component.Identifier.Key.DIVIDE;
252 case Keyboard.KEY_SYSRQ:
253 return Component.Identifier.Key.SYSRQ;
254 case Keyboard.KEY_RMENU:
255 return Component.Identifier.Key.RALT;
256 case Keyboard.KEY_PAUSE:
257 return Component.Identifier.Key.PAUSE;
258 case Keyboard.KEY_HOME:
259 return Component.Identifier.Key.HOME;
260 case Keyboard.KEY_UP:
261 return Component.Identifier.Key.UP;
262 case Keyboard.KEY_PRIOR:
263 return Component.Identifier.Key.PAGEUP;
264 case Keyboard.KEY_LEFT:
265 return Component.Identifier.Key.LEFT;
266 case Keyboard.KEY_RIGHT:
267 return Component.Identifier.Key.RIGHT;
268 case Keyboard.KEY_END:
269 return Component.Identifier.Key.END;
270 case Keyboard.KEY_DOWN:
271 return Component.Identifier.Key.DOWN;
272 case Keyboard.KEY_NEXT:
273 return Component.Identifier.Key.PAGEDOWN;
274 case Keyboard.KEY_INSERT:
275 return Component.Identifier.Key.INSERT;
276 case Keyboard.KEY_DELETE:
277 return Component.Identifier.Key.DELETE;
278 case Keyboard.KEY_LMETA:
279 return Component.Identifier.Key.LWIN;
280 case Keyboard.KEY_RMETA:
281 return Component.Identifier.Key.RWIN;
282 case Keyboard.KEY_APPS:
283 return Component.Identifier.Key.APPS;
284 case Keyboard.KEY_POWER:
285 return Component.Identifier.Key.POWER;
286 case Keyboard.KEY_SLEEP:
287 return Component.Identifier.Key.SLEEP;
288 default:
289 return Component.Identifier.Key.UNKNOWN;
290 }
291 }
292 }
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.jinput;
32
33 import net.java.games.input.Controller;
34 import net.java.games.input.ControllerEnvironment;
35 import net.java.games.util.plugins.Plugin;
36
37 /**
38 * @author elias
39 */
40 public class LWJGLEnvironmentPlugin extends ControllerEnvironment implements Plugin {
41 private final Controller[] controllers;
42
43 public LWJGLEnvironmentPlugin() {
44 this.controllers = new Controller[]{new LWJGLKeyboard(), new LWJGLMouse()};
45 }
46
47 public Controller[] getControllers() {
48 return controllers;
49 }
50
51 public boolean isSupported() {
52 return true;
53 }
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.jinput;
32
33 import net.java.games.input.AbstractComponent;
34 import net.java.games.input.Keyboard;
35 import net.java.games.input.Component;
36 import net.java.games.input.Controller;
37 import net.java.games.input.Rumbler;
38 import net.java.games.input.Event;
39 import java.util.List;
40 import java.util.ArrayList;
41
42 import java.io.IOException;
43
44 import java.lang.reflect.Field;
45 import java.lang.reflect.Modifier;
46
47 /**
48 * @author elias
49 */
50 final class LWJGLKeyboard extends Keyboard {
51 protected LWJGLKeyboard() {
52 super("LWJGLKeyboard", createComponents(), new Controller[]{}, new Rumbler[]{});
53 }
54
55 private final static Component[] createComponents() {
56 List components = new ArrayList();
57 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];
60 try {
61 if (Modifier.isStatic(vkey_field.getModifiers()) && vkey_field.getType() == int.class &&
62 vkey_field.getName().startsWith("KEY_")) {
63 int vkey_code = vkey_field.getInt(null);
64 Component.Identifier.Key key_id = KeyMap.map(vkey_code);
65 if (key_id != Component.Identifier.Key.UNKNOWN)
66 components.add(new Key(key_id, vkey_code));
67 }
68 } catch (IllegalAccessException e) {
69 throw new RuntimeException(e);
70 }
71 }
72 return (Component[])components.toArray(new Component[]{});
73 }
74
75 public final synchronized void pollDevice() throws IOException {
76 if (!org.lwjgl.input.Keyboard.isCreated())
77 return;
78 org.lwjgl.input.Keyboard.poll();
79 Component[] components = getComponents();
80 for (int i = 0; i < components.length; i++) {
81 Key key = (Key)components[i];
82 key.update();
83 }
84 }
85
86 protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
87 if (!org.lwjgl.input.Keyboard.isCreated())
88 return false;
89 if (!org.lwjgl.input.Keyboard.next())
90 return false;
91 int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey();
92 if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
93 return false;
94 Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
95 if (key_id == null)
96 return false;
97 Component key = getComponent(key_id);
98 if (key == null)
99 return false;
100 float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
101 event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
102 return true;
103 }
104
105
106 private final static class Key extends AbstractComponent {
107 private final int lwjgl_key;
108 private float value;
109
110 public Key(Component.Identifier.Key key_id, int lwjgl_key) {
111 super(key_id.getName(), key_id);
112 this.lwjgl_key = lwjgl_key;
113 }
114
115 public final void update() {
116 this.value = org.lwjgl.input.Keyboard.isKeyDown(lwjgl_key) ? 1 : 0;
117 }
118
119 protected final float poll() {
120 return value;
121 }
122
123 public final boolean isRelative() {
124 return false;
125 }
126
127 public final boolean isAnalog() {
128 return false;
129 }
130 }
131 }
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.jinput;
32
33 import java.io.IOException;
34
35 import net.java.games.input.AbstractComponent;
36 import net.java.games.input.Component;
37 import net.java.games.input.Controller;
38 import net.java.games.input.Event;
39 import net.java.games.input.Mouse;
40 import net.java.games.input.Rumbler;
41
42 /**
43 * @author elias
44 */
45 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;
51
52 private int event_state = EVENT_DONE;
53
54 protected LWJGLMouse() {
55 super("LWJGLMouse", createComponents(), new Controller[]{}, new Rumbler[]{});
56 }
57
58 private final static Component[] createComponents() {
59 return new Component[]{new Axis(Component.Identifier.Axis.X),
60 new Axis(Component.Identifier.Axis.Y),
61 new Axis(Component.Identifier.Axis.Z),
62 new Button(Component.Identifier.Button.LEFT),
63 new Button(Component.Identifier.Button.MIDDLE),
64 new Button(Component.Identifier.Button.RIGHT)};
65 }
66
67 public final synchronized void pollDevice() throws IOException {
68 if (!org.lwjgl.input.Mouse.isCreated())
69 return;
70 org.lwjgl.input.Mouse.poll();
71 for (int i = 0; i < 3; i++)
72 setButtonState(i);
73 }
74
75 private final Button map(int lwjgl_button) {
76 switch (lwjgl_button) {
77 case 0:
78 return (Button)getLeft();
79 case 1:
80 return (Button)getRight();
81 case 2:
82 return (Button)getMiddle();
83 default:
84 return null;
85 }
86 }
87
88 private final void setButtonState(int lwjgl_button) {
89 Button button = map(lwjgl_button);
90 if (button != null)
91 button.setValue(org.lwjgl.input.Mouse.isButtonDown(lwjgl_button) ? 1 : 0);
92 }
93
94 protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
95 if (!org.lwjgl.input.Mouse.isCreated())
96 return false;
97 while (true) {
98 long nanos = org.lwjgl.input.Mouse.getEventNanoseconds();
99 switch (event_state) {
100 case EVENT_X:
101 event_state = EVENT_Y;
102 int dx = org.lwjgl.input.Mouse.getEventDX();
103 if (dx != 0) {
104 event.set(getX(), dx, nanos);
105 return true;
106 }
107 break;
108 case EVENT_Y:
109 event_state = EVENT_WHEEL;
110 /* We must negate the y coord since lwjgl uses the
111 * OpenGL coordinate system
112 */
113 int dy = -org.lwjgl.input.Mouse.getEventDY();
114 if (dy != 0) {
115 event.set(getY(), dy, nanos);
116 return true;
117 }
118 break;
119 case EVENT_WHEEL:
120 event_state = EVENT_BUTTON;
121 int dwheel = org.lwjgl.input.Mouse.getEventDWheel();
122 if (dwheel != 0) {
123 event.set(getWheel(), dwheel, nanos);
124 return true;
125 }
126 break;
127 case EVENT_BUTTON:
128 event_state = EVENT_DONE;
129 int lwjgl_button = org.lwjgl.input.Mouse.getEventButton();
130 if (lwjgl_button != -1) {
131 Button button = map(lwjgl_button);
132 if (button != null) {
133 event.set(button, org.lwjgl.input.Mouse.getEventButtonState() ? 1f : 0f, nanos);
134 return true;
135 }
136 }
137 break;
138 case EVENT_DONE:
139 if (!org.lwjgl.input.Mouse.next())
140 return false;
141 event_state = EVENT_X;
142 break;
143 default:
144 break;
145 }
146 }
147 }
148
149 final static class Axis extends AbstractComponent {
150 public Axis(Component.Identifier.Axis axis_id) {
151 super(axis_id.getName(), axis_id);
152 }
153
154 public final boolean isRelative() {
155 return true;
156 }
157
158 protected final float poll() throws IOException {
159 return 0;
160 }
161
162 public final boolean isAnalog() {
163 return true;
164 }
165 }
166
167 final static class Button extends AbstractComponent {
168 private float value;
169
170 public Button(Component.Identifier.Button button_id) {
171 super(button_id.getName(), button_id);
172 }
173
174 protected final void setValue(float value) {
175 this.value = value;
176 }
177
178 protected final float poll() throws IOException {
179 return value;
180 }
181
182 public final boolean isRelative() {
183 return false;
184 }
185
186 public final boolean isAnalog() {
187 return false;
188 }
189 }
190 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Base class for matrices. When a matrix is constructed it will be the identity
39 * matrix unless otherwise stated.
40 *
41 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 2983 $
43 * $Id: Matrix.java 2983 2008-04-07 18:36:09Z matzon $
44 */
45 public abstract class Matrix implements Serializable {
46
47 /**
48 * Constructor for Matrix.
49 */
50 public Matrix() {
51 super();
52 }
53
54 /**
55 * Set this matrix to be the identity matrix.
56 * @return this
57 */
58 public abstract Matrix setIdentity();
59
60
61 /**
62 * Invert this matrix
63 * @return this
64 */
65 public abstract Matrix invert();
66
67
68 /**
69 * Load from a float buffer. The buffer stores the matrix in column major
70 * (OpenGL) order.
71 *
72 * @param buf A float buffer to read from
73 * @return this
74 */
75 public abstract Matrix load(FloatBuffer buf);
76
77
78 /**
79 * Load from a float buffer. The buffer stores the matrix in row major
80 * (mathematical) order.
81 *
82 * @param buf A float buffer to read from
83 * @return this
84 */
85 public abstract Matrix loadTranspose(FloatBuffer buf);
86
87
88 /**
89 * Negate this matrix
90 * @return this
91 */
92 public abstract Matrix negate();
93
94
95 /**
96 * Store this matrix in a float buffer. The matrix is stored in column
97 * major (openGL) order.
98 * @param buf The buffer to store this matrix in
99 * @return this
100 */
101 public abstract Matrix store(FloatBuffer buf);
102
103
104 /**
105 * Store this matrix in a float buffer. The matrix is stored in row
106 * major (maths) order.
107 * @param buf The buffer to store this matrix in
108 * @return this
109 */
110 public abstract Matrix storeTranspose(FloatBuffer buf);
111
112
113 /**
114 * Transpose this matrix
115 * @return this
116 */
117 public abstract Matrix transpose();
118
119
120 /**
121 * Set this matrix to 0.
122 * @return this
123 */
124 public abstract Matrix setZero();
125
126
127 /**
128 * @return the determinant of the matrix
129 */
130 public abstract float determinant();
131
132
133 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Holds a 2x2 matrix
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Matrix2f.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44
45 public class Matrix2f extends Matrix implements Serializable {
46
47 private static final long serialVersionUID = 1L;
48
49 public float m00, m01, m10, m11;
50
51 /**
52 * Constructor for Matrix2f. The matrix is initialised to the identity.
53 */
54 public Matrix2f() {
55 setIdentity();
56 }
57
58 /**
59 * Constructor
60 */
61 public Matrix2f(Matrix2f src) {
62 load(src);
63 }
64
65 /**
66 * Load from another matrix
67 * @param src The source matrix
68 * @return this
69 */
70 public Matrix2f load(Matrix2f src) {
71 return load(src, this);
72 }
73
74 /**
75 * Copy the source matrix to the destination matrix.
76 * @param src The source matrix
77 * @param dest The destination matrix, or null if a new one should be created.
78 * @return The copied matrix
79 */
80 public static Matrix2f load(Matrix2f src, Matrix2f dest) {
81 if (dest == null)
82 dest = new Matrix2f();
83
84 dest.m00 = src.m00;
85 dest.m01 = src.m01;
86 dest.m10 = src.m10;
87 dest.m11 = src.m11;
88
89 return dest;
90 }
91
92 /**
93 * Load from a float buffer. The buffer stores the matrix in column major
94 * (OpenGL) order.
95 *
96 * @param buf A float buffer to read from
97 * @return this
98 */
99 public Matrix load(FloatBuffer buf) {
100
101 m00 = buf.get();
102 m01 = buf.get();
103 m10 = buf.get();
104 m11 = buf.get();
105
106 return this;
107 }
108
109 /**
110 * Load from a float buffer. The buffer stores the matrix in row major
111 * (mathematical) order.
112 *
113 * @param buf A float buffer to read from
114 * @return this
115 */
116 public Matrix loadTranspose(FloatBuffer buf) {
117
118 m00 = buf.get();
119 m10 = buf.get();
120 m01 = buf.get();
121 m11 = buf.get();
122
123 return this;
124 }
125
126 /**
127 * Store this matrix in a float buffer. The matrix is stored in column
128 * major (openGL) order.
129 * @param buf The buffer to store this matrix in
130 */
131 public Matrix store(FloatBuffer buf) {
132 buf.put(m00);
133 buf.put(m01);
134 buf.put(m10);
135 buf.put(m11);
136 return this;
137 }
138
139 /**
140 * Store this matrix in a float buffer. The matrix is stored in row
141 * major (maths) order.
142 * @param buf The buffer to store this matrix in
143 */
144 public Matrix storeTranspose(FloatBuffer buf) {
145 buf.put(m00);
146 buf.put(m10);
147 buf.put(m01);
148 buf.put(m11);
149 return this;
150 }
151
152
153
154 /**
155 * Add two matrices together and place the result in a third matrix.
156 * @param left The left source matrix
157 * @param right The right source matrix
158 * @param dest The destination matrix, or null if a new one is to be created
159 * @return the destination matrix
160 */
161 public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest) {
162 if (dest == null)
163 dest = new Matrix2f();
164
165 dest.m00 = left.m00 + right.m00;
166 dest.m01 = left.m01 + right.m01;
167 dest.m10 = left.m10 + right.m10;
168 dest.m11 = left.m11 + right.m11;
169
170 return dest;
171 }
172
173 /**
174 * Subtract the right matrix from the left and place the result in a third matrix.
175 * @param left The left source matrix
176 * @param right The right source matrix
177 * @param dest The destination matrix, or null if a new one is to be created
178 * @return the destination matrix
179 */
180 public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest) {
181 if (dest == null)
182 dest = new Matrix2f();
183
184 dest.m00 = left.m00 - right.m00;
185 dest.m01 = left.m01 - right.m01;
186 dest.m10 = left.m10 - right.m10;
187 dest.m11 = left.m11 - right.m11;
188
189 return dest;
190 }
191
192 /**
193 * Multiply the right matrix by the left and place the result in a third matrix.
194 * @param left The left source matrix
195 * @param right The right source matrix
196 * @param dest The destination matrix, or null if a new one is to be created
197 * @return the destination matrix
198 */
199 public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest) {
200 if (dest == null)
201 dest = new Matrix2f();
202
203 float m00 = left.m00 * right.m00 + left.m10 * right.m01;
204 float m01 = left.m01 * right.m00 + left.m11 * right.m01;
205 float m10 = left.m00 * right.m10 + left.m10 * right.m11;
206 float m11 = left.m01 * right.m10 + left.m11 * right.m11;
207
208 dest.m00 = m00;
209 dest.m01 = m01;
210 dest.m10 = m10;
211 dest.m11 = m11;
212
213 return dest;
214 }
215
216 /**
217 * Transform a Vector by a matrix and return the result in a destination
218 * vector.
219 * @param left The left matrix
220 * @param right The right vector
221 * @param dest The destination vector, or null if a new one is to be created
222 * @return the destination vector
223 */
224 public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) {
225 if (dest == null)
226 dest = new Vector2f();
227
228 float x = left.m00 * right.x + left.m10 * right.y;
229 float y = left.m01 * right.x + left.m11 * right.y;
230
231 dest.x = x;
232 dest.y = y;
233
234 return dest;
235 }
236
237 /**
238 * Transpose this matrix
239 * @return this
240 */
241 public Matrix transpose() {
242 return transpose(this);
243 }
244
245 /**
246 * Transpose this matrix and place the result in another matrix.
247 * @param dest The destination matrix or null if a new matrix is to be created
248 * @return the transposed matrix
249 */
250 public Matrix2f transpose(Matrix2f dest) {
251 return transpose(this, dest);
252 }
253
254 /**
255 * Transpose the source matrix and place the result in the destination matrix.
256 * @param src The source matrix or null if a new matrix is to be created
257 * @param dest The destination matrix or null if a new matrix is to be created
258 * @return the transposed matrix
259 */
260 public static Matrix2f transpose(Matrix2f src, Matrix2f dest) {
261 if (dest == null)
262 dest = new Matrix2f();
263
264 float m01 = src.m10;
265 float m10 = src.m01;
266
267 dest.m01 = m01;
268 dest.m10 = m10;
269
270 return dest;
271 }
272
273 /**
274 * Invert this matrix
275 * @return this if successful, null otherwise
276 */
277 public Matrix invert() {
278 return invert(this, this);
279 }
280
281 /**
282 * Invert the source matrix and place the result in the destination matrix.
283 * @param src The source matrix to be inverted
284 * @param dest The destination matrix or null if a new matrix is to be created
285 * @return The inverted matrix, or null if source can't be reverted.
286 */
287 public static Matrix2f invert(Matrix2f src, Matrix2f dest) {
288 /*
289 *inv(A) = 1/det(A) * adj(A);
290 */
291
292 float determinant = src.determinant();
293 if (determinant != 0) {
294 if (dest == null)
295 dest = new Matrix2f();
296 float determinant_inv = 1f/determinant;
297 float t00 = src.m11*determinant_inv;
298 float t01 = -src.m01*determinant_inv;
299 float t11 = src.m00*determinant_inv;
300 float t10 = -src.m10*determinant_inv;
301
302 dest.m00 = t00;
303 dest.m01 = t01;
304 dest.m10 = t10;
305 dest.m11 = t11;
306 return dest;
307 } else
308 return null;
309 }
310
311 /**
312 * Returns a string representation of this matrix
313 */
314 public String toString() {
315 StringBuffer buf = new StringBuffer();
316 buf.append(m00).append(' ').append(m10).append(' ').append('\n');
317 buf.append(m01).append(' ').append(m11).append(' ').append('\n');
318 return buf.toString();
319 }
320
321 /**
322 * Negate this matrix
323 * @return this
324 */
325 public Matrix negate() {
326 return negate(this);
327 }
328
329 /**
330 * Negate this matrix and stash the result in another matrix.
331 * @param dest The destination matrix, or null if a new matrix is to be created
332 * @return the negated matrix
333 */
334 public Matrix2f negate(Matrix2f dest) {
335 return negate(this, this);
336 }
337
338 /**
339 * Negate the source matrix and stash the result in the destination matrix.
340 * @param src The source matrix to be negated
341 * @param dest The destination matrix, or null if a new matrix is to be created
342 * @return the negated matrix
343 */
344 public static Matrix2f negate(Matrix2f src, Matrix2f dest) {
345 if (dest == null)
346 dest = new Matrix2f();
347
348 dest.m00 = -src.m00;
349 dest.m01 = -src.m01;
350 dest.m10 = -src.m10;
351 dest.m11 = -src.m11;
352
353 return dest;
354 }
355
356 /**
357 * Set this matrix to be the identity matrix.
358 * @return this
359 */
360 public Matrix setIdentity() {
361 return setIdentity(this);
362 }
363
364 /**
365 * Set the source matrix to be the identity matrix.
366 * @param src The matrix to set to the identity.
367 * @return The source matrix
368 */
369 public static Matrix2f setIdentity(Matrix2f src) {
370 src.m00 = 1.0f;
371 src.m01 = 0.0f;
372 src.m10 = 0.0f;
373 src.m11 = 1.0f;
374 return src;
375 }
376
377 /**
378 * Set this matrix to 0.
379 * @return this
380 */
381 public Matrix setZero() {
382 return setZero(this);
383 }
384
385 public static Matrix2f setZero(Matrix2f src) {
386 src.m00 = 0.0f;
387 src.m01 = 0.0f;
388 src.m10 = 0.0f;
389 src.m11 = 0.0f;
390 return src;
391 }
392
393 /* (non-Javadoc)
394 * @see org.lwjgl.vector.Matrix#determinant()
395 */
396 public float determinant() {
397 return m00 * m11 - m01*m10;
398 }
399 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Holds a 3x3 matrix.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Matrix3f.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44
45 public class Matrix3f extends Matrix implements Serializable {
46
47 private static final long serialVersionUID = 1L;
48
49 public float m00,
50 m01,
51 m02,
52 m10,
53 m11,
54 m12,
55 m20,
56 m21,
57 m22;
58
59 /**
60 * Constructor for Matrix3f. Matrix is initialised to the identity.
61 */
62 public Matrix3f() {
63 super();
64 setIdentity();
65 }
66
67 /**
68 * Load from another matrix
69 * @param src The source matrix
70 * @return this
71 */
72 public Matrix3f load(Matrix3f src) {
73 return load(src, this);
74 }
75
76 /**
77 * Copy source matrix to destination matrix
78 * @param src The source matrix
79 * @param dest The destination matrix, or null of a new matrix is to be created
80 * @return The copied matrix
81 */
82 public static Matrix3f load(Matrix3f src, Matrix3f dest) {
83 if (dest == null)
84 dest = new Matrix3f();
85
86 dest.m00 = src.m00;
87 dest.m10 = src.m10;
88 dest.m20 = src.m20;
89 dest.m01 = src.m01;
90 dest.m11 = src.m11;
91 dest.m21 = src.m21;
92 dest.m02 = src.m02;
93 dest.m12 = src.m12;
94 dest.m22 = src.m22;
95
96 return dest;
97 }
98
99 /**
100 * Load from a float buffer. The buffer stores the matrix in column major
101 * (OpenGL) order.
102 *
103 * @param buf A float buffer to read from
104 * @return this
105 */
106 public Matrix load(FloatBuffer buf) {
107
108 m00 = buf.get();
109 m01 = buf.get();
110 m02 = buf.get();
111 m10 = buf.get();
112 m11 = buf.get();
113 m12 = buf.get();
114 m20 = buf.get();
115 m21 = buf.get();
116 m22 = buf.get();
117
118 return this;
119 }
120
121 /**
122 * Load from a float buffer. The buffer stores the matrix in row major
123 * (maths) order.
124 *
125 * @param buf A float buffer to read from
126 * @return this
127 */
128 public Matrix loadTranspose(FloatBuffer buf) {
129
130 m00 = buf.get();
131 m10 = buf.get();
132 m20 = buf.get();
133 m01 = buf.get();
134 m11 = buf.get();
135 m21 = buf.get();
136 m02 = buf.get();
137 m12 = buf.get();
138 m22 = buf.get();
139
140 return this;
141 }
142
143 /**
144 * Store this matrix in a float buffer. The matrix is stored in column
145 * major (openGL) order.
146 * @param buf The buffer to store this matrix in
147 */
148 public Matrix store(FloatBuffer buf) {
149 buf.put(m00);
150 buf.put(m01);
151 buf.put(m02);
152 buf.put(m10);
153 buf.put(m11);
154 buf.put(m12);
155 buf.put(m20);
156 buf.put(m21);
157 buf.put(m22);
158 return this;
159 }
160
161 /**
162 * Store this matrix in a float buffer. The matrix is stored in row
163 * major (maths) order.
164 * @param buf The buffer to store this matrix in
165 */
166 public Matrix storeTranspose(FloatBuffer buf) {
167 buf.put(m00);
168 buf.put(m10);
169 buf.put(m20);
170 buf.put(m01);
171 buf.put(m11);
172 buf.put(m21);
173 buf.put(m02);
174 buf.put(m12);
175 buf.put(m22);
176 return this;
177 }
178
179 /**
180 * Add two matrices together and place the result in a third matrix.
181 * @param left The left source matrix
182 * @param right The right source matrix
183 * @param dest The destination matrix, or null if a new one is to be created
184 * @return the destination matrix
185 */
186 public static Matrix3f add(Matrix3f left, Matrix3f right, Matrix3f dest) {
187 if (dest == null)
188 dest = new Matrix3f();
189
190 dest.m00 = left.m00 + right.m00;
191 dest.m01 = left.m01 + right.m01;
192 dest.m02 = left.m02 + right.m02;
193 dest.m10 = left.m10 + right.m10;
194 dest.m11 = left.m11 + right.m11;
195 dest.m12 = left.m12 + right.m12;
196 dest.m20 = left.m20 + right.m20;
197 dest.m21 = left.m21 + right.m21;
198 dest.m22 = left.m22 + right.m22;
199
200 return dest;
201 }
202
203 /**
204 * Subtract the right matrix from the left and place the result in a third matrix.
205 * @param left The left source matrix
206 * @param right The right source matrix
207 * @param dest The destination matrix, or null if a new one is to be created
208 * @return the destination matrix
209 */
210 public static Matrix3f sub(Matrix3f left, Matrix3f right, Matrix3f dest) {
211 if (dest == null)
212 dest = new Matrix3f();
213
214 dest.m00 = left.m00 - right.m00;
215 dest.m01 = left.m01 - right.m01;
216 dest.m02 = left.m02 - right.m02;
217 dest.m10 = left.m10 - right.m10;
218 dest.m11 = left.m11 - right.m11;
219 dest.m12 = left.m12 - right.m12;
220 dest.m20 = left.m20 - right.m20;
221 dest.m21 = left.m21 - right.m21;
222 dest.m22 = left.m22 - right.m22;
223
224 return dest;
225 }
226
227 /**
228 * Multiply the right matrix by the left and place the result in a third matrix.
229 * @param left The left source matrix
230 * @param right The right source matrix
231 * @param dest The destination matrix, or null if a new one is to be created
232 * @return the destination matrix
233 */
234 public static Matrix3f mul(Matrix3f left, Matrix3f right, Matrix3f dest) {
235 if (dest == null)
236 dest = new Matrix3f();
237
238 float m00 =
239 left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02;
240 float m01 =
241 left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02;
242 float m02 =
243 left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02;
244 float m10 =
245 left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12;
246 float m11 =
247 left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12;
248 float m12 =
249 left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12;
250 float m20 =
251 left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22;
252 float m21 =
253 left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22;
254 float m22 =
255 left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22;
256
257 dest.m00 = m00;
258 dest.m01 = m01;
259 dest.m02 = m02;
260 dest.m10 = m10;
261 dest.m11 = m11;
262 dest.m12 = m12;
263 dest.m20 = m20;
264 dest.m21 = m21;
265 dest.m22 = m22;
266
267 return dest;
268 }
269
270 /**
271 * Transform a Vector by a matrix and return the result in a destination
272 * vector.
273 * @param left The left matrix
274 * @param right The right vector
275 * @param dest The destination vector, or null if a new one is to be created
276 * @return the destination vector
277 */
278 public static Vector3f transform(Matrix3f left, Vector3f right, Vector3f dest) {
279 if (dest == null)
280 dest = new Vector3f();
281
282 float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z;
283 float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z;
284 float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z;
285
286 dest.x = x;
287 dest.y = y;
288 dest.z = z;
289
290 return dest;
291 }
292
293 /**
294 * Transpose this matrix
295 * @return this
296 */
297 public Matrix transpose() {
298 return transpose(this, this);
299 }
300
301 /**
302 * Transpose this matrix and place the result in another matrix
303 * @param dest The destination matrix or null if a new matrix is to be created
304 * @return the transposed matrix
305 */
306 public Matrix3f transpose(Matrix3f dest) {
307 return transpose(this, dest);
308 }
309
310 /**
311 * Transpose the source matrix and place the result into the destination matrix
312 * @param src The source matrix to be transposed
313 * @param dest The destination matrix or null if a new matrix is to be created
314 * @return the transposed matrix
315 */
316 public static Matrix3f transpose(Matrix3f src, Matrix3f dest) {
317 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;
328
329 dest.m00 = m00;
330 dest.m01 = m01;
331 dest.m02 = m02;
332 dest.m10 = m10;
333 dest.m11 = m11;
334 dest.m12 = m12;
335 dest.m20 = m20;
336 dest.m21 = m21;
337 dest.m22 = m22;
338 return dest;
339 }
340
341 /**
342 * @return the determinant of the matrix
343 */
344 public float determinant() {
345 float f =
346 m00 * (m11 * m22 - m12 * m21)
347 + m01 * (m12 * m20 - m10 * m22)
348 + m02 * (m10 * m21 - m11 * m20);
349 return f;
350 }
351
352 /**
353 * Returns a string representation of this matrix
354 */
355 public String toString() {
356 StringBuffer buf = new StringBuffer();
357 buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append('\n');
358 buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append('\n');
359 buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append('\n');
360 return buf.toString();
361 }
362
363 /**
364 * Invert this matrix
365 * @return this if successful, null otherwise
366 */
367 public Matrix invert() {
368 return invert(this, this);
369 }
370
371 /**
372 * Invert the source matrix and put the result into the destination matrix
373 * @param src The source matrix to be inverted
374 * @param dest The destination matrix, or null if a new one is to be created
375 * @return The inverted matrix if successful, null otherwise
376 */
377 public static Matrix3f invert(Matrix3f src, Matrix3f dest) {
378 float determinant = src.determinant();
379
380 if (determinant != 0) {
381 if (dest == null)
382 dest = new Matrix3f();
383 /* do it the ordinary way
384 *
385 * inv(A) = 1/det(A) * adj(T), where adj(T) = transpose(Conjugate Matrix)
386 *
387 * m00 m01 m02
388 * m10 m11 m12
389 * m20 m21 m22
390 */
391 float determinant_inv = 1f/determinant;
392
393 // get the conjugate matrix
394 float t00 = src.m11 * src.m22 - src.m12* src.m21;
395 float t01 = - src.m10 * src.m22 + src.m12 * src.m20;
396 float t02 = src.m10 * src.m21 - src.m11 * src.m20;
397 float t10 = - src.m01 * src.m22 + src.m02 * src.m21;
398 float t11 = src.m00 * src.m22 - src.m02 * src.m20;
399 float t12 = - src.m00 * src.m21 + src.m01 * src.m20;
400 float t20 = src.m01 * src.m12 - src.m02 * src.m11;
401 float t21 = -src.m00 * src.m12 + src.m02 * src.m10;
402 float t22 = src.m00 * src.m11 - src.m01 * src.m10;
403
404 dest.m00 = t00*determinant_inv;
405 dest.m11 = t11*determinant_inv;
406 dest.m22 = t22*determinant_inv;
407 dest.m01 = t10*determinant_inv;
408 dest.m10 = t01*determinant_inv;
409 dest.m20 = t02*determinant_inv;
410 dest.m02 = t20*determinant_inv;
411 dest.m12 = t21*determinant_inv;
412 dest.m21 = t12*determinant_inv;
413 return dest;
414 } else
415 return null;
416 }
417
418
419 /**
420 * Negate this matrix
421 * @return this
422 */
423 public Matrix negate() {
424 return negate(this);
425 }
426
427 /**
428 * Negate this matrix and place the result in a destination matrix.
429 * @param dest The destination matrix, or null if a new matrix is to be created
430 * @return the negated matrix
431 */
432 public Matrix3f negate(Matrix3f dest) {
433 return negate(this, this);
434 }
435
436 /**
437 * Negate the source matrix and place the result in the destination matrix.
438 * @param src The source matrix
439 * @param dest The destination matrix, or null if a new matrix is to be created
440 * @return the negated matrix
441 */
442 public static Matrix3f negate(Matrix3f src, Matrix3f dest) {
443 if (dest == null)
444 dest = new Matrix3f();
445
446 dest.m00 = -src.m00;
447 dest.m01 = -src.m02;
448 dest.m02 = -src.m01;
449 dest.m10 = -src.m10;
450 dest.m11 = -src.m12;
451 dest.m12 = -src.m11;
452 dest.m20 = -src.m20;
453 dest.m21 = -src.m22;
454 dest.m22 = -src.m21;
455 return dest;
456 }
457
458 /**
459 * Set this matrix to be the identity matrix.
460 * @return this
461 */
462 public Matrix setIdentity() {
463 return setIdentity(this);
464 }
465
466 /**
467 * Set the matrix to be the identity matrix.
468 * @param m The matrix to be set to the identity
469 * @return m
470 */
471 public static Matrix3f setIdentity(Matrix3f m) {
472 m.m00 = 1.0f;
473 m.m01 = 0.0f;
474 m.m02 = 0.0f;
475 m.m10 = 0.0f;
476 m.m11 = 1.0f;
477 m.m12 = 0.0f;
478 m.m20 = 0.0f;
479 m.m21 = 0.0f;
480 m.m22 = 1.0f;
481 return m;
482 }
483
484 /**
485 * Set this matrix to 0.
486 * @return this
487 */
488 public Matrix setZero() {
489 return setZero(this);
490 }
491
492 /**
493 * Set the matrix matrix to 0.
494 * @param m The matrix to be set to 0
495 * @return m
496 */
497 public static Matrix3f setZero(Matrix3f m) {
498 m.m00 = 0.0f;
499 m.m01 = 0.0f;
500 m.m02 = 0.0f;
501 m.m10 = 0.0f;
502 m.m11 = 0.0f;
503 m.m12 = 0.0f;
504 m.m20 = 0.0f;
505 m.m21 = 0.0f;
506 m.m22 = 0.0f;
507 return m;
508 }
509 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 * Holds a 4x4 float matrix.
38 *
39 * @author foo
40 */
41 public class Matrix4f extends Matrix implements Serializable {
42 private static final long serialVersionUID = 1L;
43
44 public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33;
45
46 /**
47 * Construct a new matrix, initialized to the identity.
48 */
49 public Matrix4f() {
50 super();
51 setIdentity();
52 }
53
54 /**
55 * Returns a string representation of this matrix
56 */
57 public String toString() {
58 StringBuffer buf = new StringBuffer();
59 buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n');
60 buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n');
61 buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n');
62 buf.append(m03).append(' ').append(m13).append(' ').append(m23).append(' ').append(m33).append('\n');
63 return buf.toString();
64 }
65
66 /**
67 * Set this matrix to be the identity matrix.
68 * @return this
69 */
70 public Matrix setIdentity() {
71 return setIdentity(this);
72 }
73
74 /**
75 * Set the given matrix to be the identity matrix.
76 * @param m The matrix to set to the identity
77 * @return m
78 */
79 public static Matrix4f setIdentity(Matrix4f m) {
80 m.m00 = 1.0f;
81 m.m01 = 0.0f;
82 m.m02 = 0.0f;
83 m.m03 = 0.0f;
84 m.m10 = 0.0f;
85 m.m11 = 1.0f;
86 m.m12 = 0.0f;
87 m.m13 = 0.0f;
88 m.m20 = 0.0f;
89 m.m21 = 0.0f;
90 m.m22 = 1.0f;
91 m.m23 = 0.0f;
92 m.m30 = 0.0f;
93 m.m31 = 0.0f;
94 m.m32 = 0.0f;
95 m.m33 = 1.0f;
96
97 return m;
98 }
99
100 /**
101 * Set this matrix to 0.
102 * @return this
103 */
104 public Matrix setZero() {
105 return setZero(this);
106 }
107
108 /**
109 * Set the given matrix to 0.
110 * @param m The matrix to set to 0
111 * @return m
112 */
113 public static Matrix4f setZero(Matrix4f m) {
114 m.m00 = 0.0f;
115 m.m01 = 0.0f;
116 m.m02 = 0.0f;
117 m.m03 = 0.0f;
118 m.m10 = 0.0f;
119 m.m11 = 0.0f;
120 m.m12 = 0.0f;
121 m.m13 = 0.0f;
122 m.m20 = 0.0f;
123 m.m21 = 0.0f;
124 m.m22 = 0.0f;
125 m.m23 = 0.0f;
126 m.m30 = 0.0f;
127 m.m31 = 0.0f;
128 m.m32 = 0.0f;
129 m.m33 = 0.0f;
130
131 return m;
132 }
133
134 /**
135 * Load from another matrix4f
136 * @param src The source matrix
137 * @return this
138 */
139 public Matrix4f load(Matrix4f src) {
140 return load(src, this);
141 }
142
143 /**
144 * Copy the source matrix to the destination matrix
145 * @param src The source matrix
146 * @param dest The destination matrix, or null of a new one is to be created
147 * @return The copied matrix
148 */
149 public static Matrix4f load(Matrix4f src, Matrix4f dest) {
150 if (dest == null)
151 dest = new Matrix4f();
152 dest.m00 = src.m00;
153 dest.m01 = src.m01;
154 dest.m02 = src.m02;
155 dest.m03 = src.m03;
156 dest.m10 = src.m10;
157 dest.m11 = src.m11;
158 dest.m12 = src.m12;
159 dest.m13 = src.m13;
160 dest.m20 = src.m20;
161 dest.m21 = src.m21;
162 dest.m22 = src.m22;
163 dest.m23 = src.m23;
164 dest.m30 = src.m30;
165 dest.m31 = src.m31;
166 dest.m32 = src.m32;
167 dest.m33 = src.m33;
168
169 return dest;
170 }
171
172 /**
173 * Load from a float buffer. The buffer stores the matrix in column major
174 * (OpenGL) order.
175 *
176 * @param buf A float buffer to read from
177 * @return this
178 */
179 public Matrix load(FloatBuffer buf) {
180
181 m00 = buf.get();
182 m01 = buf.get();
183 m02 = buf.get();
184 m03 = buf.get();
185 m10 = buf.get();
186 m11 = buf.get();
187 m12 = buf.get();
188 m13 = buf.get();
189 m20 = buf.get();
190 m21 = buf.get();
191 m22 = buf.get();
192 m23 = buf.get();
193 m30 = buf.get();
194 m31 = buf.get();
195 m32 = buf.get();
196 m33 = buf.get();
197
198 return this;
199 }
200
201 /**
202 * Load from a float buffer. The buffer stores the matrix in row major
203 * (maths) order.
204 *
205 * @param buf A float buffer to read from
206 * @return this
207 */
208 public Matrix loadTranspose(FloatBuffer buf) {
209
210 m00 = buf.get();
211 m10 = buf.get();
212 m20 = buf.get();
213 m30 = buf.get();
214 m01 = buf.get();
215 m11 = buf.get();
216 m21 = buf.get();
217 m31 = buf.get();
218 m02 = buf.get();
219 m12 = buf.get();
220 m22 = buf.get();
221 m32 = buf.get();
222 m03 = buf.get();
223 m13 = buf.get();
224 m23 = buf.get();
225 m33 = buf.get();
226
227 return this;
228 }
229
230 /**
231 * Store this matrix in a float buffer. The matrix is stored in column
232 * major (openGL) order.
233 * @param buf The buffer to store this matrix in
234 */
235 public Matrix store(FloatBuffer buf) {
236 buf.put(m00);
237 buf.put(m01);
238 buf.put(m02);
239 buf.put(m03);
240 buf.put(m10);
241 buf.put(m11);
242 buf.put(m12);
243 buf.put(m13);
244 buf.put(m20);
245 buf.put(m21);
246 buf.put(m22);
247 buf.put(m23);
248 buf.put(m30);
249 buf.put(m31);
250 buf.put(m32);
251 buf.put(m33);
252 return this;
253 }
254
255 /**
256 * Store this matrix in a float buffer. The matrix is stored in row
257 * major (maths) order.
258 * @param buf The buffer to store this matrix in
259 */
260 public Matrix storeTranspose(FloatBuffer buf) {
261 buf.put(m00);
262 buf.put(m10);
263 buf.put(m20);
264 buf.put(m30);
265 buf.put(m01);
266 buf.put(m11);
267 buf.put(m21);
268 buf.put(m31);
269 buf.put(m02);
270 buf.put(m12);
271 buf.put(m22);
272 buf.put(m32);
273 buf.put(m03);
274 buf.put(m13);
275 buf.put(m23);
276 buf.put(m33);
277 return this;
278 }
279
280
281 /**
282 * Add two matrices together and place the result in a third matrix.
283 * @param left The left source matrix
284 * @param right The right source matrix
285 * @param dest The destination matrix, or null if a new one is to be created
286 * @return the destination matrix
287 */
288 public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) {
289 if (dest == null)
290 dest = new Matrix4f();
291
292 dest.m00 = left.m00 + right.m00;
293 dest.m01 = left.m01 + right.m01;
294 dest.m02 = left.m02 + right.m02;
295 dest.m03 = left.m03 + right.m03;
296 dest.m10 = left.m10 + right.m10;
297 dest.m11 = left.m11 + right.m11;
298 dest.m12 = left.m12 + right.m12;
299 dest.m13 = left.m13 + right.m13;
300 dest.m20 = left.m20 + right.m20;
301 dest.m21 = left.m21 + right.m21;
302 dest.m22 = left.m22 + right.m22;
303 dest.m23 = left.m23 + right.m23;
304 dest.m30 = left.m30 + right.m30;
305 dest.m31 = left.m31 + right.m31;
306 dest.m32 = left.m32 + right.m32;
307 dest.m33 = left.m33 + right.m33;
308
309 return dest;
310 }
311
312 /**
313 * Subtract the right matrix from the left and place the result in a third matrix.
314 * @param left The left source matrix
315 * @param right The right source matrix
316 * @param dest The destination matrix, or null if a new one is to be created
317 * @return the destination matrix
318 */
319 public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) {
320 if (dest == null)
321 dest = new Matrix4f();
322
323 dest.m00 = left.m00 - right.m00;
324 dest.m01 = left.m01 - right.m01;
325 dest.m02 = left.m02 - right.m02;
326 dest.m03 = left.m03 - right.m03;
327 dest.m10 = left.m10 - right.m10;
328 dest.m11 = left.m11 - right.m11;
329 dest.m12 = left.m12 - right.m12;
330 dest.m13 = left.m13 - right.m13;
331 dest.m20 = left.m20 - right.m20;
332 dest.m21 = left.m21 - right.m21;
333 dest.m22 = left.m22 - right.m22;
334 dest.m23 = left.m23 - right.m23;
335 dest.m30 = left.m30 - right.m30;
336 dest.m31 = left.m31 - right.m31;
337 dest.m32 = left.m32 - right.m32;
338 dest.m33 = left.m33 - right.m33;
339
340 return dest;
341 }
342
343 /**
344 * Multiply the right matrix by the left and place the result in a third matrix.
345 * @param left The left source matrix
346 * @param right The right source matrix
347 * @param dest The destination matrix, or null if a new one is to be created
348 * @return the destination matrix
349 */
350 public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest) {
351 if (dest == null)
352 dest = new Matrix4f();
353
354 float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02 + left.m30 * right.m03;
355 float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02 + left.m31 * right.m03;
356 float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02 + left.m32 * right.m03;
357 float m03 = left.m03 * right.m00 + left.m13 * right.m01 + left.m23 * right.m02 + left.m33 * right.m03;
358 float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12 + left.m30 * right.m13;
359 float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12 + left.m31 * right.m13;
360 float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12 + left.m32 * right.m13;
361 float m13 = left.m03 * right.m10 + left.m13 * right.m11 + left.m23 * right.m12 + left.m33 * right.m13;
362 float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22 + left.m30 * right.m23;
363 float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22 + left.m31 * right.m23;
364 float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22 + left.m32 * right.m23;
365 float m23 = left.m03 * right.m20 + left.m13 * right.m21 + left.m23 * right.m22 + left.m33 * right.m23;
366 float m30 = left.m00 * right.m30 + left.m10 * right.m31 + left.m20 * right.m32 + left.m30 * right.m33;
367 float m31 = left.m01 * right.m30 + left.m11 * right.m31 + left.m21 * right.m32 + left.m31 * right.m33;
368 float m32 = left.m02 * right.m30 + left.m12 * right.m31 + left.m22 * right.m32 + left.m32 * right.m33;
369 float m33 = left.m03 * right.m30 + left.m13 * right.m31 + left.m23 * right.m32 + left.m33 * right.m33;
370
371 dest.m00 = m00;
372 dest.m01 = m01;
373 dest.m02 = m02;
374 dest.m03 = m03;
375 dest.m10 = m10;
376 dest.m11 = m11;
377 dest.m12 = m12;
378 dest.m13 = m13;
379 dest.m20 = m20;
380 dest.m21 = m21;
381 dest.m22 = m22;
382 dest.m23 = m23;
383 dest.m30 = m30;
384 dest.m31 = m31;
385 dest.m32 = m32;
386 dest.m33 = m33;
387
388 return dest;
389 }
390
391 /**
392 * Transform a Vector by a matrix and return the result in a destination
393 * vector.
394 * @param left The left matrix
395 * @param right The right vector
396 * @param dest The destination vector, or null if a new one is to be created
397 * @return the destination vector
398 */
399 public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) {
400 if (dest == null)
401 dest = new Vector4f();
402
403 float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z + left.m30 * right.w;
404 float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z + left.m31 * right.w;
405 float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z + left.m32 * right.w;
406 float w = left.m03 * right.x + left.m13 * right.y + left.m23 * right.z + left.m33 * right.w;
407
408 dest.x = x;
409 dest.y = y;
410 dest.z = z;
411 dest.w = w;
412
413 return dest;
414 }
415
416 /**
417 * Transpose this matrix
418 * @return this
419 */
420 public Matrix transpose() {
421 return transpose(this);
422 }
423
424 /**
425 * Translate this matrix
426 * @param vec The vector to translate by
427 * @return this
428 */
429 public Matrix4f translate(Vector2f vec) {
430 return translate(vec, this);
431 }
432
433 /**
434 * Translate this matrix
435 * @param vec The vector to translate by
436 * @return this
437 */
438 public Matrix4f translate(Vector3f vec) {
439 return translate(vec, this);
440 }
441
442 /**
443 * Scales this matrix
444 * @param vec The vector to scale by
445 * @return this
446 */
447 public Matrix4f scale(Vector3f vec) {
448 return scale(vec, this, this);
449 }
450
451 /**
452 * Scales the source matrix and put the result in the destination matrix
453 * @param vec The vector to scale by
454 * @param src The source matrix
455 * @param dest The destination matrix, or null if a new matrix is to be created
456 * @return The scaled matrix
457 */
458 public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest) {
459 if (dest == null)
460 dest = new Matrix4f();
461 dest.m00 = src.m00 * vec.x;
462 dest.m01 = src.m01 * vec.x;
463 dest.m02 = src.m02 * vec.x;
464 dest.m03 = src.m03 * vec.x;
465 dest.m10 = src.m10 * vec.y;
466 dest.m11 = src.m11 * vec.y;
467 dest.m12 = src.m12 * vec.y;
468 dest.m13 = src.m13 * vec.y;
469 dest.m20 = src.m20 * vec.z;
470 dest.m21 = src.m21 * vec.z;
471 dest.m22 = src.m22 * vec.z;
472 dest.m23 = src.m23 * vec.z;
473 return dest;
474 }
475
476 /**
477 * Rotates the matrix around the given axis the specified angle
478 * @param angle the angle, in radians.
479 * @param axis The vector representing the rotation axis. Must be normalized.
480 * @return this
481 */
482 public Matrix4f rotate(float angle, Vector3f axis) {
483 return rotate(angle, axis, this);
484 }
485
486 /**
487 * Rotates the matrix around the given axis the specified angle
488 * @param angle the angle, in radians.
489 * @param axis The vector representing the rotation axis. Must be normalized.
490 * @param dest The matrix to put the result, or null if a new matrix is to be created
491 * @return The rotated matrix
492 */
493 public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) {
494 return rotate(angle, axis, this, dest);
495 }
496
497 /**
498 * Rotates the source matrix around the given axis the specified angle and
499 * put the result in the destination matrix.
500 * @param angle the angle, in radians.
501 * @param axis The vector representing the rotation axis. Must be normalized.
502 * @param src The matrix to rotate
503 * @param dest The matrix to put the result, or null if a new matrix is to be created
504 * @return The rotated matrix
505 */
506 public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest) {
507 if (dest == null)
508 dest = new Matrix4f();
509 float c = (float) Math.cos(angle);
510 float s = (float) Math.sin(angle);
511 float oneminusc = 1.0f - c;
512 float xy = axis.x*axis.y;
513 float yz = axis.y*axis.z;
514 float xz = axis.x*axis.z;
515 float xs = axis.x*s;
516 float ys = axis.y*s;
517 float zs = axis.z*s;
518
519 float f00 = axis.x*axis.x*oneminusc+c;
520 float f01 = xy*oneminusc+zs;
521 float f02 = xz*oneminusc-ys;
522 // n[3] not used
523 float f10 = xy*oneminusc-zs;
524 float f11 = axis.y*axis.y*oneminusc+c;
525 float f12 = yz*oneminusc+xs;
526 // n[7] not used
527 float f20 = xz*oneminusc+ys;
528 float f21 = yz*oneminusc-xs;
529 float f22 = axis.z*axis.z*oneminusc+c;
530
531 float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02;
532 float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02;
533 float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02;
534 float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02;
535 float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12;
536 float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12;
537 float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12;
538 float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12;
539 dest.m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22;
540 dest.m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22;
541 dest.m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22;
542 dest.m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22;
543 dest.m00 = t00;
544 dest.m01 = t01;
545 dest.m02 = t02;
546 dest.m03 = t03;
547 dest.m10 = t10;
548 dest.m11 = t11;
549 dest.m12 = t12;
550 dest.m13 = t13;
551 return dest;
552 }
553
554 /**
555 * Translate this matrix and stash the result in another matrix
556 * @param vec The vector to translate by
557 * @param dest The destination matrix or null if a new matrix is to be created
558 * @return the translated matrix
559 */
560 public Matrix4f translate(Vector3f vec, Matrix4f dest) {
561 return translate(vec, this, dest);
562 }
563
564 /**
565 * Translate the source matrix and stash the result in the destination matrix
566 * @param vec The vector to translate by
567 * @param src The source matrix
568 * @param dest The destination matrix or null if a new matrix is to be created
569 * @return The translated matrix
570 */
571 public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) {
572 if (dest == null)
573 dest = new Matrix4f();
574
575 dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z;
576 dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z;
577 dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z;
578 dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z;
579
580 return dest;
581 }
582
583 /**
584 * Translate this matrix and stash the result in another matrix
585 * @param vec The vector to translate by
586 * @param dest The destination matrix or null if a new matrix is to be created
587 * @return the translated matrix
588 */
589 public Matrix4f translate(Vector2f vec, Matrix4f dest) {
590 return translate(vec, this, dest);
591 }
592
593 /**
594 * Translate the source matrix and stash the result in the destination matrix
595 * @param vec The vector to translate by
596 * @param src The source matrix
597 * @param dest The destination matrix or null if a new matrix is to be created
598 * @return The translated matrix
599 */
600 public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) {
601 if (dest == null)
602 dest = new Matrix4f();
603
604 dest.m30 += src.m00 * vec.x + src.m10 * vec.y;
605 dest.m31 += src.m01 * vec.x + src.m11 * vec.y;
606 dest.m32 += src.m02 * vec.x + src.m12 * vec.y;
607 dest.m33 += src.m03 * vec.x + src.m13 * vec.y;
608
609 return dest;
610 }
611
612 /**
613 * Transpose this matrix and place the result in another matrix
614 * @param dest The destination matrix or null if a new matrix is to be created
615 * @return the transposed matrix
616 */
617 public Matrix4f transpose(Matrix4f dest) {
618 return transpose(this, dest);
619 }
620
621 /**
622 * Transpose the source matrix and place the result in the destination matrix
623 * @param src The source matrix
624 * @param dest The destination matrix or null if a new matrix is to be created
625 * @return the transposed matrix
626 */
627 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;
646
647 dest.m00 = m00;
648 dest.m01 = m01;
649 dest.m02 = m02;
650 dest.m03 = m03;
651 dest.m10 = m10;
652 dest.m11 = m11;
653 dest.m12 = m12;
654 dest.m13 = m13;
655 dest.m20 = m20;
656 dest.m21 = m21;
657 dest.m22 = m22;
658 dest.m23 = m23;
659 dest.m30 = m30;
660 dest.m31 = m31;
661 dest.m32 = m32;
662 dest.m33 = m33;
663
664 return dest;
665 }
666
667 /**
668 * @return the determinant of the matrix
669 */
670 public float determinant() {
671 float f =
672 m00
673 * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32)
674 - m13 * m22 * m31
675 - m11 * m23 * m32
676 - m12 * m21 * m33);
677 f -= m01
678 * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32)
679 - m13 * m22 * m30
680 - m10 * m23 * m32
681 - m12 * m20 * m33);
682 f += m02
683 * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31)
684 - m13 * m21 * m30
685 - m10 * m23 * m31
686 - m11 * m20 * m33);
687 f -= m03
688 * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31)
689 - m12 * m21 * m30
690 - m10 * m22 * m31
691 - m11 * m20 * m32);
692 return f;
693 }
694
695 /**
696 * Calculate the determinant of a 3x3 matrix
697 * @return result
698 */
699
700 private static float determinant3x3(float t00, float t01, float t02,
701 float t10, float t11, float t12,
702 float t20, float t21, float t22)
703 {
704 return t00 * (t11 * t22 - t12 * t21)
705 + t01 * (t12 * t20 - t10 * t22)
706 + t02 * (t10 * t21 - t11 * t20);
707 }
708
709 /**
710 * Invert this matrix
711 * @return this if successful, null otherwise
712 */
713 public Matrix invert() {
714 return invert(this, this);
715 }
716
717 /**
718 * Invert the source matrix and put the result in the destination
719 * @param src The source matrix
720 * @param dest The destination matrix, or null if a new matrix is to be created
721 * @return The inverted matrix if successful, null otherwise
722 */
723 public static Matrix4f invert(Matrix4f src, Matrix4f dest) {
724 float determinant = src.determinant();
725
726 if (determinant != 0) {
727 /*
728 * m00 m01 m02 m03
729 * m10 m11 m12 m13
730 * m20 m21 m22 m23
731 * m30 m31 m32 m33
732 */
733 if (dest == null)
734 dest = new Matrix4f();
735 float determinant_inv = 1f/determinant;
736
737 // first row
738 float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33);
739 float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33);
740 float t02 = determinant3x3(src.m10, src.m11, src.m13, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33);
741 float t03 = -determinant3x3(src.m10, src.m11, src.m12, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32);
742 // second row
743 float t10 = -determinant3x3(src.m01, src.m02, src.m03, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33);
744 float t11 = determinant3x3(src.m00, src.m02, src.m03, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33);
745 float t12 = -determinant3x3(src.m00, src.m01, src.m03, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33);
746 float t13 = determinant3x3(src.m00, src.m01, src.m02, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32);
747 // third row
748 float t20 = determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m31, src.m32, src.m33);
749 float t21 = -determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m30, src.m32, src.m33);
750 float t22 = determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m30, src.m31, src.m33);
751 float t23 = -determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m30, src.m31, src.m32);
752 // fourth row
753 float t30 = -determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m21, src.m22, src.m23);
754 float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23);
755 float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, src.m23);
756 float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22);
757
758 // transpose and divide by the determinant
759 dest.m00 = t00*determinant_inv;
760 dest.m11 = t11*determinant_inv;
761 dest.m22 = t22*determinant_inv;
762 dest.m33 = t33*determinant_inv;
763 dest.m01 = t10*determinant_inv;
764 dest.m10 = t01*determinant_inv;
765 dest.m20 = t02*determinant_inv;
766 dest.m02 = t20*determinant_inv;
767 dest.m12 = t21*determinant_inv;
768 dest.m21 = t12*determinant_inv;
769 dest.m03 = t30*determinant_inv;
770 dest.m30 = t03*determinant_inv;
771 dest.m13 = t31*determinant_inv;
772 dest.m31 = t13*determinant_inv;
773 dest.m32 = t23*determinant_inv;
774 dest.m23 = t32*determinant_inv;
775 return dest;
776 } else
777 return null;
778 }
779
780 /**
781 * Negate this matrix
782 * @return this
783 */
784 public Matrix negate() {
785 return negate(this);
786 }
787
788 /**
789 * Negate this matrix and place the result in a destination matrix.
790 * @param dest The destination matrix, or null if a new matrix is to be created
791 * @return the negated matrix
792 */
793 public Matrix4f negate(Matrix4f dest) {
794 return negate(this, this);
795 }
796
797 /**
798 * Negate this matrix and place the result in a destination matrix.
799 * @param src The source matrix
800 * @param dest The destination matrix, or null if a new matrix is to be created
801 * @return The negated matrix
802 */
803 public static Matrix4f negate(Matrix4f src, Matrix4f dest) {
804 if (dest == null)
805 dest = new Matrix4f();
806
807 dest.m00 = -src.m00;
808 dest.m01 = -src.m01;
809 dest.m02 = -src.m02;
810 dest.m03 = -src.m03;
811 dest.m10 = -src.m10;
812 dest.m11 = -src.m11;
813 dest.m12 = -src.m12;
814 dest.m13 = -src.m13;
815 dest.m20 = -src.m20;
816 dest.m21 = -src.m21;
817 dest.m22 = -src.m22;
818 dest.m23 = -src.m23;
819 dest.m30 = -src.m30;
820 dest.m31 = -src.m31;
821 dest.m32 = -src.m32;
822 dest.m33 = -src.m33;
823
824 return dest;
825 }
826 }
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.vector;
32
33 /**
34 *
35 * Quaternions for LWJGL!
36 *
37 * @author fbi
38 * @version $Revision: 2983 $
39 * $Id: Quaternion.java 2983 2008-04-07 18:36:09Z matzon $
40 */
41
42 import java.nio.FloatBuffer;
43
44 public class Quaternion extends Vector implements ReadableVector4f {
45 private static final long serialVersionUID = 1L;
46
47 public float x, y, z, w;
48
49 /**
50 * C'tor. The quaternion will be initialized to the identity.
51 */
52 public Quaternion() {
53 super();
54 setIdentity();
55 }
56
57 /**
58 * C'tor
59 *
60 * @param src
61 */
62 public Quaternion(ReadableVector4f src) {
63 set(src);
64 }
65
66 /**
67 * C'tor
68 *
69 */
70 public Quaternion(float x, float y, float z, float w) {
71 set(x, y, z, w);
72 }
73
74 /*
75 * (non-Javadoc)
76 *
77 * @see org.lwjgl.util.vector.WritableVector2f#set(float, float)
78 */
79 public void set(float x, float y) {
80 this.x = x;
81 this.y = y;
82 }
83
84 /*
85 * (non-Javadoc)
86 *
87 * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float)
88 */
89 public void set(float x, float y, float z) {
90 this.x = x;
91 this.y = y;
92 this.z = z;
93 }
94
95 /*
96 * (non-Javadoc)
97 *
98 * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float,
99 * float)
100 */
101 public void set(float x, float y, float z, float w) {
102 this.x = x;
103 this.y = y;
104 this.z = z;
105 this.w = w;
106 }
107
108 /**
109 * Load from another Vector4f
110 *
111 * @param src
112 * The source vector
113 * @return this
114 */
115 public Quaternion set(ReadableVector4f src) {
116 x = src.getX();
117 y = src.getY();
118 z = src.getZ();
119 w = src.getW();
120 return this;
121 }
122
123 /**
124 * Set this quaternion to the multiplication identity.
125 * @return this
126 */
127 public Quaternion setIdentity() {
128 return setIdentity(this);
129 }
130
131 /**
132 * Set the given quaternion to the multiplication identity.
133 * @param q The quaternion
134 * @return q
135 */
136 public static Quaternion setIdentity(Quaternion q) {
137 q.x = 0;
138 q.y = 0;
139 q.z = 0;
140 q.w = 1;
141 return q;
142 }
143
144 /**
145 * @return the length squared of the quaternion
146 */
147 public float lengthSquared() {
148 return x * x + y * y + z * z + w * w;
149 }
150
151 /**
152 * Normalise the source quaternion and place the result in another quaternion.
153 *
154 * @param src
155 * The source quaternion
156 * @param dest
157 * The destination quaternion, or null if a new quaternion is to be
158 * created
159 * @return The normalised quaternion
160 */
161 public static Quaternion normalise(Quaternion src, Quaternion dest) {
162 float inv_l = 1f/src.length();
163
164 if (dest == null)
165 dest = new Quaternion();
166
167 dest.set(src.x * inv_l, src.y * inv_l, src.z * inv_l, src.w * inv_l);
168
169 return dest;
170 }
171
172 /**
173 * Normalise this quaternion and place the result in another quaternion.
174 *
175 * @param dest
176 * The destination quaternion, or null if a new quaternion is to be
177 * created
178 * @return the normalised quaternion
179 */
180 public Quaternion normalise(Quaternion dest) {
181 return normalise(this, dest);
182 }
183
184 /**
185 * The dot product of two quaternions
186 *
187 * @param left
188 * The LHS quat
189 * @param right
190 * The RHS quat
191 * @return left dot right
192 */
193 public static float dot(Quaternion left, Quaternion right) {
194 return left.x * right.x + left.y * right.y + left.z * right.z + left.w
195 * right.w;
196 }
197
198 /**
199 * Calculate the conjugate of this quaternion and put it into the given one
200 *
201 * @param dest
202 * The quaternion which should be set to the conjugate of this
203 * quaternion
204 */
205 public Quaternion negate(Quaternion dest) {
206 return negate(this, dest);
207 }
208
209 /**
210 * Calculate the conjugate of this quaternion and put it into the given one
211 *
212 * @param src
213 * The source quaternion
214 * @param dest
215 * The quaternion which should be set to the conjugate of this
216 * quaternion
217 */
218 public static Quaternion negate(Quaternion src, Quaternion dest) {
219 if (dest == null)
220 dest = new Quaternion();
221
222 dest.x = -src.x;
223 dest.y = -src.y;
224 dest.z = -src.z;
225 dest.w = src.w;
226
227 return dest;
228 }
229
230 /**
231 * Calculate the conjugate of this quaternion
232 */
233 public Vector negate() {
234 return negate(this, this);
235 }
236
237 /* (non-Javadoc)
238 * @see org.lwjgl.util.vector.Vector#load(java.nio.FloatBuffer)
239 */
240 public Vector load(FloatBuffer buf) {
241 x = buf.get();
242 y = buf.get();
243 z = buf.get();
244 w = buf.get();
245 return this;
246 }
247
248 /*
249 * (non-Javadoc)
250 *
251 * @see org.lwjgl.vector.Vector#scale(float)
252 */
253 public Vector scale(float scale) {
254 return scale(scale, this, this);
255 }
256
257 /**
258 * Scale the source quaternion by scale and put the result in the destination
259 * @param scale The amount to scale by
260 * @param src The source quaternion
261 * @param dest The destination quaternion, or null if a new quaternion is to be created
262 * @return The scaled quaternion
263 */
264 public static Quaternion scale(float scale, Quaternion src, Quaternion dest) {
265 if (dest == null)
266 dest = new Quaternion();
267 dest.x = src.x * scale;
268 dest.y = src.y * scale;
269 dest.z = src.z * scale;
270 dest.w = src.w * scale;
271 return dest;
272 }
273
274 /* (non-Javadoc)
275 * @see org.lwjgl.util.vector.ReadableVector#store(java.nio.FloatBuffer)
276 */
277 public Vector store(FloatBuffer buf) {
278 buf.put(x);
279 buf.put(y);
280 buf.put(z);
281 buf.put(w);
282
283 return this;
284 }
285
286 /**
287 * @return x
288 */
289 public final float getX() {
290 return x;
291 }
292
293 /**
294 * @return y
295 */
296 public final float getY() {
297 return y;
298 }
299
300 /**
301 * Set X
302 *
303 * @param x
304 */
305 public final void setX(float x) {
306 this.x = x;
307 }
308
309 /**
310 * Set Y
311 *
312 * @param y
313 */
314 public final void setY(float y) {
315 this.y = y;
316 }
317
318 /**
319 * Set Z
320 *
321 * @param z
322 */
323 public void setZ(float z) {
324 this.z = z;
325 }
326
327 /*
328 * (Overrides)
329 *
330 * @see org.lwjgl.vector.ReadableVector3f#getZ()
331 */
332 public float getZ() {
333 return z;
334 }
335
336 /**
337 * Set W
338 *
339 * @param w
340 */
341 public void setW(float w) {
342 this.w = w;
343 }
344
345 /*
346 * (Overrides)
347 *
348 * @see org.lwjgl.vector.ReadableVector3f#getW()
349 */
350 public float getW() {
351 return w;
352 }
353
354 public String toString() {
355 return "Quaternion: " + x + " " + y + " " + z + " " + w;
356 }
357
358 /**
359 * Sets the value of this quaternion to the quaternion product of
360 * quaternions left and right (this = left * right). Note that this is safe
361 * for aliasing (e.g. this can be left or right).
362 *
363 * @param left
364 * the first quaternion
365 * @param right
366 * the second quaternion
367 */
368 public static Quaternion mul(Quaternion left, Quaternion right,
369 Quaternion dest) {
370 if (dest == null)
371 dest = new Quaternion();
372 dest.set(left.x * right.w + left.w * right.x + left.y * right.z
373 - left.z * right.y, left.y * right.w + left.w * right.y
374 + left.z * right.x - left.x * right.z, left.z * right.w
375 + left.w * right.z + left.x * right.y - left.y * right.x,
376 left.w * right.w - left.x * right.x - left.y * right.y
377 - left.z * right.z);
378 return dest;
379 }
380
381 /**
382 *
383 * Multiplies quaternion left by the inverse of quaternion right and places
384 * the value into this quaternion. The value of both argument quaternions is
385 * preservered (this = left * right^-1).
386 *
387 * @param left
388 * the left quaternion
389 * @param right
390 * the right quaternion
391 */
392 public static Quaternion mulInverse(Quaternion left, Quaternion right,
393 Quaternion dest) {
394 float n = right.lengthSquared();
395 // zero-div may occur.
396 n = (n == 0.0 ? n : 1 / n);
397 // store on stack once for aliasing-safty
398 if (dest == null)
399 dest = new Quaternion();
400 dest
401 .set((left.x * right.w - left.w * right.x - left.y
402 * right.z + left.z * right.y)
403 * n, (left.y * right.w - left.w * right.y - left.z
404 * right.x + left.x * right.z)
405 * n, (left.z * right.w - left.w * right.z - left.x
406 * right.y + left.y * right.x)
407 * n, (left.w * right.w + left.x * right.x + left.y
408 * right.y + left.z * right.z)
409 * n);
410
411 return dest;
412 }
413
414 /**
415 * Sets the value of this quaternion to the equivalent rotation of the
416 * Axis-Angle argument.
417 *
418 * @param a1
419 * the axis-angle: (x,y,z) is the axis and w is the angle
420 */
421 public final void setFromAxisAngle(Vector4f a1) {
422 x = a1.x;
423 y = a1.y;
424 z = a1.z;
425 float n = (float) Math.sqrt(x * x + y * y + z * z);
426 // zero-div may occur.
427 float s = (float) (Math.sin(0.5 * a1.w) / n);
428 x *= s;
429 y *= s;
430 z *= s;
431 w = (float) Math.cos(0.5 * a1.w);
432 }
433
434 /**
435 * Sets the value of this quaternion using the rotational component of the
436 * passed matrix.
437 *
438 * @param m
439 * The matrix
440 * @return this
441 */
442 public final Quaternion setFromMatrix(Matrix4f m) {
443 return setFromMatrix(m, this);
444 }
445
446 /**
447 * Sets the value of the source quaternion using the rotational component of the
448 * passed matrix.
449 *
450 * @param m
451 * The source matrix
452 * @param q
453 * The destination quaternion, or null if a new quaternion is to be created
454 * @return q
455 */
456 public final static Quaternion setFromMatrix(Matrix4f m, Quaternion q) {
457 return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20,
458 m.m21, m.m22);
459 }
460
461 /**
462 * Sets the value of this quaternion using the rotational component of the
463 * passed matrix.
464 *
465 * @param m
466 * The source matrix
467 */
468 public final Quaternion setFromMatrix(Matrix3f m) {
469 return setFromMatrix(m, this);
470 }
471
472 /**
473 * Sets the value of the source quaternion using the rotational component of the
474 * passed matrix.
475 *
476 * @param m
477 * The source matrix
478 * @param q
479 * The destination quaternion, or null if a new quaternion is to be created
480 * @return q
481 */
482 public static final Quaternion setFromMatrix(Matrix3f m, Quaternion q) {
483 return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20,
484 m.m21, m.m22);
485 }
486
487 /**
488 * Private method to perform the matrix-to-quaternion conversion
489 */
490 private Quaternion setFromMat(float m00, float m01, float m02, float m10,
491 float m11, float m12, float m20, float m21, float m22) {
492
493 float s;
494 float tr = m00 + m11 + m22;
495 if (tr >= 0.0) {
496 s = (float) Math.sqrt(tr + 1.0);
497 w = s * 0.5f;
498 s = 0.5f / s;
499 x = (m21 - m12) * s;
500 y = (m02 - m20) * s;
501 z = (m10 - m01) * s;
502 } else {
503 float max = Math.max(Math.max(m00, m11), m22);
504 if (max == m00) {
505 s = (float) Math.sqrt(m00 - (m11 + m22) + 1.0);
506 x = s * 0.5f;
507 s = 0.5f / s;
508 y = (m01 + m10) * s;
509 z = (m20 + m02) * s;
510 w = (m21 - m12) * s;
511 } else if (max == m11) {
512 s = (float) Math.sqrt(m11 - (m22 + m00) + 1.0);
513 y = s * 0.5f;
514 s = 0.5f / s;
515 z = (m12 + m21) * s;
516 x = (m01 + m10) * s;
517 w = (m02 - m20) * s;
518 } else {
519 s = (float) Math.sqrt(m22 - (m00 + m11) + 1.0);
520 z = s * 0.5f;
521 s = 0.5f / s;
522 x = (m20 + m02) * s;
523 y = (m12 + m21) * s;
524 w = (m10 - m01) * s;
525 }
526 }
527 return this;
528 }
529 }
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.vector;
32
33 import java.nio.FloatBuffer;
34
35 /**
36 * @author foo
37 */
38 public interface ReadableVector {
39 /**
40 * @return the length of the vector
41 */
42 public float length();
43 /**
44 * @return the length squared of the vector
45 */
46 public float lengthSquared();
47 /**
48 * Store this vector in a FloatBuffer
49 * @param buf The buffer to store it in, at the current position
50 * @return this
51 */
52 public Vector store(FloatBuffer buf);
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.util.vector;
32
33 /**
34 * @author foo
35 */
36 public interface ReadableVector2f extends ReadableVector {
37 /**
38 * @return x
39 */
40 public float getX();
41 /**
42 * @return y
43 */
44 public float getY();
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.vector;
32
33 /**
34 * @author foo
35 */
36 public interface ReadableVector3f extends ReadableVector2f {
37 /**
38 * @return z
39 */
40 public float getZ();
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.vector;
32
33 /**
34 * @author foo
35 */
36 public interface ReadableVector4f extends ReadableVector3f {
37
38 /**
39 * @return w
40 */
41 public float getW();
42
43 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Base class for vectors.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44 public abstract class Vector implements Serializable, ReadableVector {
45
46 /**
47 * Constructor for Vector.
48 */
49 public Vector() {
50 super();
51 }
52
53 /**
54 * @return the length of the vector
55 */
56 public final float length() {
57 return (float) Math.sqrt(lengthSquared());
58 }
59
60
61 /**
62 * @return the length squared of the vector
63 */
64 public abstract float lengthSquared();
65
66 /**
67 * Load this vector from a FloatBuffer
68 * @param buf The buffer to load it from, at the current position
69 * @return this
70 */
71 public abstract Vector load(FloatBuffer buf);
72
73 /**
74 * Negate a vector
75 * @return this
76 */
77 public abstract Vector negate();
78
79
80 /**
81 * Normalise this vector
82 * @return this
83 */
84 public final Vector normalise() {
85 float len = length();
86 if (len != 0.0f) {
87 float l = 1.0f / len;
88 return scale(l);
89 } else
90 throw new IllegalStateException("Zero length vector");
91 }
92
93
94 /**
95 * Store this vector in a FloatBuffer
96 * @param buf The buffer to store it in, at the current position
97 * @return this
98 */
99 public abstract Vector store(FloatBuffer buf);
100
101
102 /**
103 * Scale this vector
104 * @param scale The scale factor
105 * @return this
106 */
107 public abstract Vector scale(float scale);
108
109
110
111 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Holds a 2-tuple vector.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector2f.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44
45 public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f {
46
47 private static final long serialVersionUID = 1L;
48
49 public float x, y;
50
51 /**
52 * Constructor for Vector3f.
53 */
54 public Vector2f() {
55 super();
56 }
57
58 /**
59 * Constructor
60 */
61 public Vector2f(ReadableVector2f src) {
62 set(src);
63 }
64
65 /**
66 * Constructor
67 */
68 public Vector2f(float x, float y) {
69 set(x, y);
70 }
71
72 /* (non-Javadoc)
73 * @see org.lwjgl.util.vector.WritableVector2f#set(float, float)
74 */
75 public void set(float x, float y) {
76 this.x = x;
77 this.y = y;
78 }
79
80 /**
81 * Load from another Vector2f
82 * @param src The source vector
83 * @return this
84 */
85 public Vector2f set(ReadableVector2f src) {
86 x = src.getX();
87 y = src.getY();
88 return this;
89 }
90
91 /**
92 * @return the length squared of the vector
93 */
94 public float lengthSquared() {
95 return x * x + y * y;
96 }
97
98 /**
99 * Translate a vector
100 * @param x The translation in x
101 * @param y the translation in y
102 * @return this
103 */
104 public Vector2f translate(float x, float y) {
105 this.x += x;
106 this.y += y;
107 return this;
108 }
109
110 /**
111 * Negate a vector
112 * @return this
113 */
114 public Vector negate() {
115 x = -x;
116 y = -y;
117 return this;
118 }
119
120 /**
121 * Negate a vector and place the result in a destination vector.
122 * @param dest The destination vector or null if a new vector is to be created
123 * @return the negated vector
124 */
125 public Vector2f negate(Vector2f dest) {
126 if (dest == null)
127 dest = new Vector2f();
128 dest.x = -x;
129 dest.y = -y;
130 return dest;
131 }
132
133
134 /**
135 * Normalise this vector and place the result in another vector.
136 * @param dest The destination vector, or null if a new vector is to be created
137 * @return the normalised vector
138 */
139 public Vector2f normalise(Vector2f dest) {
140 float l = length();
141
142 if (dest == null)
143 dest = new Vector2f(x / l, y / l);
144 else
145 dest.set(x / l, y / l);
146
147 return dest;
148 }
149
150 /**
151 * The dot product of two vectors is calculated as
152 * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z
153 * @param left The LHS vector
154 * @param right The RHS vector
155 * @return left dot right
156 */
157 public static float dot(Vector2f left, Vector2f right) {
158 return left.x * right.x + left.y * right.y;
159 }
160
161
162
163 /**
164 * Calculate the angle between two vectors, in radians
165 * @param a A vector
166 * @param b The other vector
167 * @return the angle between the two vectors, in radians
168 */
169 public static float angle(Vector2f a, Vector2f b) {
170 float dls = dot(a, b) / (a.length() * b.length());
171 if (dls < -1f)
172 dls = -1f;
173 else if (dls > 1.0f)
174 dls = 1.0f;
175 return (float)Math.acos(dls);
176 }
177
178 /**
179 * Add a vector to another vector and place the result in a destination
180 * vector.
181 * @param left The LHS vector
182 * @param right The RHS vector
183 * @param dest The destination vector, or null if a new vector is to be created
184 * @return the sum of left and right in dest
185 */
186 public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) {
187 if (dest == null)
188 return new Vector2f(left.x + right.x, left.y + right.y);
189 else {
190 dest.set(left.x + right.x, left.y + right.y);
191 return dest;
192 }
193 }
194
195 /**
196 * Subtract a vector from another vector and place the result in a destination
197 * vector.
198 * @param left The LHS vector
199 * @param right The RHS vector
200 * @param dest The destination vector, or null if a new vector is to be created
201 * @return left minus right in dest
202 */
203 public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) {
204 if (dest == null)
205 return new Vector2f(left.x - right.x, left.y - right.y);
206 else {
207 dest.set(left.x - right.x, left.y - right.y);
208 return dest;
209 }
210 }
211
212 /**
213 * Store this vector in a FloatBuffer
214 * @param buf The buffer to store it in, at the current position
215 * @return this
216 */
217 public Vector store(FloatBuffer buf) {
218 buf.put(x);
219 buf.put(y);
220 return this;
221 }
222
223 /**
224 * Load this vector from a FloatBuffer
225 * @param buf The buffer to load it from, at the current position
226 * @return this
227 */
228 public Vector load(FloatBuffer buf) {
229 x = buf.get();
230 y = buf.get();
231 return this;
232 }
233
234 /* (non-Javadoc)
235 * @see org.lwjgl.vector.Vector#scale(float)
236 */
237 public Vector scale(float scale) {
238
239 x *= scale;
240 y *= scale;
241
242 return this;
243 }
244
245 /* (non-Javadoc)
246 * @see java.lang.Object#toString()
247 */
248 public String toString() {
249 StringBuffer sb = new StringBuffer(64);
250
251 sb.append("Vector2f[");
252 sb.append(x);
253 sb.append(", ");
254 sb.append(y);
255 sb.append(']');
256 return sb.toString();
257 }
258
259 /**
260 * @return x
261 */
262 public final float getX() {
263 return x;
264 }
265
266 /**
267 * @return y
268 */
269 public final float getY() {
270 return y;
271 }
272
273 /**
274 * Set X
275 * @param x
276 */
277 public final void setX(float x) {
278 this.x = x;
279 }
280
281 /**
282 * Set Y
283 * @param y
284 */
285 public final void setY(float y) {
286 this.y = y;
287 }
288
289 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Holds a 3-tuple vector.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector3f.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44
45 public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f {
46
47 private static final long serialVersionUID = 1L;
48
49 public float x, y, z;
50
51 /**
52 * Constructor for Vector3f.
53 */
54 public Vector3f() {
55 super();
56 }
57
58 /**
59 * Constructor
60 */
61 public Vector3f(ReadableVector3f src) {
62 set(src);
63 }
64
65 /**
66 * Constructor
67 */
68 public Vector3f(float x, float y, float z) {
69 set(x, y, z);
70 }
71
72 /* (non-Javadoc)
73 * @see org.lwjgl.util.vector.WritableVector2f#set(float, float)
74 */
75 public void set(float x, float y) {
76 this.x = x;
77 this.y = y;
78 }
79
80 /* (non-Javadoc)
81 * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float)
82 */
83 public void set(float x, float y, float z) {
84 this.x = x;
85 this.y = y;
86 this.z = z;
87 }
88
89 /**
90 * Load from another Vector3f
91 * @param src The source vector
92 * @return this
93 */
94 public Vector3f set(ReadableVector3f src) {
95 x = src.getX();
96 y = src.getY();
97 z = src.getZ();
98 return this;
99 }
100
101 /**
102 * @return the length squared of the vector
103 */
104 public float lengthSquared() {
105 return x * x + y * y + z * z;
106 }
107
108 /**
109 * Translate a vector
110 * @param x The translation in x
111 * @param y the translation in y
112 * @return this
113 */
114 public Vector3f translate(float x, float y, float z) {
115 this.x += x;
116 this.y += y;
117 this.z += z;
118 return this;
119 }
120
121 /**
122 * Add a vector to another vector and place the result in a destination
123 * vector.
124 * @param left The LHS vector
125 * @param right The RHS vector
126 * @param dest The destination vector, or null if a new vector is to be created
127 * @return the sum of left and right in dest
128 */
129 public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) {
130 if (dest == null)
131 return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z);
132 else {
133 dest.set(left.x + right.x, left.y + right.y, left.z + right.z);
134 return dest;
135 }
136 }
137
138 /**
139 * Subtract a vector from another vector and place the result in a destination
140 * vector.
141 * @param left The LHS vector
142 * @param right The RHS vector
143 * @param dest The destination vector, or null if a new vector is to be created
144 * @return left minus right in dest
145 */
146 public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) {
147 if (dest == null)
148 return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z);
149 else {
150 dest.set(left.x - right.x, left.y - right.y, left.z - right.z);
151 return dest;
152 }
153 }
154
155 /**
156 * The cross product of two vectors.
157 *
158 * @param left The LHS vector
159 * @param right The RHS vector
160 * @param dest The destination result, or null if a new vector is to be created
161 * @return left cross right
162 */
163 public static Vector3f cross(
164 Vector3f left,
165 Vector3f right,
166 Vector3f dest)
167 {
168
169 if (dest == null)
170 dest = new Vector3f();
171
172 dest.set(
173 left.y * right.z - left.z * right.y,
174 right.x * left.z - right.z * left.x,
175 left.x * right.y - left.y * right.x
176 );
177
178 return dest;
179 }
180
181
182
183 /**
184 * Negate a vector
185 * @return this
186 */
187 public Vector negate() {
188 x = -x;
189 y = -y;
190 z = -z;
191 return this;
192 }
193
194 /**
195 * Negate a vector and place the result in a destination vector.
196 * @param dest The destination vector or null if a new vector is to be created
197 * @return the negated vector
198 */
199 public Vector3f negate(Vector3f dest) {
200 if (dest == null)
201 dest = new Vector3f();
202 dest.x = -x;
203 dest.y = -y;
204 dest.z = -z;
205 return dest;
206 }
207
208
209 /**
210 * Normalise this vector and place the result in another vector.
211 * @param dest The destination vector, or null if a new vector is to be created
212 * @return the normalised vector
213 */
214 public Vector3f normalise(Vector3f dest) {
215 float l = length();
216
217 if (dest == null)
218 dest = new Vector3f(x / l, y / l, z / l);
219 else
220 dest.set(x / l, y / l, z / l);
221
222 return dest;
223 }
224
225 /**
226 * The dot product of two vectors is calculated as
227 * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z
228 * @param left The LHS vector
229 * @param right The RHS vector
230 * @return left dot right
231 */
232 public static float dot(Vector3f left, Vector3f right) {
233 return left.x * right.x + left.y * right.y + left.z * right.z;
234 }
235
236 /**
237 * Calculate the angle between two vectors, in radians
238 * @param a A vector
239 * @param b The other vector
240 * @return the angle between the two vectors, in radians
241 */
242 public static float angle(Vector3f a, Vector3f b) {
243 float dls = dot(a, b) / (a.length() * b.length());
244 if (dls < -1f)
245 dls = -1f;
246 else if (dls > 1.0f)
247 dls = 1.0f;
248 return (float)Math.acos(dls);
249 }
250
251 /* (non-Javadoc)
252 * @see org.lwjgl.vector.Vector#load(FloatBuffer)
253 */
254 public Vector load(FloatBuffer buf) {
255 x = buf.get();
256 y = buf.get();
257 z = buf.get();
258 return this;
259 }
260
261 /* (non-Javadoc)
262 * @see org.lwjgl.vector.Vector#scale(float)
263 */
264 public Vector scale(float scale) {
265
266 x *= scale;
267 y *= scale;
268 z *= scale;
269
270 return this;
271
272 }
273
274 /* (non-Javadoc)
275 * @see org.lwjgl.vector.Vector#store(FloatBuffer)
276 */
277 public Vector store(FloatBuffer buf) {
278
279 buf.put(x);
280 buf.put(y);
281 buf.put(z);
282
283 return this;
284 }
285
286 /* (non-Javadoc)
287 * @see java.lang.Object#toString()
288 */
289 public String toString() {
290 StringBuffer sb = new StringBuffer(64);
291
292 sb.append("Vector3f[");
293 sb.append(x);
294 sb.append(", ");
295 sb.append(y);
296 sb.append(", ");
297 sb.append(z);
298 sb.append(']');
299 return sb.toString();
300 }
301
302 /**
303 * @return x
304 */
305 public final float getX() {
306 return x;
307 }
308
309 /**
310 * @return y
311 */
312 public final float getY() {
313 return y;
314 }
315
316 /**
317 * Set X
318 * @param x
319 */
320 public final void setX(float x) {
321 this.x = x;
322 }
323
324 /**
325 * Set Y
326 * @param y
327 */
328 public final void setY(float y) {
329 this.y = y;
330 }
331
332 /**
333 * Set Z
334 * @param z
335 */
336 public void setZ(float z) {
337 this.z = z;
338 }
339
340 /* (Overrides)
341 * @see org.lwjgl.vector.ReadableVector3f#getZ()
342 */
343 public float getZ() {
344 return z;
345 }
346 }
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.vector;
32
33 import java.io.Serializable;
34 import java.nio.FloatBuffer;
35
36 /**
37 *
38 * Holds a 4-tuple vector.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector4f.java 2983 2008-04-07 18:36:09Z matzon $
43 */
44
45 public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f {
46
47 private static final long serialVersionUID = 1L;
48
49 public float x, y, z, w;
50
51 /**
52 * Constructor for Vector4f.
53 */
54 public Vector4f() {
55 super();
56 }
57
58 /**
59 * Constructor
60 */
61 public Vector4f(ReadableVector4f src) {
62 set(src);
63 }
64
65 /**
66 * Constructor
67 */
68 public Vector4f(float x, float y, float z, float w) {
69 set(x, y, z, w);
70 }
71
72 /* (non-Javadoc)
73 * @see org.lwjgl.util.vector.WritableVector2f#set(float, float)
74 */
75 public void set(float x, float y) {
76 this.x = x;
77 this.y = y;
78 }
79
80 /* (non-Javadoc)
81 * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float)
82 */
83 public void set(float x, float y, float z) {
84 this.x = x;
85 this.y = y;
86 this.z = z;
87 }
88
89 /* (non-Javadoc)
90 * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float)
91 */
92 public void set(float x, float y, float z, float w) {
93 this.x = x;
94 this.y = y;
95 this.z = z;
96 this.w = w;
97 }
98
99 /**
100 * Load from another Vector4f
101 * @param src The source vector
102 * @return this
103 */
104 public Vector4f set(ReadableVector4f src) {
105 x = src.getX();
106 y = src.getY();
107 z = src.getZ();
108 w = src.getW();
109 return this;
110 }
111
112 /**
113 * @return the length squared of the vector
114 */
115 public float lengthSquared() {
116 return x * x + y * y + z * z + w * w;
117 }
118
119 /**
120 * Translate a vector
121 * @param x The translation in x
122 * @param y the translation in y
123 * @return this
124 */
125 public Vector4f translate(float x, float y, float z, float w) {
126 this.x += x;
127 this.y += y;
128 this.z += z;
129 this.w += w;
130 return this;
131 }
132
133 /**
134 * Add a vector to another vector and place the result in a destination
135 * vector.
136 * @param left The LHS vector
137 * @param right The RHS vector
138 * @param dest The destination vector, or null if a new vector is to be created
139 * @return the sum of left and right in dest
140 */
141 public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) {
142 if (dest == null)
143 return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w);
144 else {
145 dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w);
146 return dest;
147 }
148 }
149
150 /**
151 * Subtract a vector from another vector and place the result in a destination
152 * vector.
153 * @param left The LHS vector
154 * @param right The RHS vector
155 * @param dest The destination vector, or null if a new vector is to be created
156 * @return left minus right in dest
157 */
158 public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) {
159 if (dest == null)
160 return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w);
161 else {
162 dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w);
163 return dest;
164 }
165 }
166
167
168 /**
169 * Negate a vector
170 * @return this
171 */
172 public Vector negate() {
173 x = -x;
174 y = -y;
175 z = -z;
176 w = -w;
177 return this;
178 }
179
180 /**
181 * Negate a vector and place the result in a destination vector.
182 * @param dest The destination vector or null if a new vector is to be created
183 * @return the negated vector
184 */
185 public Vector4f negate(Vector4f dest) {
186 if (dest == null)
187 dest = new Vector4f();
188 dest.x = -x;
189 dest.y = -y;
190 dest.z = -z;
191 dest.w = -w;
192 return dest;
193 }
194
195
196 /**
197 * Normalise this vector and place the result in another vector.
198 * @param dest The destination vector, or null if a new vector is to be created
199 * @return the normalised vector
200 */
201 public Vector4f normalise(Vector4f dest) {
202 float l = length();
203
204 if (dest == null)
205 dest = new Vector4f(x / l, y / l, z / l, w / l);
206 else
207 dest.set(x / l, y / l, z / l, w / l);
208
209 return dest;
210 }
211
212 /**
213 * The dot product of two vectors is calculated as
214 * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w
215 * @param left The LHS vector
216 * @param right The RHS vector
217 * @return left dot right
218 */
219 public static float dot(Vector4f left, Vector4f right) {
220 return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
221 }
222
223 /**
224 * Calculate the angle between two vectors, in radians
225 * @param a A vector
226 * @param b The other vector
227 * @return the angle between the two vectors, in radians
228 */
229 public static float angle(Vector4f a, Vector4f b) {
230 float dls = dot(a, b) / (a.length() * b.length());
231 if (dls < -1f)
232 dls = -1f;
233 else if (dls > 1.0f)
234 dls = 1.0f;
235 return (float)Math.acos(dls);
236 }
237
238 /* (non-Javadoc)
239 * @see org.lwjgl.vector.Vector#load(FloatBuffer)
240 */
241 public Vector load(FloatBuffer buf) {
242 x = buf.get();
243 y = buf.get();
244 z = buf.get();
245 w = buf.get();
246 return this;
247 }
248
249 /* (non-Javadoc)
250 * @see org.lwjgl.vector.Vector#scale(float)
251 */
252 public Vector scale(float scale) {
253 x *= scale;
254 y *= scale;
255 z *= scale;
256 w *= scale;
257 return this;
258 }
259
260 /* (non-Javadoc)
261 * @see org.lwjgl.vector.Vector#store(FloatBuffer)
262 */
263 public Vector store(FloatBuffer buf) {
264
265 buf.put(x);
266 buf.put(y);
267 buf.put(z);
268 buf.put(w);
269
270 return this;
271 }
272
273 public String toString() {
274 return "Vector4f: " + x + " " + y + " " + z + " " + w;
275 }
276
277 /**
278 * @return x
279 */
280 public final float getX() {
281 return x;
282 }
283
284 /**
285 * @return y
286 */
287 public final float getY() {
288 return y;
289 }
290
291 /**
292 * Set X
293 * @param x
294 */
295 public final void setX(float x) {
296 this.x = x;
297 }
298
299 /**
300 * Set Y
301 * @param y
302 */
303 public final void setY(float y) {
304 this.y = y;
305 }
306
307 /**
308 * Set Z
309 * @param z
310 */
311 public void setZ(float z) {
312 this.z = z;
313 }
314
315
316 /* (Overrides)
317 * @see org.lwjgl.vector.ReadableVector3f#getZ()
318 */
319 public float getZ() {
320 return z;
321 }
322
323 /**
324 * Set W
325 * @param w
326 */
327 public void setW(float w) {
328 this.w = w;
329 }
330
331 /* (Overrides)
332 * @see org.lwjgl.vector.ReadableVector3f#getZ()
333 */
334 public float getW() {
335 return w;
336 }
337
338
339 }
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.vector;
32
33 /**
34 * Writable interface to Vector2fs
35 * @author $author$
36 * @version $revision$
37 * $Id: WritableVector2f.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface WritableVector2f {
40
41 /**
42 * Set the X value
43 * @param x
44 */
45 public void setX(float x);
46
47 /**
48 * Set the Y value
49 * @param y
50 */
51 public void setY(float y);
52
53 /**
54 * Set the X,Y values
55 * @param x
56 * @param y
57 */
58 public void set(float x, float y);
59
60 }
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.vector;
32
33 /**
34 * Writable interface to Vector3fs
35 * @author $author$
36 * @version $revision$
37 * $Id: WritableVector3f.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface WritableVector3f extends WritableVector2f {
40
41 /**
42 * Set the Z value
43 * @param z
44 */
45 public void setZ(float z);
46
47 /**
48 * Set the X,Y,Z values
49 * @param x
50 * @param y
51 * @param z
52 */
53 public void set(float x, float y, float z);
54
55 }
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.vector;
32
33 /**
34 * Writable interface to Vector4fs
35 * @author $author$
36 * @version $revision$
37 * $Id: WritableVector4f.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39 public interface WritableVector4f extends WritableVector3f {
40
41 /**
42 * Set the W value
43 * @param w
44 */
45 public void setW(float w);
46
47 /**
48 * Set the X,Y,Z,W values
49 * @param x
50 * @param y
51 * @param z
52 * @param w
53 */
54 public void set(float x, float y, float z, float w);
55
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
32 /**
33 * $Id: awt_tools.h 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #ifndef __LWJGL_AWT_TOOLS_H
40 #define __LWJGL_AWT_TOOLS_H
41
42 #include <jni.h>
43 #include <jawt_md.h>
44
45 typedef struct {
46 JAWT awt;
47 JAWT_DrawingSurface* ds;
48 JAWT_DrawingSurfaceInfo *dsi;
49 } AWTSurfaceLock;
50
51 #endif
52
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 * $Id: common_tools.c 3167 2008-12-22 16:38:57Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3167 $
37 */
38
39 #include <jni.h>
40 #include <stdlib.h>
41 #include "common_tools.h"
42 #include "org_lwjgl_DefaultSysImplementation.h"
43
44 static bool debug = false;
45 static JavaVM *jvm;
46
47 void initAttribList(attrib_list_t *list) {
48 list->current_index = 0;
49 }
50
51 void putAttrib(attrib_list_t *list, int attrib) {
52 if (list->current_index == ATTRIB_LIST_SIZE) {
53 printfDebug("Ignoring attrib %d: attrib list size too small", attrib);
54 return;
55 }
56 list->attribs[list->current_index] = attrib;
57 list->current_index++;
58 }
59
60 JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
61 (JNIEnv *env, jobject ignored, jboolean enable) {
62 debug = enable == JNI_TRUE ? true : false;
63 }
64
65 bool isDebugEnabled(void) {
66 return debug;
67 }
68
69 static int do_vsnprintf(char* buffer, size_t buffer_size, const char *format, va_list ap) {
70 #ifdef _MSC_VER
71 return vsnprintf_s(buffer, buffer_size, _TRUNCATE, format, ap);
72 #else
73 va_list cp_ap;
74 va_copy(cp_ap, ap);
75 int res = vsnprintf(buffer, buffer_size, format, cp_ap);
76 va_end(cp_ap);
77 return res;
78 #endif
79 }
80
81 static jstring sprintfJavaString(JNIEnv *env, const char *format, va_list ap) {
82 int buffer_size = 2;
83 char *buffer;
84 jstring str;
85 int str_size;
86 buffer = (char *)malloc(sizeof(char)*buffer_size);
87 if (buffer == NULL)
88 return NULL;
89 str_size = do_vsnprintf(buffer, buffer_size, format, ap);
90 if (str_size > buffer_size) {
91 free(buffer);
92 buffer_size = str_size + 1;
93 buffer = (char *)malloc(sizeof(char)*buffer_size);
94 if (buffer == NULL)
95 return NULL;
96 do_vsnprintf(buffer, buffer_size, format, ap);
97 }
98 str = (*env)->NewStringUTF(env, buffer);
99 free(buffer);
100 return str;
101 }
102
103 void printfDebugJava(JNIEnv *env, const char *format, ...) {
104 jstring str;
105 jclass org_lwjgl_LWJGLUtil_class;
106 jmethodID log_method;
107 va_list ap;
108 if (isDebugEnabled() && !(*env)->ExceptionOccurred(env)) {
109 va_start(ap, format);
110 str = sprintfJavaString(env, format, ap);
111 va_end(ap);
112 org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil");
113 if (org_lwjgl_LWJGLUtil_class == NULL)
114 return;
115 log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V");
116 if (log_method == NULL)
117 return;
118 (*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str);
119 }
120 }
121
122 void printfDebug(const char *format, ...) {
123 va_list ap;
124 va_start(ap, format);
125 if (isDebugEnabled())
126 vfprintf(stderr, format, ap);
127 va_end(ap);
128 }
129
130 static void throwFormattedGeneralException(JNIEnv * env, const char *exception_name, const char *format, va_list ap) {
131 jclass cls;
132 jstring str;
133 jmethodID exception_constructor;
134 jobject exception;
135
136 if ((*env)->ExceptionCheck(env) == JNI_TRUE)
137 return; // The JVM crashes if we try to throw two exceptions from one native call
138 str = sprintfJavaString(env, format, ap);
139 cls = (*env)->FindClass(env, exception_name);
140 exception_constructor = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;)V");
141 exception = (*env)->NewObject(env, cls, exception_constructor, str);
142 (*env)->Throw(env, exception);
143 }
144
145 void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) {
146 jclass cls;
147
148 if ((*env)->ExceptionCheck(env) == JNI_TRUE)
149 return; // The JVM crashes if we try to throw two exceptions from one native call
150 cls = (*env)->FindClass(env, exception_name);
151 (*env)->ThrowNew(env, cls, err);
152 }
153
154 void throwFMODException(JNIEnv * env, const char * err) {
155 throwGeneralException(env, "org/lwjgl/fmod3/FMODException", err);
156 }
157
158 void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...) {
159 va_list ap;
160 va_start(ap, format);
161 throwFormattedGeneralException(env, "java/lang/RuntimeException", format, ap);
162 va_end(ap);
163 }
164
165 void throwFormattedException(JNIEnv * env, const char *format, ...) {
166 va_list ap;
167 va_start(ap, format);
168 throwFormattedGeneralException(env, "org/lwjgl/LWJGLException", format, ap);
169 va_end(ap);
170 }
171
172 void throwException(JNIEnv * env, const char * err) {
173 throwGeneralException(env, "org/lwjgl/LWJGLException", err);
174 }
175
176 // retrieves the locale-specific C string
177 char * GetStringNativeChars(JNIEnv *env, jstring jstr) {
178 jbyteArray bytes = 0;
179 jthrowable exc;
180 char *result = 0;
181 jclass jcls_str;
182 jmethodID MID_String_getBytes;
183
184 /* out of memory error? */
185 if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
186 return 0;
187 }
188
189 // aquire getBytes method
190 jcls_str = (*env)->FindClass(env, "java/lang/String");
191 MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B");
192
193 // get the bytes
194 bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
195 exc = (*env)->ExceptionOccurred(env);
196
197 // 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);
212 return (char*) result;
213 }
214
215 /* creates locale specific string, unsigned argument to
216 * match GLuchar and ALuchar types
217 */
218 jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *ustr) {
219 const char *str = (const char *)ustr;
220 if (str == NULL)
221 return NULL;
222 return NewStringNativeWithLength(env, str, strlen(str));
223 }
224
225 // creates locale specific string
226 jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
227 jclass jcls_str;
228 jmethodID jmethod_str;
229 jstring result;
230 jbyteArray bytes;
231 if (str==NULL) {
232 return NULL;
233 }
234
235 jcls_str = (*env)->FindClass(env,"java/lang/String");
236 if (jcls_str == NULL)
237 return NULL;
238 jmethod_str = (*env)->GetMethodID(env,jcls_str, "<init>", "([B)V");
239 if (jmethod_str == NULL)
240 return NULL;
241
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;
256 }
257
258 bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) {
259 int i;
260 void **ext_function_pointer_pointer;
261 for (i = 0; i < num_functions; i++) {
262 ExtFunction *function = functions + i;
263 if (function->ext_function_name != NULL) {
264 void *ext_func_pointer = gpa(function->ext_function_name);
265 if (ext_func_pointer == NULL)
266 return false;
267 ext_function_pointer_pointer = function->ext_function_pointer;
268 *ext_function_pointer_pointer = ext_func_pointer;
269 }
270 }
271 return true;
272 }
273
274 jobject newJavaManagedByteBuffer(JNIEnv *env, const int size) {
275 jclass bufferutils_class = (*env)->FindClass(env, "org/lwjgl/BufferUtils");
276 jmethodID createByteBuffer = (*env)->GetStaticMethodID(env, bufferutils_class, "createByteBuffer", "(I)Ljava/nio/ByteBuffer;");
277 jobject buffer = (*env)->CallStaticObjectMethod(env, bufferutils_class, createByteBuffer, size);
278 return buffer;
279 }
280
281 void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions) {
282 JNINativeMethod *methods;
283 JavaMethodAndExtFunction *function;
284 void *ext_func_pointer;
285 void **ext_function_pointer_pointer;
286 JNINativeMethod *method;
287 int i;
288 if (clazz == NULL) {
289 throwException(env, "Null class");
290 return;
291 }
292 methods = (JNINativeMethod *)malloc(num_functions*sizeof(JNINativeMethod));
293 for (i = 0; i < num_functions; i++) {
294 function = functions + i;
295 if (function->ext_function_name != NULL) {
296 ext_func_pointer = gpa(function->ext_function_name);
297 if (ext_func_pointer == NULL) {
298 free(methods);
299 throwException(env, "Missing driver symbols");
300 return;
301 }
302 ext_function_pointer_pointer = function->ext_function_pointer;
303 *ext_function_pointer_pointer = ext_func_pointer;
304 }
305 method = methods + i;
306 method->name = function->method_name;
307 method->signature = function->signature;
308 method->fnPtr = function->method_pointer;
309 }
310 (*env)->RegisterNatives(env, clazz, methods, num_functions);
311 free(methods);
312 }
313
314 bool getBooleanProperty(JNIEnv *env, const char* propertyName) {
315 jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName));
316 jclass org_lwjgl_LWJGLUtil_class;
317 jmethodID getBoolean;
318 if (property == NULL)
319 return false;
320 org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil");
321 if (org_lwjgl_LWJGLUtil_class == NULL)
322 return false;
323 getBoolean = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "getPrivilegedBoolean", "(Ljava/lang/String;)Z");
324 if (getBoolean == NULL)
325 return false;
326 return (*env)->CallStaticBooleanMethod(env, org_lwjgl_LWJGLUtil_class, getBoolean, property) ? true : false;
327 }
328
329 JNIEnv *getThreadEnv() {
330 JNIEnv *env;
331 (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4);
332 return env;
333 }
334
335 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
336 jvm = vm;
337 return JNI_VERSION_1_4;
338 }
339
340 JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
341 }
342
343 bool positionBuffer(JNIEnv *env, jobject buffer, jint position) {
344 jclass buffer_class;
345 jmethodID position_method;
346
347 buffer_class = (*env)->GetObjectClass(env, buffer);
348 if (buffer_class == NULL)
349 return false;
350 position_method = (*env)->GetMethodID(env, buffer_class, "position", "(I)Ljava/nio/Buffer;");
351 if (position_method == NULL)
352 return false;
353 (*env)->CallObjectMethod(env, buffer, position_method, position);
354 return true;
355 }
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 * $Id: common_tools.h 2988 2008-04-07 19:31:23Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2988 $
37 */
38
39 #ifndef _COMMON_TOOLS_H
40 #define _COMMON_TOOLS_H
41
42 #include <jni.h>
43 #include <string.h>
44 #include <stdlib.h>
45
46 #define ATTRIB_LIST_SIZE (256)
47
48 typedef struct {
49 int current_index;
50 int attribs[ATTRIB_LIST_SIZE];
51 } attrib_list_t;
52
53 #ifndef __cplusplus
54 #ifndef bool
55 typedef enum {false, true} bool;
56 #endif
57 #endif
58
59 #ifdef _MSC_VER
60 #define inline __inline
61 #include <Basetsd.h>
62 #else
63 #include <inttypes.h>
64 #endif
65
66 static inline void * safeGetBufferAddress(JNIEnv *env, jobject buffer) {
67 if (buffer != NULL) {
68 #ifdef __cplusplus
69 return (void *)((char *)env->GetDirectBufferAddress(buffer));
70 #else
71 return (void *)((char *)(*env)->GetDirectBufferAddress(env, buffer));
72 #endif
73 } else
74 return NULL;
75 }
76
77 static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) {
78 if (p != NULL) {
79 #ifdef __cplusplus
80 return env->NewDirectByteBuffer(p, size);
81 #else
82 return (*env)->NewDirectByteBuffer(env, p, size);
83 #endif
84 } else
85 return NULL;
86 }
87
88 static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) {
89 if (old_buffer != NULL) {
90 void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer);
91 jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer);
92 if (old_buffer_address == p && capacity == size)
93 return old_buffer;
94 }
95 return safeNewBuffer(env, p, size);
96
97 }
98
99 static inline void *offsetToPointer(jlong offset) {
100 return (char *)NULL + offset;
101 }
102
103 typedef void *(* ExtGetProcAddressPROC) (const char *func_name);
104 typedef struct {
105 char *method_name;
106 char *signature;
107 void *method_pointer;
108
109 char *ext_function_name;
110 void **ext_function_pointer;
111 } JavaMethodAndExtFunction;
112
113 typedef struct {
114 char *ext_function_name;
115 void **ext_function_pointer;
116 } ExtFunction;
117
118 #define NUMFUNCTIONS(x) (sizeof(x)/sizeof(JavaMethodAndExtFunction));
119
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123
124 extern JNIEnv *getThreadEnv();
125 extern void initAttribList(attrib_list_t *list);
126 extern void putAttrib(attrib_list_t *list, int attrib);
127
128 extern bool isDebugEnabled(void);
129 extern jstring getVersionString(JNIEnv *env);
130 extern void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err);
131 extern void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...);
132 extern void throwException(JNIEnv *env, const char *msg);
133 extern void throwFormattedException(JNIEnv * env, const char *format, ...);
134 extern void throwFMODException(JNIEnv * env, const char * err);
135 extern void setDebugEnabled(bool enable);
136 extern void printfDebugJava(JNIEnv *env, const char *format, ...);
137 extern void printfDebug(const char *format, ...);
138 extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
139 extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
140 extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length);
141 extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
142 extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
143 extern bool positionBuffer(JNIEnv *env, jobject buffer, jint position);
144
145 extern void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions);
146 extern bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions);
147
148 #ifdef __cplusplus
149 }
150 #endif
151
152 #endif
153
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 "extal.h"
34
35 typedef ALvoid* (ALAPIENTRY *alGetProcAddressPROC)(const ALubyte* fname);
36 /* alGetProcAddress is commented out, since we don't use it anyway */
37 //static alGetProcAddressPROC alGetProcAddress = NULL;
38
39 /**
40 * Initializes OpenAL by loading the library
41 */
42 /*void InitializeOpenAL(JNIEnv *env, jstring oalPath) {
43 //load our library
44 if (!tryLoadLibrary(env, oalPath)) {
45 throwException(env, "Could not load openal library.");
46 return;
47 }
48 alGetProcAddress = (alGetProcAddressPROC)NativeGetFunctionPointer("alGetProcAddress");
49 if (alGetProcAddress == NULL) {
50 UnLoadOpenAL();
51 throwException(env, "Could not load alGetProcAddress function pointer.");
52 return;
53 }
54 }*/
55
56 /**
57 * Retrieves a pointer to the named function
58 *
59 * @param function Name of function
60 * @return pointer to named function, or NULL if not found
61 */
62 void* extal_GetProcAddress(const char* function) {
63 void *p;
64 /* p = alGetProcAddress((const ALubyte*)function);
65 if (p == NULL) {*/
66 p = NativeGetFunctionPointer(function);
67 if (p == NULL) {
68 printfDebug("Could not locate symbol %s\n", function);
69 }
70 // }
71 return p;
72 }
73
74 void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
75 ext_InitializeClass(env, clazz, &extal_GetProcAddress, num_functions, functions);
76 }
77
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 _AL_TEST_H
33 #define _AL_TEST_H
34
35 #ifdef _WIN32
36 #include <windows.h>
37 #endif
38
39 #include <jni.h>
40 #include "common_tools.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #if defined(_WIN32)
47 #ifdef _OPENAL32LIB
48 #define ALCAPI __declspec(dllexport)
49 #else
50 #define ALCAPI __declspec(dllimport)
51 #endif
52
53 #define ALCAPIENTRY __cdecl
54 #else
55 #define ALCAPI
56 #define ALCAPIENTRY
57
58 #endif
59
60 #ifdef _WIN32
61 #ifdef _OPENAL32LIB
62 #define ALAPI __declspec(dllexport)
63 #else
64 #define ALAPI __declspec(dllimport)
65 #endif
66 #define ALAPIENTRY __cdecl
67 #define AL_CALLBACK
68 #else
69 #define ALAPI
70 #define ALAPIENTRY
71 #define AL_CALLBACK
72 #endif
73
74 #define INITGUID
75 #define OPENAL
76
77 // ALC typedefs
78 typedef struct ALCdevice_struct ALCdevice;
79 typedef struct ALCcontext_struct ALCcontext;
80 /** 8-bit boolean */
81 typedef char ALCboolean;
82
83 /** character */
84 typedef char ALCchar;
85
86 /** signed 8-bit 2's complement integer */
87 typedef char ALCbyte;
88
89 /** unsigned 8-bit integer */
90 typedef unsigned char ALCubyte;
91
92 /** signed 16-bit 2's complement integer */
93 typedef short ALCshort;
94
95 /** unsigned 16-bit integer */
96 typedef unsigned short ALCushort;
97
98 /** signed 32-bit 2's complement integer */
99 typedef int ALCint;
100
101 /** unsigned 32-bit integer */
102 typedef unsigned int ALCuint;
103
104 /** non-negative 32-bit binary integer size */
105 typedef int ALCsizei;
106
107 /** enumerated 32-bit value */
108 typedef int ALCenum;
109
110 /** 32-bit IEEE754 floating-point */
111 typedef float ALCfloat;
112
113 /** 64-bit IEEE754 floating-point */
114 typedef double ALCdouble;
115
116 /** void type (for opaque pointers only) */
117 typedef void ALCvoid;
118
119 // AL typedefs
120 /** 8-bit boolean */
121 typedef char ALboolean;
122
123 /** character */
124 typedef char ALchar;
125
126 /** signed 8-bit 2's complement integer */
127 typedef char ALbyte;
128
129 /** unsigned 8-bit integer */
130 typedef unsigned char ALubyte;
131
132 /** signed 16-bit 2's complement integer */
133 typedef short ALshort;
134
135 /** unsigned 16-bit integer */
136 typedef unsigned short ALushort;
137
138 /** signed 32-bit 2's complement integer */
139 typedef int ALint;
140
141 /** unsigned 32-bit integer */
142 typedef unsigned int ALuint;
143
144 /** non-negative 32-bit binary integer size */
145 typedef int ALsizei;
146
147 /** enumerated 32-bit value */
148 typedef int ALenum;
149
150 /** 32-bit IEEE754 floating-point */
151 typedef float ALfloat;
152
153 /** 64-bit IEEE754 floating-point */
154 typedef double ALdouble;
155
156 /** void type (for opaque pointers only) */
157 typedef void ALvoid;
158
159 void* extal_GetProcAddress(const char* function);
160 void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
161
162 /* Platform dependent functions */
163 void *NativeGetFunctionPointer(const char *function);
164 void tryLoadLibrary(JNIEnv *env, jstring path);
165 void UnLoadOpenAL();
166
167 #ifdef __cplusplus
168 }
169 #endif
170
171 #endif
0 /* ----------------------------------------------------------------------------
1 Copyright (c) 2001-2002, Lev Povalahev
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12 * The name of the author may be used to endorse or promote products
13 derived from this software without specific prior written permission.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 THE POSSIBILITY OF SUCH DAMAGE.
25 ------------------------------------------------------------------------------*/
26 /*
27 Lev Povalahev
28
29 levp@gmx.net
30
31 http://www.uni-karlsruhe.de/~uli2/
32
33 */
34
35 #include <stdio.h>
36 #include <string.h>
37 #include "extgl.h"
38 #include "common_tools.h"
39
40 void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
41 ext_InitializeClass(env, clazz, &extgl_GetProcAddress, num_functions, functions);
42 }
43
44 bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions) {
45 return ext_InitializeFunctions(&extgl_GetProcAddress, num_functions, functions);
46 }
47
48 bool extgl_QueryExtension(const GLubyte*extensions, const char *name)
49 {
50 const GLubyte *start;
51 GLubyte *where, *terminator;
52
53 if (extensions == NULL) {
54 printfDebug("NULL extension string\n");
55 return false;
56 }
57
58 /* Extension names should not have spaces. */
59 where = (GLubyte *) strchr(name, ' ');
60 if (where || *name == '\0')
61 return false;
62
63 /* It takes a bit of care to be fool-proof about parsing the
64 OpenGL extensions string. Don't be fooled by sub-strings,
65 etc. */
66 start = extensions;
67 for (;;)
68 {
69 where = (GLubyte *) strstr((const char *) start, name);
70 if (!where)
71 break;
72 terminator = where + strlen(name);
73 if (where == start || *(where - 1) == ' ')
74 if (*terminator == ' ' || *terminator == '\0') {
75 return true;
76 }
77 start = terminator;
78 }
79 return false;
80
81 }
82
0 /* Small parts were taken from Mesa's glext.h and gl.h, here's the license: */
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 6.5.1
5 *
6 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /* Some parts derived from files copyright (c) 2001-2002 Lev Povalahev under this license: */
27
28 /* ----------------------------------------------------------------------------
29 Copyright (c) 2002, Lev Povalahev
30 All rights reserved.
31
32 Redistribution and use in source and binary forms, with or without modification,
33 are permitted provided that the following conditions are met:
34
35 * Redistributions of source code must retain the above copyright notice,
36 this list of conditions and the following disclaimer.
37 * Redistributions in binary form must reproduce the above copyright notice,
38 this list of conditions and the following disclaimer in the documentation
39 and/or other materials provided with the distribution.
40 * The name of the author may be used to endorse or promote products
41 derived from this software without specific prior written permission.
42
43 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
44 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
47 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
49 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
52 THE POSSIBILITY OF SUCH DAMAGE.
53 ------------------------------------------------------------------------------*/
54 /*
55 GL_draw_range_elements support added by Benjamin Karaban
56
57 Lev Povalahev contact information:
58
59 levp@gmx.net
60
61 http://www.uni-karlsruhe.de/~uli2/
62 */
63
64 #ifndef __EXTGL_H__
65 #define __EXTGL_H__
66
67 #include <jni.h>
68
69 #include <string.h>
70 #include <stddef.h>
71
72 #include "common_tools.h"
73
74 #if defined(_WIN32) || defined(_WIN64)
75 #include <windows.h> // fix APIENTRY macro redefinition
76 # define int64_t __int64
77 # define uint64_t unsigned __int64
78 #endif
79
80 #ifndef APIENTRY
81 #define APIENTRY
82 #endif
83
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;
134
135 /* helper stuff */
136
137 /* initializes everything, call this right after the rc is created. the function returns true if successful */
138 extern bool extgl_Open(JNIEnv *env);
139 extern void extgl_Close(void);
140 extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
141 extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions);
142 extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name);
143 extern void *extgl_GetProcAddress(const char *name);
144
145 #endif /* __EXTGL_H__ */
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_openal_AL.h"
34 #include "extal.h"
35
36 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate(JNIEnv *env, jclass clazz, jstring oalPath) {
37 tryLoadLibrary(env, oalPath);
38 }
39
40 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy(JNIEnv *env, jclass clazz) {
41 UnLoadOpenAL();
42 }
43
44 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass al_class) {
45 (*env)->UnregisterNatives(env, al_class);
46 }
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 * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
34 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
37 * @author Brian Matzon <brian@matzon.dk>
38 * @version $Revision: 2279 $
39 */
40
41 /* OpenAL includes */
42 #include "extal.h"
43
44 //alc
45 typedef ALCubyte* (ALCAPIENTRY *alcGetStringPROC)(ALCdevice *device,ALCenum param);
46 typedef ALCvoid (ALCAPIENTRY *alcGetIntegervPROC)(ALCdevice *device,ALCenum param,ALCsizei size,ALCint *data);
47 typedef ALCdevice* (ALCAPIENTRY *alcOpenDevicePROC)(ALCubyte *deviceName);
48 typedef ALCboolean (ALCAPIENTRY *alcCloseDevicePROC)(ALCdevice *device);
49 typedef ALCcontext* (ALCAPIENTRY *alcCreateContextPROC)(ALCdevice *device,ALCint *attrList);
50 typedef ALCenum (ALCAPIENTRY *alcMakeContextCurrentPROC)(ALCcontext *context);
51 typedef ALCvoid (ALCAPIENTRY *alcProcessContextPROC)(ALCcontext *context);
52 typedef ALCdevice* (ALCAPIENTRY *alcGetContextsDevicePROC)(ALCcontext *context);
53 typedef ALCvoid (ALCAPIENTRY *alcSuspendContextPROC)(ALCcontext *context);
54 typedef ALCvoid (ALCAPIENTRY *alcDestroyContextPROC)(ALCcontext *context);
55 typedef ALCenum (ALCAPIENTRY *alcGetErrorPROC)(ALCdevice *device);
56 typedef ALCboolean (ALCAPIENTRY *alcIsExtensionPresentPROC)(ALCdevice *device,ALCubyte *extName);
57 //typedef ALCvoid* (ALCAPIENTRY *alcGetProcAddressPROC)(ALCdevice *device,ALCubyte *funcName);
58 typedef ALCenum (ALCAPIENTRY *alcGetEnumValuePROC)(ALCdevice *device,ALCubyte *enumName);
59 typedef ALCcontext* (ALCAPIENTRY *alcGetCurrentContextPROC)(ALCvoid);
60
61 static alcGetCurrentContextPROC alcGetCurrentContext = NULL;
62 static alcGetStringPROC alcGetString;
63 static alcGetIntegervPROC alcGetIntegerv;
64 static alcOpenDevicePROC alcOpenDevice;
65 static alcCloseDevicePROC alcCloseDevice;
66 static alcCreateContextPROC alcCreateContext;
67 static alcMakeContextCurrentPROC alcMakeContextCurrent;
68 static alcProcessContextPROC alcProcessContext;
69 static alcGetContextsDevicePROC alcGetContextsDevice;
70 static alcSuspendContextPROC alcSuspendContext;
71 static alcDestroyContextPROC alcDestroyContext;
72 static alcGetErrorPROC alcGetError;
73 static alcIsExtensionPresentPROC alcIsExtensionPresent;
74 //static alcGetProcAddressPROC alcGetProcAddress;
75 static alcGetEnumValuePROC alcGetEnumValue;
76
77 /**
78 * This function returns strings related to the context.
79 *
80 * C Specification:
81 * ALubyte * alcGetString(ALCdevice *device, ALenum token);
82 */
83 static jstring JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) {
84 const char* alcString = (const char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token);
85 int length;
86 int i=1;
87
88 if(alcString == NULL) {
89 return NULL;
90 }
91
92 // Special treatment of enumeration tokens
93 // These are encoded using \0 between elements and a finishing \0\0
94 switch(token) {
95 case 0x1005: // ALC_DEVICE_SPECIFIER
96 case 0x310: // ALC_CAPTURE_DEVICE_SPECIFIER
97 case 0x1013: // ALC_ALL_DEVICES_SPECIFIER
98 while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
99 i++;
100 }
101 length = i + 1;
102 break;
103 default:
104 length = strlen(alcString);
105 }
106 return NewStringNativeWithLength(env, alcString, length);
107 }
108
109 /**
110 * This function returns integers related to the context.
111 *
112 * C Specification:
113 * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest);
114 */
115 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jobject dest, jint offset) {
116 ALint* address = NULL;
117 if (dest != NULL) {
118 address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest);
119 }
120 alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address);
121 }
122
123 /**
124 * This function opens a device by name.
125 *
126 * C Specification:
127 * ALCdevice *alcOpenDevice( const ALubyte *tokstr );
128 */
129 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) {
130 char * tokenstring;
131 ALCdevice* device;
132
133 if(tokstr != NULL) {
134 tokenstring = GetStringNativeChars(env, tokstr);
135 } else {
136 tokenstring = NULL;
137 }
138
139 /* get device */
140 device = alcOpenDevice((ALubyte *) tokenstring);
141
142 if(tokenstring != NULL) {
143 free(tokenstring);
144 }
145
146 return (jlong)((intptr_t)device);
147 }
148
149 /**
150 * This function closes a device by name.
151 *
152 * C Specification:
153 * bool alcCloseDevice( ALCdevice *dev );
154 */
155 static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcCloseDevice (JNIEnv *env, jclass clazz, jlong deviceaddress) {
156 return alcCloseDevice((ALCdevice*)((intptr_t)deviceaddress));
157 }
158
159 /**
160 * This function creates a context using a specified device.
161 *
162 * C Specification:
163 * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist );
164 */
165 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) {
166 ALint* address = NULL;
167 ALCcontext* context;
168
169 if (attrlist != NULL) {
170 address = (ALint*) safeGetBufferAddress(env, attrlist);
171 }
172 context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address);
173
174 return (jlong)((intptr_t)context);
175 }
176
177 /**
178 * This function makes a specified context the current context.
179 *
180 * C Specification:
181 * ALCboolean alcMakeContextCurrent(ALCcontext *context);
182 */
183 static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) {
184 ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress);
185 return alcMakeContextCurrent(context);
186 }
187
188 /**
189 * This function tells a context to begin processing.
190 *
191 * C Specification:
192 * void alcProcessContext(ALCcontext *context);
193 */
194 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcProcessContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
195 alcProcessContext((ALCcontext*)((intptr_t)contextaddress));
196 }
197
198 /**
199 * This function retrieves the current context.
200 *
201 * C Specification:
202 * ALCcontext* alcGetCurrentContext( ALvoid );
203 */
204 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext (JNIEnv *env, jclass clazz) {
205 ALCcontext* context = alcGetCurrentContext();
206 return (jlong)((intptr_t)context);
207 }
208
209 /**
210 * This function retrieves the specified contexts device
211 *
212 * C Specification:
213 * ALCdevice* alcGetContextsDevice(ALCcontext *context);
214 */
215 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice (JNIEnv *env, jclass clazz, jlong contextaddress) {
216 ALCdevice* device = alcGetContextsDevice((ALCcontext*)((intptr_t)contextaddress));
217 return (jlong)((intptr_t)device);
218 }
219
220 /**
221 * This function suspends processing on a specified context.
222 *
223 * C Specification:
224 * void alcSuspendContext(ALCcontext *context);
225 */
226 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcSuspendContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
227 alcSuspendContext((ALCcontext*)((intptr_t)contextaddress));
228 }
229
230 /**
231 * This function destroys a context.
232 *
233 * C Specification:
234 * void alcDestroyContext(ALCcontext *context);
235 */
236 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcDestroyContext (JNIEnv *env, jclass clazz, jlong contextaddress) {
237 alcDestroyContext((ALCcontext*)((intptr_t)contextaddress));
238 }
239
240 /**
241 * This function retrieves the specified devices context error state.
242 *
243 * C Specification:
244 * ALCenum alcGetError(ALCdevice *device);
245 */
246 static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetError (JNIEnv *env, jclass clazz, jlong deviceaddress) {
247 return alcGetError((ALCdevice*)((intptr_t)deviceaddress));
248 }
249
250 /**
251 * This function queries if a specified context extension is available.
252 *
253 * C Specification:
254 * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName);
255 */
256 static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) {
257 /* get extension */
258 ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
259
260 jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname);
261
262 free(functionname);
263
264 return result;
265 }
266
267 /**
268 * This function retrieves the enum value for a specified enumeration name.
269 *
270 * C Specification:
271 * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName);
272 */
273 static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) {
274 /* get extension */
275 ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
276
277 jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname);
278
279 free(enumerationname);
280
281 return result;
282 }
283
284 /**
285 * Loads the context OpenAL functions
286 *
287 * @return true if all methods were loaded, false if one of the methods could not be loaded
288 */
289 #ifdef __cplusplus
290 extern "C" {
291 #endif
292 JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC10_initNativeStubs(JNIEnv *env, jclass clazz) {
293 JavaMethodAndExtFunction functions[] = {
294 {"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString},
295 {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv},
296 {"nalcOpenDevice", "(Ljava/lang/String;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice},
297 {"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice},
298 {"nalcCreateContext", "(JLjava/nio/IntBuffer;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
299 {"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent},
300 {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext},
301 {"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext},
302 {"nalcGetContextsDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice, "alcGetContextsDevice", (void*)&alcGetContextsDevice},
303 {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext},
304 {"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext},
305 {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError},
306 {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent},
307 {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue}
308 };
309 int num_functions = NUMFUNCTIONS(functions);
310 extal_InitializeClass(env, clazz, num_functions, functions);
311 }
312 #ifdef __cplusplus
313 }
314 #endif
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 * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
34 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
37 * @author Brian Matzon <brian@matzon.dk>
38 * @version $Revision: 2279 $
39 */
40
41 /* OpenAL includes */
42 #include "extal.h"
43
44 //alc
45 typedef ALCdevice * (ALCAPIENTRY *alcCaptureOpenDevicePROC)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
46 typedef ALCboolean (ALCAPIENTRY *alcCaptureCloseDevicePROC)( ALCdevice *device );
47 typedef void (ALCAPIENTRY *alcCaptureStartPROC)( ALCdevice *device );
48 typedef void (ALCAPIENTRY *alcCaptureStopPROC)( ALCdevice *device );
49 typedef void (ALCAPIENTRY *alcCaptureSamplesPROC)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
50
51 static alcCaptureOpenDevicePROC alcCaptureOpenDevice;
52 static alcCaptureCloseDevicePROC alcCaptureCloseDevice;
53 static alcCaptureStartPROC alcCaptureStart;
54 static alcCaptureStopPROC alcCaptureStop;
55 static alcCaptureSamplesPROC alcCaptureSamples;
56
57 /*
58 * Class: org_lwjgl_openal_ALC11
59 * Method: nalcCaptureOpenDevice
60 * Signature: (Ljava/lang/String;III)J
61 */
62 static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jstring devicename, jint frequency, jint format, jint buffersize) {
63 ALubyte* dev_name = NULL;
64 ALCdevice* device = NULL;
65
66 if(devicename != NULL) {
67 dev_name = (ALubyte*) GetStringNativeChars(env, devicename);
68 }
69
70 device = alcCaptureOpenDevice((const char *)dev_name, (unsigned int) frequency, format, buffersize);
71
72 free(dev_name);
73 return (jlong) ((intptr_t)device);
74 }
75
76 /*
77 * Class: org_lwjgl_openal_ALC11
78 * Method: nalcCaptureCloseDevice
79 * Signature: (J)Z
80 */
81 static jboolean JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice(JNIEnv *env, jclass clazz, jlong device) {
82 return (jboolean) alcCaptureCloseDevice((ALCdevice*) ((intptr_t)device));
83 }
84
85 /*
86 * Class: org_lwjgl_openal_ALC11
87 * Method: nalcCaptureStart
88 * Signature: (J)V
89 */
90 static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStart(JNIEnv *env, jclass clazz, jlong device) {
91 alcCaptureStart((ALCdevice*) ((intptr_t)device));
92 }
93
94 /*
95 * Class: org_lwjgl_openal_ALC11
96 * Method: nalcCaptureStop
97 * Signature: (J)V
98 */
99 static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStop(JNIEnv * env, jclass clazz, jlong device) {
100 alcCaptureStop((ALCdevice*) ((intptr_t)device));
101 }
102
103 /*
104 * Class: org_lwjgl_openal_ALC11
105 * Method: nalcCaptureSamples
106 * Signature: (JLjava/nio/ByteBuffer;I)V
107 */
108 static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, jint samples) {
109 ALvoid *buffer_address = ((ALbyte *)(((char*)(*env)->GetDirectBufferAddress(env, buffer)) + position));
110 alcCaptureSamples((ALCdevice*) ((intptr_t)device), buffer_address, samples);
111 }
112
113 /**
114 * Loads the context OpenAL functions
115 *
116 * @return true if all methods were loaded, false if one of the methods could not be loaded
117 */
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC11_initNativeStubs(JNIEnv *env, jclass clazz) {
122 JavaMethodAndExtFunction functions[] = {
123 {"nalcCaptureOpenDevice", "(Ljava/lang/String;III)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice},
124 {"nalcCaptureCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice, "alcCaptureCloseDevice", (void*)&alcCaptureCloseDevice},
125 {"nalcCaptureStart", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStart, "alcCaptureStart", (void*)&alcCaptureStart},
126 {"nalcCaptureStop", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStop, "alcCaptureStop", (void*)&alcCaptureStop},
127 {"nalcCaptureSamples", "(JLjava/nio/ByteBuffer;II)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples}
128 };
129 int num_functions = NUMFUNCTIONS(functions);
130 extal_InitializeClass(env, clazz, num_functions, functions);
131 }
132 #ifdef __cplusplus
133 }
134 #endif
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 * $Id: org_lwjgl_opengl_AWTSurfaceLock.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <jawt_md.h>
41 #include "org_lwjgl_opengl_AWTSurfaceLock.h"
42 #include "awt_tools.h"
43 #include "common_tools.h"
44
45 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_createHandle
46 (JNIEnv *env, jclass clazz) {
47 return newJavaManagedByteBuffer(env, sizeof(AWTSurfaceLock));
48 }
49
50 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_lockAndInitHandle
51 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject canvas) {
52 JAWT awt;
53 JAWT_DrawingSurface* ds;
54 JAWT_DrawingSurfaceInfo *dsi;
55 AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
56 awt.version = JAWT_VERSION_1_4;
57 if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
58 throwException(env, "Could not get the JAWT interface");
59 return JNI_FALSE;
60 }
61
62 ds = awt.GetDrawingSurface(env, canvas);
63 if (ds == NULL) {
64 throwException(env, "Could not get the drawing surface");
65 return JNI_FALSE;
66 }
67
68 if((ds->Lock(ds) & JAWT_LOCK_ERROR) != 0) {
69 awt.FreeDrawingSurface(ds);
70 throwException(env, "Could not lock the drawing surface");
71 return JNI_FALSE;
72 }
73
74 dsi = ds->GetDrawingSurfaceInfo(ds);
75 if (dsi != NULL) {
76 awt_lock->awt = awt;
77 awt_lock->ds = ds;
78 awt_lock->dsi = dsi;
79 return JNI_TRUE;
80 }
81 ds->Unlock(ds);
82 awt.FreeDrawingSurface(ds);
83 return JNI_FALSE;
84 }
85
86 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_nUnlock
87 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle) {
88 AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
89 awt_lock->ds->FreeDrawingSurfaceInfo(awt_lock->dsi);
90 awt_lock->ds->Unlock(awt_lock->ds);
91 awt_lock->awt.FreeDrawingSurface(awt_lock->ds);
92 }
93
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 "common_tools.h"
34 #include "org_lwjgl_opengl_GLContext.h"
35 #include "extgl.h"
36
37 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) {
38 jlong address_jlong;
39 char *function_name_pointer = GetStringNativeChars(env, function_name);
40 void *address = extgl_GetProcAddress(function_name_pointer);
41 free(function_name_pointer);
42 address_jlong = (jlong)(intptr_t)address;
43 return address_jlong;
44 }
45
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) {
47 extgl_Open(env);
48 }
49
50 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nUnloadOpenGLLibrary(JNIEnv * env, jclass clazz) {
51 extgl_Close();
52 }
53
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_resetNativeStubs(JNIEnv *env, jclass clazz, jclass gl_class) {
55 (*env)->UnregisterNatives(env, gl_class);
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
32 /**
33 * $Id: context.c 3116 2008-08-19 16:46:03Z spasi $
34 *
35 * Include file to access public window features
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3116 $
39 */
40
41 #include <jni.h>
42 #include <X11/X.h>
43 #include <X11/Xlib.h>
44 #include <X11/Xutil.h>
45 #include "extgl_glx.h"
46 #include "context.h"
47
48 XVisualInfo *getVisualInfoFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info) {
49 XVisualInfo *vis_info;
50 if (!peer_info->glx13) {
51 XVisualInfo template;
52 template.visualid = peer_info->config.glx_config.visualid;
53 template.depth = peer_info->config.glx_config.depth;
54 template.screen = peer_info->screen;
55 int num_infos;
56 vis_info = XGetVisualInfo(peer_info->display, VisualIDMask | VisualScreenMask | VisualDepthMask, &template, &num_infos);
57 if (vis_info == NULL) {
58 throwException(env, "Could not find VisualInfo from peer info");
59 return NULL;
60 }
61 // Check the assumption from GLX 1.3 docs that a VisualInfo is uniquely identified by its
62 // {VisualID, screen, depth} tuple
63 if (num_infos != 1) {
64 XFree(vis_info);
65 throwException(env, "No unique VisualInfo matches peer info");
66 return NULL;
67 }
68 } else {
69 GLXFBConfig *configs = getFBConfigFromPeerInfo(env, peer_info);
70 if (configs == NULL)
71 return NULL;
72 vis_info = lwjgl_glXGetVisualFromFBConfig(peer_info->display, configs[0]);
73 if (vis_info == NULL)
74 throwException(env, "Could not get VisualInfo from GLX 1.3 config");
75 XFree(configs);
76 }
77 return vis_info;
78 }
79
80 GLXFBConfig *getFBConfigFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info) {
81 int attribs[] = {GLX_FBCONFIG_ID, peer_info->config.glx13_config.config_id, None, None};
82 int num_elements;
83 GLXFBConfig *configs = lwjgl_glXChooseFBConfig(peer_info->display, peer_info->screen, attribs, &num_elements);
84 if (configs == NULL) {
85 throwException(env, "Could not find GLX 1.3 config from peer info");
86 return NULL;
87 }
88 // Check that only one FBConfig matches the config id
89 if (num_elements != 1) {
90 XFree(configs);
91 throwException(env, "No unique GLX 1.3 config matches peer info");
92 return NULL;
93 }
94 return configs;
95 }
96
97 static int convertToBPE(int bpp) {
98 int bpe;
99 switch (bpp) {
100 case 0:
101 bpe = 0;
102 break;
103 case 32:
104 case 24:
105 bpe = 8;
106 break;
107 case 16: /* Fall through */
108 default:
109 bpe = 4;
110 break;
111 }
112 return bpe;
113 }
114
115 static GLXFBConfig *chooseVisualGLX13FromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, int drawable_type, bool double_buffer) {
116 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
117 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
118 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
119 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
120 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
121 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
122 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
123 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
124
125 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
126 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
127 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
128 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
129
130 int bpe = convertToBPE(bpp);
131 int accum_bpe = convertToBPE(accum_bpp);
132 attrib_list_t attrib_list;
133 initAttribList(&attrib_list);
134 int render_type;
135
136 if ( floating_point )
137 render_type = GLX_RGBA_FLOAT_BIT;
138 else if ( floating_point_packed )
139 render_type = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
140 else
141 render_type = GLX_RGBA_BIT;
142
143 putAttrib(&attrib_list, GLX_RENDER_TYPE); putAttrib(&attrib_list, render_type);
144 putAttrib(&attrib_list, GLX_DOUBLEBUFFER); putAttrib(&attrib_list, double_buffer ? True : False);
145 putAttrib(&attrib_list, GLX_DRAWABLE_TYPE); putAttrib(&attrib_list, drawable_type);
146 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
147 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
148 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
149 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
150 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
151 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
152 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
153 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
154 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
155 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
156 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
157 if (stereo) {
158 putAttrib(&attrib_list, GLX_STEREO); putAttrib(&attrib_list, True);
159 }
160 // Assume the caller has checked support for multisample
161 if (samples > 0) {
162 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
163 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples);
164 }
165 if (sRGB) {
166 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True);
167 }
168 putAttrib(&attrib_list, None); putAttrib(&attrib_list, None);
169 int num_formats = 0;
170 GLXFBConfig* configs = lwjgl_glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats);
171 if (num_formats > 0) {
172 return configs;
173 } else {
174 if (configs != NULL)
175 XFree(configs);
176 return NULL;
177 }
178 }
179
180 GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer) {
181 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
182 int bpp;
183 if (use_display_bpp) {
184 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
185 GLXFBConfig *configs = chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
186 if (configs != NULL)
187 return configs;
188 else
189 bpp = 16;
190 } else
191 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
192 return chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
193 }
194
195 static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, bool double_buffer) {
196 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
197 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
198 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
199 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
200 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
201 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
202 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
203 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
204
205 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
206 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
207
208 int bpe = convertToBPE(bpp);
209 int accum_bpe = convertToBPE(accum_bpp);
210 attrib_list_t attrib_list;
211 initAttribList(&attrib_list);
212 putAttrib(&attrib_list, GLX_RGBA);
213 putAttrib(&attrib_list, GLX_DOUBLEBUFFER);
214 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
215 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
216 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
217 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
218 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
219 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
220 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
221 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
222 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
223 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
224 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
225 if (stereo)
226 putAttrib(&attrib_list, GLX_STEREO);
227 // Assume the caller has checked support for multisample
228 if (samples > 0) {
229 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
230 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples);
231 }
232 if (sRGB)
233 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
234 putAttrib(&attrib_list, None);
235 return lwjgl_glXChooseVisual(disp, screen, attrib_list.attribs);
236 }
237
238 XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer) {
239 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
240 int bpp;
241 if (use_display_bpp) {
242 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
243 XVisualInfo *vis_info = chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
244 if (vis_info != NULL)
245 return vis_info;
246 else
247 bpp = 16;
248 } else
249 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
250 return chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
251 }
252
253 static void dumpVisualInfo(JNIEnv *env, Display *display, GLXExtensions *extension_flags, XVisualInfo *vis_info) {
254 int alpha, depth, stencil, r, g, b;
255 int sample_buffers = 0;
256 int samples = 0;
257 lwjgl_glXGetConfig(display, vis_info, GLX_RED_SIZE, &r);
258 lwjgl_glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g);
259 lwjgl_glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b);
260 lwjgl_glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha);
261 lwjgl_glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth);
262 lwjgl_glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil);
263 if (extension_flags->GLX_ARB_multisample) {
264 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers);
265 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples);
266 }
267 printfDebugJava(env, "Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d", r, g, b, alpha, depth, stencil, sample_buffers, samples);
268 }
269
270 bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffered, bool force_glx13) {
271 if ((*env)->GetDirectBufferCapacity(env, peer_info_handle) < sizeof(X11PeerInfo)) {
272 throwException(env, "Handle too small");
273 return false;
274 }
275 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
276 GLXExtensions extension_flags;
277 if (!extgl_InitGLX(display, screen, &extension_flags)) {
278 throwException(env, "Could not init GLX");
279 return false;
280 }
281 if (!extension_flags.GLX13 && force_glx13) {
282 throwException(env, "GLX13 is required, but is not available");
283 return false;
284 }
285 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
286 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
287 if (samples > 0 && !extension_flags.GLX_ARB_multisample) {
288 throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample");
289 return false;
290 }
291 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
292 if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point
293 throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float");
294 return false;
295 }
296 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
297 if (floating_point_packed && !(extension_flags.GLX13 && extension_flags.GLX_EXT_fbconfig_packed_float)) { // We need GLX13 to support packed floating point
298 throwException(env, "Packed floating point specified but there's no support for GLX_EXT_fbconfig_packed_float");
299 return false;
300 }
301 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
302 if (sRGB && !extension_flags.GLX_ARB_framebuffer_sRGB) {
303 throwException(env, "sRGB specified but there's no support for GLX_ARB_framebuffer_sRGB");
304 return false;
305 }
306
307 peer_info->glx13 = extension_flags.GLX13;
308 if (peer_info->glx13) {
309 GLXFBConfig *configs = chooseVisualGLX13(env, display, screen, pixel_format, use_display_bpp, drawable_type, double_buffered);
310 if (configs == NULL) {
311 throwException(env, "Could not choose GLX13 config");
312 return false;
313 }
314 if (isDebugEnabled()) {
315 XVisualInfo *vis_info = lwjgl_glXGetVisualFromFBConfig(display, configs[0]);
316 if (vis_info != NULL) {
317 dumpVisualInfo(env, display, &extension_flags, vis_info);
318 XFree(vis_info);
319 }
320 }
321 int config_id;
322 int result = lwjgl_glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id);
323 XFree(configs);
324 if (result != Success) {
325 throwException(env, "Could not get GLX_FBCONFIG_ID from GLXFBConfig");
326 return false;
327 }
328 peer_info->config.glx13_config.config_id = config_id;
329 } else {
330 XVisualInfo *vis_info = chooseVisualGLX(env, display, screen, pixel_format, use_display_bpp, double_buffered);
331 if (vis_info == NULL) {
332 throwException(env, "Could not choose visual");
333 return false;
334 }
335 peer_info->config.glx_config.visualid = vis_info->visualid;
336 peer_info->config.glx_config.depth = vis_info->depth;
337 peer_info->screen = vis_info->screen;
338 if (isDebugEnabled())
339 dumpVisualInfo(env, display, &extension_flags, vis_info);
340 XFree(vis_info);
341 }
342 peer_info->display = display;
343 peer_info->screen = screen;
344 peer_info->drawable = None;
345 return true;
346 }
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 * $Id: context.h 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Include file to access public window features
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #ifndef _LWJGL_CONTEXT_H_INCLUDED_
42 #define _LWJGL_CONTEXT_H_INCLUDED_
43
44 #include <jni.h>
45 #include <X11/X.h>
46 #include <X11/Xlib.h>
47 #include <X11/Xutil.h>
48 #include "extgl_glx.h"
49
50 typedef struct {
51 VisualID visualid;
52 int depth;
53 } GLXConfig;
54
55 typedef struct {
56 GLXFBConfigID config_id;
57 } GLX13Config;
58
59 typedef struct {
60 Display *display;
61 int screen;
62 GLXDrawable drawable;
63 // This flag determines the appropriate glx struct
64 bool glx13;
65 union {
66 GLXConfig glx_config;
67 GLX13Config glx13_config;
68 } config;
69 } X11PeerInfo;
70
71 /* GLX 1.3 chooser */
72 extern GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer);
73
74 /* Default GLX chooser*/
75 extern XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer);
76
77 extern XVisualInfo *getVisualInfoFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info);
78 extern GLXFBConfig *getFBConfigFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info);
79
80 extern bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffered, bool force_glx13);
81
82 #endif /* _LWJGL_CONTEXT_H_INCLUDED_ */
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 * $Id: display.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Linux specific library for display handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/extensions/xf86vmode.h>
44 #include <X11/extensions/Xrandr.h>
45 #include <X11/Xutil.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <math.h>
49 #include "common_tools.h"
50 #include "org_lwjgl_opengl_LinuxDisplay.h"
51
52 #define NUM_XRANDR_RETRIES 5
53
54 typedef struct {
55 int width;
56 int height;
57 int freq;
58 union {
59 int size_index; // Data for Xrandr extension
60 XF86VidModeModeInfo xf86vm_modeinfo; // Data for XF86VidMode extension
61 } mode_data;
62 } mode_info;
63
64 static bool getXF86VidModeVersion(JNIEnv *env, Display *disp, int *major, int *minor) {
65 int event_base, error_base;
66
67 if (!XF86VidModeQueryExtension(disp, &event_base, &error_base)) {
68 printfDebugJava(env, "XF86VidMode extension not available");
69 return false;
70 }
71 if (!XF86VidModeQueryVersion(disp, major, minor)) {
72 throwException(env, "Could not query XF86VidMode version");
73 return false;
74 }
75 printfDebugJava(env, "XF86VidMode extension version %i.%i", *major, *minor);
76 return true;
77 }
78
79 static bool getXrandrVersion(JNIEnv *env, Display *disp, int *major, int *minor) {
80 int event_base, error_base;
81
82 if (!XRRQueryExtension(disp, &event_base, &error_base)) {
83 printfDebugJava(env, "Xrandr extension not available");
84 return false;
85 }
86 if (!XRRQueryVersion(disp, major, minor)) {
87 throwException(env, "Could not query Xrandr version");
88 return false;
89 }
90 printfDebugJava(env, "Xrandr extension version %i.%i", *major, *minor);
91 return true;
92 }
93
94 static bool isXrandrSupported(JNIEnv *env, Display *disp) {
95 int major, minor;
96 if (!getXrandrVersion(env, disp, &major, &minor))
97 return false;
98 return major >= 1;
99 }
100
101 static bool isXF86VidModeSupported(JNIEnv *env, Display *disp) {
102 int minor_ver, major_ver;
103 if (!getXF86VidModeVersion(env, disp, &major_ver, &minor_ver))
104 return false;
105 return major_ver >= 2;
106 }
107
108 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported(JNIEnv *env, jclass unused, jlong display) {
109 Display *disp = (Display *)(intptr_t)display;
110 jboolean result = isXrandrSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
111 return result;
112 }
113
114 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported(JNIEnv *env, jclass unused, jlong display) {
115 Display *disp = (Display *)(intptr_t)display;
116 jboolean result = isXF86VidModeSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
117 return result;
118 }
119
120 static mode_info *getXrandrDisplayModes(Display *disp, int screen, int *num_modes) {
121 int num_randr_sizes;
122 XRRScreenSize *sizes = XRRSizes(disp, screen, &num_randr_sizes);
123 mode_info *avail_modes = NULL;
124 int list_size = 0;
125 /* Count number of modes */
126 int i;
127 int mode_index = 0;
128 for (i = 0; i < num_randr_sizes; i++) {
129 int num_randr_rates;
130 short *freqs = XRRRates(disp, screen, i, &num_randr_rates);
131 int j;
132 for (j = 0; j < num_randr_rates; j++) {
133 if (list_size <= mode_index) {
134 list_size += 1;
135 avail_modes = (mode_info *)realloc(avail_modes, sizeof(mode_info)*list_size);
136 if (avail_modes == NULL)
137 return NULL;
138 }
139 avail_modes[mode_index].width = sizes[i].width;
140 avail_modes[mode_index].height = sizes[i].height;
141 avail_modes[mode_index].freq = freqs[j];
142 avail_modes[mode_index].mode_data.size_index = i;
143 mode_index++;
144 }
145 }
146 *num_modes = mode_index;
147 return avail_modes;
148 }
149
150 static mode_info *getXF86VidModeDisplayModes(Display *disp, int screen, int *num_modes) {
151 int num_xf86vm_modes;
152 XF86VidModeModeInfo **avail_xf86vm_modes;
153 XF86VidModeGetAllModeLines(disp, screen, &num_xf86vm_modes, &avail_xf86vm_modes);
154 mode_info *avail_modes = (mode_info *)malloc(sizeof(mode_info)*num_xf86vm_modes);
155 if (avail_modes == NULL) {
156 XFree(avail_xf86vm_modes);
157 return NULL;
158 }
159 int i;
160 for (i = 0; i < num_xf86vm_modes; i++) {
161 avail_modes[i].width = avail_xf86vm_modes[i]->hdisplay;
162 avail_modes[i].height = avail_xf86vm_modes[i]->vdisplay;
163 avail_modes[i].freq = 0; // No frequency support in XF86VidMode
164 avail_modes[i].mode_data.xf86vm_modeinfo = *avail_xf86vm_modes[i];
165 }
166 XFree(avail_xf86vm_modes);
167 *num_modes = num_xf86vm_modes;
168 return avail_modes;
169 }
170
171 static mode_info *getDisplayModes(Display *disp, int screen, jint extension, int *num_modes) {
172 switch (extension) {
173 case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE:
174 return getXF86VidModeDisplayModes(disp, screen, num_modes);
175 case org_lwjgl_opengl_LinuxDisplay_XRANDR:
176 return getXrandrDisplayModes(disp, screen, num_modes);
177 case org_lwjgl_opengl_LinuxDisplay_NONE:
178 // fall through
179 default:
180 return NULL;
181 }
182 }
183
184 static bool setXF86VidModeMode(Display *disp, int screen, mode_info *mode) {
185 return True == XF86VidModeSwitchToMode(disp, screen, &mode->mode_data.xf86vm_modeinfo);
186 }
187
188 /* Try to set the mode specified through XRandR.
189 * Return value is the Status code of the mode switch
190 * The timestamp parameter is filled with the latest timestamp returned from XRRConfigTimes
191 */
192 static Status trySetXrandrMode(Display *disp, int screen, mode_info *mode, Time *timestamp) {
193 Status status;
194 Drawable root_window = RootWindow(disp, screen);
195 XRRScreenConfiguration *screen_configuration = XRRGetScreenInfo(disp, root_window);
196 Time config_time;
197 *timestamp = XRRConfigTimes(screen_configuration, &config_time);
198 Rotation current_rotation;
199 XRRConfigCurrentConfiguration(screen_configuration, &current_rotation);
200 status = XRRSetScreenConfigAndRate(disp, screen_configuration, root_window, mode->mode_data.size_index, current_rotation, mode->freq, *timestamp);
201 XRRFreeScreenConfigInfo(screen_configuration);
202 return status;
203 }
204
205 static bool setXrandrMode(Display *disp, int screen, mode_info *mode) {
206 int iteration;
207 Time timestamp;
208 Status status = trySetXrandrMode(disp, screen, mode, &timestamp);
209 if (status == 0)
210 return true; // Success
211 Time new_timestamp;
212 for (iteration = 0; iteration < NUM_XRANDR_RETRIES; iteration++) {
213 status = trySetXrandrMode(disp, screen, mode, &new_timestamp);
214 if (status == 0)
215 return true; // Success
216 if (new_timestamp == timestamp) {
217 return false; // Failure, and the stamps are equal meaning that the failure is not merely transient
218 }
219 timestamp = new_timestamp;
220 }
221 return false;
222 }
223
224 static bool setMode(JNIEnv *env, Display *disp, int screen, jint extension, int width, int height, int freq) {
225 int num_modes, i;
226 mode_info *avail_modes = getDisplayModes(disp, screen, extension, &num_modes);
227 if (avail_modes == NULL) {
228 printfDebugJava(env, "Could not get display modes");
229 return false;
230 }
231 bool result = false;
232 for (i = 0; i < num_modes; ++i) {
233 printfDebugJava(env, "Mode %d: %dx%d @%d", i, avail_modes[i].width, avail_modes[i].height, avail_modes[i].freq);
234 if (avail_modes[i].width == width && avail_modes[i].height == height && avail_modes[i].freq == freq) {
235 switch (extension) {
236 case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE:
237 if (!setXF86VidModeMode(disp, screen, &avail_modes[i])) {
238 printfDebugJava(env, "Could not switch mode");
239 continue;
240 }
241 break;
242 case org_lwjgl_opengl_LinuxDisplay_XRANDR:
243 if (!setXrandrMode(disp, screen, &avail_modes[i])) {
244 printfDebugJava(env, "Could not switch mode");
245 continue;
246 }
247 break;
248 case org_lwjgl_opengl_LinuxDisplay_NONE: // Should never happen, since NONE imply no available display modes
249 default: // Should never happen
250 continue;
251 }
252 result = true;
253 break;
254 }
255 }
256 free(avail_modes);
257 XFlush(disp);
258 return result;
259 }
260
261 static int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) {
262 int ramp_size;
263 if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) {
264 throwException(env, "XF86VidModeGetGammaRampSize call failed");
265 return 0;
266 }
267 return ramp_size;
268 }
269
270 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nConvertToNativeRamp(JNIEnv *env, jclass unused, jobject ramp_buffer, jint buffer_offset, jint length) {
271 const jfloat *ramp_ptr = (const jfloat *)(*env)->GetDirectBufferAddress(env, ramp_buffer) + buffer_offset;
272 jobject native_ramp = newJavaManagedByteBuffer(env, length*3*sizeof(unsigned short));
273 if (native_ramp == NULL) {
274 throwException(env, "Failed to allocate gamma ramp buffer");
275 return NULL;
276 }
277 unsigned short *native_ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, native_ramp);
278 int i;
279 for (i = 0; i < length; i++) {
280 float scaled_gamma = ramp_ptr[i]*0xffff;
281 short scaled_gamma_short = (unsigned short)roundf(scaled_gamma);
282 native_ramp_ptr[i] = scaled_gamma_short;
283 native_ramp_ptr[i + length] = scaled_gamma_short;
284 native_ramp_ptr[i + length*2] = scaled_gamma_short;
285 }
286 return native_ramp;
287 }
288
289 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused, jlong display, jint screen) {
290 Display *disp = (Display *)(intptr_t)display;
291 int ramp_size = getGammaRampLengthOfDisplay(env, disp, screen);
292 jobject ramp_buffer = newJavaManagedByteBuffer(env, sizeof(unsigned short)*3*ramp_size);
293 if (ramp_buffer == NULL) {
294 throwException(env, "Could not allocate gamma ramp buffer");
295 return NULL;
296 }
297 unsigned short *ramp = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer);
298 if (!XF86VidModeGetGammaRamp(disp, screen, ramp_size, ramp,
299 ramp + ramp_size, ramp + ramp_size*2)) {
300 throwException(env, "Could not get the current gamma ramp");
301 return NULL;
302 }
303 return ramp_buffer;
304 }
305
306 static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer) {
307 if (ramp_buffer == NULL)
308 return;
309 unsigned short *ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer);
310 jlong capacity = (*env)->GetDirectBufferCapacity(env, ramp_buffer);
311 int size = capacity/(sizeof(unsigned short)*3);
312 if (size == 0)
313 return;
314 if (XF86VidModeSetGammaRamp(disp, screen, size, ramp_ptr, ramp_ptr + size, ramp_ptr + size*2) == False) {
315 throwException(env, "Could not set gamma ramp.");
316 }
317 }
318
319 static bool switchDisplayMode(JNIEnv * env, Display *disp, int screen, jint extension, jobject mode) {
320 if (mode == NULL) {
321 throwException(env, "mode must be non-null");
322 return false;
323 }
324 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
325 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
326 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
327 jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I");
328 int width = (*env)->GetIntField(env, mode, fid_width);
329 int height = (*env)->GetIntField(env, mode, fid_height);
330 int freq = (*env)->GetIntField(env, mode, fid_freq);
331 if (!setMode(env, disp, screen, extension, width, height, freq)) {
332 throwException(env, "Could not switch mode.");
333 return false;
334 }
335 return true;
336 }
337
338 static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) {
339 int num_modes, i;
340 mode_info *avail_modes;
341 int bpp = XDefaultDepth(disp, screen);
342 avail_modes = getDisplayModes(disp, screen, extension, &num_modes);
343 if (avail_modes == NULL) {
344 printfDebugJava(env, "Could not get display modes");
345 return NULL;
346 }
347 // Allocate an array of DisplayModes big enough
348 jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
349 jobjectArray ret = (*env)->NewObjectArray(env, num_modes, displayModeClass, NULL);
350 jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
351
352 for (i = 0; i < num_modes; i++) {
353 jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, avail_modes[i].width, avail_modes[i].height, bpp, avail_modes[i].freq);
354 (*env)->SetObjectArrayElement(env, ret, i, displayMode);
355 }
356 free(avail_modes);
357 return ret;
358 }
359
360 static jobject getCurrentXRandrMode(JNIEnv * env, Display *disp, int screen) {
361 Drawable root_window = RootWindow(disp, screen);
362 XRRScreenConfiguration *config = XRRGetScreenInfo(disp, root_window);
363 if (config == NULL) {
364 throwException(env, "Could not get current screen configuration.");
365 return NULL;
366 }
367 short rate = XRRConfigCurrentRate(config);
368 Rotation current_rotation;
369 SizeID size_index = XRRConfigCurrentConfiguration(config, &current_rotation);
370 int n_sizes;
371 XRRScreenSize *sizes = XRRConfigSizes(config, &n_sizes);
372 if (size_index >= n_sizes) {
373 throwFormattedException(env, "Xrandr current index (%d) is larger than or equals to the number of sizes (%d).", size_index, n_sizes);
374 XRRFreeScreenConfigInfo(config);
375 return NULL;
376 }
377 XRRScreenSize current_size = sizes[size_index];
378 XRRFreeScreenConfigInfo(config);
379 int bpp = XDefaultDepth(disp, screen);
380 jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
381 jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
382 jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, current_size.width, current_size.height, bpp, rate);
383 return displayMode;
384 }
385
386 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display, jint screen) {
387 Display *disp = (Display *)(intptr_t)display;
388 return getCurrentXRandrMode(env, disp, screen);
389 }
390
391 JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension) {
392 Display *disp = (Display *)(intptr_t)display;
393 return getAvailableDisplayModes(env, disp, screen, extension);
394 }
395
396 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) {
397 Display *disp = (Display *)(intptr_t)display;
398 switchDisplayMode(env, disp, screen, extension, mode);
399 }
400
401 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz, jlong display_ptr, jint screen) {
402 Display *disp = (Display *)(intptr_t)display_ptr;
403 return (jint)getGammaRampLengthOfDisplay(env, disp, screen);
404 }
405
406 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) {
407 Display *disp = (Display *)(intptr_t)display;
408 setGamma(env, disp, screen, gamma_buffer);
409 }
410
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 #include <dlfcn.h>
32 #include "extgl_glx.h"
33
34 glXGetFBConfigsPROC lwjgl_glXGetFBConfigs = NULL;
35 glXChooseFBConfigPROC lwjgl_glXChooseFBConfig = NULL;
36 glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib = NULL;
37 glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig = NULL;
38 glXCreateWindowPROC lwjgl_glXCreateWindow = NULL;
39 glXDestroyWindowPROC lwjgl_glXDestroyWindow = NULL;
40 glXCreatePixmapPROC lwjgl_glXCreatePixmap = NULL;
41 glXDestroyPixmapPROC lwjgl_glXDestroyPixmap = NULL;
42 glXCreatePbufferPROC lwjgl_glXCreatePbuffer = NULL;
43 glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer = NULL;
44 glXQueryDrawablePROC lwjgl_glXQueryDrawable = NULL;
45 glXCreateNewContextPROC lwjgl_glXCreateNewContext = NULL;
46 glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent = NULL;
47 glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable = NULL;
48 glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay = NULL;
49 glXQueryContextPROC lwjgl_glXQueryContext = NULL;
50 glXSelectEventPROC lwjgl_glXSelectEvent = NULL;
51 glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent = NULL;
52 glXChooseVisualPROC lwjgl_glXChooseVisual = NULL;
53 glXCopyContextPROC lwjgl_glXCopyContext = NULL;
54 glXCreateContextPROC lwjgl_glXCreateContext = NULL;
55 glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap = NULL;
56 glXDestroyContextPROC lwjgl_glXDestroyContext = NULL;
57 glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap = NULL;
58 glXGetConfigPROC lwjgl_glXGetConfig = NULL;
59 glXGetCurrentContextPROC lwjgl_glXGetCurrentContext = NULL;
60 glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable = NULL;
61 glXIsDirectPROC lwjgl_glXIsDirect = NULL;
62 glXMakeCurrentPROC lwjgl_glXMakeCurrent = NULL;
63 glXQueryExtensionPROC lwjgl_glXQueryExtension = NULL;
64 glXQueryVersionPROC lwjgl_glXQueryVersion = NULL;
65 glXSwapBuffersPROC lwjgl_glXSwapBuffers = NULL;
66 glXUseXFontPROC lwjgl_glXUseXFont = NULL;
67 glXWaitGLPROC lwjgl_glXWaitGL = NULL;
68 glXWaitXPROC lwjgl_glXWaitX = NULL;
69 glXGetClientStringPROC lwjgl_glXGetClientString = NULL;
70 glXQueryServerStringPROC lwjgl_glXQueryServerString = NULL;
71 glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString = NULL;
72
73 /* GLX_SGI_swap_control */
74 glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI = NULL;
75
76 /* GLX_ARB_create_context */
77 glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB = NULL;
78
79 static void * lib_gl_handle = NULL;
80
81 typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName);
82
83 static glXGetProcAddressARBPROC lwjgl_glXGetProcAddressARB;
84
85 static GLXExtensions symbols_flags;
86
87 /** returns true if the extention is available */
88 static bool GLXQueryExtension(Display *disp, int screen, const char *name) {
89 const GLubyte *exts = (const GLubyte *)lwjgl_glXQueryExtensionsString(disp, screen);
90 return extgl_QueryExtension(exts, name);
91 }
92
93 static void extgl_InitGLX13() {
94 ExtFunction functions[] = {
95 {"glXGetFBConfigs", (void*)&lwjgl_glXGetFBConfigs},
96 {"glXChooseFBConfig", (void*)&lwjgl_glXChooseFBConfig},
97 {"glXGetFBConfigAttrib", (void*)&lwjgl_glXGetFBConfigAttrib},
98 {"glXGetVisualFromFBConfig", (void*)&lwjgl_glXGetVisualFromFBConfig},
99 {"glXCreateWindow", (void*)&lwjgl_glXCreateWindow},
100 {"glXDestroyWindow", (void*)&lwjgl_glXDestroyWindow},
101 {"glXCreatePixmap", (void*)&lwjgl_glXCreatePixmap},
102 {"glXDestroyPixmap", (void*)&lwjgl_glXDestroyPixmap},
103 {"glXCreatePbuffer", (void*)&lwjgl_glXCreatePbuffer},
104 {"glXDestroyPbuffer", (void*)&lwjgl_glXDestroyPbuffer},
105 {"glXQueryDrawable", (void*)&lwjgl_glXQueryDrawable},
106 {"glXCreateNewContext", (void*)&lwjgl_glXCreateNewContext},
107 {"glXMakeContextCurrent", (void*)&lwjgl_glXMakeContextCurrent},
108 {"glXGetCurrentReadDrawable", (void*)&lwjgl_glXGetCurrentReadDrawable},
109 {"glXGetCurrentDisplay", (void*)&lwjgl_glXGetCurrentDisplay},
110 {"glXQueryContext", (void*)&lwjgl_glXQueryContext},
111 {"glXSelectEvent", (void*)&lwjgl_glXSelectEvent},
112 {"glXGetSelectedEvent", (void*)&lwjgl_glXGetSelectedEvent}};
113 symbols_flags.GLX13 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
114 }
115
116 static void extgl_InitGLX12(void) {
117 ExtFunction functions[] = {
118 {"glXChooseVisual", (void*)&lwjgl_glXChooseVisual},
119 {"glXCopyContext", (void*)&lwjgl_glXCopyContext},
120 {"glXCreateContext", (void*)&lwjgl_glXCreateContext},
121 {"glXCreateGLXPixmap", (void*)&lwjgl_glXCreateGLXPixmap},
122 {"glXDestroyContext", (void*)&lwjgl_glXDestroyContext},
123 {"glXDestroyGLXPixmap", (void*)&lwjgl_glXDestroyGLXPixmap},
124 {"glXGetConfig", (void*)&lwjgl_glXGetConfig},
125 {"glXGetCurrentContext", (void*)&lwjgl_glXGetCurrentContext},
126 {"glXGetCurrentDrawable", (void*)&lwjgl_glXGetCurrentDrawable},
127 {"glXIsDirect", (void*)&lwjgl_glXIsDirect},
128 {"glXMakeCurrent", (void*)&lwjgl_glXMakeCurrent},
129 {"glXQueryExtension", (void*)&lwjgl_glXQueryExtension},
130 {"glXQueryVersion", (void*)&lwjgl_glXQueryVersion},
131 {"glXSwapBuffers", (void*)&lwjgl_glXSwapBuffers},
132 {"glXUseXFont", (void*)&lwjgl_glXUseXFont},
133 {"glXWaitGL", (void*)&lwjgl_glXWaitGL},
134 {"glXWaitX", (void*)&lwjgl_glXWaitX},
135 {"glXGetClientString", (void*)&lwjgl_glXGetClientString},
136 {"glXQueryServerString", (void*)&lwjgl_glXQueryServerString},
137 {"glXQueryExtensionsString", (void*)&lwjgl_glXQueryExtensionsString}};
138 symbols_flags.GLX12 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
139 }
140
141 static void extgl_InitGLXSGISwapControl() {
142 ExtFunction functions[] = {
143 {"glXSwapIntervalSGI", (void*)&lwjgl_glXSwapIntervalSGI}};
144 symbols_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
145 }
146
147 static void extgl_InitGLXARBCreateContext() {
148 ExtFunction functions[] = {
149 {"glXCreateContextAttribsARB", (void*)&lwjgl_glXCreateContextAttribsARB}};
150 symbols_flags.GLX_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
151 }
152
153 static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExtensions *extension_flags) {
154 /* extension_flags.GLX_EXT_visual_info = GLXQueryExtension(disp, screen, "GLX_EXT_visual_info");
155 extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(disp, screen, "GLX_EXT_visual_rating");*/
156 extension_flags->GLX_SGI_swap_control = symbols_flags.GLX_SGI_swap_control && GLXQueryExtension(disp, screen, "GLX_SGI_swap_control");
157 extension_flags->GLX_ARB_multisample = GLXQueryExtension(disp, screen, "GLX_ARB_multisample");
158 extension_flags->GLX_ARB_fbconfig_float = GLXQueryExtension(disp, screen, "GLX_ARB_fbconfig_float");
159 extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(disp, screen, "GLX_EXT_fbconfig_packed_float");
160 extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB");
161 extension_flags->GLX_ARB_create_context = GLXQueryExtension(disp, screen, "GLX_ARB_create_context");
162 }
163
164 bool extgl_Open(JNIEnv *env) {
165 if (lib_gl_handle != NULL)
166 return true;
167 /*
168 * Actually we don't need the RTLD_GLOBAL flag, since the symbols
169 * we load should be private to us. However, according to the
170 * documentation at
171 *
172 * http://dri.sourceforge.net/doc/DRIuserguide.html
173 *
174 * DRI drivers need this flag to work properly
175 */
176 lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
177 if (lib_gl_handle == NULL) {
178 throwFormattedException(env, "Error loading libGL.so.1: %s", dlerror());
179 return false;
180 }
181 lwjgl_glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB");
182 if (lwjgl_glXGetProcAddressARB == NULL) {
183 extgl_Close();
184 throwException(env, "Could not get address of glXGetProcAddressARB");
185 return false;
186 }
187 /* Unlike Windows, GLX function addresses are context-independent
188 * so we only have to initialize the addresses once at load
189 */
190 extgl_InitGLX12();
191 extgl_InitGLX13();
192 extgl_InitGLXSGISwapControl();
193 extgl_InitGLXARBCreateContext();
194 return true;
195 }
196
197 void *extgl_GetProcAddress(const char *name) {
198 void *t = (void*)lwjgl_glXGetProcAddressARB((const GLubyte*)name);
199 if (t == NULL) {
200 t = dlsym(lib_gl_handle, name);
201 if (t == NULL) {
202 printfDebug("Could not locate symbol %s\n", name);
203 }
204 }
205 return t;
206 }
207
208 void extgl_Close(void) {
209 dlclose(lib_gl_handle);
210 lib_gl_handle = NULL;
211 }
212
213 bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags) {
214 int major, minor;
215 /* Assume glx ver >= 1.2 */
216 // Check GLX 1.2 symbols available
217 if (!symbols_flags.GLX12)
218 return false;
219 if (lwjgl_glXQueryVersion(disp, &major, &minor) != True)
220 return false;
221 bool glx12 = major > 1 || (major == 1 && minor >= 2);
222 // Check GLX 1.2 version
223 if (!glx12)
224 return false;
225 extension_flags->GLX12 = glx12;
226 extension_flags->GLX13 = major > 1 || (major == 1 && minor >= 3);
227 extension_flags->GLX14 = major > 1 || (major == 1 && minor >= 4);
228 extgl_InitGLXSupportedExtensions(disp, screen, extension_flags);
229 return true;
230 }
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 EXTGL_GLX_H
33 #define EXTGL_GLX_H
34
35 #include <X11/Xutil.h>
36 #include "extgl.h"
37
38 /*
39 * Names for attributes to lwjgl_glXGetConfig.
40 */
41 #define GLX_USE_GL 1 /* support GLX rendering */
42 #define GLX_BUFFER_SIZE 2 /* depth of the color buffer */
43 #define GLX_LEVEL 3 /* level in plane stacking */
44 #define GLX_RGBA 4 /* true if RGBA mode */
45 #define GLX_DOUBLEBUFFER 5 /* double buffering supported */
46 #define GLX_STEREO 6 /* stereo buffering supported */
47 #define GLX_AUX_BUFFERS 7 /* number of aux buffers */
48 #define GLX_RED_SIZE 8 /* number of red component bits */
49 #define GLX_GREEN_SIZE 9 /* number of green component bits */
50 #define GLX_BLUE_SIZE 10 /* number of blue component bits */
51 #define GLX_ALPHA_SIZE 11 /* number of alpha component bits */
52 #define GLX_DEPTH_SIZE 12 /* number of depth bits */
53 #define GLX_STENCIL_SIZE 13 /* number of stencil bits */
54 #define GLX_ACCUM_RED_SIZE 14 /* number of red accum bits */
55 #define GLX_ACCUM_GREEN_SIZE 15 /* number of green accum bits */
56 #define GLX_ACCUM_BLUE_SIZE 16 /* number of blue accum bits */
57 #define GLX_ACCUM_ALPHA_SIZE 17 /* number of alpha accum bits */
58
59 #define GLX_SAMPLE_BUFFERS_ARB 100000 /* number of multisample buffers */
60 #define GLX_SAMPLES_ARB 100001 /* number of multisample samples */
61
62 /*
63 * FBConfig-specific attributes
64 */
65 #define GLX_X_VISUAL_TYPE 0x22
66 #define GLX_CONFIG_CAVEAT 0x20 /* Like visual_info VISUAL_CAVEAT */
67 #define GLX_TRANSPARENT_TYPE 0x23
68 #define GLX_TRANSPARENT_INDEX_VALUE 0x24
69 #define GLX_TRANSPARENT_RED_VALUE 0x25
70 #define GLX_TRANSPARENT_GREEN_VALUE 0x26
71 #define GLX_TRANSPARENT_BLUE_VALUE 0x27
72 #define GLX_TRANSPARENT_ALPHA_VALUE 0x28
73 #define GLX_DRAWABLE_TYPE 0x8010
74 #define GLX_RENDER_TYPE 0x8011
75 #define GLX_X_RENDERABLE 0x8012
76 #define GLX_FBCONFIG_ID 0x8013
77 #define GLX_MAX_PBUFFER_WIDTH 0x8016
78 #define GLX_MAX_PBUFFER_HEIGHT 0x8017
79 #define GLX_MAX_PBUFFER_PIXELS 0x8018
80 #define GLX_VISUAL_ID 0x800B
81
82 #define GLX_DRAWABLE_TYPE_SGIX GLX_DRAWABLE_TYPE
83 #define GLX_RENDER_TYPE_SGIX GLX_RENDER_TYPE
84 #define GLX_X_RENDERABLE_SGIX GLX_X_RENDERABLE
85 #define GLX_FBCONFIG_ID_SGIX GLX_FBCONFIG_ID
86 #define GLX_MAX_PBUFFER_WIDTH_SGIX GLX_MAX_PBUFFER_WIDTH
87 #define GLX_MAX_PBUFFER_HEIGHT_SGIX GLX_MAX_PBUFFER_HEIGHT
88 #define GLX_MAX_PBUFFER_PIXELS_SGIX GLX_MAX_PBUFFER_PIXELS
89 #define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
90 #define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
91
92 /*
93 * Error return values from lwjgl_glXGetConfig. Success is indicated by
94 * a value of 0.
95 */
96 #define GLX_BAD_SCREEN 1 /* screen # is bad */
97 #define GLX_BAD_ATTRIBUTE 2 /* attribute to get is bad */
98 #define GLX_NO_EXTENSION 3 /* no glx extension on server */
99 #define GLX_BAD_VISUAL 4 /* visual # not known by GLX */
100 #define GLX_BAD_CONTEXT 5
101 #define GLX_BAD_VALUE 6
102 #define GLX_BAD_ENUM 7
103
104
105 /* FBConfig attribute values */
106
107 /*
108 * Generic "don't care" value for lwjgl_glX ChooseFBConfig attributes (except
109 * GLX_LEVEL).
110 */
111 #define GLX_DONT_CARE 0xFFFFFFFF
112
113 /* GLX_RENDER_TYPE bits */
114 #define GLX_RGBA_BIT 0x00000001
115 #define GLX_COLOR_INDEX_BIT 0x00000002
116 #define GLX_RGBA_BIT_SGIX GLX_RGBA_BIT
117 #define GLX_COLOR_INDEX_BIT_SGIX GLX_COLOR_INDEX_BIT
118
119 /* GLX_DRAWABLE_TYPE bits */
120 #define GLX_WINDOW_BIT 0x00000001
121 #define GLX_PIXMAP_BIT 0x00000002
122 #define GLX_PBUFFER_BIT 0x00000004
123 #define GLX_WINDOW_BIT_SGIX GLX_WINDOW_BIT
124 #define GLX_PIXMAP_BIT_SGIX GLX_PIXMAP_BIT
125 #define GLX_PBUFFER_BIT_SGIX GLX_PBUFFER_BIT
126
127 /* GLX_CONFIG_CAVEAT attribute values */
128 #define GLX_NONE 0x8000
129 #define GLX_SLOW_CONFIG 0x8001
130 #define GLX_NON_CONFORMANT_CONFIG 0x800D
131
132 /* GLX_X_VISUAL_TYPE attribute values */
133 #define GLX_TRUE_COLOR 0x8002
134 #define GLX_DIRECT_COLOR 0x8003
135 #define GLX_PSEUDO_COLOR 0x8004
136 #define GLX_STATIC_COLOR 0x8005
137 #define GLX_GRAY_SCALE 0x8006
138 #define GLX_STATIC_GRAY 0x8007
139
140 /* GLX_TRANSPARENT_TYPE attribute values */
141 /* #define GLX_NONE 0x8000 */
142 #define GLX_TRANSPARENT_RGB 0x8008
143 #define GLX_TRANSPARENT_INDEX 0x8009
144
145 /* lwjgl_glXCreateGLXPbuffer attributes */
146 #define GLX_PRESERVED_CONTENTS 0x801B
147 #define GLX_LARGEST_PBUFFER 0x801C
148 #define GLX_PBUFFER_HEIGHT 0x8040 /* New for GLX 1.3 */
149 #define GLX_PBUFFER_WIDTH 0x8041 /* New for GLX 1.3 */
150 #define GLX_PRESERVED_CONTENTS_SGIX GLX_PRESERVED_CONTENTS
151 #define GLX_LARGEST_PBUFFER_SGIX GLX_LARGEST_PBUFFER
152
153 /* lwjgl_glXQueryGLXPBuffer attributes */
154 #define GLX_WIDTH 0x801D
155 #define GLX_HEIGHT 0x801E
156 #define GLX_EVENT_MASK 0x801F
157 #define GLX_WIDTH_SGIX GLX_WIDTH
158 #define GLX_HEIGHT_SGIX GLX_HEIGHT
159 #define GLX_EVENT_MASK_SGIX GLX_EVENT_MASK
160
161 /* lwjgl_glXCreateNewContext render_type attribute values */
162 #define GLX_RGBA_TYPE 0x8014
163 #define GLX_COLOR_INDEX_TYPE 0x8015
164 #define GLX_RGBA_TYPE_SGIX GLX_RGBA_TYPE
165 #define GLX_COLOR_INDEX_TYPE_SGIX GLX_COLOR_INDEX_TYPE
166
167 /* lwjgl_glXQueryContext attributes */
168 /* #define GLX_FBCONFIG_ID 0x8013 */
169 /* #define GLX_RENDER_TYPE 0x8011 */
170 #define GLX_SCREEN 0x800C
171
172 /* lwjgl_glXSelectEvent event mask bits */
173 #define GLX_PBUFFER_CLOBBER_MASK 0x08000000
174 #define GLX_PBUFFER_CLOBBER_MASK_SGIX GLX_PBUFFER_CLOBBER_MASK
175
176 /* GLXPbufferClobberEvent event_type values */
177 #define GLX_DAMAGED 0x8020
178 #define GLX_SAVED 0x8021
179 #define GLX_DAMAGED_SGIX GLX_DAMAGED
180 #define GLX_SAVED_SGIX GLX_SAVED
181
182 /* GLXPbufferClobberEvent draw_type values */
183 #define GLX_WINDOW 0x8022
184 #define GLX_PBUFFER 0x8023
185 #define GLX_WINDOW_SGIX GLX_WINDOW
186 #define GLX_PBUFFER_SGIX GLX_PBUFFER
187
188 /* GLXPbufferClobberEvent buffer_mask bits */
189 #define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
190 #define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
191 #define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
192 #define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
193 #define GLX_AUX_BUFFERS_BIT 0x00000010
194 #define GLX_DEPTH_BUFFER_BIT 0x00000020
195 #define GLX_STENCIL_BUFFER_BIT 0x00000040
196 #define GLX_ACCUM_BUFFER_BIT 0x00000080
197 #define GLX_FRONT_LEFT_BUFFER_BIT_SGIX GLX_FRONT_LEFT_BUFFER_BIT
198 #define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX GLX_FRONT_RIGHT_BUFFER_BIT
199 #define GLX_BACK_LEFT_BUFFER_BIT_SGIX GLX_BACK_LEFT_BUFFER_BIT
200 #define GLX_BACK_RIGHT_BUFFER_BIT_SGIX GLX_BACK_RIGHT_BUFFER_BIT
201 #define GLX_AUX_BUFFERS_BIT_SGIX GLX_AUX_BUFFERS_BIT
202 #define GLX_DEPTH_BUFFER_BIT_SGIX GLX_DEPTH_BUFFER_BIT
203 #define GLX_STENCIL_BUFFER_BIT_SGIX GLX_STENCIL_BUFFER_BIT
204 #define GLX_ACCUM_BUFFER_BIT_SGIX GLX_ACCUM_BUFFER_BIT
205
206 /*
207 * Extension return values from lwjgl_glXGetConfig. These are also
208 * accepted as parameter values for lwjgl_glXChooseVisual.
209 */
210
211 #define GLX_X_VISUAL_TYPE_EXT 0x22 /* visual_info extension type */
212 #define GLX_TRANSPARENT_TYPE_EXT 0x23 /* visual_info extension */
213 #define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 /* visual_info extension */
214 #define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 /* visual_info extension */
215 #define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 /* visual_info extension */
216 #define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 /* visual_info extension */
217 #define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 /* visual_info extension */
218
219 /* Property values for visual_type */
220 #define GLX_TRUE_COLOR_EXT 0x8002
221 #define GLX_DIRECT_COLOR_EXT 0x8003
222 #define GLX_PSEUDO_COLOR_EXT 0x8004
223 #define GLX_STATIC_COLOR_EXT 0x8005
224 #define GLX_GRAY_SCALE_EXT 0x8006
225 #define GLX_STATIC_GRAY_EXT 0x8007
226
227 /* Property values for transparent pixel */
228 #define GLX_NONE_EXT 0x8000
229 #define GLX_TRANSPARENT_RGB_EXT 0x8008
230 #define GLX_TRANSPARENT_INDEX_EXT 0x8009
231
232 /* Property values for visual_rating */
233 #define GLX_VISUAL_CAVEAT_EXT 0x20 /* visual_rating extension type */
234 #define GLX_SLOW_VISUAL_EXT 0x8001
235 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
236
237 /*
238 * Names for attributes to lwjgl_glXGetClientString.
239 */
240 #define GLX_VENDOR 0x1
241 #define GLX_VERSION 0x2
242 #define GLX_EXTENSIONS 0x3
243
244 /*
245 * Names for attributes to lwjgl_glXQueryContextInfoEXT.
246 */
247 #define GLX_SHARE_CONTEXT_EXT 0x800A /* id of share context */
248 #define GLX_VISUAL_ID_EXT 0x800B /* id of context's visual */
249 #define GLX_SCREEN_EXT 0x800C /* screen number */
250
251 /* NV_float_buffer */
252 #define GLX_FLOAT_COMPONENTS_NV 0x20B0
253
254 /* GLX_ARB_fbconfig_float */
255 #define GLX_RGBA_FLOAT_TYPE 0x20B9
256 #define GLX_RGBA_FLOAT_BIT 0x0004
257
258 /* GLX_ARB_fbconfig_float */
259 #define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1
260 #define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008
261
262 /* GLX_ARB_framebuffer_sRGB */
263 #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
264
265 /* GLX_ARB_create_context */
266 #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
267 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
268 #define GLX_CONTEXT_FLAGS_ARB 0x2094
269
270 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001
271 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
272
273 typedef XID GLXContextID;
274 typedef XID GLXPixmap;
275 typedef XID GLXDrawable;
276 typedef XID GLXPbuffer;
277 typedef XID GLXWindow;
278 typedef XID GLXFBConfigID;
279
280 typedef struct __GLXcontextRec *GLXContext;
281
282 typedef struct __GLXFBConfigRec *GLXFBConfig;
283
284 typedef GLXFBConfig * (APIENTRY * glXGetFBConfigsPROC) (Display *dpy, int screen, int *nelements);
285 typedef GLXFBConfig * (APIENTRY * glXChooseFBConfigPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
286 typedef int (APIENTRY * glXGetFBConfigAttribPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
287 typedef XVisualInfo * (APIENTRY * glXGetVisualFromFBConfigPROC) (Display *dpy, GLXFBConfig config);
288 typedef GLXWindow (APIENTRY * glXCreateWindowPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
289 typedef void (APIENTRY * glXDestroyWindowPROC) (Display *dpy, GLXWindow win);
290 typedef GLXPixmap (APIENTRY * glXCreatePixmapPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
291 typedef void (APIENTRY * glXDestroyPixmapPROC) (Display *dpy, GLXPixmap pixmap);
292 typedef GLXPbuffer (APIENTRY * glXCreatePbufferPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
293 typedef void (APIENTRY * glXDestroyPbufferPROC) (Display *dpy, GLXPbuffer pbuf);
294 typedef void (APIENTRY * glXQueryDrawablePROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
295 typedef GLXContext (APIENTRY * glXCreateNewContextPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
296 typedef Bool (APIENTRY * glXMakeContextCurrentPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
297 typedef GLXDrawable (APIENTRY * glXGetCurrentReadDrawablePROC) (void);
298 typedef Display * (APIENTRY * glXGetCurrentDisplayPROC) (void);
299 typedef int (APIENTRY * glXQueryContextPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
300 typedef void (APIENTRY * glXSelectEventPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
301 typedef void (APIENTRY * glXGetSelectedEventPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
302
303 typedef GLXContextID (APIENTRY * glXGetContextIDEXTPROC) (const GLXContext ctx);
304 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawableEXTPROC) (void);
305 typedef GLXContext (APIENTRY * glXImportContextEXTPROC) (Display *dpy, GLXContextID contextID);
306 typedef void (APIENTRY * glXFreeContextEXTPROC) (Display *dpy, GLXContext ctx);
307 typedef int (APIENTRY * glXQueryContextInfoEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
308
309 typedef XVisualInfo* (APIENTRY * glXChooseVisualPROC) (Display *dpy, int screen, int *attribList);
310 typedef void (APIENTRY * glXCopyContextPROC) (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
311 typedef GLXContext (APIENTRY * glXCreateContextPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
312 typedef GLXPixmap (APIENTRY * glXCreateGLXPixmapPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
313 typedef void (APIENTRY * glXDestroyContextPROC) (Display *dpy, GLXContext ctx);
314 typedef void (APIENTRY * glXDestroyGLXPixmapPROC) (Display *dpy, GLXPixmap pix);
315 typedef int (APIENTRY * glXGetConfigPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
316 typedef GLXContext (APIENTRY * glXGetCurrentContextPROC) (void);
317 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawablePROC) (void);
318 typedef Bool (APIENTRY * glXIsDirectPROC) (Display *dpy, GLXContext ctx);
319 typedef Bool (APIENTRY * glXMakeCurrentPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
320 typedef Bool (APIENTRY * glXQueryExtensionPROC) (Display *dpy, int *errorBase, int *eventBase);
321 typedef Bool (APIENTRY * glXQueryVersionPROC) (Display *dpy, int *major, int *minor);
322 typedef void (APIENTRY * glXSwapBuffersPROC) (Display *dpy, GLXDrawable drawable);
323 typedef void (APIENTRY * glXUseXFontPROC) (Font font, int first, int count, int listBase);
324 typedef void (APIENTRY * glXWaitGLPROC) (void);
325 typedef void (APIENTRY * glXWaitXPROC) (void);
326 typedef const char * (APIENTRY * glXGetClientStringPROC) (Display *dpy, int name );
327 typedef const char * (APIENTRY * glXQueryServerStringPROC) (Display *dpy, int screen, int name );
328 typedef const char * (APIENTRY * glXQueryExtensionsStringPROC) (Display *dpy, int screen );
329
330 /* GLX_SGI_swap_control */
331 typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval);
332
333 /* GLX_ARB_create_context */
334 typedef GLXContext (APIENTRY * glXCreateContextAttribsARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
335
336 typedef struct {
337 bool GLX12;
338 bool GLX13;
339 bool GLX14;
340 /* bool GLX_EXT_visual_info;
341 bool GLX_EXT_visual_rating;*/
342 bool GLX_SGI_swap_control;
343 bool GLX_ARB_multisample;
344 bool GLX_ARB_fbconfig_float;
345 bool GLX_EXT_fbconfig_packed_float;
346 bool GLX_ARB_framebuffer_sRGB;
347 bool GLX_ARB_create_context;
348 } GLXExtensions;
349
350 /* Add _ to global symbols to avoid symbol clash with the OpenGL library */
351 extern glXGetFBConfigsPROC lwjgl_glXGetFBConfigs;
352 extern glXChooseFBConfigPROC lwjgl_glXChooseFBConfig;
353 extern glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib;
354 extern glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig;
355 extern glXCreateWindowPROC lwjgl_glXCreateWindow;
356 extern glXDestroyWindowPROC lwjgl_glXDestroyWindow;
357 extern glXCreatePixmapPROC lwjgl_glXCreatePixmap;
358 extern glXDestroyPixmapPROC lwjgl_glXDestroyPixmap;
359 extern glXCreatePbufferPROC lwjgl_glXCreatePbuffer;
360 extern glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer;
361 extern glXQueryDrawablePROC lwjgl_glXQueryDrawable;
362 extern glXCreateNewContextPROC lwjgl_glXCreateNewContext;
363 extern glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent;
364 extern glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable;
365 extern glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay;
366 extern glXQueryContextPROC lwjgl_glXQueryContext;
367 extern glXSelectEventPROC lwjgl_glXSelectEvent;
368 extern glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent;
369
370 extern glXChooseVisualPROC lwjgl_glXChooseVisual;
371 extern glXCopyContextPROC lwjgl_glXCopyContext;
372 extern glXCreateContextPROC lwjgl_glXCreateContext;
373 extern glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap;
374 extern glXDestroyContextPROC lwjgl_glXDestroyContext;
375 extern glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap;
376 extern glXGetConfigPROC lwjgl_glXGetConfig;
377 extern glXGetCurrentContextPROC lwjgl_glXGetCurrentContext;
378 extern glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable;
379 extern glXIsDirectPROC lwjgl_glXIsDirect;
380 extern glXMakeCurrentPROC lwjgl_glXMakeCurrent;
381 extern glXQueryExtensionPROC lwjgl_glXQueryExtension;
382 extern glXQueryVersionPROC lwjgl_glXQueryVersion;
383 extern glXSwapBuffersPROC lwjgl_glXSwapBuffers;
384 extern glXUseXFontPROC lwjgl_glXUseXFont;
385 extern glXWaitGLPROC lwjgl_glXWaitGL;
386 extern glXWaitXPROC lwjgl_glXWaitX;
387 extern glXGetClientStringPROC lwjgl_glXGetClientString;
388 extern glXQueryServerStringPROC lwjgl_glXQueryServerString;
389 extern glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString;
390
391 extern glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI;
392
393 extern glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB;
394
395 extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags);
396
397 #endif
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 "org_lwjgl_openal_AL.h"
36 #include "extal.h"
37 #include "common_tools.h"
38
39 #include <dlfcn.h>
40
41 static void* handleOAL;
42
43 void *NativeGetFunctionPointer(const char *function) {
44 return dlsym(handleOAL, function);
45 }
46
47 void tryLoadLibrary(JNIEnv *env, jstring path) {
48 char *path_str = GetStringNativeChars(env, path);
49 printfDebugJava(env, "Testing '%s'", path_str);
50 handleOAL = dlopen(path_str, RTLD_LAZY);
51 if (handleOAL != NULL) {
52 printfDebugJava(env, "Found OpenAL at '%s'", path_str);
53 } else {
54 throwException(env, "Could not load OpenAL library");
55 }
56 free(path_str);
57 }
58
59 void UnLoadOpenAL() {
60 if (handleOAL != NULL) {
61 dlclose(handleOAL);
62 handleOAL = NULL;
63 }
64 }
0 {
1 global:
2 Java_*;
3 JNI_OnLoad;
4 JNI_OnUnload;
5 local: *;
6 };
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 * $Id: org_lwjgl_input_Cursor.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Linux cursor handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/Xcursor/Xcursor.h>
44 #include "org_lwjgl_input_Cursor.h"
45 #include "org_lwjgl_opengl_LinuxDisplay.h"
46 #include "common_tools.h"
47
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCapabilities
49 (JNIEnv *env, jclass clazz, jlong display) {
50 Display *disp = (Display *)(intptr_t)display;
51 int caps = 0;
52 XcursorBool argb_supported = XcursorSupportsARGB(disp);
53 XcursorBool anim_supported = XcursorSupportsAnim(disp);
54 if (argb_supported)
55 caps |= org_lwjgl_input_Cursor_CURSOR_8_BIT_ALPHA | org_lwjgl_input_Cursor_CURSOR_ONE_BIT_TRANSPARENCY;
56 if (anim_supported)
57 caps |= org_lwjgl_input_Cursor_CURSOR_ANIMATION;
58 return caps;
59 }
60
61 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize
62 (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr)
63 {
64 Display *disp = (Display *)(intptr_t)display;
65 Window window = (Window)window_ptr;
66 unsigned int width_return = 0;
67 unsigned int height_return = 0;
68 XQueryBestCursor(disp, window, 1, 1, &width_return, &height_return);
69 return width_return > height_return ? width_return : height_return;
70 }
71
72 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize
73 (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr)
74 {
75 Display *disp = (Display *)(intptr_t)display;
76 Window window = (Window)window_ptr;
77 unsigned int width_return = 0;
78 unsigned int height_return = 0;
79 XQueryBestCursor(disp, window, 0xffffffff, 0xffffffff, &width_return, &height_return);
80 return width_return > height_return ? height_return : width_return;
81 }
82
83 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
84 (JNIEnv *env, jclass clazz, jlong display, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
85 {
86 Display *disp = (Display *)(intptr_t)display;
87 const int *delays = NULL;
88 if (delay_buffer != NULL)
89 delays = (const int *)(*env)->GetDirectBufferAddress(env, delay_buffer) + delays_offset;
90 XcursorPixel *pixels = (XcursorPixel *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset;
91 int stride = width*height;
92 XcursorImages *cursor_images = XcursorImagesCreate(num_images);
93 if (cursor_images == NULL) {
94 throwException(env, "Could not allocate cursor.");
95 return None;
96 }
97 cursor_images->nimage = num_images;
98 int i;
99 for (i = 0; i < num_images; i++) {
100 XcursorImage *cursor_image = XcursorImageCreate(width, height);
101 cursor_image->xhot = x_hotspot;
102 cursor_image->yhot = y_hotspot;
103 cursor_image->pixels = &(pixels[stride*i]);
104 if (num_images > 1)
105 cursor_image->delay = delays[i];
106 cursor_images->images[i] = cursor_image;
107 }
108 Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images);
109 XcursorImagesDestroy(cursor_images);
110 return cursor;
111 }
112
113 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
114 (JNIEnv *env, jclass clazz, jlong display, jlong cursor_ptr)
115 {
116 Display *disp = (Display *)(intptr_t)display;
117 Cursor cursor = (Cursor)cursor_ptr;
118 XFreeCursor(disp, cursor);
119 }
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 * $Id: org_lwjgl_opengl_Display.c 3188 2009-03-19 21:50:30Z elias_naur $
34 *
35 * Linux specific display functions.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3188 $
39 */
40
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/Xutil.h>
44 #include <X11/extensions/xf86vmode.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <assert.h>
48 #include <jni.h>
49 #include <jawt_md.h>
50 #include "common_tools.h"
51 #include "extgl.h"
52 #include "extgl_glx.h"
53 #include "context.h"
54 #include "org_lwjgl_opengl_LinuxDisplay.h"
55 #include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h"
56 #include "org_lwjgl_LinuxSysImplementation.h"
57
58 #define ERR_MSG_SIZE 1024
59
60 typedef struct {
61 unsigned long flags;
62 unsigned long functions;
63 unsigned long decorations;
64 long input_mode;
65 unsigned long status;
66 } MotifWmHints;
67
68 #define MWM_HINTS_DECORATIONS (1L << 1)
69
70 static GLXWindow glx_window = None;
71
72 static Colormap cmap;
73 static int current_depth;
74 static Pixmap current_icon_pixmap;
75 static Pixmap current_icon_mask_pixmap;
76
77 static Visual *current_visual;
78
79 static bool checkXError(JNIEnv *env, Display *disp) {
80 XSync(disp, False);
81 return (*env)->ExceptionCheck(env) == JNI_FALSE;
82 }
83
84 static int global_error_handler(Display *disp, XErrorEvent *error) {
85 JNIEnv *env = getThreadEnv();
86 if (env != NULL) {
87 jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay");
88 if (org_lwjgl_LinuxDisplay_class == NULL) {
89 // Don't propagate error
90 (*env)->ExceptionClear(env);
91 return 0;
92 }
93 jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I");
94 if (handler_method == NULL)
95 return 0;
96 return (*env)->CallStaticIntMethod(env, org_lwjgl_LinuxDisplay_class, handler_method, (jlong)(intptr_t)disp, (jlong)(intptr_t)error,
97 (jlong)(intptr_t)error->display, (jlong)error->serial, (jlong)error->error_code, (jlong)error->request_code, (jlong)error->minor_code);
98 } else
99 return 0;
100 }
101
102 static jlong openDisplay(JNIEnv *env) {
103 Display *display_connection = XOpenDisplay(NULL);
104 if (display_connection == NULL) {
105 throwException(env, "Could not open X display connection");
106 return (intptr_t)NULL;
107 }
108 return (intptr_t)display_connection;
109 }
110
111 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
112 (JNIEnv *env, jobject ignored) {
113 return org_lwjgl_LinuxSysImplementation_JNI_VERSION;
114 }
115
116 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) {
117 Display *disp = (Display *)(intptr_t)display_ptr;
118 char err_msg_buffer[ERR_MSG_SIZE];
119 XGetErrorText(disp, error_code, err_msg_buffer, ERR_MSG_SIZE);
120 err_msg_buffer[ERR_MSG_SIZE - 1] = '\0';
121 return NewStringNativeWithLength(env, err_msg_buffer, strlen(err_msg_buffer));
122 }
123
124 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr, jlong display_ptr, jlong event_ptr) {
125 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
126 Display *disp = (Display *)(intptr_t)display_ptr;
127 XErrorEvent *event = (XErrorEvent *)(intptr_t)event_ptr;
128 return (jint)handler(disp, event);
129 }
130
131 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler(JNIEnv *env, jclass unused) {
132 return (intptr_t)XSetErrorHandler(global_error_handler);
133 }
134
135 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr) {
136 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
137 return (intptr_t)XSetErrorHandler(handler);
138 }
139
140 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_sync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) {
141 Display *disp = (Display *)(intptr_t)display_ptr;
142 XSync(disp, throw_away_events ? True : False);
143 }
144
145 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) {
146 Display *disp = (Display *)(intptr_t)display_ptr;
147 return XDefaultScreen(disp);
148 }
149
150 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom(JNIEnv *env, jclass unused, jlong display_ptr, jstring atom_name_obj, jboolean only_if_exists) {
151 Display *disp = (Display *)(intptr_t)display_ptr;
152 char *atom_name = GetStringNativeChars(env, atom_name_obj);
153 if (atom_name == NULL)
154 return 0;
155 Atom atom = XInternAtom(disp, atom_name, only_if_exists ? True : False);
156 free(atom_name);
157 return atom;
158 }
159
160 static void setDecorations(Display *disp, Window window, int dec) {
161 Atom motif_hints_atom = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
162 MotifWmHints motif_hints;
163 motif_hints.flags = MWM_HINTS_DECORATIONS;
164 motif_hints.decorations = dec;
165 XChangeProperty(disp, window, motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long));
166 }
167
168 static bool isLegacyFullscreen(jint window_mode) {
169 return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY;
170 }
171
172 static void setWindowTitle(Display *disp, Window window, const char *title) {
173 XStoreName(disp, window, title);
174 }
175
176 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
177 return openDisplay(env);
178 }
179
180 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz, jlong display) {
181 Display *disp = (Display *)(intptr_t)display;
182 XCloseDisplay(disp);
183 }
184
185 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jlong window, jobject peer_info_handle) {
186 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
187 if (peer_info->glx13)
188 peer_info->drawable = glx_window;
189 else
190 peer_info->drawable = window;
191 }
192
193 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject pixel_format) {
194 Display *disp = (Display *)(intptr_t)display;
195 initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, true, GLX_WINDOW_BIT, true, false);
196 }
197
198 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jstring title_obj) {
199 Display *disp = (Display *)(intptr_t)display;
200 Window window = (Window)window_ptr;
201 char * title = GetStringNativeChars(env, title_obj);
202 setWindowTitle(disp, window, title);
203 free(title);
204 }
205
206 static void freeIconPixmap(Display *disp) {
207 if (current_icon_mask_pixmap != 0) {
208 XFreePixmap(disp, current_icon_mask_pixmap);
209 current_icon_mask_pixmap = 0;
210 }
211 if (current_icon_pixmap != 0) {
212 XFreePixmap(disp, current_icon_pixmap);
213 current_icon_pixmap = 0;
214 }
215 }
216
217 static void destroyWindow(JNIEnv *env, Display *disp, Window window) {
218 if (glx_window != None) {
219 lwjgl_glXDestroyWindow(disp, glx_window);
220 glx_window = None;
221 }
222 XDestroyWindow(disp, window);
223 XFreeColormap(disp, cmap);
224 freeIconPixmap(disp);
225 }
226
227 static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp, int screen) {
228 unsigned long nitems;
229 Atom actual_type;
230 int actual_format;
231 unsigned long bytes_after;
232 Atom *supported_list;
233 Atom netwm_supported_atom = XInternAtom(disp, "_NET_SUPPORTED", False);
234 int result = XGetWindowProperty(disp, RootWindow(disp, screen), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
235 if (result != Success) {
236 throwException(env, "Unable to query _NET_SUPPORTED window property");
237 return false;
238 }
239 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
240 bool supported = false;
241 unsigned long i;
242 for (i = 0; i < nitems; i++) {
243 if (fullscreen_atom == supported_list[i]) {
244 supported = true;
245 break;
246 }
247 }
248 XFree(supported_list);
249 return supported;
250 }
251
252 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display, jint screen) {
253 Display *disp = (Display *)(intptr_t)display;
254 return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE;
255 }
256
257 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint x, jint y, jint width, jint height) {
258 Display *disp = (Display *)(intptr_t)display;
259 Window window = (Window)window_ptr;
260 XMoveWindow(disp, window, x, y);
261 XResizeWindow(disp, window, width, height);
262 }
263
264 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize(JNIEnv *env, jclass clazz, jlong display, jboolean synchronize) {
265 Display *disp = (Display *)(intptr_t)display;
266 XSynchronize(disp, synchronize ? True : False);
267 }
268
269 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) {
270 Display *disp = (Display *)(intptr_t)display;
271 return RootWindow(disp, screen);
272 }
273
274 static void updateWindowHints(JNIEnv *env, Display *disp, Window window) {
275 XWMHints* win_hints = XAllocWMHints();
276 if (win_hints == NULL) {
277 throwException(env, "XAllocWMHints failed");
278 return;
279 }
280
281 win_hints->flags = InputHint;
282 win_hints->input = True;
283 if (current_icon_pixmap != 0) {
284 win_hints->flags |= IconPixmapHint;
285 win_hints->icon_pixmap = current_icon_pixmap;
286 }
287 if (current_icon_mask_pixmap != 0) {
288 win_hints->flags |= IconMaskHint;
289 win_hints->icon_mask = current_icon_mask_pixmap;
290 }
291
292 XSetWMHints(disp, window, win_hints);
293 XFree(win_hints);
294 XFlush(disp);
295 }
296
297 static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle) {
298 Window parent = (Window)parent_handle;
299 Window win;
300 XSetWindowAttributes attribs;
301 int attribmask;
302
303 XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
304 if (vis_info == NULL)
305 return false;
306 cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone);
307 attribs.colormap = cmap;
308 attribs.border_pixel = 0;
309 attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
310 attribmask = CWColormap | CWEventMask | CWBorderPixel;
311 if (isLegacyFullscreen(window_mode)) {
312 attribmask |= CWOverrideRedirect;
313 attribs.override_redirect = True;
314 }
315 win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
316
317 current_depth = vis_info->depth;
318 current_visual = vis_info->visual;
319
320 XFree(vis_info);
321 if (!checkXError(env, disp)) {
322 XFreeColormap(disp, cmap);
323 return false;
324 }
325 // printfDebugJava(env, "Created window");
326 if (undecorated) {
327 // Use Motif decoration hint property and hope the window manager respects them
328 setDecorations(disp, win, 0);
329 }
330 XSizeHints * size_hints = XAllocSizeHints();
331 size_hints->flags = PMinSize | PMaxSize;
332 size_hints->min_width = width;
333 size_hints->max_width = width;
334 size_hints->min_height = height;
335 size_hints->max_height = height;
336 XSetWMNormalHints(disp, win, size_hints);
337 updateWindowHints(env, disp, win);
338 XFree(size_hints);
339 #define NUM_ATOMS 1
340 Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/};
341 XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS);
342 if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
343 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
344 XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
345 XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
346 }
347 if (!checkXError(env, disp)) {
348 destroyWindow(env, disp, win);
349 return 0;
350 }
351 return win;
352 }
353
354 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_reparentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr, jlong parent_ptr, jint x, jint y) {
355 Display *disp = (Display *)(intptr_t)display;
356 Window window = (Window)window_ptr;
357 Window parent = (Window)parent_ptr;
358 XReparentWindow(disp, window, parent, x, y);
359 }
360
361 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
362 Display *disp = (Display *)(intptr_t)display;
363 Window window = (Window)window_ptr;
364 XMapRaised(disp, window);
365 }
366
367 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
368 Display *disp = (Display *)(intptr_t)display;
369 Window window = (Window)window_ptr;
370 Window root, parent;
371 Window *children;
372 unsigned int nchildren;
373 if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) {
374 throwException(env, "XQueryTree failed");
375 return None;
376 }
377 if (children != NULL)
378 XFree(children);
379 return parent;
380 }
381
382 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty(JNIEnv *env, jclass unusued, jlong display, jlong window_ptr, jlong property_ptr) {
383 Display *disp = (Display *)(intptr_t)display;
384 Window window = (Window)window_ptr;
385 Atom property = (Atom)property_ptr;
386 int num_props;
387 Atom *properties = XListProperties(disp, window, &num_props);
388 if (properties == NULL)
389 return JNI_FALSE;
390 jboolean result = JNI_FALSE;
391 for (int i = 0; i < num_props; i++) {
392 if (properties[i] == property) {
393 result = JNI_TRUE;
394 break;
395 }
396 }
397 XFree(properties);
398 return result;
399 }
400
401 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) {
402 Display *disp = (Display *)(intptr_t)display;
403 Window window = (Window)window_ptr;
404 XSetInputFocus(disp, window, RevertToParent, time);
405 }
406
407 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) {
408 Display *disp = (Display *)(intptr_t)display;
409 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
410 GLXFBConfig *fb_config = NULL;
411 if (peer_info->glx13) {
412 fb_config = getFBConfigFromPeerInfo(env, peer_info);
413 if (fb_config == NULL)
414 return 0;
415 }
416 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
417 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
418 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
419 int width = (*env)->GetIntField(env, mode, fid_width);
420 int height = (*env)->GetIntField(env, mode, fid_height);
421 Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle);
422 if ((*env)->ExceptionOccurred(env)) {
423 return 0;
424 }
425 if (peer_info->glx13) {
426 glx_window = lwjgl_glXCreateWindow(disp, *fb_config, win, NULL);
427 XFree(fb_config);
428 }
429 if (!checkXError(env, disp)) {
430 lwjgl_glXDestroyWindow(disp, glx_window);
431 destroyWindow(env, disp, win);
432 }
433 return win;
434 }
435
436 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
437 Display *disp = (Display *)(intptr_t)display;
438 Window window = (Window)window_ptr;
439 destroyWindow(env, disp, window);
440 }
441
442 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
443 JAWT jawt;
444 jawt.version = JAWT_VERSION_1_4;
445 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
446 throwException(env, "GetAWT failed");
447 return;
448 }
449 jawt.Lock(env);
450 }
451
452 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT(JNIEnv *env, jclass clazz) {
453 JAWT jawt;
454 jawt.version = JAWT_VERSION_1_4;
455 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
456 throwException(env, "GetAWT failed");
457 return;
458 }
459 jawt.Unlock(env);
460 }
461
462 static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height, int format, int depth) {
463 Pixmap pixmap = XCreatePixmap(disp, window, width, height, depth);
464 /* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed
465 * since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer)
466 */
467 char *icon_copy = (char *)malloc(sizeof(*icon_copy)*data_size);
468
469 if (icon_copy == NULL) {
470 XFreePixmap(disp, pixmap);
471 throwException(env, "malloc failed");
472 return None;
473 }
474 memcpy(icon_copy, data, data_size);
475 XImage *image = XCreateImage(disp, current_visual, depth, format, 0, icon_copy, width, height, 32, 0);
476 if (image == NULL) {
477 XFreePixmap(disp, pixmap);
478 free(icon_copy);
479 throwException(env, "XCreateImage failed");
480 return None;
481 }
482
483 GC gc = XCreateGC(disp, pixmap, 0, NULL);
484 XPutImage(disp, pixmap, gc, image, 0, 0, 0, 0, width, height);
485 XFreeGC(disp, gc);
486 XDestroyImage(image);
487 // We won't free icon_copy because it is freed by XDestroyImage
488 return pixmap;
489 }
490
491 static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, int rgb_size, char *mask_data, int mask_size, int width, int height) {
492 freeIconPixmap(disp);
493 current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, rgb_size, width, height, ZPixmap, current_depth);
494 if ((*env)->ExceptionCheck(env))
495 return;
496 current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, mask_size, width, height, XYPixmap, 1);
497 if ((*env)->ExceptionCheck(env)) {
498 freeIconPixmap(disp);
499 return;
500 }
501
502 updateWindowHints(env, disp, window);
503 }
504
505 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
506 (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jint rgb_size, jobject icon_mask_buffer, jint mask_size, jint width, jint height)
507 {
508 Display *disp = (Display *)(intptr_t)display;
509 Window window = (Window)window_ptr;
510 char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer);
511 char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer);
512
513 setIcon(env, disp, window, rgb_data, rgb_size, mask_data, mask_size, width, height);
514 }
515
516 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
517 Display *disp = (Display *)(intptr_t)display_ptr;
518 return XUngrabKeyboard(disp, CurrentTime);
519 }
520
521 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
522 Display *disp = (Display *)(intptr_t)display_ptr;
523 Window win = (Window)window_ptr;
524 return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
525 }
526
527 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
528 Display *disp = (Display *)(intptr_t)display_ptr;
529 Window win = (Window)window_ptr;
530 Cursor cursor = (Cursor)cursor_ptr;
531 int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
532 return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime);
533 }
534
535 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
536 Display *disp = (Display *)(intptr_t)display_ptr;
537 Window win = (Window)window_ptr;
538 XWindowAttributes win_attribs;
539
540 XGetWindowAttributes(disp, win, &win_attribs);
541 XF86VidModeSetViewPort(disp, screen, win_attribs.x, win_attribs.y);
542 }
543
544 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer(JNIEnv *env, jclass unused, jlong display_ptr) {
545 Display *disp = (Display *)(intptr_t)display_ptr;
546 return XUngrabPointer(disp, CurrentTime);
547 }
548
549 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
550 Display *disp = (Display *)(intptr_t)display_ptr;
551 Window win = (Window)window_ptr;
552 Cursor cursor = (Cursor)cursor_ptr;
553 XDefineCursor(disp, win, cursor);
554 }
555
556 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
557 Display *disp = (Display *)(intptr_t)display_ptr;
558 Window win = (Window)window_ptr;
559 unsigned int best_width, best_height;
560 if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
561 throwException(env, "Could not query best cursor size");
562 return false;
563 }
564 Pixmap mask = XCreatePixmap(disp, win, best_width, best_height, 1);
565 XGCValues gc_values;
566 gc_values.foreground = 0;
567 GC gc = XCreateGC(disp, mask, GCForeground, &gc_values);
568 XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
569 XFreeGC(disp, gc);
570 XColor dummy_color;
571 Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
572 XFreePixmap(disp, mask);
573 return cursor;
574 }
575
576 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
577 Display *disp = (Display *)(intptr_t)display_ptr;
578 int revert_mode;
579 Window win;
580 XGetInputFocus(disp, &win, &revert_mode);
581 return win;
582 }
583
584 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
585 Display *disp = (Display *)(intptr_t)display_ptr;
586 Window win = (Window)window_ptr;
587 XIconifyWindow(disp, win, screen);
588 }
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 * $Id: org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <jawt_md.h>
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/Xutil.h>
44 #include "awt_tools.h"
45 #include "org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.h"
46 #include "context.h"
47
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_getScreenFromSurfaceInfo
49 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle) {
50 const AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
51 // Get the platform-specific drawing info
52 JAWT_X11DrawingSurfaceInfo *dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)awt_lock->dsi->platformInfo;
53
54 XVisualInfo template;
55 int num_infos;
56 template.visualid = dsi_x11->visualID;
57 template.depth = dsi_x11->depth;
58 XVisualInfo *vis_info = XGetVisualInfo(dsi_x11->display, VisualIDMask | VisualDepthMask, &template, &num_infos);
59 if (vis_info == NULL) {
60 throwException(env, "Could not determine screen");
61 return -1;
62 }
63 int screen = vis_info[0].screen;
64 XFree(vis_info);
65 return screen;
66 }
67
68 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_nInitHandle
69 (JNIEnv *env, jclass clazz, int screen, jobject lock_buffer_handle, jobject peer_info_handle) {
70 const AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
71 X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
72 // Get the platform-specific drawing info
73 JAWT_X11DrawingSurfaceInfo *dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)awt_lock->dsi->platformInfo;
74
75 peer_info->display = dsi_x11->display;
76 peer_info->screen = screen;
77 peer_info->drawable = dsi_x11->drawable;
78 peer_info->glx13 = false;
79 peer_info->config.glx_config.visualid = dsi_x11->visualID;
80 peer_info->config.glx_config.depth = dsi_x11->depth;
81 }
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 * $Id: org_lwjgl_opengl_LinuxCanvasImplementation.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <X11/X.h>
41 #include <X11/Xlib.h>
42 #include <X11/Xutil.h>
43 #include "org_lwjgl_opengl_LinuxCanvasImplementation.h"
44 #include "extgl_glx.h"
45 #include "context.h"
46
47 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat
48 (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject pixel_format) {
49 Display *disp = (Display *)(intptr_t)display;
50 GLXExtensions extension_flags;
51 if (!extgl_InitGLX(disp, screen, &extension_flags)) {
52 throwException(env, "Could not initialize GLX");
53 return -1;
54 }
55 XVisualInfo *vis_info = chooseVisualGLX(env, disp, screen, pixel_format, true, true);
56 if (vis_info == NULL) {
57 throwException(env, "Could not choose a VisualInfo");
58 return -1;
59 }
60
61 VisualID vis_id = vis_info->visualid;
62 XFree(vis_info);
63 return vis_id;
64 }
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 * $Id: org_lwjgl_opengl_LinuxContextImplementation.c 3203 2009-04-24 20:35:33Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3203 $
37 */
38
39 #include <jni.h>
40 #include <X11/X.h>
41 #include <X11/Xlib.h>
42 #include <X11/Xutil.h>
43 #include "org_lwjgl_opengl_LinuxContextImplementation.h"
44 #include "extgl_glx.h"
45 #include "context.h"
46 #include "common_tools.h"
47
48 typedef struct {
49 GLXExtensions extension_flags;
50 GLXContext context;
51 } X11Context;
52
53 static bool checkContext(JNIEnv *env, Display *display, GLXContext context) {
54 if (context == NULL) {
55 throwException(env, "Could not create GLX context");
56 return false;
57 }
58 /*
59 * Ditched the requirement that contexts have to be direct. It was
60 * never true that all accelerated contexts are direct, but it
61 * was a reasonable test until the appearance of Xgl and AIGLX.
62 * Now the test is at best useless, and at worst wrong,
63 * in case the current X server accelerates indirect rendering.
64 */
65 /* jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
66 if (!allow_software_acceleration && lwjgl_glXIsDirect(display, context) == False) {
67 lwjgl_glXDestroyContext(display, context);
68 throwException(env, "Could not create a direct GLX context");
69 return false;
70 }*/
71 return true;
72 }
73
74 static void createContextGLX13(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, jobject attribs, GLXContext shared_context) {
75 GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info);
76 if (config == NULL)
77 return;
78 GLXContext context;
79 if (attribs) {
80 const int *attrib_list = (const int *)(*env)->GetDirectBufferAddress(env, attribs);
81 context = lwjgl_glXCreateContextAttribsARB(peer_info->display, *config, shared_context, True, attrib_list);
82 } else {
83 int render_type;
84 if (lwjgl_glXGetFBConfigAttrib(peer_info->display, *config, GLX_RENDER_TYPE, &render_type) != 0) {
85 throwException(env, "Could not get GLX_RENDER_TYPE attribute");
86 return;
87 }
88 int context_render_type = (render_type & GLX_RGBA_FLOAT_BIT) != 0 ? GLX_RGBA_FLOAT_TYPE : GLX_RGBA_TYPE;
89 context = lwjgl_glXCreateNewContext(peer_info->display, *config, context_render_type, shared_context, True);
90 }
91 XFree(config);
92 if (!checkContext(env, peer_info->display, context))
93 return;
94 context_info->context = context;
95 }
96
97 static void createContextGLX(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, GLXContext shared_context) {
98 XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
99 if (vis_info == NULL)
100 return;
101 GLXContext context = lwjgl_glXCreateContext(peer_info->display, vis_info, shared_context, True);
102 XFree(vis_info);
103 if (!checkContext(env, peer_info->display, context))
104 return;
105 context_info->context = context;
106 }
107
108 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval
109 (JNIEnv *env, jclass clazz, jobject context_handle, jint value)
110 {
111 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
112 if (context_info->extension_flags.GLX_SGI_swap_control) {
113 lwjgl_glXSwapIntervalSGI(value);
114 }
115 }
116
117 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate
118 (JNIEnv *env , jclass clazz, jobject peer_handle, jobject attribs, jobject shared_context_handle) {
119 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(X11Context));
120 if (context_handle == NULL) {
121 throwException(env, "Could not allocate handle buffer");
122 return NULL;
123 }
124 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
125 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
126 GLXExtensions extension_flags;
127 if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) {
128 throwException(env, "Could not initialize GLX");
129 return NULL;
130 }
131 GLXContext shared_context = NULL;
132 if (shared_context_handle != NULL) {
133 X11Context *shared_context_info = (*env)->GetDirectBufferAddress(env, shared_context_handle);
134 shared_context = shared_context_info->context;
135 }
136 if (peer_info->glx13) {
137 createContextGLX13(env, peer_info, context_info, extension_flags.GLX_ARB_create_context ? attribs : NULL, shared_context);
138 } else {
139 createContextGLX(env, peer_info, context_info, shared_context);
140 }
141 context_info->extension_flags = extension_flags;
142 return context_handle;
143 }
144
145 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy
146 (JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) {
147 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
148 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
149 lwjgl_glXDestroyContext(peer_info->display, context_info->context);
150 }
151
152 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext
153 (JNIEnv *env , jclass clazz, jobject peer_info_handle) {
154 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
155 Bool result;
156 if (peer_info->glx13) {
157 result = lwjgl_glXMakeContextCurrent(peer_info->display, None, None, NULL);
158 } else {
159 result = lwjgl_glXMakeCurrent(peer_info->display, None, NULL);
160 }
161 if (!result)
162 throwException(env, "Could not release current context");
163 }
164
165 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCurrent
166 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
167 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
168 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
169 Bool result;
170 if (peer_info->glx13) {
171 result = lwjgl_glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context);
172 } else {
173 result = lwjgl_glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context);
174 }
175 if (!result)
176 throwException(env, "Could not make context current");
177 }
178
179 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent
180 (JNIEnv *env, jclass clazz, jobject context_handle) {
181 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
182 return context_info->context == lwjgl_glXGetCurrentContext();
183 }
184
185 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers
186 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
187 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
188 lwjgl_glXSwapBuffers(peer_info->display, peer_info->drawable);
189 }
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 * $Id: org_lwjgl_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2598 $
37 */
38
39 #include <X11/X.h>
40 #include <X11/Xlib.h>
41 #include <X11/Xutil.h>
42 #include <jni.h>
43 #include "common_tools.h"
44 #include "org_lwjgl_opengl_LinuxEvent.h"
45
46 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer(JNIEnv *env, jclass unused) {
47 return newJavaManagedByteBuffer(env, sizeof(XEvent));
48 }
49
50 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_getPending(JNIEnv *env, jclass unused, jlong display_ptr) {
51 Display *disp = (Display *)(intptr_t)display_ptr;
52 return XPending(disp);
53 }
54
55 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSetWindow(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) {
56 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
57 Window window = (Window)window_ptr;
58 event->xany.window = window;
59 }
60
61 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSendEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong display_ptr, jlong window_ptr, jboolean propagate, jlong eventmask) {
62 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
63 Display *disp = (Display *)(intptr_t)display_ptr;
64 Window window = (Window)window_ptr;
65 XSendEvent(disp, window, propagate == JNI_TRUE ? True : False, eventmask, event);
66 }
67
68 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusDetail(JNIEnv *env, jclass unused, jobject event_buffer) {
69 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
70 return event->xfocus.detail;
71 }
72
73 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusMode(JNIEnv *env, jclass unused, jobject event_buffer) {
74 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
75 return event->xfocus.mode;
76 }
77
78 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) {
79 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
80 Window window = (Window)window_ptr;
81 return XFilterEvent(event, window) == True ? JNI_TRUE : JNI_FALSE;
82 }
83
84 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nNextEvent(JNIEnv *env, jclass unused, jlong display_ptr, jobject event_buffer) {
85 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
86 Display *disp = (Display *)(intptr_t)display_ptr;
87 XNextEvent(disp, event);
88 }
89
90 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetType(JNIEnv *env, jclass unused, jobject event_buffer) {
91 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
92 return event->type;
93 }
94
95 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetWindow(JNIEnv *env, jclass unused, jobject event_buffer) {
96 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
97 return event->xany.window;
98 }
99
100 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientMessageType(JNIEnv *env, jclass unused, jobject event_buffer) {
101 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
102 return event->xclient.message_type;
103 }
104
105 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientData(JNIEnv *env, jclass unused, jobject event_buffer, jint index) {
106 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
107 return event->xclient.data.l[index];
108 }
109
110 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientFormat(JNIEnv *env, jclass unused, jobject event_buffer) {
111 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
112 return event->xclient.format;
113 }
114
115 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime(JNIEnv *env, jclass unused, jobject event_buffer) {
116 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
117 return event->xbutton.time;
118 }
119
120 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonState(JNIEnv *env, jclass unused, jobject event_buffer) {
121 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
122 return event->xbutton.state;
123 }
124
125 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonType(JNIEnv *env, jclass unused, jobject event_buffer) {
126 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
127 return event->xbutton.type;
128 }
129
130 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonButton(JNIEnv *env, jclass unused, jobject event_buffer) {
131 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
132 return event->xbutton.button;
133 }
134
135 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
136 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
137 return event->xbutton.root;
138 }
139
140 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonXRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
141 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
142 return event->xbutton.x_root;
143 }
144
145 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonYRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
146 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
147 return event->xbutton.y_root;
148 }
149
150 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonX(JNIEnv *env, jclass unused, jobject event_buffer) {
151 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
152 return event->xbutton.x;
153 }
154
155 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonY(JNIEnv *env, jclass unused, jobject event_buffer) {
156 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
157 return event->xbutton.y;
158 }
159
160 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) {
161 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
162 XKeyEvent *key_event = &(event->xkey);
163 return (jlong)(intptr_t)key_event;
164 }
165
166 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime(JNIEnv *env, jclass unused, jobject event_buffer) {
167 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
168 return event->xkey.time;
169 }
170
171 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyType(JNIEnv *env, jclass unused, jobject event_buffer) {
172 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
173 return event->xkey.type;
174 }
175
176 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyKeyCode(JNIEnv *env, jclass unused, jobject event_buffer) {
177 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
178 return event->xkey.keycode;
179 }
180
181 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyState(JNIEnv *env, jclass unused, jobject event_buffer) {
182 XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
183 return event->xkey.state;
184 }
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 * $Id: org_lwjgl_input_Keyboard.c 2399 2006-06-30 19:28:00Z elias_naur $
34 *
35 * Linux keyboard handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2399 $
39 */
40
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/XKBlib.h>
44 #include <X11/Xutil.h>
45 #include <X11/keysym.h>
46 #include "common_tools.h"
47 #include "org_lwjgl_opengl_LinuxKeyboard.h"
48
49 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getModifierMapping(JNIEnv *env, jclass unused, jlong display_ptr) {
50 Display *disp = (Display *)(intptr_t)display_ptr;
51 XModifierKeymap *modifier_map = XGetModifierMapping(disp);
52 return (intptr_t)modifier_map;
53 }
54
55 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_nSetDetectableKeyRepeat(JNIEnv *env, jclass unused, jlong display_ptr, jboolean set_enabled) {
56 Display *disp = (Display *)(intptr_t)display_ptr;
57 Bool enabled = set_enabled == JNI_TRUE ? True : False;
58 Bool result = XkbSetDetectableAutoRepeat(disp, enabled, NULL);
59 return result == enabled ? JNI_TRUE : JNI_FALSE;
60 }
61
62 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_freeModifierMapping(JNIEnv *env, jclass unused, jlong mapping_ptr) {
63 XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr;
64 XFreeModifiermap(modifier_map);
65 }
66
67 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getMaxKeyPerMod(JNIEnv *env, jclass unsused, jlong mapping_ptr) {
68 XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr;
69 return modifier_map->max_keypermod;
70 }
71
72 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupModifierMap(JNIEnv *env, jclass unused, jlong mapping_ptr, jint index) {
73 XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr;
74 KeyCode key_code = modifier_map->modifiermap[index];
75 return key_code;
76 }
77
78 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_keycodeToKeySym(JNIEnv *env, jclass unused, jlong display_ptr, jint key_code) {
79 Display *disp = (Display *)(intptr_t)display_ptr;
80 KeySym key_sym = XKeycodeToKeysym(disp, key_code, 0);
81 return key_sym;
82 }
83
84 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_openIM(JNIEnv *env, jclass unused, jlong display_ptr) {
85 Display *disp = (Display *)(intptr_t)display_ptr;
86 XIM xim = XOpenIM(disp, NULL, NULL, NULL);
87 return (intptr_t)xim;
88 }
89
90 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_createIC(JNIEnv *env, jclass unused, jlong xim_ptr, jlong window_ptr) {
91 Window win = (Window)window_ptr;
92 XIM xim = (XIM)(intptr_t)xim_ptr;
93 XIC xic = XCreateIC(xim, XNClientWindow, win, XNFocusWindow, win, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, NULL);
94 return (intptr_t)xic;
95 }
96
97 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_setupIMEventMask(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong xic_ptr) {
98 Display *disp = (Display *)(intptr_t)display_ptr;
99 Window win = (Window)window_ptr;
100 XIC xic = (XIC)(intptr_t)xic_ptr;
101 long im_event_mask;
102 XWindowAttributes win_attributes;
103
104 XGetWindowAttributes(disp, win, &win_attributes);
105 XGetICValues(xic, XNFilterEvents, &im_event_mask, NULL);
106 XSelectInput(disp, win, win_attributes.your_event_mask | im_event_mask);
107 XSetICFocus(xic);
108 }
109
110 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_destroyIC(JNIEnv *env, jclass unused, jlong xic_ptr) {
111 XIC xic = (XIC)(intptr_t)xic_ptr;
112 XDestroyIC(xic);
113 }
114
115 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_closeIM(JNIEnv *env, jclass unused, jlong xim_ptr) {
116 XIM xim = (XIM)(intptr_t)xim_ptr;
117 XCloseIM(xim);
118 }
119
120 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupKeysym(JNIEnv *env, jclass unused, jlong event_ptr, jint index) {
121 XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr;
122 return XLookupKeysym(event, index);
123 }
124
125 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_toUpper(JNIEnv *env, jclass unused, jlong keysym) {
126 KeySym lower_case, upper_case;
127 XConvertCase(keysym, &lower_case, &upper_case);
128 return upper_case;
129 }
130
131 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupString(JNIEnv *env, jclass unused, jlong event_ptr, jobject buffer_obj, jobject compose_status_obj) {
132 XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr;
133 char *buffer = (char *)(*env)->GetDirectBufferAddress(env, buffer_obj);
134 int capacity = (*env)->GetDirectBufferCapacity(env, buffer_obj);
135 XComposeStatus *status = (XComposeStatus *)(*env)->GetDirectBufferAddress(env, compose_status_obj);
136 return XLookupString(event, buffer, capacity, NULL, status);
137 }
138
139 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_allocateComposeStatus(JNIEnv *env, jclass unused) {
140 return newJavaManagedByteBuffer(env, sizeof(XComposeStatus));
141 }
142
143 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_utf8LookupString(JNIEnv *env, jclass unused, jlong xic_ptr, jlong event_ptr, jobject buffer_obj, jint buffer_position, jint buffer_size) {
144 XIC xic = (XIC)(intptr_t)xic_ptr;
145 XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr;
146 char *buffer = buffer_position + (char *)(*env)->GetDirectBufferAddress(env, buffer_obj);
147 Status status;
148 size_t num_bytes = Xutf8LookupString(xic, event, buffer, buffer_size, NULL, &status);
149 positionBuffer(env, buffer_obj, num_bytes);
150 return status;
151 }
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 * $Id: org_lwjgl_input_Keyboard.c 2399 2006-06-30 19:28:00Z elias_naur $
34 *
35 * Linux mouse handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2399 $
39 */
40
41 #include <X11/X.h>
42 #include <X11/Xlib.h>
43 #include <X11/Xutil.h>
44 #include "common_tools.h"
45 #include "org_lwjgl_opengl_LinuxMouse.h"
46
47 static void getWindowAttributes(jlong display_ptr, jlong window_ptr, XWindowAttributes *attr) {
48 Display *disp = (Display *)(intptr_t)display_ptr;
49 Window win = (Window)window_ptr;
50 XGetWindowAttributes(disp, win, attr);
51 }
52
53 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowHeight(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
54 XWindowAttributes window_attributes;
55 getWindowAttributes(display_ptr, window_ptr, &window_attributes);
56 return window_attributes.height;
57 }
58
59 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowWidth(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
60 XWindowAttributes window_attributes;
61 getWindowAttributes(display_ptr, window_ptr, &window_attributes);
62 return window_attributes.width;
63 }
64
65 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nWarpCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint x, jint y) {
66 Display *disp = (Display *)(intptr_t)display_ptr;
67 Window win = (Window)window_ptr;
68 XWarpPointer(disp, None, win, 0, 0, 0, 0, x, y);
69 }
70
71 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxMouse_nQueryPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jobject result_buffer) {
72 Display *disp = (Display *)(intptr_t)display_ptr;
73 Window win = (Window)window_ptr;
74 Window root_return, child_return;
75 int root_x, root_y, win_x, win_y;
76 unsigned int mask_return;
77 jint *result = (jint *)(*env)->GetDirectBufferAddress(env, result_buffer);
78 int result_size = (*env)->GetDirectBufferCapacity(env, result_buffer);
79 if (result_size < 4) {
80 throwFormattedException(env, "Not enough space in result buffer (%d)", result_size);
81 return (intptr_t)NULL;
82 }
83
84 XQueryPointer(disp, win, &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return);
85 result[0] = root_x;
86 result[1] = root_y;
87 result[2] = win_x;
88 result[3] = win_y;
89 return root_return;
90 }
91
92 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nSendWarpEvent(JNIEnv *env, jclass unusued, jlong display_ptr, jlong window_ptr, jlong warp_atom_ptr, jint x, jint y) {
93 Atom warp_atom = (Atom)warp_atom_ptr;
94 Display *disp = (Display *)(intptr_t)display_ptr;
95 Window win = (Window)window_ptr;
96 XEvent warp_event;
97 warp_event.type = ClientMessage;
98 warp_event.xclient.window = win;
99 warp_event.xclient.message_type = warp_atom;
100 warp_event.xclient.format = 32;
101 warp_event.xclient.data.l[0] = x;
102 warp_event.xclient.data.l[1] = y;
103 XSendEvent(disp, win, False, 0, &warp_event);
104 }
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 * $Id: org_lwjgl_opengl_LinuxPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include "org_lwjgl_opengl_LinuxPeerInfo.h"
41 #include "context.h"
42 #include "common_tools.h"
43
44 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_createHandle
45 (JNIEnv *env, jclass clazz) {
46 return newJavaManagedByteBuffer(env, sizeof(X11PeerInfo));
47 }
48
49 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDisplay(JNIEnv *env, jclass unused, jobject handle) {
50 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, handle);
51 return (jlong)(intptr_t)peer_info->display;
52 }
53
54 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDrawable(JNIEnv *env, jclass unused, jobject handle) {
55 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, handle);
56 return peer_info->drawable;
57 }
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 * $Id: org_lwjgl_opengl_Pbuffer.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Linux Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #include <stdlib.h>
42 #include "org_lwjgl_opengl_LinuxPbufferPeerInfo.h"
43 #include "org_lwjgl_opengl_Pbuffer.h"
44 #include "extgl.h"
45 #include "context.h"
46 #include "common_tools.h"
47
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
49 (JNIEnv *env, jclass clazz, jlong display, jint screen)
50 {
51 Display *disp = (Display *)(intptr_t)display;
52 GLXExtensions extension_flags;
53 if (!extgl_InitGLX(disp, screen, &extension_flags))
54 return 0;
55 // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
56 return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
57 }
58
59 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle
60 (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jint width, jint height, jobject pixel_format) {
61 Display *disp = (Display *)(intptr_t)display;
62 GLXExtensions extension_flags;
63 if (!extgl_InitGLX(disp, screen, &extension_flags) || !extension_flags.GLX13) {
64 throwException(env, "No Pbuffer support");
65 return;
66 }
67 bool result = initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, false, GLX_PBUFFER_BIT, false, true);
68 if (!result)
69 return;
70 const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width,
71 GLX_PBUFFER_HEIGHT, height,
72 GLX_PRESERVED_CONTENTS, True,
73 GLX_LARGEST_PBUFFER, False,
74 None, None};
75
76 X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
77 GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info);
78 if (config != NULL) {
79 GLXPbuffer buffer = lwjgl_glXCreatePbuffer(peer_info->display, *config, buffer_attribs);
80 XFree(config);
81 peer_info->drawable = buffer;
82 }
83 }
84
85 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nDestroy
86 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
87 X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
88 lwjgl_glXDestroyPbuffer(peer_info->display, peer_info->drawable);
89 }
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 * $Id: context.h 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Base Win32 display
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #ifndef __LWJGL_CONTEXT_H
42 #define __LWJGL_CONTEXT_H
43
44 #include <Cocoa/Cocoa.h>
45 #include <OpenGL/gl.h>
46 #include <OpenGL/glext.h>
47 #include "common_tools.h"
48
49 typedef struct {
50 NSOpenGLPixelFormat *pixel_format;
51 bool window;
52 union {
53 NSView *nsview;
54 NSOpenGLPixelBuffer *pbuffer;
55 };
56 } MacOSXPeerInfo;
57
58 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered);
59 #endif
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 * $Id: context.m 3116 2008-08-19 16:46:03Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
37 */
38
39 #import <CoreFoundation/CoreFoundation.h>
40 #import "context.h"
41
42 static CFBundleRef opengl_bundle = NULL;
43
44 void *extgl_GetProcAddress(const char *name) {
45 CFStringRef cf_name = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
46 void *address = CFBundleGetFunctionPointerForName(opengl_bundle, cf_name);
47 CFRelease(cf_name);
48 if (address == NULL)
49 printfDebug("Could not locate symbol %s\n", name);
50 return address;
51 }
52
53 static CFBundleRef loadFramework(JNIEnv *env) {
54 CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenGL.framework");
55 if (framework_path == NULL) {
56 printfDebugJava(env, "Failed to allocate string");
57 return NULL;
58 }
59 CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE);
60 if (url == NULL) {
61 printfDebugJava(env, "Failed to allocate URL");
62 return NULL;
63 }
64 CFBundleRef opengl_bundle = CFBundleCreate(NULL, url);
65 CFRelease(url);
66 return opengl_bundle;
67 }
68
69 bool extgl_Open(JNIEnv *env) {
70 if (opengl_bundle != NULL)
71 return true;
72 opengl_bundle = loadFramework(env);
73 if (opengl_bundle != NULL) {
74 return true;
75 } else {
76 throwException(env, "Could not load OpenGL library");
77 return false;
78 }
79 }
80
81 void extgl_Close(void)
82 {
83 if (opengl_bundle != NULL) {
84 CFRelease(opengl_bundle);
85 opengl_bundle = NULL;
86 }
87 }
88
89 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) {
90 int bpp;
91 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
92 if (use_display_bpp)
93 bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
94 else
95 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
96
97 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
98 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
99 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
100 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
101 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
102 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
103 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
104 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
105 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
106 // TODO: Add floating_point_packed attribute below
107 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
108 // TODO: Add sRGB attribute below
109 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
110
111 attrib_list_t attribs;
112 jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
113 initAttribList(&attribs);
114 if (!allow_software_acceleration)
115 putAttrib(&attribs, NSOpenGLPFAAccelerated);
116 if (double_buffered)
117 putAttrib(&attribs, NSOpenGLPFADoubleBuffer);
118 putAttrib(&attribs, NSOpenGLPFAMinimumPolicy);
119 putAttrib(&attribs, NSOpenGLPFAColorSize); putAttrib(&attribs, bpp);
120 putAttrib(&attribs, NSOpenGLPFAAlphaSize); putAttrib(&attribs, alpha);
121 putAttrib(&attribs, NSOpenGLPFADepthSize); putAttrib(&attribs, depth);
122 putAttrib(&attribs, NSOpenGLPFAStencilSize); putAttrib(&attribs, stencil);
123 putAttrib(&attribs, NSOpenGLPFAAccumSize); putAttrib(&attribs, accum_bpp + accum_alpha);
124 putAttrib(&attribs, NSOpenGLPFASampleBuffers); putAttrib(&attribs, samples > 0 ? 1 : 0);
125 putAttrib(&attribs, NSOpenGLPFASamples); putAttrib(&attribs, samples);
126 putAttrib(&attribs, NSOpenGLPFAAuxBuffers); putAttrib(&attribs, num_aux_buffers);
127 if (support_window)
128 putAttrib(&attribs, NSOpenGLPFAWindow);
129 if (support_pbuffer)
130 putAttrib(&attribs, NSOpenGLPFAPixelBuffer);
131 if (stereo)
132 putAttrib(&attribs, NSOpenGLPFAStereo);
133 if (floating_point)
134 putAttrib(&attribs, NSOpenGLPFAColorFloat);
135 putAttrib(&attribs, 0);
136 NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs.attribs];
137
138 if (fmt == nil) {
139 throwException(env, "Could not create pixel format");
140 return NULL;
141 }
142 return fmt;
143 }
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 "extal.h"
40 #include "common_tools.h"
41
42 /**
43 * $Id: macosx_al.c 2985 2008-04-07 18:42:36Z matzon $
44 *
45 * This file contains the AL extension assigning mechanism
46 *
47 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2985 $
49 */
50
51 static const struct mach_header* handleOAL = NULL;
52 static CFBundleRef openal_bundle = NULL;
53
54 void *NativeGetFunctionPointer(const char *function) {
55 void *address = NULL;
56 if (handleOAL != NULL) {
57 char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
58 if (mac_symbol_name == NULL)
59 return NULL;
60 mac_symbol_name[0] = '_';
61 strcpy(&(mac_symbol_name[1]), function);
62 NSSymbol symbol = NSLookupSymbolInImage(handleOAL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
63 free(mac_symbol_name);
64 if (symbol != NULL) {
65 address = NSAddressOfSymbol(symbol);
66 }
67 } else if (openal_bundle != NULL) {
68 CFStringRef cf_function = CFStringCreateWithCString(NULL, function, kCFStringEncodingUTF8);
69 address = CFBundleGetFunctionPointerForName(openal_bundle, cf_function);
70 CFRelease(cf_function);
71 }
72 return address;
73 }
74
75 static CFBundleRef tryLoadFramework(JNIEnv *env) {
76 CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenAL.framework");
77 if (framework_path == NULL) {
78 printfDebugJava(env, "Failed to allocate string");
79 return NULL;
80 }
81 CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE);
82 if (url == NULL) {
83 printfDebugJava(env, "Failed to allocate URL");
84 return NULL;
85 }
86 CFBundleRef openal_bundle = CFBundleCreate(NULL, url);
87 CFRelease(url);
88 return openal_bundle;
89 }
90
91 void tryLoadLibrary(JNIEnv *env, jstring path) {
92 const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
93 printfDebugJava(env, "Testing '%s'", path_str);
94 handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
95 if (handleOAL != NULL) {
96 printfDebugJava(env, "Found OpenAL at '%s'", path_str);
97 } else {
98 throwException(env, "Could not load OpenAL library");
99 }
100 (*env)->ReleaseStringUTFChars(env, path, path_str);
101 }
102
103 /**
104 * Unloads the OpenAL Library
105 */
106 void UnLoadOpenAL() {
107 if (openal_bundle != NULL) {
108 CFRelease(openal_bundle);
109 openal_bundle = NULL;
110 }
111 }
112
113 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreateDefault(JNIEnv *env, jclass clazz) {
114 openal_bundle = tryLoadFramework(env);
115 if (openal_bundle != NULL)
116 printfDebugJava(env, "Found OpenAL Bundle");
117 else
118 throwException(env, "Could not load OpenAL framework");
119 }
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 * $Id: org_lwjgl_input_Mouse.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Mac OS X mouse handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #include <jni.h>
42 #include <ApplicationServices/ApplicationServices.h>
43 #include "org_lwjgl_opengl_MacOSXMouseEventQueue.h"
44 #include "common_tools.h"
45
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) {
47 CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE);
48 if (grab)
49 CGDisplayHideCursor(kCGDirectMainDisplay);
50 else
51 CGDisplayShowCursor(kCGDirectMainDisplay);
52 }
53
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nWarpCursor(JNIEnv *env, jclass unused, jint x, jint y) {
55 CGPoint p;
56 p.x = x;
57 p.y = y;
58 CGWarpMouseCursorPosition(p);
59 }
60
61 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas(JNIEnv *env, jclass unused, jobject delta_buffer) {
62 CGMouseDelta dx, dy;
63 CGGetLastMouseDelta(&dx, &dy);
64 int buffer_length = (*env)->GetDirectBufferCapacity(env, delta_buffer);
65 if (buffer_length != 2) {
66 printfDebugJava(env, "Delta buffer not large enough!");
67 return;
68 }
69 jint *buffer = (*env)->GetDirectBufferAddress(env, delta_buffer);
70 buffer[0] = dx;
71 buffer[1] = dy;
72 }
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 * $Id: org_lwjgl_opengl_Display.m 3055 2008-04-30 14:58:47Z elias_naur $
34 *
35 * Mac OS X specific display functions.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3055 $
39 */
40
41 #import <Cocoa/Cocoa.h>
42 #import <Carbon/Carbon.h>
43 #import <jawt_md.h>
44 #import <jni.h>
45 #import <unistd.h>
46 //#import "display.h"
47 #import "common_tools.h"
48 #import "org_lwjgl_opengl_MacOSXDisplay.h"
49 #import "org_lwjgl_MacOSXSysImplementation.h"
50
51 #define WAIT_DELAY 100
52
53 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
54 (JNIEnv *env, jobject ignored) {
55 return org_lwjgl_MacOSXSysImplementation_JNI_VERSION;
56 }
57
58 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma(JNIEnv *env, jobject this) {
59 CGDisplayRestoreColorSyncSettings();
60 }
61
62 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) {
63 const CGGammaValue *values = (*env)->GetDirectBufferAddress(env, gamma_buffer);
64 CGTableCount table_size = (*env)->GetDirectBufferCapacity(env, gamma_buffer);
65 CGDisplayErr err = CGSetDisplayTransferByTable(kCGDirectMainDisplay, table_size, values, values, values);
66 if (err != CGDisplayNoErr) {
67 throwException(env, "Could not set display gamma");
68 }
69 }
70
71 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nHideUI(JNIEnv *env, jobject this, jboolean hide) {
72 if (hide == JNI_TRUE) {
73 SetSystemUIMode(kUIModeContentSuppressed, 0);
74 } else {
75 SetSystemUIMode(kUIModeNormal, 0);
76 }
77 }
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 * $Id: org_lwjgl_opengl_MacOSXCanvasPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <jawt_md.h>
41 #include "awt_tools.h"
42 #include "org_lwjgl_opengl_MacOSXCanvasPeerInfo.h"
43 #include "context.h"
44 #include "common_tools.h"
45
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
47 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) {
48 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
49 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
50 AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
51 JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo;
52 peer_info->nsview = macosx_dsi->cocoaViewRef;
53 peer_info->window = true;
54 [pool release];
55 }
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 * $Id: org_lwjgl_opengl_MacOSXContextImplementation.m 3116 2008-08-19 16:46:03Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
37 */
38
39 #import <jni.h>
40 #import <Cocoa/Cocoa.h>
41 #import "org_lwjgl_opengl_MacOSXContextImplementation.h"
42 #import "context.h"
43 #import "common_tools.h"
44
45 typedef struct {
46 NSOpenGLContext *context;
47 } MacOSXContext;
48
49 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCreate
50 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) {
51 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
52 MacOSXPeerInfo *peer_info;
53 MacOSXContext *shared_context_info;
54 MacOSXContext *context_info;
55 NSOpenGLContext *context;
56 NSOpenGLContext *shared_context = NULL;
57 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXContext));
58 if (context_handle == NULL) {
59 throwException(env, "Could not create handle buffer");
60 return NULL;
61 }
62 peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
63 if (shared_context_handle != NULL) {
64 shared_context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle);
65 shared_context = shared_context_info->context;
66 }
67 context = [[NSOpenGLContext alloc] initWithFormat:peer_info->pixel_format shareContext:shared_context];
68 if (context == NULL) {
69 throwException(env, "Could not create context");
70 return NULL;
71 }
72 context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
73 context_info->context = context;
74 [pool release];
75 return context_handle;
76 }
77
78 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSwapBuffers
79 (JNIEnv *env, jclass clazz, jobject context_handle) {
80 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
81 MacOSXContext *peer_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
82 [peer_info->context flushBuffer];
83 [pool release];
84 }
85
86
87 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nUpdate
88 (JNIEnv *env, jclass clazz, jobject context_handle) {
89 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
90 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
91 [context_info->context update];
92 [pool release];
93 }
94
95 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_clearDrawable
96 (JNIEnv *env, jclass clazz, jobject context_handle) {
97 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
98 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
99 [context_info->context clearDrawable];
100 [pool release];
101 }
102
103 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nReleaseCurrentContext
104 (JNIEnv *env, jclass clazz) {
105 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
106 [NSOpenGLContext clearCurrentContext];
107 [pool release];
108 }
109
110 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_setView
111 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
112 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
113 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
114 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
115 if (peer_info->window) {
116 [context_info->context setView: peer_info->nsview];
117 } else {
118 [context_info->context setPixelBuffer:peer_info->pbuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:0];
119 }
120 [pool release];
121 }
122
123 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nMakeCurrent
124 (JNIEnv *env, jclass clazz, jobject context_handle) {
125 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
126 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
127 [context_info->context makeCurrentContext];
128 [pool release];
129 }
130
131 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nIsCurrent
132 (JNIEnv *env, jclass clazz, jobject context_handle) {
133 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
134 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
135 bool result = context_info->context == [NSOpenGLContext currentContext];
136 [pool release];
137 return result ? JNI_TRUE : JNI_FALSE;
138 }
139
140 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSetSwapInterval
141 (JNIEnv *env, jclass clazz, jobject context_handle, jint int_value) {
142 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
143 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
144 GLint value = int_value;
145 [context_info->context setValues:&value forParameter:NSOpenGLCPSwapInterval];
146 [pool release];
147 }
148
149 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nDestroy
150 (JNIEnv *env, jclass clazz, jobject context_handle) {
151 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
152 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
153 [context_info->context clearDrawable];
154 [context_info->context release];
155 [pool release];
156 }
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 * $Id: org_lwjgl_opengl_MacOSXPbufferPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #import <jni.h>
40 #import <Cocoa/Cocoa.h>
41 #import "org_lwjgl_opengl_MacOSXPbufferPeerInfo.h"
42 #import "context.h"
43 #import "common_tools.h"
44
45 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nCreate(JNIEnv *env, jclass clazz, jobject peer_info_handle, jint width, jint height) {
46 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
47 NSOpenGLPixelBuffer *pbuffer = nil;
48 // check if the texture is power of 2
49 if ( (( width > 0 ) && ( width & ( width-1)) == 0) || (( height > 0 ) && ( height & ( height-1)) == 0) )
50 {
51 pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_2D
52 textureInternalFormat:GL_RGBA
53 textureMaxMipMapLevel:0
54 pixelsWide:width
55 pixelsHigh:height];
56 }
57 else
58 {
59 pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT
60 textureInternalFormat:GL_RGBA
61 textureMaxMipMapLevel:0
62 pixelsWide:width
63 pixelsHigh:height];
64 }
65 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
66 peer_info->pbuffer = pbuffer;
67 peer_info->window = false;
68 [pool release];
69 }
70
71 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nDestroy
72 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
73 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
74 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
75 [peer_info->pbuffer release];
76 [pool release];
77 }
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 * $Id: org_lwjgl_opengl_MacOSXPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #import <jni.h>
40 #import <Cocoa/Cocoa.h>
41 #import "org_lwjgl_opengl_MacOSXPeerInfo.h"
42 #import "context.h"
43 #import "common_tools.h"
44
45 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_createHandle
46 (JNIEnv *env, jclass clazz) {
47 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
48 jobject handle = newJavaManagedByteBuffer(env, sizeof(MacOSXPeerInfo));
49 [pool release];
50 return handle;
51 }
52
53 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nChoosePixelFormat
54 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject pixel_format, jboolean use_display_bpp, jboolean support_window, jboolean support_pbuffer, jboolean double_buffered) {
55 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
56 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
57 NSOpenGLPixelFormat *macosx_pixel_format = choosePixelFormat(env, pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered);
58 if (pixel_format == nil) {
59 throwException(env, "Could not find pixel format");
60 return;
61 }
62 peer_info->pixel_format = macosx_pixel_format;
63 [pool release];
64 }
65
66 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nDestroy
67 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
68 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
69 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
70 [peer_info->pixel_format release];
71 [pool release];
72 }
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 * $Id: LWJGL.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Basic DLL stub.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #define WIN32_LEAN_AND_MEAN
42 #include <windows.h>
43 #include <stdio.h>
44 #include <jni.h>
45 #include "org_lwjgl_opengl_WindowsDisplay.h"
46
47 HINSTANCE dll_handle;
48
49 /*
50 * DLL entry point for Windows. Called when Java loads the .dll
51 */
52 BOOL WINAPI DllMain(
53 HINSTANCE hinstDLL, // handle to DLL module
54 DWORD fdwReason, // reason for calling function
55 LPVOID lpvReserved // reserved
56 )
57 {
58 dll_handle = hinstDLL;
59 return TRUE; // Success
60 }
61
62 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDllInstance(JNIEnv *env, jclass unused) {
63 return (LONG_PTR)dll_handle;
64 }
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 * $Id: Window.h 3227 2009-07-07 19:47:55Z matzon $
34 *
35 * Include file to access public window features
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3227 $
39 */
40 #ifndef _LWJGL_WINDOW_H_INCLUDED_
41 #define _LWJGL_WINDOW_H_INCLUDED_
42
43 #define WIN32_LEAN_AND_MEAN
44 #ifndef _WIN32_WINDOWS
45 #define _WIN32_WINDOWS 0x0500
46 #endif
47 #ifndef WINVER
48 #define WINVER 0x0500
49 #endif
50 #ifndef _WIN32_WINNT
51 #define _WIN32_WINNT 0x0400
52 #endif
53
54 #include <windows.h>
55 #include <jni.h>
56 #include "common_tools.h"
57
58 #ifdef _PRIVATE_WINDOW_H_
59 #define WINDOW_H_API
60 #else
61 #define WINDOW_H_API extern
62 #endif /* _PRIVATE_WINDOW_H_ */
63
64 #endif /* _LWJGL_WINDOW_H_INCLUDED_ */
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 * $Id: context.c 3139 2008-10-28 09:53:16Z elias_naur $
34 *
35 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3139 $
37 */
38
39 #include <malloc.h>
40 #include <jni.h>
41 #include "common_tools.h"
42 #include "extgl.h"
43 #include "extgl_wgl.h"
44 #include "context.h"
45
46 extern HINSTANCE dll_handle; // Handle to the LWJGL dll
47
48 #define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name"
49
50 /*
51 * Register the LWJGL window class.
52 * Returns true for success, or false for failure
53 */
54 bool registerWindow(WNDPROC win_proc, LPCTSTR class_name)
55 {
56 WNDCLASS windowClass;
57 memset(&windowClass, 0, sizeof(windowClass));
58 windowClass.style = CS_OWNDC;
59 windowClass.lpfnWndProc = win_proc;
60 windowClass.cbClsExtra = 0;
61 windowClass.cbWndExtra = 0;
62 windowClass.hInstance = dll_handle;
63 windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
64 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
65 windowClass.hbrBackground = NULL;
66 windowClass.lpszMenuName = NULL;
67 windowClass.lpszClassName = class_name;
68
69 if (RegisterClass(&windowClass) == 0) {
70 printfDebug("Failed to register window class\n");
71 return false;
72 }
73 return true;
74 }
75
76 static LRESULT CALLBACK dummyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
77 return DefWindowProc(hwnd, msg, wParam, lParam);
78 }
79
80 bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat) {
81 PIXELFORMATDESCRIPTOR desc;
82 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
83 throwFormattedException(env, "DescribePixelFormat failed (%d)", GetLastError());
84 return false;
85 }
86
87 // make that the pixel format of the device context
88 if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) {
89 throwFormattedException(env, "SetPixelFormat failed (%d)", GetLastError());
90 return false;
91 }
92 return true;
93 }
94
95 /*
96 * Close the window
97 */
98 void closeWindow(HWND *hwnd, HDC *hdc)
99 {
100 // Release device context
101 if (*hdc != NULL && *hwnd != NULL) {
102 ReleaseDC(*hwnd, *hdc);
103 *hdc = NULL;
104 }
105
106 // Close the window
107 if (*hwnd != NULL) {
108 ShowWindow(*hwnd, SW_HIDE);
109 DestroyWindow(*hwnd);
110 *hwnd = NULL;
111 }
112 }
113
114 void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window) {
115 DWORD exstyle, windowflags;
116 if (undecorated) {
117 exstyle = WS_EX_APPWINDOW;
118 windowflags = WS_POPUP;
119 } else if (child_window) {
120 exstyle = 0;
121 windowflags = WS_CHILDWINDOW;
122 } else {
123 exstyle = WS_EX_APPWINDOW;
124 windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
125 }
126 windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
127 *windowflags_return = windowflags;
128 *exstyle_return = exstyle;
129 }
130
131 HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent)
132 {
133 RECT clientSize;
134 DWORD exstyle, windowflags;
135 HWND new_hwnd;
136
137 getWindowFlags(&windowflags, &exstyle, undecorated, child_window);
138
139 clientSize.bottom = height;
140 clientSize.left = 0;
141 clientSize.right = width;
142 clientSize.top = 0;
143
144 AdjustWindowRectEx(
145 &clientSize, // client-rectangle structure
146 windowflags, // window styles
147 FALSE, // menu-present option
148 exstyle // extended window style
149 );
150 // Create the window now, using that class:
151 new_hwnd = CreateWindowEx (
152 exstyle,
153 window_class_name,
154 "",
155 windowflags,
156 x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
157 parent,
158 NULL,
159 dll_handle,
160 NULL);
161
162 return new_hwnd;
163 }
164
165 static int convertToBPE(int bpp) {
166 int bpe;
167 switch (bpp) {
168 case 0:
169 bpe = 0;
170 break;
171 case 32:
172 case 24:
173 bpe = 8;
174 break;
175 case 16: /* Fall through */
176 default:
177 bpe = 4;
178 break;
179 }
180 return bpe;
181 }
182
183 static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) {
184 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
185 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
186 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
187 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
188 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
189 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
190 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
191 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
192
193 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
194 jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
195 jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
196 jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
197
198 int pixel_type;
199 int iPixelFormat;
200 unsigned int num_formats_returned;
201 attrib_list_t attrib_list;
202 GLuint *pixelFormatCaps_ptr;
203 jlong pixelFormatCapsSize;
204 BOOL result;
205 jlong i;
206 int bpe = convertToBPE(bpp);
207
208 if ( floating_point )
209 pixel_type = WGL_TYPE_RGBA_FLOAT_ARB;
210 else if ( floating_point_packed )
211 pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT;
212 else
213 pixel_type = WGL_TYPE_RGBA_ARB;
214
215 initAttribList(&attrib_list);
216 if (window) {
217 putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE);
218 }
219 if (pbuffer) {
220 putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE);
221 }
222 if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"))
223 putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB);
224 putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type);
225 putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE);
226 putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE);
227 putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe);
228 putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe);
229 putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe);
230 putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha);
231 putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth);
232 putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil);
233 // Assume caller checked extension availability
234 if (samples > 0) {
235 putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
236 putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples);
237 }
238 putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp);
239 putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha);
240 putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE);
241 putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers);
242 if (sRGB) {
243 putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, TRUE);
244 }
245
246 // Assume caller checked extension availability
247 if (pixelFormatCaps != NULL) {
248 pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps);
249 pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps);
250
251 for (i = 0; i < pixelFormatCapsSize; i++)
252 putAttrib(&attrib_list, pixelFormatCaps_ptr[i]);
253 }
254 putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0);
255 result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned);
256
257 if (result == FALSE || num_formats_returned < 1) {
258 throwFormattedException(env, "Failed to find ARB pixel format %d %d\n", result, num_formats_returned);
259 return -1;
260 }
261 return iPixelFormat;
262 }
263
264 static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) {
265 int bpp;
266 int iPixelFormat;
267 int fallback_bpp = 16;
268 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
269 if (use_hdc_bpp) {
270 bpp = GetDeviceCaps(hdc, BITSPIXEL);
271 iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
272 if ((*env)->ExceptionOccurred(env)) {
273 (*env)->ExceptionClear(env);
274 printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
275 bpp = fallback_bpp;
276 } else
277 return iPixelFormat;
278 } else
279 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
280 return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
281 }
282
283 /*
284 * Find an appropriate pixel format
285 */
286 static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer)
287 {
288 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
289 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
290 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
291 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
292 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
293 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
294 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
295 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
296 unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
297 PFD_SUPPORT_OPENGL |
298 (double_buffer ? PFD_DOUBLEBUFFER : 0) |
299 (stereo ? PFD_STEREO : 0);
300 PIXELFORMATDESCRIPTOR desc;
301 int iPixelFormat;
302 PIXELFORMATDESCRIPTOR pfd = {
303 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
304 1, // version number
305 flags, // RGBA type
306 PFD_TYPE_RGBA,
307 (BYTE)bpp,
308 0, 0, 0, 0, 0, 0, // color bits ignored
309 (BYTE)alpha,
310 0, // shift bit ignored
311 accum_bpp + accum_alpha, // no accumulation buffer
312 0, 0, 0, 0, // accum bits ignored
313 (BYTE)depth,
314 (BYTE)stencil,
315 num_aux_buffers,
316 PFD_MAIN_PLANE, // main layer
317 0, // reserved
318 0, 0, 0 // layer masks ignored
319 };
320 // get the best available match of pixel format for the device context
321 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
322 if (iPixelFormat == 0) {
323 throwException(env, "Failed to choose pixel format");
324 return -1;
325 }
326
327 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
328 throwException(env, "Could not describe pixel format");
329 return -1;
330 }
331
332 if (desc.cColorBits < bpp) {
333 throwException(env, "Insufficient color precision");
334 return -1;
335 }
336
337 if (desc.cAlphaBits < alpha) {
338 throwException(env, "Insufficient alpha precision");
339 return -1;
340 }
341
342 if (desc.cStencilBits < stencil) {
343 throwException(env, "Insufficient stencil precision");
344 return -1;
345 }
346
347 if (desc.cDepthBits < depth) {
348 throwException(env, "Insufficient depth buffer precision");
349 return -1;
350 }
351
352 if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) {
353 jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
354 // secondary check for software override
355 if(!allowSoftwareOpenGL) {
356 throwException(env, "Pixel format not accelerated");
357 return -1;
358 }
359 }
360
361 if ((desc.dwFlags & flags) != flags) {
362 throwException(env, "Capabilities not supported");
363 return -1;
364 }
365 return iPixelFormat;
366 }
367
368 static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bool use_hdc_bpp, bool double_buffer) {
369 int bpp;
370 int iPixelFormat;
371 int fallback_bpp = 16;
372 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
373 if (use_hdc_bpp) {
374 bpp = GetDeviceCaps(hdc, BITSPIXEL);
375 iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
376 if ((*env)->ExceptionOccurred(env)) {
377 (*env)->ExceptionClear(env);
378 printfDebugJava(env, "Failed to find pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
379 bpp = fallback_bpp;
380 } else
381 return iPixelFormat;
382 } else
383 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
384 return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
385 }
386
387 static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) {
388 if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) {
389 throwException(env, "Could not bind context to dummy window");
390 return false;
391 }
392 extgl_InitWGL(extensions);
393
394 if (!extensions->WGL_ARB_pixel_format) {
395 throwException(env, "No support for WGL_ARB_pixel_format");
396 return false;
397 }
398 if (samples > 0 && !extensions->WGL_ARB_multisample) {
399 throwException(env, "No support for WGL_ARB_multisample");
400 return false;
401 }
402 /*
403 * Apparently, some drivers don't report WGL_ARB_pixel_format_float
404 * even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float
405 * is supported.
406 */
407 if (floating_point && !(extensions->WGL_ARB_pixel_format_float || extensions->WGL_ATI_pixel_format_float)) {
408 throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float");
409 return false;
410 }
411 if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) {
412 throwException(env, "No support for WGL_EXT_pixel_format_packed_float");
413 return false;
414 }
415 if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) {
416 throwException(env, "No support for WGL_ARB_framebuffer_sRGB");
417 return false;
418 }
419 if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) {
420 throwException(env, "No support for WGL_ARB_render_texture");
421 return false;
422 }
423 return true;
424 }
425
426 int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) {
427 HGLRC dummy_hglrc;
428 HDC saved_current_hdc;
429 HGLRC saved_current_hglrc;
430 WGLExtensions extensions;
431 HWND dummy_hwnd;
432 HDC dummy_hdc;
433 int pixel_format_id;
434 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
435
436 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
437 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
438 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
439 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
440 bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL;
441
442 pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer);
443 if (!(*env)->ExceptionOccurred(env) && use_arb_selection) {
444 dummy_hwnd = createDummyWindow(origin_x, origin_y);
445 if (dummy_hwnd == NULL) {
446 throwException(env, "Could not create dummy window");
447 return -1;
448 }
449 dummy_hdc = GetDC(dummy_hwnd);
450 if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) {
451 closeWindow(&dummy_hwnd, &dummy_hdc);
452 return -1;
453 }
454 dummy_hglrc = wglCreateContext(dummy_hdc);
455 if (dummy_hglrc == NULL) {
456 closeWindow(&dummy_hwnd, &dummy_hdc);
457 throwException(env, "Failed to create OpenGL rendering context");
458 return -1;
459 }
460 // Save the current HDC and HGLRC to avoid disruption
461 saved_current_hdc = wglGetCurrentDC();
462 saved_current_hglrc = wglGetCurrentContext();
463 if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) {
464 pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer);
465 }
466 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
467 wglDeleteContext(dummy_hglrc);
468 closeWindow(&dummy_hwnd, &dummy_hdc);
469 }
470 return pixel_format_id;
471 }
472
473 static bool registerDummyWindow() {
474 static bool window_registered = false;
475 if (!window_registered) {
476 if (!registerWindow(dummyWindowProc, _CONTEXT_PRIVATE_CLASS_NAME)) {
477 return false;
478 }
479 window_registered = true;
480 }
481 return true;
482 }
483
484 HWND createDummyWindow(int origin_x, int origin_y) {
485 if (!registerDummyWindow())
486 return NULL;
487 return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
488 }
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 * $Id: context.h 3139 2008-10-28 09:53:16Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3139 $
37 */
38
39 #ifndef __LWJGL_CONTEXT_H
40 #define __LWJGL_CONTEXT_H
41
42 #include <windows.h>
43 #include <jni.h>
44 #include "common_tools.h"
45 #include "extgl.h"
46 #include "extgl_wgl.h"
47
48 typedef struct {
49 union {
50 HWND hwnd;
51 struct {
52 HPBUFFERARB pbuffer;
53 // Contains the function pointers that
54 // created the pbuffer
55 WGLExtensions extensions;
56 } pbuffer;
57 } u;
58 HDC drawable_hdc;
59 } WindowsPeerInfo;
60
61 /*
62 * Register the LWJGL window class.
63 * Returns true for success, or false for failure
64 */
65 extern bool registerWindow();
66
67 extern bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat);
68
69 /*
70 * Close the window
71 */
72 extern void closeWindow(HWND *hwnd, HDC *hdc);
73
74 /**
75 * Create a dummy window suitable to create contexts from
76 */
77 extern HWND createDummyWindow(int x, int y);
78
79 /**
80 * Return appropriate window and extended style flags from the given fullscreen and undecorated property
81 */
82 extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window);
83
84 /*
85 * Create a window with the specified position, size, and
86 * fullscreen attribute. The window will have DirectInput associated
87 * with it.
88 *
89 * Returns true for success, or false for failure
90 */
91 extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent);
92
93 extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer);
94
95 #endif
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 * $Id: display.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Windows specific library for display handling.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #include <windows.h>
42 #include <jni.h>
43 #include "org_lwjgl_opengl_WindowsDisplay.h"
44 #include "display.h"
45 #include "common_tools.h"
46
47 static jobject createDisplayMode(JNIEnv *env, DEVMODE *devmode) {
48 jclass displayModeClass;
49
50 jmethodID displayModeConstructor;
51
52 displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
53 if (displayModeClass == NULL)
54 return NULL;
55 displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
56 if (displayModeConstructor == NULL)
57 return NULL;
58
59 return (*env)->NewObject(env, displayModeClass, displayModeConstructor,
60 devmode->dmPelsWidth, devmode->dmPelsHeight,
61 devmode->dmBitsPerPel, devmode->dmDisplayFrequency);
62 }
63
64 /**
65 * Choose displaymodes using extended codepath (multiple displaydevices)
66 */
67 jobjectArray getAvailableDisplayModes(JNIEnv * env) {
68
69 int i = 0, j = 0, n = 0;
70
71 // DISPLAY_DEVICE DisplayDevice;
72 DEVMODE DevMode;
73 jobject *display_mode_objects = NULL;
74 int list_size = 0;
75
76 jclass displayModeClass;
77 jobjectArray ret;
78 displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
79
80 ZeroMemory(&DevMode, sizeof(DEVMODE));
81 // ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));
82
83 DevMode.dmSize = sizeof(DEVMODE);
84 // DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
85
86 /* Multi-monitor stuff commented out since we're only really interested in the primary monitor */
87 /* while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
88 // continue if mirroring device
89 if((DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) != 0) {
90 continue;
91 }
92
93 j = 0;
94 while(EnumDisplaySettings((const char *) DisplayDevice.DeviceName, j++, &DevMode) != 0) {*/
95 while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
96 // Filter out indexed modes
97 if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) {
98 jobject displayMode;
99 if (list_size <= n) {
100 list_size += 1;
101 display_mode_objects = (jobject *)realloc(display_mode_objects, sizeof(jobject)*list_size);
102 if (display_mode_objects == NULL)
103 return NULL;
104 }
105 displayMode = createDisplayMode(env, &DevMode);
106 display_mode_objects[n++] = displayMode;
107 }
108 }
109 // }
110 printfDebugJava(env, "Found %d displaymodes", n);
111
112 ret = (*env)->NewObjectArray(env, n, displayModeClass, NULL);
113 for (i = 0; i < n; i++) {
114 (*env)->SetObjectArrayElement(env, ret, i, display_mode_objects[i]);
115 }
116 free(display_mode_objects);
117 return ret;
118 }
119
120 void switchDisplayMode(JNIEnv * env, jobject mode) {
121 DEVMODE devmode;
122
123 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
124 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
125 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
126 jfieldID fid_bpp = (*env)->GetFieldID(env, cls_displayMode, "bpp", "I");
127 jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I");
128
129 int width = (*env)->GetIntField(env, mode, fid_width);
130 int height = (*env)->GetIntField(env, mode, fid_height);
131 int bpp = (*env)->GetIntField(env, mode, fid_bpp);
132 int freq = (*env)->GetIntField(env, mode, fid_freq);
133 LONG cdsret;
134
135 ZeroMemory(&devmode, sizeof(DEVMODE));
136 devmode.dmSize = sizeof(DEVMODE);
137 devmode.dmBitsPerPel = bpp;
138 devmode.dmPelsWidth = width;
139 devmode.dmPelsHeight = height;
140 devmode.dmDisplayFrequency = freq;
141 devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
142 if (freq != 0)
143 devmode.dmFields |= DM_DISPLAYFREQUENCY;
144 cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
145
146 if (cdsret != DISP_CHANGE_SUCCESSFUL) {
147 /* What's the proper way to do this multiply with 2 thing, if at all necessary? */
148 /* // Failed: so let's check to see if it's a wierd dual screen display
149 printfDebugJava(env, "Failed to set display mode (%ld) ... assuming dual monitors", cdsret);
150 devmode.dmPelsWidth = width * 2;
151 cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
152
153 if (cdsret != DISP_CHANGE_SUCCESSFUL) {
154 printfDebugJava(env, "Failed to set display mode using dual monitors (%ld)", cdsret);*/
155 throwFormattedException(env, "Failed to set display mode (%ld).", cdsret);
156 return;
157 // }
158 }
159 }
160
161 static jobject createNativeGammaBuffer(JNIEnv *env) {
162 return newJavaManagedByteBuffer(env, sizeof(WORD)*3*org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH);
163 }
164
165 jobject getCurrentGammaRamp(JNIEnv *env) {
166 jobject gamma_buffer;
167 WORD *gamma;
168 HDC screenDC;
169
170 gamma_buffer = createNativeGammaBuffer(env);
171 if (gamma_buffer == NULL)
172 return NULL;
173 gamma = (WORD *)(*env)->GetDirectBufferAddress(env, gamma_buffer);
174
175 // Get the screen
176 screenDC = GetDC(NULL);
177 if (screenDC == NULL) {
178 throwException(env, "Couldn't get screen DC!");
179 return NULL;
180 }
181 // Get the default gamma ramp
182 if (GetDeviceGammaRamp(screenDC, gamma) == FALSE) {
183 printfDebugJava(env, "Failed to get initial device gamma");
184 }
185 ReleaseDC(NULL, screenDC);
186 return gamma_buffer;
187 }
188
189 void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) {
190 HDC screenDC;
191 WORD *gammaRamp = (WORD *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer);
192
193 screenDC = GetDC(NULL);
194 if (SetDeviceGammaRamp(screenDC, gammaRamp) == FALSE) {
195 throwException(env, "Failed to set device gamma.");
196 }
197 ReleaseDC(NULL, screenDC);
198 }
199
200 jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj) {
201 int i;
202 float scaledRampEntry;
203 WORD rampEntry;
204 const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj);
205 jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj);
206 jobject native_ramp;
207 WORD *native_ramp_buffer;
208
209 native_ramp = createNativeGammaBuffer(env);
210 if (native_ramp == NULL)
211 return NULL;
212 native_ramp_buffer = (WORD *)(*env)->GetDirectBufferAddress(env, native_ramp);
213 // Turn array of floats into array of RGB WORDs
214
215 for (i = 0; i < gamma_ramp_length; i++) {
216 scaledRampEntry = gammaRamp[i]*0xffff;
217 rampEntry = (WORD)scaledRampEntry;
218 native_ramp_buffer[i] = rampEntry;
219 native_ramp_buffer[i + org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH] = rampEntry;
220 native_ramp_buffer[i + 2*org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH] = rampEntry;
221 }
222 return native_ramp;
223 }
224
225 jobject getCurrentDisplayMode(JNIEnv * env) {
226 DEVMODE devmode;
227 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) {
228 throwFormattedException(env, "Couldn't get current display settings (%ld)", GetLastError());
229 return NULL;
230 }
231 return createDisplayMode(env, &devmode);
232 }
233
234 void resetDisplayMode(JNIEnv * env) {
235 // Under Windows, all we have to do is:
236 ChangeDisplaySettings(NULL, 0);
237 }
238
239 jobject getVersion(JNIEnv * env, char *driver)
240 {
241 DWORD var = 0;
242 DWORD dwInfoSize;
243 LPVOID lpInfoBuff;
244 BOOL bRetval;
245 jclass version_class;
246 jmethodID version_cons;
247 jobject ret = NULL;
248
249 version_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsFileVersion");
250 if (version_class == NULL)
251 return NULL;
252 version_cons = (*env)->GetMethodID(env, version_class, "<init>", "(II)V");
253 if (version_cons == NULL)
254 return NULL;
255
256 dwInfoSize = GetFileVersionInfoSize(driver, &var);
257 lpInfoBuff = malloc(dwInfoSize);
258 if (lpInfoBuff == NULL) {
259 throwException(env, "Failed to allocate lpInfoBuff");
260 return NULL;
261 }
262 bRetval = GetFileVersionInfo(driver, 0, dwInfoSize, lpInfoBuff);
263 if (bRetval != 0) {
264 VS_FIXEDFILEINFO * fxdFileInfo;
265
266 UINT uiLen = 0;
267 bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void *)&fxdFileInfo, &uiLen);
268 if (bRetval != 0)
269 ret = (*env)->NewObject(env, version_class, version_cons, fxdFileInfo->dwProductVersionMS, fxdFileInfo->dwProductVersionLS);
270 }
271
272 free(lpInfoBuff);
273
274 return ret;
275 }
276
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 * $Id: display.h 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * Windows specific library for display handling.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
39 */
40
41 #ifndef _DISPLAY_H
42 #define _DISPLAY_H
43
44 #include <jni.h>
45
46 extern jobjectArray getAvailableDisplayModes(JNIEnv *env);
47 extern void switchDisplayMode(JNIEnv * env, jobject mode);
48 extern void resetDisplayMode(JNIEnv * env);
49 extern void restoreDisplayMode(void);
50 extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer);
51 extern jobject getCurrentGammaRamp(JNIEnv *env);
52 extern jobject getCurrentDisplayMode(JNIEnv * env);
53 extern jobject getVersion(JNIEnv * env, char *driver);
54 extern jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj);
55
56 #endif
0 /* ----------------------------------------------------------------------------
1 Copyright (c) 2001-2002, Lev Povalahev
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12 * The name of the author may be used to endorse or promote products
13 derived from this software without specific prior written permission.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 THE POSSIBILITY OF SUCH DAMAGE.
25 ------------------------------------------------------------------------------*/
26 /*
27 Lev Povalahev
28
29 levp@gmx.net
30
31 http://www.uni-karlsruhe.de/~uli2/
32
33 */
34
35 #include <stdio.h>
36 #include <string.h>
37 #include "extgl_wgl.h"
38 #include "extgl.h"
39
40 static HMODULE lib_gl_handle = NULL;
41
42 void *extgl_GetProcAddress(const char *name) {
43 void *t = wglGetProcAddress(name);
44 if (t == NULL)
45 {
46 t = GetProcAddress(lib_gl_handle, name);
47 if (t == NULL)
48 {
49 printfDebug("Could not locate symbol %s\n", name);
50 }
51 }
52 return t;
53 }
54
55 bool extgl_Open(JNIEnv *env) {
56 if (lib_gl_handle != NULL)
57 return true;
58 // load the dynamic libraries for OpenGL
59 lib_gl_handle = LoadLibrary("opengl32.dll");
60 if (lib_gl_handle == NULL) {
61 throwException(env, "Could not load OpenGL library");
62 return false;
63 }
64 return true;
65 }
66
67 void extgl_Close(void) {
68 FreeLibrary(lib_gl_handle);
69 lib_gl_handle = NULL;
70 }
71
72 /** returns true if the extension is available */
73 static bool WGLQueryExtension(WGLExtensions *extensions, const char *name) {
74 const GLubyte *extension_string;
75
76 if (!extensions->WGL_ARB_extensions_string)
77 if (!extensions->WGL_EXT_extensions_string)
78 return false;
79 else
80 extension_string = (GLubyte*)extensions->wglGetExtensionsStringEXT();
81 else
82 extension_string = (GLubyte*)extensions->wglGetExtensionsStringARB(wglGetCurrentDC());
83 return extgl_QueryExtension(extension_string, name);
84 }
85
86 static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) {
87 ExtFunction functions[] = {
88 {"wglCreatePbufferARB", (void *)&extensions->wglCreatePbufferARB},
89 {"wglGetPbufferDCARB", (void *)&extensions->wglGetPbufferDCARB},
90 {"wglReleasePbufferDCARB", (void *)&extensions->wglReleasePbufferDCARB},
91 {"wglDestroyPbufferARB", (void *)&extensions->wglDestroyPbufferARB},
92 {"wglQueryPbufferARB", (void *)&extensions->wglQueryPbufferARB}};
93 if (extensions->WGL_ARB_pbuffer)
94 extensions->WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
95 }
96
97 static void extgl_InitWGLARBPixelFormat(WGLExtensions *extensions) {
98 ExtFunction functions[] = {
99 {"wglGetPixelFormatAttribivARB", (void *)&extensions->wglGetPixelFormatAttribivARB},
100 {"wglGetPixelFormatAttribfvARB", (void *)&extensions->wglGetPixelFormatAttribfvARB},
101 {"wglChoosePixelFormatARB", (void *)&extensions->wglChoosePixelFormatARB}};
102 if (extensions->WGL_ARB_pixel_format)
103 extensions->WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
104 }
105
106 static void extgl_InitWGLARBRenderTexture(WGLExtensions *extensions) {
107 ExtFunction functions[] = {
108 {"wglBindTexImageARB", (void *)&extensions->wglBindTexImageARB},
109 {"wglReleaseTexImageARB", (void *)&extensions->wglReleaseTexImageARB},
110 {"wglSetPbufferAttribARB", (void *)&extensions->wglSetPbufferAttribARB}};
111 if (extensions->WGL_ARB_render_texture)
112 extensions->WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
113 }
114
115 static void extgl_InitWGLEXTSwapControl(WGLExtensions *extensions) {
116 ExtFunction functions[] = {
117 {"wglSwapIntervalEXT", (void *)&extensions->wglSwapIntervalEXT},
118 {"wglGetSwapIntervalEXT", (void *)&extensions->wglGetSwapIntervalEXT}};
119 if (extensions->WGL_EXT_swap_control)
120 extensions->WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
121 }
122
123 static void extgl_InitWGLARBMakeCurrentRead(WGLExtensions *extensions) {
124 ExtFunction functions[] = {
125 {"wglMakeContextCurrentARB", (void *)&extensions->wglMakeContextCurrentARB},
126 {"wglGetCurrentReadDCARB", (void *)&extensions->wglGetCurrentReadDCARB}};
127 if (extensions->WGL_ARB_make_current_read)
128 extensions->WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
129 }
130
131 static void extgl_InitWGLARBCreateContext(WGLExtensions *extensions) {
132 ExtFunction functions[] = {
133 {"wglCreateContextAttribsARB", (void *)&extensions->wglCreateContextAttribsARB}
134 };
135 if (extensions->WGL_ARB_create_context)
136 extensions->WGL_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
137 }
138
139 static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) {
140 extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region");
141 extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read");
142 extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample");
143 extensions->WGL_ARB_pixel_format_float = WGLQueryExtension(extensions, "WGL_ARB_pixel_format_float");
144 extensions->WGL_ATI_pixel_format_float = WGLQueryExtension(extensions, "WGL_ATI_pixel_format_float");
145 extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer");
146 extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format");
147 extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture");
148 extensions->WGL_EXT_swap_control = WGLQueryExtension(extensions, "WGL_EXT_swap_control");
149 extensions->WGL_NV_render_depth_texture = WGLQueryExtension(extensions, "WGL_NV_render_depth_texture");
150 extensions->WGL_NV_render_texture_rectangle = WGLQueryExtension(extensions, "WGL_NV_render_texture_rectangle");
151 extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB");
152 extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float");
153 extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context");
154 }
155
156 static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) {
157 ExtFunction functions[] = {
158 {"wglGetExtensionsStringEXT", (void *)&extensions->wglGetExtensionsStringEXT}
159 };
160 extensions->WGL_EXT_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
161 }
162
163 static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) {
164 ExtFunction functions[] = {
165 {"wglGetExtensionsStringARB", (void *)&extensions->wglGetExtensionsStringARB}
166 };
167 extensions->WGL_ARB_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
168 }
169
170 void extgl_InitWGL(WGLExtensions *extensions) {
171 extgl_InitWGLARBExtensionsString(extensions);
172 extgl_InitWGLEXTExtensionsString(extensions);
173
174 extgl_InitSupportedWGLExtensions(extensions);
175
176 extgl_InitWGLARBMakeCurrentRead(extensions);
177 extgl_InitWGLEXTSwapControl(extensions);
178 extgl_InitWGLARBRenderTexture(extensions);
179 extgl_InitWGLARBPixelFormat(extensions);
180 extgl_InitWGLARBPbuffer(extensions);
181 extgl_InitWGLARBCreateContext(extensions);
182 }
0 /* ----------------------------------------------------------------------------
1 Copyright (c) 2001-2002, Lev Povalahev
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12 * The name of the author may be used to endorse or promote products
13 derived from this software without specific prior written permission.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 THE POSSIBILITY OF SUCH DAMAGE.
25 ------------------------------------------------------------------------------*/
26 /*
27 Lev Povalahev
28
29 levp@gmx.net
30
31 http://www.uni-karlsruhe.de/~uli2/
32
33 */
34
35 #ifndef _EXTGL_WGL_H
36 #define _EXTGL_WGL_H
37
38 #include <windows.h>
39 #include "extgl.h"
40 #include "common_tools.h"
41
42 /*-------------------------------------------------------------------*/
43 /*------------WGL_EXT_EXTENSION_STRING-------------------------------*/
44 /*-------------------------------------------------------------------*/
45
46 typedef const char* (APIENTRY * wglGetExtensionsStringEXTPROC) ();
47
48 /*-------------------------------------------------------------------*/
49 /*------------WGL_ARB_EXTENSION_STRING-------------------------------*/
50 /*-------------------------------------------------------------------*/
51
52 typedef const char* (APIENTRY * wglGetExtensionsStringARBPROC) (HDC hdc);
53
54 /*-------------------------------------------------------------------*/
55 /*------------WGL_ARB_PBUFFER----------------------------------------*/
56 /*-------------------------------------------------------------------*/
57
58 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D
59 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D
60 #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
61 #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
62 #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
63 #define WGL_PBUFFER_LARGEST_ARB 0x2033
64 #define WGL_PBUFFER_WIDTH_ARB 0x2034
65 #define WGL_PBUFFER_HEIGHT_ARB 0x2035
66 #define WGL_PBUFFER_LOST_ARB 0x2036
67
68 DECLARE_HANDLE(HPBUFFERARB);
69
70 typedef HPBUFFERARB (APIENTRY * wglCreatePbufferARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
71 typedef HDC (APIENTRY * wglGetPbufferDCARBPROC) (HPBUFFERARB hPbuffer);
72 typedef int (APIENTRY * wglReleasePbufferDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
73 typedef BOOL (APIENTRY * wglDestroyPbufferARBPROC) (HPBUFFERARB hPbuffer);
74 typedef BOOL (APIENTRY * wglQueryPbufferARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
75
76 /*-------------------------------------------------------------------*/
77 /*------------WGL_ARB_PIXEL_FORMAT-----------------------------------*/
78 /*-------------------------------------------------------------------*/
79
80 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
81 #define WGL_DRAW_TO_WINDOW_ARB 0x2001
82 #define WGL_DRAW_TO_BITMAP_ARB 0x2002
83 #define WGL_ACCELERATION_ARB 0x2003
84 #define WGL_NEED_PALETTE_ARB 0x2004
85 #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
86 #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
87 #define WGL_SWAP_METHOD_ARB 0x2007
88 #define WGL_NUMBER_OVERLAYS_ARB 0x2008
89 #define WGL_NUMBER_UNDERLAYS_ARB 0x2009
90 #define WGL_TRANSPARENT_ARB 0x200A
91 #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
92 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
93 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
94 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
95 #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
96 #define WGL_SHARE_DEPTH_ARB 0x200C
97 #define WGL_SHARE_STENCIL_ARB 0x200D
98 #define WGL_SHARE_ACCUM_ARB 0x200E
99 #define WGL_SUPPORT_GDI_ARB 0x200F
100 #define WGL_SUPPORT_OPENGL_ARB 0x2010
101 #define WGL_DOUBLE_BUFFER_ARB 0x2011
102 #define WGL_STEREO_ARB 0x2012
103 #define WGL_PIXEL_TYPE_ARB 0x2013
104 #define WGL_COLOR_BITS_ARB 0x2014
105 #define WGL_RED_BITS_ARB 0x2015
106 #define WGL_RED_SHIFT_ARB 0x2016
107 #define WGL_GREEN_BITS_ARB 0x2017
108 #define WGL_GREEN_SHIFT_ARB 0x2018
109 #define WGL_BLUE_BITS_ARB 0x2019
110 #define WGL_BLUE_SHIFT_ARB 0x201A
111 #define WGL_ALPHA_BITS_ARB 0x201B
112 #define WGL_ALPHA_SHIFT_ARB 0x201C
113 #define WGL_ACCUM_BITS_ARB 0x201D
114 #define WGL_ACCUM_RED_BITS_ARB 0x201E
115 #define WGL_ACCUM_GREEN_BITS_ARB 0x201F
116 #define WGL_ACCUM_BLUE_BITS_ARB 0x2020
117 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
118 #define WGL_DEPTH_BITS_ARB 0x2022
119 #define WGL_STENCIL_BITS_ARB 0x2023
120 #define WGL_AUX_BUFFERS_ARB 0x2024
121 #define WGL_NO_ACCELERATION_ARB 0x2025
122 #define WGL_GENERIC_ACCELERATION_ARB 0x2026
123 #define WGL_FULL_ACCELERATION_ARB 0x2027
124 #define WGL_SWAP_EXCHANGE_ARB 0x2028
125 #define WGL_SWAP_COPY_ARB 0x2029
126 #define WGL_SWAP_UNDEFINED_ARB 0x202A
127 #define WGL_TYPE_RGBA_ARB 0x202B
128 #define WGL_TYPE_COLORINDEX_ARB 0x202C
129
130 typedef BOOL (APIENTRY * wglGetPixelFormatAttribivARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
131 typedef BOOL (APIENTRY * wglGetPixelFormatAttribfvARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
132 typedef BOOL (APIENTRY * wglChoosePixelFormatARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
133
134 typedef BOOL (APIENTRY * wglBindTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
135 typedef BOOL (APIENTRY * wglReleaseTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
136 typedef BOOL (APIENTRY * wglSetPbufferAttribARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
137
138 /*-------------------------------------------------------------------*/
139 /*------------WGL_EXT_SWAP_CONTROL-----------------------------------*/
140 /*-------------------------------------------------------------------*/
141
142 typedef BOOL (APIENTRY * wglSwapIntervalEXTPROC) (int interval);
143 typedef int (APIENTRY * wglGetSwapIntervalEXTPROC) (void);
144
145 /*-------------------------------------------------------------------*/
146 /*------------WGL_ARB_MAKE_CURRENT_READ------------------------------*/
147 /*-------------------------------------------------------------------*/
148
149 #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
150 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
151
152 typedef BOOL (APIENTRY * wglMakeContextCurrentARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
153 typedef HDC (APIENTRY * wglGetCurrentReadDCARBPROC) (void);
154
155 /*-------------------------------------------------------------------*/
156 /*------------WGL_ARB_MULTISAMPLE------------------------------------*/
157 /*-------------------------------------------------------------------*/
158
159 #define WGL_SAMPLE_BUFFERS_ARB 0x2041
160 #define WGL_SAMPLES_ARB 0x2042
161
162 /*-------------------------------------------------------------------*/
163 /*------------WGL_ARB_pixel_format_float ----------------------------*/
164 /*-------------------------------------------------------------------*/
165
166 #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
167
168 /*-------------------------------------------------------------------*/
169 /*------------WGL_ATI_pixel_format_float ----------------------------*/
170 /*-------------------------------------------------------------------*/
171
172 #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
173
174 /*------------------------------------------------------------------*/
175 /*------------ WGL_ARB_framebuffer_sRGB ----------------------------*/
176 /*------------------------------------------------------------------*/
177
178 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
179
180 /*---------------------------------------------------------------------------*/
181 /*------------ WGL_EXT_pixel_format_packed_float ----------------------------*/
182 /*---------------------------------------------------------------------------*/
183
184 #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
185
186 /*----------------------------------------------------------------*/
187 /*------------ WGL_ARB_create_context ----------------------------*/
188 /*----------------------------------------------------------------*/
189
190 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
191 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
192 #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
193 #define WGL_CONTEXT_FLAGS_ARB 0x2094
194
195 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
196 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
197
198 #define ERROR_INVALID_VERSION_ARB 0x2095
199
200 typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
201
202 typedef struct {
203 bool WGL_ARB_buffer_region;
204 bool WGL_ARB_extensions_string;
205 bool WGL_ARB_make_current_read;
206 bool WGL_ARB_multisample;
207 bool WGL_ARB_pbuffer;
208 bool WGL_ARB_pixel_format;
209 bool WGL_ARB_render_texture;
210 bool WGL_EXT_extensions_string;
211 bool WGL_EXT_swap_control;
212 bool WGL_NV_render_depth_texture;
213 bool WGL_NV_render_texture_rectangle;
214 bool WGL_ARB_pixel_format_float;
215 bool WGL_ATI_pixel_format_float;
216 bool WGL_ARB_framebuffer_sRGB;
217 bool WGL_EXT_pixel_format_packed_float;
218 bool WGL_ARB_create_context;
219
220 wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT;
221
222 wglGetExtensionsStringARBPROC wglGetExtensionsStringARB;
223
224 wglCreatePbufferARBPROC wglCreatePbufferARB;
225 wglGetPbufferDCARBPROC wglGetPbufferDCARB;
226 wglReleasePbufferDCARBPROC wglReleasePbufferDCARB;
227 wglDestroyPbufferARBPROC wglDestroyPbufferARB;
228 wglQueryPbufferARBPROC wglQueryPbufferARB;
229
230 wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB;
231 wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB;
232 wglChoosePixelFormatARBPROC wglChoosePixelFormatARB;
233
234 wglBindTexImageARBPROC wglBindTexImageARB;
235 wglReleaseTexImageARBPROC wglReleaseTexImageARB;
236 wglSetPbufferAttribARBPROC wglSetPbufferAttribARB;
237
238 wglSwapIntervalEXTPROC wglSwapIntervalEXT;
239 wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT;
240
241 wglMakeContextCurrentARBPROC wglMakeContextCurrentARB;
242 wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB;
243
244 wglCreateContextAttribsARBPROC wglCreateContextAttribsARB;
245 } WGLExtensions;
246
247 extern void extgl_InitWGL(WGLExtensions *extensions);
248
249
250 #endif
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 * $Id: org_lwjgl_Sys.c 3259 2009-12-02 23:11:14Z matzon $
34 *
35 * Windows system library.
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3259 $
39 */
40
41 #include "Window.h"
42 #include "mmsystem.h"
43 #include "org_lwjgl_WindowsSysImplementation.h"
44 #include "common_tools.h"
45 #include <malloc.h>
46 #include <commctrl.h>
47
48 JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetTime(JNIEnv * env, jclass unused) {
49 DWORD time;
50
51 timeBeginPeriod(1);
52 time = timeGetTime();
53 timeEndPeriod(1);
54
55 return time;
56 }
57
58 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) {
59 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
60 char * eMessageText = GetStringNativeChars(env, message);
61 char * cTitleBarText = GetStringNativeChars(env, title);
62 MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST);
63
64 printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
65
66 free(eMessageText);
67 free(cTitleBarText);
68 }
69
70 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls(JNIEnv * env, jclass unused) {
71 InitCommonControls();
72 }
73
74 JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard
75 (JNIEnv * env, jclass unused)
76 {
77 // Check to see if there's text available in the clipboard
78 BOOL textAvailable = IsClipboardFormatAvailable(CF_TEXT);
79 BOOL unicodeAvailable = IsClipboardFormatAvailable(CF_UNICODETEXT);
80 void *clipboard_data;
81 jstring ret;
82 HANDLE hglb;
83 const wchar_t * str;
84
85 if (unicodeAvailable) {
86 if (!OpenClipboard(NULL))
87 return NULL;
88 hglb = GetClipboardData(CF_UNICODETEXT);
89 if (hglb == NULL) {
90 CloseClipboard();
91 return NULL;
92 }
93 clipboard_data = GlobalLock(hglb);
94 if (clipboard_data == NULL) {
95 CloseClipboard();
96 return NULL;
97 }
98 str = (const wchar_t *)clipboard_data;
99 ret = (*env)->NewString(env, str, wcslen(str));
100 } else if (textAvailable) {
101 if (!OpenClipboard(NULL))
102 return NULL;
103 hglb = GetClipboardData(CF_TEXT);
104 if (hglb == NULL) {
105 CloseClipboard();
106 return NULL;
107 }
108 clipboard_data = GlobalLock(hglb);
109 if (clipboard_data == NULL) {
110 CloseClipboard();
111 return NULL;
112 }
113 ret = NewStringNativeWithLength(env, (const char *) clipboard_data, strlen(clipboard_data));
114 } else {
115 return NULL;
116 }
117 GlobalUnlock(hglb);
118 CloseClipboard();
119 return ret;
120 }
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 * $Id: org_lwjgl_input_Cursor.c 3263 2010-01-10 22:46:41Z matzon $
34 *
35 * win32 mouse handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3263 $
39 */
40
41 #include "Window.h"
42 #include "org_lwjgl_input_Cursor.h"
43 #include "org_lwjgl_opengl_WindowsDisplay.h"
44 #include "common_tools.h"
45
46 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateCursor
47 (JNIEnv *env, jclass unused, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
48 {
49 unsigned char col0, col1, col2, col3, col4, col5, col6, col7;
50 unsigned char mask;
51 BITMAPINFO bitmapInfo;
52
53 HBITMAP cursorMask;
54 HCURSOR *cursor_handle;
55
56 HCURSOR cursor = NULL;
57 ICONINFO iconInfo;
58 char *ptrCursorImage;
59 HBITMAP colorDIB;
60 int *srcPtr;
61 char *dstPtr;
62 int bitWidth;
63 int scanlinePad;
64 int imageSize; // Size in bits
65 unsigned char *maskPixels;
66 int pixelCount = 0;
67 int maskCount = 0;
68 HBITMAP colorBitmap;
69 int x, y;
70 HDC hDC;
71 jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(HCURSOR));
72
73 int *pixels;
74 if (handle_buffer == NULL) {
75 throwException(env, "Could not allocate handle");
76 return NULL;
77 }
78 pixels = (int *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset;
79
80 memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
81 bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
82 bitmapInfo.bmiHeader.biWidth = width;
83 bitmapInfo.bmiHeader.biHeight = -height;
84 bitmapInfo.bmiHeader.biPlanes = 1;
85
86 bitmapInfo.bmiHeader.biBitCount = 24;
87 bitmapInfo.bmiHeader.biCompression = BI_RGB;
88
89 hDC = GetDC(NULL);
90
91 colorDIB = CreateDIBSection(hDC, (BITMAPINFO*)&(bitmapInfo),
92 DIB_RGB_COLORS,
93 (void*)&(ptrCursorImage),
94 NULL, 0);
95 srcPtr = pixels;
96 dstPtr = ptrCursorImage;
97 if (!dstPtr) {
98 throwException(env, "Could not allocate DIB section.");
99 ReleaseDC(NULL, hDC);
100 return NULL;
101 }
102 for (y = 0; y < height; y++ ) {
103 for (x = 0; x < width; x++ ) {
104 dstPtr[2] = (*srcPtr >> 0x10) & 0xFF;
105 dstPtr[1] = (*srcPtr >> 0x08) & 0xFF;
106 dstPtr[0] = *srcPtr & 0xFF;
107
108 srcPtr++;
109 dstPtr += 3;
110 }
111 }
112
113 colorBitmap = CreateDIBitmap(hDC,
114 (BITMAPINFOHEADER*)&bitmapInfo.bmiHeader,
115 CBM_INIT,
116 (void *)ptrCursorImage,
117 (BITMAPINFO*)&bitmapInfo,
118 DIB_RGB_COLORS);
119
120 DeleteObject(colorDIB);
121
122 // Convert alpha map to pixel packed mask
123 bitWidth = width >> 3;
124 scanlinePad = bitWidth & (sizeof(WORD) - 1);
125 imageSize = (bitWidth + scanlinePad)*height; // Size in bits
126 maskPixels = (unsigned char*)malloc(sizeof(unsigned char)*imageSize);
127 memset(maskPixels, 0, imageSize);
128 for (y = 0; y < height; y++)
129 for (x = 0; x < bitWidth; x++) {
130 col0 = (pixels[pixelCount++] & 0x01000000) >> 17;
131 col1 = (pixels[pixelCount++] & 0x01000000) >> 18;
132 col2 = (pixels[pixelCount++] & 0x01000000) >> 19;
133 col3 = (pixels[pixelCount++] & 0x01000000) >> 20;
134 col4 = (pixels[pixelCount++] & 0x01000000) >> 21;
135 col5 = (pixels[pixelCount++] & 0x01000000) >> 22;
136 col6 = (pixels[pixelCount++] & 0x01000000) >> 23;
137 col7 = (pixels[pixelCount++] & 0x01000000) >> 24;
138 mask = col0 | col1 | col2 | col3 | col4 | col5 | col6 | col7;
139 maskPixels[maskCount++] = ~mask; // 1 is tranparant, 0 opaque
140 }
141
142 cursorMask = CreateBitmap(width, height, 1, 1, maskPixels);
143
144 memset(&iconInfo, 0, sizeof(ICONINFO));
145 iconInfo.hbmMask = cursorMask;
146 iconInfo.hbmColor = colorBitmap;
147 iconInfo.fIcon = FALSE;
148 iconInfo.xHotspot = x_hotspot;
149 iconInfo.yHotspot = y_hotspot;
150 cursor = CreateIconIndirect(&iconInfo);
151 DeleteObject(colorBitmap);
152 DeleteObject(cursorMask);
153 free(maskPixels);
154 ReleaseDC(NULL, hDC);
155
156 cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer);
157 *cursor_handle = cursor;
158 return handle_buffer;
159 }
160
161 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_doDestroyCursor
162 (JNIEnv *env, jclass unused, jobject handle_buffer)
163 {
164 HCURSOR *cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer);
165 DestroyCursor(*cursor_handle);
166 }
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 * $Id: org_lwjgl_opengl_Display.c 3302 2010-03-31 23:56:24Z spasi $
34 *
35 * Base Windows display
36 *
37 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3302 $
39 */
40
41 #define _PRIVATE_WINDOW_H_
42 #include <windowsx.h>
43 #include <malloc.h>
44 #include "Window.h"
45 #include "extgl_wgl.h"
46 #include "common_tools.h"
47 #include "display.h"
48 #include "org_lwjgl_opengl_WindowsDisplay.h"
49 #include "org_lwjgl_WindowsSysImplementation.h"
50 #include "context.h"
51 #include <commctrl.h>
52
53 #define WINDOWCLASSNAME "LWJGL"
54
55 /*
56 * WindowProc for the GL window.
57 */
58 static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
59 UINT msg,
60 WPARAM wParam,
61 LPARAM lParam)
62 {
63 jclass display_class;
64 jclass display_class_global;
65 jmethodID handleMessage_method;
66 LONG message_time;
67 JNIEnv *env = getThreadEnv();
68 if (env != NULL && !(*env)->ExceptionOccurred(env)) {
69 /*
70 * We'll cache a global reference to the WindowsDisplay class in the window's user data.
71 * This is not so much to avoid lookup overhead as it is to avoid problems
72 * with AWT. Specifically, awt code can indirectly call this message handler
73 * when it does a SendMessage on the main thread to the currently focused window,
74 * which could be a LWJGL window. The FindClass will then fail because the calling
75 * internal awt class is using the system class loader, not the application loader
76 * where lwjgl is found.
77 *
78 * The very first message sent to this handler is sent when
79 * a window is created, where we are sure that the calling class' classloader has
80 * LWJGL classes in it.
81 */
82 display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA);
83 if (display_class_global == NULL) {
84 display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay");
85 if (display_class != NULL) {
86 display_class_global = (*env)->NewGlobalRef(env, display_class);
87 if (display_class_global != NULL)
88 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)display_class_global);
89 }
90 }
91 if (display_class_global != NULL) {
92 message_time = GetMessageTime();
93 handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I");
94 if (handleMessage_method != NULL)
95 return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
96 }
97 }
98 return DefWindowProc(hWnd, msg, wParam, lParam);
99 }
100
101 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
102 return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
103 }
104
105 /*
106 * Handle native Windows messages
107 */
108 static void handleMessages(JNIEnv *env) {
109 /*
110 * Now's our chance to deal with Windows messages that are
111 * otherwise just piling up and causing everything not to
112 * work properly
113 */
114 MSG msg;
115 while (!(*env)->ExceptionOccurred(env) && PeekMessage(
116 &msg, // message information
117 NULL, // handle to window
118 0, // first message
119 0, // last message
120 PM_REMOVE // removal options
121 ))
122 {
123 if (msg.message == WM_QUIT)
124 break;
125 TranslateMessage(&msg);
126 DispatchMessage(&msg);
127 }
128 }
129
130 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDC(JNIEnv *env, jclass unused, jlong hwnd_ptr) {
131 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
132 return (INT_PTR)GetDC(hwnd);
133 }
134
135 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle
136 (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) {
137 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
138 char * title = GetStringNativeChars(env, title_obj);
139 SetWindowText(hwnd, title);
140 free(title);
141 }
142
143 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate(JNIEnv * env, jclass class) {
144 handleMessages(env);
145 }
146
147 JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getAvailableDisplayModes(JNIEnv *env, jobject self) {
148 return getAvailableDisplayModes(env);
149 }
150
151 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
152 (JNIEnv *env, jobject ignored) {
153 return org_lwjgl_WindowsSysImplementation_JNI_VERSION;
154 }
155
156 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) {
157 HWND hwnd;
158 static bool oneShotInitialised = false;
159 if (!oneShotInitialised) {
160 if (!registerWindow(lwjglWindowProc, WINDOWCLASSNAME)) {
161 throwException(env, "Could not register window class");
162 return 0;
163 }
164 oneShotInitialised = true;
165 }
166
167 hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, undecorated, child_window, (HWND)(INT_PTR)parent_hwnd);
168 return (INT_PTR)hwnd;
169 }
170
171 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) {
172 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
173 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
174 ReleaseDC(hwnd, hdc);
175 }
176
177 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong hwnd_ptr) {
178 jclass display_class_global;
179 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
180 display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA);
181 ShowWindow(hwnd, SW_HIDE);
182 DestroyWindow(hwnd);
183 if (display_class_global != NULL)
184 (*env)->DeleteGlobalRef(env, display_class_global);
185 }
186
187 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) {
188 HWND hwnd = (HWND)(INT_PTR)hwnd_int;
189 POINT point;
190 jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle);
191 jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle);
192 if (size < 2) {
193 throwFormattedRuntimeException(env, "Buffer size < 2", size);
194 return;
195 }
196 point.x = buffer[0];
197 point.y = buffer[1];
198 ClientToScreen(hwnd, &point);
199 buffer[0] = point.x;
200 buffer[1] = point.y;
201 }
202
203 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow(JNIEnv *env, jclass unused) {
204 return (INT_PTR)GetForegroundWindow();
205 }
206
207 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) {
208 return (INT_PTR)GetDesktopWindow();
209 }
210
211 static void copyBufferToRect(JNIEnv *env, jobject buffer_handle, RECT *rect) {
212 jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle);
213 jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle);
214 if (size < 4) {
215 throwFormattedRuntimeException(env, "Buffer size < 4", size);
216 return;
217 }
218 rect->top = buffer[0];
219 rect->bottom = buffer[1];
220 rect->left = buffer[2];
221 rect->right = buffer[3];
222 }
223
224 static void copyRectToBuffer(JNIEnv *env, RECT *rect, jobject buffer_handle) {
225 jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle);
226 jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle);
227 if (size < 4) {
228 throwFormattedRuntimeException(env, "Buffer size < 4", size);
229 return;
230 }
231 buffer[0] = rect->top;
232 buffer[1] = rect->bottom;
233 buffer[2] = rect->left;
234 buffer[3] = rect->right;
235 }
236
237 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jobject handle_buffer) {
238 RECT clip_rect;
239 LPRECT clip_rect_ptr;
240 if (handle_buffer != NULL) {
241 copyBufferToRect(env, handle_buffer, &clip_rect);
242 clip_rect_ptr = &clip_rect;
243 } else
244 clip_rect_ptr = NULL;
245 if (ClipCursor(clip_rect_ptr) == 0)
246 throwFormattedException(env, "ClipCursor failed (%d)", GetLastError());
247 }
248
249 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSwitchDisplayMode(JNIEnv *env, jobject self, jobject mode) {
250 switchDisplayMode(env, mode);
251 }
252
253 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nResetDisplayMode(JNIEnv *env, jobject self) {
254 resetDisplayMode(env);
255 }
256
257 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentDisplayMode(JNIEnv *env, jclass unused) {
258 return getCurrentDisplayMode(env);
259 }
260
261 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_convertToNativeRamp(JNIEnv *env, jclass unused, jobject float_ramp) {
262 return convertToNativeRamp(env, float_ramp);
263 }
264
265 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentGammaRamp(JNIEnv *env, jclass unused) {
266 return getCurrentGammaRamp(env);
267 }
268
269 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetGammaRamp(JNIEnv *env, jclass unused, jobject gamma_buffer) {
270 setGammaRamp(env, gamma_buffer);
271 }
272
273 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_showWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint mode) {
274 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
275 ShowWindow(hwnd, mode);
276 }
277
278 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setForegroundWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) {
279 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
280 SetForegroundWindow(hwnd);
281 }
282
283 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setFocus(JNIEnv *env, jclass unused, jlong hwnd_ptr) {
284 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
285 SetFocus(hwnd);
286 }
287
288 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetVersion(JNIEnv *env, jobject self, jstring driver) {
289 char *driver_str;
290 jstring result;
291 driver_str = GetStringNativeChars(env, driver);
292 if (driver_str == NULL)
293 return NULL;
294 result = getVersion(env, driver_str);
295 free(driver_str);
296 return result;
297 }
298
299 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) {
300 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
301 DWORD exstyle, windowflags;
302 RECT clientSize;
303
304 getWindowFlags(&windowflags, &exstyle, undecorated, child);
305
306 // If we're not a fullscreen window, adjust the height to account for the
307 // height of the title bar:
308 clientSize.bottom = height;
309 clientSize.left = 0;
310 clientSize.right = width;
311 clientSize.top = 0;
312
313 AdjustWindowRectEx(
314 &clientSize, // client-rectangle structure
315 windowflags, // window styles
316 FALSE, // menu-present option
317 exstyle // extended window style
318 );
319
320 SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER);
321 }
322
323 static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) {
324 unsigned char col;
325 unsigned char mask;
326 BITMAPV5HEADER bitmapInfo;
327 HBITMAP cursorMask;
328 HBITMAP colorBitmap;
329 ICONINFO iconInfo;
330 HICON icon;
331 char *ptrCursorImage;
332 int x, y;
333 char *dstPtr;
334 int imageSize;
335 unsigned char *maskPixels;
336 int widthInBytes;
337 int leftShift;
338 int maskPixelsOff;
339 int scanlineWidth;
340 HBITMAP colorDIB;
341
342 memset(&bitmapInfo, 0, sizeof(BITMAPV5HEADER));
343 bitmapInfo.bV5Size = sizeof(BITMAPV5HEADER);
344 bitmapInfo.bV5Width = width;
345 bitmapInfo.bV5Height = -height;
346 bitmapInfo.bV5Planes = 1;
347 bitmapInfo.bV5BitCount = 32;
348 bitmapInfo.bV5Compression = BI_BITFIELDS;
349 bitmapInfo.bV5RedMask = 0x00FF0000;
350 bitmapInfo.bV5GreenMask = 0x0000FF00;
351 bitmapInfo.bV5BlueMask = 0x000000FF;
352 bitmapInfo.bV5AlphaMask = 0xFF000000;
353
354 colorDIB = CreateDIBSection(GetDC(NULL), (BITMAPINFO*)&(bitmapInfo),
355 DIB_RGB_COLORS, (void*)&(ptrCursorImage), NULL, 0);
356 if (!ptrCursorImage) {
357 throwException(env, "Could not allocate DIB section.");
358 }
359
360 for (y = 0; y < height; y++ ) {
361 dstPtr = ptrCursorImage + width*4*y;;
362 for (x = 0; x < width; x++ ) {
363 dstPtr[0] = (pixels[y*width+x] >> 0x10) & 0xFF;
364 dstPtr[1] = (pixels[y*width+x] >> 0x08) & 0xFF;
365 dstPtr[2] = pixels[y*width+x] & 0xFF;
366 dstPtr[3] = (pixels[y*width+x] >> 0x18) & 0xFF;
367 dstPtr += 4;
368 }
369 }
370
371
372 colorBitmap = CreateDIBitmap(GetDC(NULL),
373 (BITMAPINFOHEADER*)&bitmapInfo,
374 CBM_INIT,
375 (void *)ptrCursorImage,
376 (BITMAPINFO*)&bitmapInfo,
377 DIB_RGB_COLORS);
378
379 DeleteObject(colorDIB);
380
381 // Convert alpha map to pixel packed mask
382
383 // number of bytes it takes to fit a bit packed scan line.
384 widthInBytes = (width & 0x7) != 0 ? (width >> 3) + 1 : (width >> 3);
385
386 // number of bytes it takes to fit WORD padded scan line.
387 scanlineWidth = widthInBytes;
388 if (scanlineWidth % sizeof(WORD) != 0) {
389 scanlineWidth = (scanlineWidth / sizeof(WORD)) * sizeof(WORD) + sizeof(WORD);
390 }
391 imageSize = scanlineWidth*height;
392 maskPixels = (unsigned char*)malloc(sizeof(unsigned char)*imageSize);
393 memset(maskPixels, 0xFF, sizeof(unsigned char)*imageSize);
394
395 cursorMask = CreateBitmap(width, height, 1, 1, maskPixels);
396
397 memset(&iconInfo, 0, sizeof(ICONINFO));
398 iconInfo.hbmMask = cursorMask;
399 iconInfo.hbmColor = colorBitmap;
400 iconInfo.fIcon = TRUE;
401 iconInfo.xHotspot = 0;
402 iconInfo.yHotspot = 0;
403 icon = CreateIconIndirect(&iconInfo);
404 DeleteObject(colorBitmap);
405 DeleteObject(cursorMask);
406 free(maskPixels);
407
408 return icon;
409 }
410
411 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyIcon
412 (JNIEnv *env, jclass clazz, jlong handle) {
413 HICON icon = (HICON)(INT_PTR)handle;
414 DestroyIcon(icon);
415 }
416
417 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_createIcon
418 (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) {
419 jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer);
420 return (INT_PTR)createWindowIcon(env, imgData, width, height);
421 }
422
423 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_sendMessage
424 (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong msg, jlong wparam, jlong lparam) {
425 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
426 return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam);
427 }
428
429 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition
430 (JNIEnv * env, jclass unused, jint x, jint y) {
431 if (!SetCursorPos(x, y))
432 printfDebugJava(env, "SetCursorPos failed");
433 }
434
435 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect
436 (JNIEnv *env, jclass unused, jlong hwnd_int, jobject rect_buffer) {
437 HWND hwnd = (HWND)(INT_PTR)hwnd_int;
438 RECT clientRect;
439 GetClientRect(hwnd, &clientRect);
440 copyRectToBuffer(env, &clientRect, rect_buffer);
441 }
442
443 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor
444 (JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer)
445 {
446 HWND hwnd = (HWND)(INT_PTR)hwnd_int;
447 HCURSOR *cursor_handle;
448 HCURSOR cursor;
449 if (handle_buffer != NULL) {
450 cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer);
451 cursor = *cursor_handle;
452 SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)cursor);
453 SetCursor(cursor);
454 } else {
455 SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)NULL);
456 SetCursor(LoadCursor(NULL, IDC_ARROW));
457 }
458 }
459
460 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics(JNIEnv *env, jclass unused, jint index) {
461 return GetSystemMetrics(index);
462 }
463
464 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCapture(JNIEnv *env, jclass unused, jlong hwnd_int) {
465 HWND hwnd = (HWND)(INT_PTR)hwnd_int;
466 return (INT_PTR) SetCapture(hwnd);
467 }
468
469 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseCapture(JNIEnv *env, jclass unused) {
470 return ReleaseCapture();
471 }
472
473 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nTrackMouseEvent(JNIEnv *env, jclass clazz, jlong hwnd_ptr) {
474 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
475 TRACKMOUSEEVENT tme;
476 tme.cbSize = sizeof(TRACKMOUSEEVENT);
477 tme.dwFlags = TME_LEAVE;
478 tme.hwndTrack = hwnd;
479 return TrackMouseEvent(&tme);
480 }
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 * $Id: org_lwjgl_opengl_Pbuffer.c 3149 2008-11-22 14:54:15Z elias_naur $
34 *
35 * Windows Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3149 $
39 */
40
41 #include <stdlib.h>
42 #include "org_lwjgl_opengl_WindowsDisplay.h"
43 #include "org_lwjgl_opengl_Pbuffer.h"
44 #include "context.h"
45
46 #include "extgl.h"
47 #include "extgl_wgl.h"
48
49 #include "common_tools.h"
50
51 static bool isPbufferSupported(WGLExtensions *extensions) {
52 return extensions->WGL_ARB_pixel_format && extensions->WGL_ARB_pbuffer;
53 }
54
55 static bool getExtensions(JNIEnv *env, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps) {
56 int origin_x = 0; int origin_y = 0;
57 HWND dummy_hwnd;
58 HDC dummy_hdc;
59 HGLRC dummy_context;
60 HDC saved_hdc;
61 HGLRC saved_context;
62 int pixel_format_id;
63
64 dummy_hwnd = createDummyWindow(origin_x, origin_y);
65 if (dummy_hwnd == NULL) {
66 throwException(env, "Could not create dummy window");
67 return false;
68 }
69 dummy_hdc = GetDC(dummy_hwnd);
70 pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, origin_x, origin_y, pixel_format, pixelFormatCaps, false, true, false, false);
71 if (pixel_format_id == -1) {
72 closeWindow(&dummy_hwnd, &dummy_hdc);
73 return false;
74 }
75 if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) {
76 closeWindow(&dummy_hwnd, &dummy_hdc);
77 return false;
78 }
79 dummy_context = wglCreateContext(dummy_hdc);
80 if (dummy_context == NULL) {
81 closeWindow(&dummy_hwnd, &dummy_hdc);
82 throwException(env, "Could not create dummy context");
83 return false;
84 }
85 saved_hdc = wglGetCurrentDC();
86 saved_context = wglGetCurrentContext();
87 if (!wglMakeCurrent(dummy_hdc, dummy_context)) {
88 wglMakeCurrent(saved_hdc, saved_context);
89 closeWindow(&dummy_hwnd, &dummy_hdc);
90 wglDeleteContext(dummy_context);
91 throwException(env, "Could not make dummy context current");
92 return false;
93 }
94 extgl_InitWGL(extensions);
95 if (!wglMakeCurrent(saved_hdc, saved_context))
96 printfDebugJava(env, "ERROR: Could not restore current context");
97 closeWindow(&dummy_hwnd, &dummy_hdc);
98 wglDeleteContext(dummy_context);
99 return true;
100 }
101
102 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetPbufferCapabilities
103 (JNIEnv *env, jobject self, jobject pixel_format)
104 {
105 int caps = 0;
106 WGLExtensions extensions;
107 if (!getExtensions(env, &extensions, pixel_format, NULL))
108 return 0;
109 if (isPbufferSupported(&extensions))
110 caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED;
111
112 if (extensions.WGL_ARB_render_texture)
113 caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED;
114
115 if (extensions.WGL_NV_render_texture_rectangle)
116 caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED;
117
118 if (extensions.WGL_NV_render_depth_texture)
119 caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED;
120
121 return caps;
122 }
123
124 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nCreate
125 (JNIEnv *env, jobject self, jobject peer_info_handle,
126 jint width, jint height, jobject pixel_format,
127 jobject pixelFormatCaps, jobject pBufferAttribs)
128 {
129 int origin_x = 0; int origin_y = 0;
130 HWND dummy_hwnd;
131 HDC dummy_hdc;
132 HPBUFFERARB Pbuffer;
133 HDC Pbuffer_dc;
134 WGLExtensions extensions;
135 const int *pBufferAttribs_ptr;
136 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
137 int pixel_format_id;
138
139 if ( pBufferAttribs != NULL ) {
140 pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs);
141 } else {
142 pBufferAttribs_ptr = NULL;
143 }
144 if (!getExtensions(env, &extensions, pixel_format, pixelFormatCaps))
145 return;
146 dummy_hwnd = createDummyWindow(origin_x, origin_y);
147 if (dummy_hwnd == NULL) {
148 throwException(env, "Could not create dummy window");
149 return;
150 }
151 dummy_hdc = GetDC(dummy_hwnd);
152 pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false);
153 if (pixel_format_id == -1) {
154 closeWindow(&dummy_hwnd, &dummy_hdc);
155 return;
156 }
157 Pbuffer = extensions.wglCreatePbufferARB(dummy_hdc, pixel_format_id, width, height, pBufferAttribs_ptr);
158 closeWindow(&dummy_hwnd, &dummy_hdc);
159 if (Pbuffer == NULL) {
160 throwException(env, "Could not create Pbuffer");
161 return;
162 }
163 Pbuffer_dc = extensions.wglGetPbufferDCARB(Pbuffer);
164 if (Pbuffer_dc == NULL) {
165 extensions.wglDestroyPbufferARB(Pbuffer);
166 throwException(env, "Could not get Pbuffer DC");
167 return;
168 }
169 peer_info->u.pbuffer.extensions = extensions;
170 peer_info->u.pbuffer.pbuffer = Pbuffer;
171 peer_info->drawable_hdc = Pbuffer_dc;
172 }
173
174 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy
175 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
176 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
177 peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc);
178 peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer);
179 }
180
181 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost
182 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
183 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
184 BOOL buffer_lost;
185 peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost);
186 return buffer_lost ? JNI_TRUE : JNI_FALSE;
187 }
188
189 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nSetPbufferAttrib
190 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint attrib, jint value) {
191 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
192 int attribs[3];
193
194 attribs[0] = attrib;
195 attribs[1] = value;
196 attribs[2] = 0;
197
198 peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs);
199 }
200
201 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer
202 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) {
203 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
204 peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer);
205 }
206
207 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer
208 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) {
209 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
210 peer_info->u.pbuffer.extensions.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer);
211 }
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 * $Id: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <jawt_md.h>
41 #include "awt_tools.h"
42 #include "org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.h"
43 #include "context.h"
44 #include "common_tools.h"
45
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo_nInitHandle
47 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) {
48 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
49 AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
50 JAWT_Win32DrawingSurfaceInfo *win32_dsi = (JAWT_Win32DrawingSurfaceInfo *)surface->dsi->platformInfo;
51 peer_info->drawable_hdc = win32_dsi->hdc;
52 peer_info->u.hwnd = win32_dsi->hwnd;
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
32 /**
33 * $Id: org_lwjgl_opengl_WindowsContextImplementation.c 3116 2008-08-19 16:46:03Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
37 */
38
39 #include <jni.h>
40 #include "org_lwjgl_opengl_WindowsContextImplementation.h"
41 #include "context.h"
42 #include "extgl_wgl.h"
43 #include "common_tools.h"
44
45 typedef struct {
46 HGLRC context;
47 } WindowsContext;
48
49 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCreate
50 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) {
51 WindowsPeerInfo *peer_info;
52 WindowsContext *shared_context_info;
53 WindowsContext *context_info;
54 HGLRC context;
55 HGLRC shared_context = NULL;
56
57 // -- We need to create a temporary context to detect the presence of WGL_ARB_create_context
58 HDC saved_current_hdc;
59 HGLRC saved_current_hglrc;
60 WGLExtensions extensions;
61 const int *attribList = attribs == NULL ? NULL : ((const int *)(*env)->GetDirectBufferAddress(env, attribs));
62
63 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext));
64 if (context_handle == NULL) {
65 throwException(env, "Could not create handle buffer");
66 return NULL;
67 }
68
69 peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
70 if (shared_context_handle != NULL) {
71 shared_context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle);
72 shared_context = shared_context_info->context;
73 }
74
75 // Create the context
76 context = wglCreateContext(peer_info->drawable_hdc);
77 if (context == NULL) {
78 throwException(env, "Could not create context");
79 return NULL;
80 }
81
82 // Save the current HDC and HGLRC to avoid disruption
83 saved_current_hdc = wglGetCurrentDC();
84 saved_current_hglrc = wglGetCurrentContext();
85
86 // Make context current and detect extensions
87 if (!wglMakeCurrent(peer_info->drawable_hdc, context)) {
88 throwException(env, "Could not bind dummy context");
89 return NULL;
90 }
91 extgl_InitWGL(&extensions);
92
93 // Restore previous context
94 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
95
96 //
97 if ( extensions.WGL_ARB_create_context ) { // We support WGL_ARB_create_context, use the new context creation routine
98 // If we have no context to share and no special attributes, we don't have to recreate the context - wglCreateContext is equivalent to wglCreateContextAttribs(hdc,0,NULL).
99 if ( shared_context != NULL || attribList != NULL ) {
100 // Delete the oldschool context
101 wglDeleteContext(context);
102 // Create a new context using WGL_ARB_create_context
103 context = (HGLRC)extensions.wglCreateContextAttribsARB(peer_info->drawable_hdc, shared_context, attribList);
104 if (context == NULL) {
105 throwException(env, "Could not create context (WGL_ARB_create_context)");
106 return NULL;
107 }
108 }
109 } else { // We don't support WGL_ARB_create_context, use the old context creation routine
110 if (shared_context != NULL && !wglShareLists(shared_context, context)) { // Use wglShareLists to share context data
111 wglDeleteContext(context);
112 throwException(env, "Could not share contexts");
113 return NULL;
114 }
115 }
116
117 context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
118 context_info->context = context;
119 return context_handle;
120 }
121
122 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers
123 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
124 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
125 SwapBuffers(peer_info->drawable_hdc);
126 }
127
128 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext
129 (JNIEnv *env, jclass clazz) {
130 wglMakeCurrent(NULL, NULL);
131 }
132
133 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nMakeCurrent
134 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
135 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
136 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
137 if (!wglMakeCurrent(peer_info->drawable_hdc, context_info->context))
138 throwException(env, "Could not make context current");
139 }
140
141 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nIsCurrent
142 (JNIEnv *env, jclass clazz, jobject context_handle) {
143 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
144 return wglGetCurrentContext() == context_info->context;
145 }
146
147 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
148 (JNIEnv *env, jclass clazz, jint value) {
149 WGLExtensions extensions;
150 extgl_InitWGL(&extensions);
151 if (extensions.WGL_EXT_swap_control) {
152 return extensions.wglSwapIntervalEXT(value) ? JNI_TRUE : JNI_FALSE;
153 } else
154 return JNI_FALSE;
155 }
156
157 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy
158 (JNIEnv *env, jclass clazz, jobject context_handle) {
159 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
160 wglDeleteContext(context_info->context);
161 }
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 * $Id: org_lwjgl_opengl_WindowsDisplayPeerInfo.c 3057 2008-04-30 16:01:25Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3057 $
37 */
38
39 #include <jni.h>
40 #include "Window.h"
41 #include "org_lwjgl_opengl_WindowsDisplayPeerInfo.h"
42 #include "context.h"
43 #include "common_tools.h"
44
45 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nInitDC
46 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jlong hwnd_ptr, jlong hdc_ptr) {
47 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
48 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
49 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
50 peer_info->drawable_hdc = hdc;
51 peer_info->u.hwnd = hwnd;
52 }
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 * $Id: org_lwjgl_input_Keyboard.c 2385 2006-06-23 16:45:21Z elias_naur $
34 *
35 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2385 $
37 */
38
39 #include "Window.h"
40 #include <jni.h>
41 #include "org_lwjgl_opengl_WindowsKeyboard.h"
42
43 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) {
44 return GetKeyState(virt_key);
45 }
46
47 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) {
48 return MapVirtualKey(uCode, uMapType);
49 }
50
51 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_isWindowsNT(JNIEnv *env, jclass unused) {
52 OSVERSIONINFO osvi;
53
54 osvi.dwOSVersionInfoSize = sizeof(osvi);
55 GetVersionEx(&osvi);
56 return osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ? JNI_TRUE : JNI_FALSE;
57 }
58
59 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToUnicode(JNIEnv *env, jclass unused, jint wVirtKey, jint wScanCode, jobject lpKeyState_obj, jobject pwszBuff_obj, jint cchBuff, jint flags) {
60 const PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj);
61 LPWSTR pwszBuff = (*env)->GetDirectBufferAddress(env, pwszBuff_obj);
62 return ToUnicode(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, flags);
63 }
64
65 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToAscii(JNIEnv *env, jclass unused, jint wVirtKey, jint wScanCode, jobject lpKeyState_obj, jobject lpChar_obj, jint flags) {
66 const PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj);
67 LPWORD lpChar = (*env)->GetDirectBufferAddress(env, lpChar_obj);
68 return ToAscii(wVirtKey, wScanCode, lpKeyState, lpChar, flags);
69 }
70
71 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyboardState(JNIEnv *env, jclass unused, jobject lpKeyState_obj) {
72 PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj);
73 return GetKeyboardState(lpKeyState);
74 }
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 * $Id: org_lwjgl_opengl_WindowsPeerInfo.c 3148 2008-11-22 14:51:36Z elias_naur $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3148 $
37 */
38
39 #include <jni.h>
40 #include "org_lwjgl_opengl_WindowsPeerInfo.h"
41 #include "context.h"
42 #include "common_tools.h"
43
44 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle
45 (JNIEnv *env, jclass clazz) {
46 return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo));
47 }
48
49 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat
50 (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) {
51 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
52 return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer);
53 }
54
55 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat
56 (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint pixel_format) {
57 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
58 applyPixelFormat(env, hdc, pixel_format);
59 }
60
61 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) {
62 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
63 return (intptr_t)peer_info->drawable_hdc;
64 }
65
66 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
67 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
68 return (intptr_t)peer_info->u.hwnd;
69 }
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 * $Id: org_lwjgl_opengl_WindowsRegistry.c 2985 2008-04-07 18:42:36Z matzon $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
37 */
38
39 #include <jni.h>
40 #include <windows.h>
41 #include "org_lwjgl_opengl_WindowsRegistry.h"
42 #include "common_tools.h"
43
44 /*
45 * Return a string containing the queried value, or NULL of the method fails.
46 * In that case, a java exception is thrown.
47 */
48 static jstring queryRegistrationKey(JNIEnv *env, HKEY root_key, LPCTSTR subkey, LPCTSTR value) {
49 DWORD buf_size = 1;
50 char *result;
51 HKEY hKey;
52 LONG lRet;
53 jstring java_result;
54
55
56 if(RegOpenKeyEx(root_key,
57 TEXT(subkey),
58 0,
59 KEY_QUERY_VALUE,
60 &hKey) != ERROR_SUCCESS) {
61 throwException(env, "Failed to open registry key");
62 return NULL;
63 }
64
65 result = (char *)malloc(buf_size);
66 if (result == NULL) {
67 RegCloseKey(hKey);
68 throwException(env, "Failed to allocate buffer");
69 return NULL;
70 }
71
72 while (1) {
73 lRet = RegQueryValueEx(hKey,
74 TEXT(value),
75 NULL,
76 NULL,
77 (LPBYTE)result,
78 &buf_size);
79 if (lRet != ERROR_SUCCESS && lRet != ERROR_MORE_DATA) {
80 RegCloseKey(hKey);
81 free(result);
82 throwException(env, "Failed query key value");
83 return NULL;
84 }
85 if (lRet == ERROR_SUCCESS) {
86 RegCloseKey(hKey);
87 // make sure the result has a terminating null
88 buf_size += 1;
89 result = (char *)realloc(result, buf_size);
90 if (result == NULL) {
91 throwException(env, "Failed to resize buffer");
92 return NULL;
93 }
94 result[buf_size - 1] = '\0';
95 java_result = NewStringNativeWithLength(env, result, strlen(result));
96 free(result);
97 return java_result;
98 }
99 result = (char *)realloc(result, buf_size);
100 if (result == NULL) {
101 RegCloseKey(hKey);
102 throwException(env, "Failed to resize buffer");
103 return NULL;
104 }
105 }
106 }
107
108 static HKEY enumToRootKey(jint root_key_enum) {
109 switch (root_key_enum) {
110 case org_lwjgl_opengl_WindowsRegistry_HKEY_CLASSES_ROOT:
111 return HKEY_CLASSES_ROOT;
112 case org_lwjgl_opengl_WindowsRegistry_HKEY_CURRENT_USER:
113 return HKEY_CURRENT_USER;
114 case org_lwjgl_opengl_WindowsRegistry_HKEY_LOCAL_MACHINE:
115 return HKEY_LOCAL_MACHINE;
116 case org_lwjgl_opengl_WindowsRegistry_HKEY_USERS:
117 return HKEY_USERS;
118 default:
119 return 0;
120 }
121 }
122
123 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_WindowsRegistry_nQueryRegistrationKey (JNIEnv *env, jclass unused, jint root_key, jstring subkey, jstring value) {
124 HKEY root = enumToRootKey(root_key);
125 char *subkey_native;
126 char *value_native;
127 jstring result;
128
129 subkey_native = GetStringNativeChars(env, subkey);
130 if (subkey_native == NULL) {
131 throwException(env, "Failed to fetch the native string");
132 return NULL;
133 }
134 value_native = GetStringNativeChars(env, value);
135 if (value_native == NULL) {
136 free(subkey_native);
137 throwException(env, "Failed to fetch the native string");
138 return NULL;
139 }
140 result = queryRegistrationKey(env, root, subkey_native, value_native);
141 free(subkey_native);
142 free(value_native);
143 return result;
144 }
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 "extal.h"
36 #include "common_tools.h"
37
38 /**
39 * $Id: windows_al.c 2985 2008-04-07 18:42:36Z matzon $
40 *
41 * This file contains the AL extension assigning mechanism
42 *
43 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2985 $
45 */
46 /* Handle to OpenAL Library */
47 static HMODULE handleOAL;
48
49 void *NativeGetFunctionPointer(const char *function) {
50 return GetProcAddress(handleOAL, function);
51 }
52
53 void tryLoadLibrary(JNIEnv *env, jstring path) {
54 char *path_str = GetStringNativeChars(env, path);
55 printfDebugJava(env, "Testing '%s'", path_str);
56 handleOAL = LoadLibrary(path_str);
57 if (handleOAL != NULL) {
58 printfDebugJava(env, "Found OpenAL at '%s'", path_str);
59 } else {
60 throwFormattedException(env, "Could not load OpenAL library (%d)", GetLastError());
61 }
62 free(path_str);
63 }
64
65 /**
66 * Unloads the OpenAL Library
67 */
68 void UnLoadOpenAL() {
69 FreeLibrary(handleOAL);
70 }
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.openal;
32
33 import java.nio.Buffer;
34 import java.nio.IntBuffer;
35 import java.nio.FloatBuffer;
36 import java.nio.DoubleBuffer;
37
38 import org.lwjgl.util.generator.*;
39
40 /**
41 * <br>
42 * This is the core OpenAL class. This class implements
43 * AL.h version 1.0
44 *
45 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3288 $
47 * $Id: AL10.java 3288 2010-03-16 17:58:48Z spasi $
48 */
49 public interface AL10 {
50 /** Bad value */
51 int AL_INVALID = -1;
52
53 /** Disable value */
54 int AL_NONE = 0;
55
56 /** Boolean False */
57 int AL_FALSE = 0;
58
59 /** Boolean True */
60 int AL_TRUE = 1;
61
62 /**
63 * Indicate the type of SOURCE.
64 * Sources can be spatialized
65 */
66 int AL_SOURCE_TYPE = 0x1027;
67
68 /** Indicate source has absolute coordinates */
69 int AL_SOURCE_ABSOLUTE = 0x201;
70
71 /** Indicate Source has listener relative coordinates */
72 int AL_SOURCE_RELATIVE = 0x202;
73
74 /**
75 * Directional source, inner cone angle, in degrees
76 * Range: [0-360]
77 * Default: 360
78 */
79 int AL_CONE_INNER_ANGLE = 0x1001;
80
81 /**
82 * Directional source, outer cone angle, in degrees.
83 * Range: [0-360]
84 * Default: 360
85 */
86 int AL_CONE_OUTER_ANGLE = 0x1002;
87
88 /**
89 * Specify the pitch to be applied, either at source,
90 * or on mixer results, at listener.
91 * Range: [0.5-2.0]
92 * Default: 1.0
93 */
94 int AL_PITCH = 0x1003;
95
96 /**
97 * Specify the current location in three dimensional space.
98 * OpenAL, like OpenGL, uses a right handed coordinate system,
99 * where in a frontal default view X (thumb) points right,
100 * Y points up (index finger), and Z points towards the
101 * viewer/camera (middle finger).
102 * To switch from a left handed coordinate system, flip the
103 * sign on the Z coordinate.
104 * Listener position is always in the world coordinate system.
105 */
106 int AL_POSITION = 0x1004;
107
108 /** Specify the current direction as forward vector. */
109 int AL_DIRECTION = 0x1005;
110
111 /** Specify the current velocity in three dimensional space. */
112 int AL_VELOCITY = 0x1006;
113
114 /**
115 * Indicate whether source has to loop infinite.
116 * Type: ALboolean
117 * Range: [TRUE, FALSE]
118 * Default: FALSE
119 */
120 int AL_LOOPING = 0x1007;
121
122 /**
123 * Indicate the buffer to provide sound samples.
124 * Type: ALuint.
125 * Range: any valid Buffer id.
126 */
127 int AL_BUFFER = 0x1009;
128
129 /**
130 * Indicate the gain (volume amplification) applied.
131 * Type: ALfloat.
132 * Range: ]0.0- ]
133 * A value of 1.0 means un-attenuated/unchanged.
134 * Each division by 2 equals an attenuation of -6dB.
135 * Each multiplicaton with 2 equals an amplification of +6dB.
136 * A value of 0.0 is meaningless with respect to a logarithmic
137 * scale; it is interpreted as zero volume - the channel
138 * is effectively disabled.
139 */
140 int AL_GAIN = 0x100A;
141
142 /**
143 * Indicate minimum source attenuation.
144 * Type: ALfloat
145 * Range: [0.0 - 1.0]
146 */
147 int AL_MIN_GAIN = 0x100D;
148
149 /**
150 * Indicate maximum source attenuation.
151 * Type: ALfloat
152 * Range: [0.0 - 1.0]
153 */
154 int AL_MAX_GAIN = 0x100E;
155
156 /**
157 * Specify the current orientation.
158 * Type: ALfv6 (at/up)
159 * Range: N/A
160 */
161 int AL_ORIENTATION = 0x100F;
162
163 /* byte offset into source (in canon format). -1 if source
164 * is not playing. Don't set this, get this.
165 *
166 * Type: ALfloat
167 * Range: [0.0 - ]
168 * Default: 1.0
169 */
170 int AL_REFERENCE_DISTANCE = 0x1020;
171
172 /**
173 * Indicate the rolloff factor for the source.
174 * Type: ALfloat
175 * Range: [0.0 - ]
176 * Default: 1.0
177 */
178 int AL_ROLLOFF_FACTOR = 0x1021;
179
180 /**
181 * Indicate the gain (volume amplification) applied.
182 * Type: ALfloat.
183 * Range: ]0.0- ]
184 * A value of 1.0 means un-attenuated/unchanged.
185 * Each division by 2 equals an attenuation of -6dB.
186 * Each multiplicaton with 2 equals an amplification of +6dB.
187 * A value of 0.0 is meaningless with respect to a logarithmic
188 * scale; it is interpreted as zero volume - the channel
189 * is effectively disabled.
190 */
191 int AL_CONE_OUTER_GAIN = 0x1022;
192
193 /**
194 * Specify the maximum distance.
195 * Type: ALfloat
196 * Range: [0.0 - ]
197 */
198 int AL_MAX_DISTANCE = 0x1023;
199
200 /**
201 * Specify the channel mask. (Creative)
202 * Type: ALuint
203 * Range: [0 - 255]
204 */
205 int AL_CHANNEL_MASK = 0x3000;
206
207 /** Source state information */
208 int AL_SOURCE_STATE = 0x1010;
209
210 /** Source state information */
211 int AL_INITIAL = 0x1011;
212
213 /** Source state information */
214 int AL_PLAYING = 0x1012;
215
216 /** Source state information */
217 int AL_PAUSED = 0x1013;
218
219 /** Source state information */
220 int AL_STOPPED = 0x1014;
221
222 /** Buffer Queue params */
223 int AL_BUFFERS_QUEUED = 0x1015;
224
225 /** Buffer Queue params */
226 int AL_BUFFERS_PROCESSED = 0x1016;
227
228 /** Sound buffers: format specifier. */
229 int AL_FORMAT_MONO8 = 0x1100;
230
231 /** Sound buffers: format specifier. */
232 int AL_FORMAT_MONO16 = 0x1101;
233
234 /** Sound buffers: format specifier. */
235 int AL_FORMAT_STEREO8 = 0x1102;
236
237 /** Sound buffers: format specifier. */
238 int AL_FORMAT_STEREO16 = 0x1103;
239
240 /** Ogg Vorbis format specifier. */
241 int AL_FORMAT_VORBIS_EXT = 0x10003;
242
243 /**
244 * Sound buffers: frequency, in units of Hertz [Hz].
245 * This is the number of samples per second. Half of the
246 * sample frequency marks the maximum significant
247 * frequency component.
248 */
249 int AL_FREQUENCY = 0x2001;
250
251 /**
252 * Sound buffers: frequency, in units of Hertz [Hz].
253 * This is the number of samples per second. Half of the
254 * sample frequency marks the maximum significant
255 * frequency component.
256 */
257 int AL_BITS = 0x2002;
258
259 /**
260 * Sound buffers: frequency, in units of Hertz [Hz].
261 * This is the number of samples per second. Half of the
262 * sample frequency marks the maximum significant
263 * frequency component.
264 */
265 int AL_CHANNELS = 0x2003;
266
267 /**
268 * Sound buffers: frequency, in units of Hertz [Hz].
269 * This is the number of samples per second. Half of the
270 * sample frequency marks the maximum significant
271 * frequency component.
272 */
273 int AL_SIZE = 0x2004;
274
275 /**
276 * Sound buffers: frequency, in units of Hertz [Hz].
277 * This is the number of samples per second. Half of the
278 * sample frequency marks the maximum significant
279 * frequency component.
280 */
281 int AL_DATA = 0x2005;
282
283 /**
284 * Buffer state.
285 *
286 * Not supported for public use (yet).
287 */
288 int AL_UNUSED = 0x2010;
289
290 /**
291 * Buffer state.
292 *
293 * Not supported for public use (yet).
294 */
295 int AL_PENDING = 0x2011;
296
297 /**
298 * Buffer state.
299 *
300 * Not supported for public use (yet).
301 */
302 int AL_PROCESSED = 0x2012;
303
304 /** Errors: No Error. */
305 int AL_NO_ERROR = AL_FALSE;
306
307 /** Illegal name passed as an argument to an AL call. */
308 int AL_INVALID_NAME = 0xA001;
309
310 /** Illegal enum passed as an argument to an AL call. */
311 int AL_INVALID_ENUM = 0xA002;
312
313 /**
314 * Illegal value passed as an argument to an AL call.
315 * Applies to parameter values, but not to enumerations.
316 */
317 int AL_INVALID_VALUE = 0xA003;
318
319 /**
320 * A function was called at inappropriate time,
321 * or in an inappropriate way, causing an illegal state.
322 * This can be an incompatible ALenum, object ID,
323 * and/or function.
324 */
325 int AL_INVALID_OPERATION = 0xA004;
326
327 /**
328 * A function could not be completed,
329 * because there is not enough memory available.
330 */
331 int AL_OUT_OF_MEMORY = 0xA005;
332
333 /** Context strings: Vendor */
334 int AL_VENDOR = 0xB001;
335
336 /** Context strings: Version */
337 int AL_VERSION = 0xB002;
338
339 /** Context strings: Renderer */
340 int AL_RENDERER = 0xB003;
341
342 /** Context strings: Extensions */
343 int AL_EXTENSIONS = 0xB004;
344
345 /** Doppler scale. Default 1.0 */
346 int AL_DOPPLER_FACTOR = 0xC000;
347
348 /** Doppler velocity. Default 1.0 */
349 int AL_DOPPLER_VELOCITY = 0xC001;
350
351 /** Distance model. Default INVERSE_DISTANCE_CLAMPED */
352 int AL_DISTANCE_MODEL = 0xD000;
353
354 /** Distance model */
355 int AL_INVERSE_DISTANCE = 0xD001;
356
357 /** Distance model */
358 int AL_INVERSE_DISTANCE_CLAMPED = 0xD002;
359
360 /**
361 * The application can temporarily disable certain AL capabilities on a per Context
362 * basis. This allows the driver implementation to optimize for certain subsets of
363 * operations. Enabling and disabling capabilities is handled using a function pair.
364 *
365 * @param capability name of a capability to enable
366 */
367 @ALvoid
368 void alEnable(int capability);
369
370 /**
371 * The application can temporarily disable certain AL capabilities on a per Context
372 * basis. This allows the driver implementation to optimize for certain subsets of
373 * operations. Enabling and disabling capabilities is handled using a function pair.
374 *
375 * @param capability name of a capability to disable
376 */
377 @ALvoid
378 void alDisable(@ALenum int capability);
379
380 /**
381 * The application can also query whether a given capability is currently enabled or
382 * not.
383 * <p>
384 * If the token used to specify target is not legal, an AL_INVALID_ENUM error will be
385 * generated.
386 * </p>
387 * <p>
388 * At this time, this mechanism is not used. There are no valid targets.
389 * </p>
390 *
391 * @param capability name of a capability to check
392 * @return true if named feature is enabled
393 */
394 boolean alIsEnabled(@ALenum int capability);
395
396 /**
397 * Hinting for implementation
398 * NOTE: This method is a NOP, but is provided for completeness.
399 *
400 * @param target The target to hint
401 * @param mode Mode to hint
402 */
403 // @ALvoid
404 // void alHint(@ALenum int target, @ALenum int mode);
405
406 /**
407 * Like OpenGL, AL uses a simplified interface for querying global state.
408 *
409 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
410 * AL_DISTANCE_MODEL.
411 * <p>
412 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
413 * in specifying pName. The amount of memory required in the destination
414 * depends on the actual state requested.
415 * </p>
416 *
417 * @return boolean state described by pname will be returned.
418 */
419 boolean alGetBoolean(@ALenum int pname);
420
421 /**
422 * Like OpenGL, AL uses a simplified interface for querying global state.
423 *
424 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
425 * AL_DISTANCE_MODEL.
426 * <p>
427 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
428 * in specifying pName. The amount of memory required in the destination
429 * depends on the actual state requested.
430 * </p>
431 *
432 * @return int state described by pname will be returned.
433 */
434 int alGetInteger(@ALenum int pname);
435
436 /**
437 * Like OpenGL, AL uses a simplified interface for querying global state.
438 *
439 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
440 * AL_DISTANCE_MODEL.
441 * <p>
442 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
443 * in specifying pName. The amount of memory required in the destination
444 * depends on the actual state requested.
445 * </p>
446 *
447 * @return float state described by pname will be returned.
448 */
449 float alGetFloat(@ALenum int pname);
450
451 /**
452 * Like OpenGL, AL uses a simplified interface for querying global state.
453 *
454 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
455 * AL_DISTANCE_MODEL.
456 * <p>
457 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
458 * in specifying pName. The amount of memory required in the destination
459 * depends on the actual state requested.
460 * </p>
461 *
462 * @return double state described by pname will be returned.
463 */
464 double alGetDouble(@ALenum int pname);
465
466 /**
467 * Like OpenGL, AL uses a simplified interface for querying global state.
468 *
469 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
470 * AL_DISTANCE_MODEL.
471 * <p>
472 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
473 * in specifying pName. The amount of memory required in the destination
474 * depends on the actual state requested.
475 * </p>
476 *
477 * @param pname state to be queried
478 * @param data Buffer to place the integers in
479 */
480 @StripPostfix("data")
481 @ALvoid
482 void alGetIntegerv(@ALenum int pname, @OutParameter @Check("1") IntBuffer data);
483
484 /**
485 * Like OpenGL, AL uses a simplified interface for querying global state.
486 *
487 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
488 * AL_DISTANCE_MODEL.
489 * <p>
490 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
491 * in specifying pName. The amount of memory required in the destination
492 * depends on the actual state requested.
493 * </p>
494 *
495 * @param pname state to be queried
496 * @param data Buffer to place the floats in
497 */
498 @StripPostfix("data")
499 @ALvoid
500 void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data);
501
502 /**
503 * Like OpenGL, AL uses a simplified interface for querying global state.
504 *
505 * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
506 * AL_DISTANCE_MODEL.
507 * <p>
508 * <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
509 * in specifying pName. The amount of memory required in the destination
510 * depends on the actual state requested.
511 * </p>
512 *
513 * @param pname state to be queried
514 * @param data Buffer to place the doubles in
515 */
516 @StripPostfix("data")
517 @ALvoid
518 void alGetDoublev(@ALenum int pname, @OutParameter @Check("1") DoubleBuffer data);
519
520 /**
521 * The application can retrieve state information global to the current AL Context.
522 * GetString will return a pointer to a constant string. Valid values for param are
523 * VERSION, RENDERER, VENDOR, and EXTENSIONS, as well as the error codes
524 * defined by AL. The application can use GetString to retrieve a string for an error
525 * code.
526 *
527 * @param pname The property to be returned
528 * @return OpenAL String property
529 */
530 @NoErrorCheck
531 String alGetString(@ALenum int pname);
532
533 /**
534 * The AL detects only a subset of those conditions that could be considered errors.
535 * This is because in many cases error checking would adversely impact the
536 * performance of an error-free program.
537 * <p>
538 * Each detectable error is assigned a numeric
539 * code. When an error is detected by AL, a flag is set and the error code is recorded.
540 * Further errors, if they occur, do not affect this recorded code. When GetError is
541 * called, the code is returned and the flag is cleared, so that a further error will again
542 * record its code. If a call to GetError returns AL_NO_ERROR then there has been no
543 * detectable error since the last call to GetError (or since the AL was initialized).
544 * </p>
545 * <p>
546 * Error codes can be mapped to strings. The GetString function returns a pointer to a
547 * constant (literal) string that is identical to the identifier used for the enumeration
548 * value, as defined in the specification.
549 * </p>
550 * <p>
551 * AL_NO_ERROR - "No Error" token.<br>
552 * AL_INVALID_NAME - Invalid Name parameter.<br>
553 * AL_INVALID_ENUM - Invalid parameter.<br>
554 * AL_INVALID_VALUE - Invalid enum parameter value.<br>
555 * AL_INVALID_OPERATION - Illegal call.<br>
556 * AL_OUT_OF_MEMORY - Unable to allocate memory.<br>
557 * </p>
558 * <p>
559 * The table summarizes the AL errors. Currently, when an error flag is set, results of
560 * AL operations are undefined only if AL_OUT_OF_MEMORY has occured. In other
561 * cases, the command generating the error is ignored so that it has no effect on AL
562 * state or output buffer contents. If the error generating command returns a value, it
563 * returns zero. If the generating command modifies values through a pointer
564 * argument, no change is made to these values. These error semantics apply only to
565 * AL errors, not to system errors such as memory access errors.
566 * </p>
567 * <p>
568 * Several error generation conditions are implicit in the description of the various AL
569 * commands. First, if a command that requires an enumerated value is passed a value
570 * that is not one of those specified as allowable for that command, the error
571 * AL_INVALID_ENUM results. This is the case even if the argument is a pointer to a
572 * symbolic constant if that value is not allowable for the given command. This will
573 * occur whether the value is allowable for other functions, or an invalid integer value.
574 * </p>
575 * <p>
576 * Integer parameters that are used as names for AL objects such as Buffers and
577 * Sources are checked for validity. If an invalid name parameter is specified in an AL
578 * command, an AL_INVALID_NAME error will be generated, and the command is
579 * ignored.
580 * </p>
581 * <p>
582 * If a negative integer is provided where an argument of type sizei is specified, the
583 * error AL_INVALID_VALUE results. The same error will result from attempts to set
584 * integral and floating point values for attributes exceeding the legal range for these.
585 * The specification does not guarantee that the implementation emits
586 * AL_INVALID_VALUE if a NaN or Infinity value is passed in for a float or double
587 * argument (as the specification does not enforce possibly expensive testing of
588 * floating point values).
589 * </p>
590 * <p>
591 * Commands can be invalid. For example, certain commands might not be applicable
592 * to a given object. There are also illegal combinations of tokens and values as
593 * arguments to a command. AL responds to any such illegal command with an
594 * AL_INVALID_OPERATION error.
595 * </p>
596 * <p>
597 * If memory is exhausted as a side effect of the execution of an AL command, either
598 * on system level or by exhausting the allocated resources at AL's internal disposal,
599 * the error AL_OUT_OF_MEMORY may be generated. This can also happen independent
600 * of recent commands if AL has to request memory for an internal task and fails to
601 * allocate the required memory from the operating system.
602 * </p>
603 * <p>
604 * Otherwise errors are generated only for conditions that are explicitely described in
605 * this specification.
606 * </p>
607 *
608 * @return current error state
609 */
610 @NoErrorCheck
611 @ALenum int alGetError();
612
613 /**
614 * To verify that a given extension is available for the current context and the device it
615 * is associated with, use this method.
616 * <p>
617 * A <code>null</code> name argument returns AL_FALSE, as do invalid and unsupported string
618 * tokens. A <code>null</code> deviceHandle will result in an INVALID_DEVICE error.
619 * </p>
620 *
621 * @param fname String describing the desired extension
622 * @return true if extension is available, false if not
623 */
624 boolean alIsExtensionPresent(String fname);
625
626 /**
627 * <p>
628 * To obtain enumeration values for extensions, the application has to use
629 * GetEnumValue of an extension token. Enumeration values are defined within the
630 * AL namespace and allocated according to specification of the core API and the
631 * extensions, thus they are context-independent.
632 * </p>
633 * <p>
634 * Returns 0 if the enumeration can not be found. The presence of an enum value does
635 * not guarantee the applicability of an extension to the current context. A non-zero
636 * return indicates merely that the implementation is aware of the existence of this
637 * extension. Implementations should not attempt to return 0 to indicate that the
638 * extensions is not supported for the current context.
639 * </p>
640 *
641 * @param ename String describing an OpenAL enum
642 * @return Actual int for the described enumeration name
643 */
644 @ALenum int alGetEnumValue(String ename);
645
646 /**
647 * Listener attributes are changed using the Listener group of commands.
648 *
649 * @param pname name of the attribute to be set
650 * @param value value to set the attribute to
651 */
652 @ALvoid
653 void alListeneri(@ALenum int pname, int value);
654
655 /**
656 * Listener attributes are changed using the Listener group of commands.
657 *
658 * @param pname name of the attribute to be set
659 * @param value floating point value to set the attribute to
660 */
661 @ALvoid
662 void alListenerf(@ALenum int pname, float value);
663
664 /**
665 * Listener attributes are changed using the Listener group of commands.
666 *
667 * @param pname name of the attribute to be set
668 * @param value FloatBuffer containing value to set the attribute to
669 */
670 @StripPostfix("value")
671 @ALvoid
672 void alListenerfv(@ALenum int pname, @Check("1") @Const FloatBuffer value);
673
674 /**
675 * Listener attributes are changed using the Listener group of commands.
676 *
677 * @param pname name of the attribute to be set
678 * @param v1 value value 1
679 * @param v2 value value 2
680 * @param v3 float value 3
681 */
682 @ALvoid
683 void alListener3f(@ALenum int pname, float v1, float v2, float v3);
684
685 /**
686 * Listener state is maintained inside the AL implementation and can be queried in
687 * full.
688 *
689 * @param pname name of the attribute to be retrieved
690 * @return int
691 */
692 void alGetListeneri(@ALenum int pname, @Result @ALint int value);
693
694 /**
695 * Listener state is maintained inside the AL implementation and can be queried in
696 * full.
697 *
698 * @param pname name of the attribute to be retrieved
699 * @return float
700 */
701 void alGetListenerf(@ALenum int pname, @Result float value);
702
703 /**
704 * Listener state is maintained inside the AL implementation and can be queried in
705 * full.
706 *
707 * @param pname name of the attribute to be retrieved
708 * @param floatdata Buffer to write floats to
709 */
710 // TODO: What's the real minimum number of elements?
711 @StripPostfix("floatdata")
712 @ALvoid
713 void alGetListenerfv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata);
714
715 /**
716 * The application requests a number of Sources using GenSources.
717 *
718 * @param sources array holding sources
719 */
720 @ALvoid
721 void alGenSources(@AutoSize("sources") @ALsizei int n, @OutParameter @ALuint IntBuffer sources);
722
723 @Alternate(value = "alGenSources", nativeAlt = true)
724 @ALvoid
725 void alGenSources2(@Constant("1") @ALsizei int n, @Result @ALuint int source);
726
727 /**
728 * The application requests deletion of a number of Sources by DeleteSources.
729 *
730 * @param sources Source array to delete from
731 */
732 @ALvoid
733 void alDeleteSources(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
734
735 @Alternate(value = "alDeleteSources", nativeAlt = true)
736 @ALvoid
737 void alDeleteSources2(@Constant("1") @ALsizei int n, @Indirect @ALuint int source);
738
739 /**
740 * The application can verify whether a source name is valid using the IsSource query.
741 *
742 * @param id id of source to be testes for validity
743 * @return true if id is valid, false if not
744 */
745 boolean alIsSource(@ALuint int id);
746
747 /**
748 * Specifies the position and other properties as taken into account during
749 * sound processing.
750 *
751 * @param source Source to det property on
752 * @param pname property to set
753 * @param value value of property
754 */
755 @ALvoid
756 void alSourcei(@ALuint int source, @ALenum int pname, int value);
757
758 /**
759 * Specifies the position and other properties as taken into account during
760 * sound processing.
761 *
762 * @param source Source to det property on
763 * @param pname property to set
764 * @param value value of property
765 */
766 @ALvoid
767 void alSourcef(@ALuint int source, @ALenum int pname, float value);
768
769 /**
770 * Specifies the position and other properties as taken into account during
771 * sound processing.
772 *
773 * @param source Source to set property on
774 * @param pname property to set
775 * @param value FloatBuffer containing value of property
776 */
777 // TODO: What's the correct minimum value?
778 @StripPostfix("value")
779 @ALvoid
780 void alSourcefv(@ALuint int source, @ALenum int pname, @Check("1") @Const FloatBuffer value);
781
782 /**
783 * Specifies the position and other properties as taken into account during
784 * sound processing.
785 *
786 * @param source Source to set property on
787 * @param pname property to set
788 * @param v1 value 1 of property
789 * @param v2 value 2 of property
790 * @param v3 value 3 of property
791 */
792 @ALvoid
793 void alSource3f(
794 @ALuint int source,
795 @ALenum int pname,
796 float v1,
797 float v2,
798 float v3);
799
800
801 /**
802 * Source state is maintained inside the AL implementation, and the current attributes
803 * can be queried. The performance of such queries is implementation dependent, no
804 * performance guarantees are made.
805 *
806 * @param source source to get property from
807 * @param pname name of property
808 * @return int
809 */
810 @ALvoid
811 void alGetSourcei(@ALuint int source, @ALenum int pname, @Result int value);
812
813 /**
814 * Source state is maintained inside the AL implementation, and the current attributes
815 * can be queried. The performance of such queries is implementation dependent, no
816 * performance guarantees are made.
817 *
818 * @param source source to get property from
819 * @param pname name of property
820 * @return float
821 */
822 @ALvoid
823 void alGetSourcef(@ALuint int source, @ALenum int pname, @Result float value);
824
825 /**
826 * Source state is maintained inside the AL implementation, and the current attributes
827 * can be queried. The performance of such queries is implementation dependent, no
828 * performance guarantees are made.
829 *
830 * @param source Source to get property from
831 * @param pname property to get
832 * @param floatdata Buffer to write floats to
833 */
834 // TODO: What's the correct minimum value?
835 @StripPostfix("floatdata")
836 @ALvoid
837 void alGetSourcefv(@ALuint int source, @ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata);
838
839 /**
840 * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus
841 * the data found in the Buffer will be fed into the processing, starting at the
842 * beginning. Play() applied to a AL_PLAYING Source will restart the Source from the
843 * beginning. It will not affect the configuration, and will leave the Source in
844 * AL_PLAYING state, but reset the sampling offset to the beginning. Play() applied to a
845 * AL_PAUSED Source will resume processing using the Source state as preserved at the
846 * Pause() operation. Play() applied to a AL_STOPPED Source will propagate it to
847 * AL_INITIAL then to AL_PLAYING immediately.
848 *
849 * @param sources array of sources to play
850 */
851 @StripPostfix("sources")
852 @ALvoid
853 void alSourcePlayv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
854
855 /**
856 * Pause() applied to an AL_INITIAL Source is a legal NOP. Pause() applied to a
857 * AL_PLAYING Source will change its state to AL_PAUSED. The Source is exempt from
858 * processing, its current state is preserved. Pause() applied to a AL_PAUSED Source is a
859 * legal NOP. Pause() applied to a AL_STOPPED Source is a legal NOP.
860 *
861 * @param sources array of sources to pause
862 */
863 @StripPostfix("sources")
864 @ALvoid
865 void alSourcePausev(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
866
867 /**
868 * Stop() applied to an AL_INITIAL Source is a legal NOP. Stop() applied to a AL_PLAYING
869 * Source will change its state to AL_STOPPED. The Source is exempt from processing,
870 * its current state is preserved. Stop() applied to a AL_PAUSED Source will change its
871 * state to AL_STOPPED, with the same consequences as on a AL_PLAYING Source. Stop()
872 * applied to a AL_STOPPED Source is a legal NOP.
873 *
874 * @param sources array of sources to stop
875 */
876 @StripPostfix("sources")
877 @ALvoid
878 void alSourceStopv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
879
880 /**
881 * Rewind() applied to an AL_INITIAL Source is a legal NOP. Rewind() applied to a
882 * AL_PLAYING Source will change its state to AL_STOPPED then AL_INITIAL. The Source is
883 * exempt from processing, its current state is preserved, with the exception of the
884 * sampling offset which is reset to the beginning. Rewind() applied to a AL_PAUSED
885 * Source will change its state to AL_INITIAL, with the same consequences as on a
886 * AL_PLAYING Source. Rewind() applied to a AL_STOPPED Source promotes the Source to
887 * AL_INITIAL, resetting the sampling offset to the beginning.
888 *
889 * @param sources array of sources to rewind
890 */
891 @StripPostfix("sources")
892 @ALvoid
893 void alSourceRewindv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
894
895 /**
896 * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus
897 * the data found in the Buffer will be fed into the processing, starting at the
898 * beginning. Play() applied to a AL_PLAYING Source will restart the Source from the
899 * beginning. It will not affect the configuration, and will leave the Source in
900 * AL_PLAYING state, but reset the sampling offset to the beginning. Play() applied to a
901 * AL_PAUSED Source will resume processing using the Source state as preserved at the
902 * Pause() operation. Play() applied to a AL_STOPPED Source will propagate it to
903 * AL_INITIAL then to AL_PLAYING immediately.
904 *
905 * @param source Source to play
906 */
907 @ALvoid
908 void alSourcePlay(@ALuint int source);
909
910 /**
911 * Pause() applied to an AL_INITIAL Source is a legal NOP. Pause() applied to a
912 * AL_PLAYING Source will change its state to AL_PAUSED. The Source is exempt from
913 * processing, its current state is preserved. Pause() applied to a AL_PAUSED Source is a
914 * legal NOP. Pause() applied to a AL_STOPPED Source is a legal NOP.
915 *
916 * @param source Source to pause
917 */
918 @ALvoid
919 void alSourcePause(@ALuint int source);
920
921 /**
922 * Stop() applied to an AL_INITIAL Source is a legal NOP. Stop() applied to a AL_PLAYING
923 * Source will change its state to AL_STOPPED. The Source is exempt from processing,
924 * its current state is preserved. Stop() applied to a AL_PAUSED Source will change its
925 * state to AL_STOPPED, with the same consequences as on a AL_PLAYING Source. Stop()
926 * applied to a AL_STOPPED Source is a legal NOP.
927 *
928 * @param source Source to stop
929 */
930 @ALvoid
931 void alSourceStop(@ALuint int source);
932
933 /**
934 * Rewind() applied to an AL_INITIAL Source is a legal NOP. Rewind() applied to a
935 * AL_PLAYING Source will change its state to AL_STOPPED then AL_INITIAL. The Source is
936 * exempt from processing, its current state is preserved, with the exception of the
937 * sampling offset which is reset to the beginning. Rewind() applied to a AL_PAUSED
938 * Source will change its state to AL_INITIAL, with the same consequences as on a
939 * AL_PLAYING Source. Rewind() applied to a AL_STOPPED Source promotes the Source to
940 * AL_INITIAL, resetting the sampling offset to the beginning.
941 *
942 * @param source Source to rewind
943 */
944 @ALvoid
945 void alSourceRewind(@ALuint int source);
946
947 /**
948 * The application requests a number of Buffers using GenBuffers.
949 *
950 * @param buffers holding buffers
951 */
952 @ALvoid
953 void alGenBuffers(@AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers);
954
955 @Alternate(value = "alGenBuffers", nativeAlt = true)
956 @ALvoid
957 void alGenBuffers2(@Constant("1") @ALsizei int n, @Result @ALuint int buffer);
958
959 /**
960 * <p>
961 * The application requests deletion of a number of Buffers by calling DeleteBuffers.
962 * </p>
963 * <p>
964 * Once deleted, Names are no longer valid for use with AL function calls. Any such
965 * use will cause an AL_INVALID_NAME error. The implementation is free to defer actual
966 * release of resources.
967 * </p>
968 * <p>
969 * IsBuffer(bname) can be used to verify deletion of a buffer. Deleting bufferName 0 is
970 * a legal NOP in both scalar and vector forms of the command. The same is true for
971 * unused buffer names, e.g. such as not allocated yet, or as released already.
972 *
973 * @param buffers Buffer to delete from
974 */
975 @ALvoid
976 void alDeleteBuffers(@AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers);
977
978 @Alternate(value = "alDeleteBuffers", nativeAlt = true)
979 @ALvoid
980 void alDeleteBuffers2(@Constant("1") @ALsizei int n, @Indirect @ALuint int buffer);
981
982 /**
983 * The application can verify whether a buffer Name is valid using the IsBuffer query.
984 *
985 * @param buffer buffer to be tested for validity
986 * @return true if supplied buffer is valid, false if not
987 */
988 boolean alIsBuffer(@ALuint int buffer);
989
990 /**
991 * <p>
992 * A special case of Buffer state is the actual sound sample data stored in asociation
993 * with the Buffer. Applications can specify sample data using BufferData.
994 * </p>
995 * <p>
996 * The data specified is copied to an internal software, or if possible, hardware buffer.
997 * The implementation is free to apply decompression, conversion, resampling, and
998 * filtering as needed. The internal format of the Buffer is not exposed to the
999 * application, and not accessible. Valid formats are AL_FORMAT_MONO8,
1000 * AL_FORMAT_MONO16, AL_FORMAT_STEREO8, and AL_FORMAT_STEREO16. An
1001 * implementation may expose other formats, see the chapter on Extensions for
1002 * information on determining if additional formats are supported.
1003 * </p>
1004 * <p>
1005 * Applications should always check for an error condition after attempting to specify
1006 * buffer data in case an implementation has to generate an AL_OUT_OF_MEMORY or
1007 * conversion related AL_INVALID_VALUE error. The application is free to reuse the
1008 * memory specified by the data pointer once the call to BufferData returns. The
1009 * implementation has to dereference, e.g. copy, the data during BufferData execution.
1010 * </p>
1011 *
1012 * @param buffer Buffer to fill
1013 * @param format format sound data is in
1014 * @param data location of data
1015 * @param freq frequency of data
1016 */
1017 @ALvoid
1018 void alBufferData(
1019 @ALuint int buffer,
1020 @ALenum int format,
1021 @ALbyte
1022 @ALshort
1023 @ALint
1024 Buffer data,
1025 @AutoSize("data")
1026 @ALsizei int size,
1027 @ALsizei int freq);
1028
1029 /**
1030 * Buffer state is maintained inside the AL implementation and can be queried in full.<br>
1031 * ALC_FREQUENCY - specified in samples per second, i.e. units of Hertz [Hz].<br>
1032 * ALC_SIZE - Size in bytes of the buffer data.<br>
1033 *
1034 * @param buffer buffer to get property from
1035 * @param pname name of property to retrieve
1036 */
1037 @ALvoid
1038 void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value);
1039
1040 /**
1041 * Buffer state is maintained inside the AL implementation and can be queried in full.<br>
1042 * ALC_FREQUENCY - specified in samples per second, i.e. units of Hertz [Hz].<br>
1043 * ALC_SIZE - Size in bytes of the buffer data.<br>
1044 *
1045 * @param buffer buffer to get property from
1046 * @param pname name of property to retrieve
1047 * @return float
1048 */
1049 @ALvoid
1050 void alGetBufferf(@ALuint int buffer, @ALenum int pname, @Result float value);
1051
1052 /**
1053 * <p>
1054 * The application can queue up one or multiple buffer names using
1055 * SourceQueueBuffers. The buffers will be queued in the sequence in which they
1056 * appear in the array.
1057 * </p>
1058 * <p>
1059 * This command is legal on a Source in any state (to allow for streaming, queueing
1060 * has to be possible on a AL_PLAYING Source). Queues are read-only with exception of
1061 * the unqueue operation. The Buffer Name AL_NONE (i.e. 0) can be queued.
1062 * </p>
1063 *
1064 * @param source source to queue buffers onto
1065 * @param buffers buffers to be queued
1066 */
1067 @ALvoid
1068 void alSourceQueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers);
1069
1070 @Alternate(value = "alSourceQueueBuffers", nativeAlt = true)
1071 @ALvoid
1072 void alSourceQueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Indirect @ALuint int buffer);
1073
1074 /**
1075 * <p>
1076 * Once a queue entry for a buffer has been appended to a queue and is pending
1077 * processing, it should not be changed. Removal of a given queue entry is not possible
1078 * unless either the Source is AL_STOPPED (in which case then entire queue is considered
1079 * processed), or if the queue entry has already been processed (AL_PLAYING or AL_PAUSED
1080 * Source).
1081 * </p>
1082 * <p>
1083 * The Unqueue command removes a number of buffers entries that have finished
1084 * processing, in the order of appearance, from the queue. The operation will fail if
1085 * more buffers are requested than available, leaving the destination arguments
1086 * unchanged. An AL_INVALID_VALUE error will be thrown. If no error, the destination
1087 * argument will have been updated accordingly.
1088 * </p>
1089 *
1090 * @param source source to unqueue buffers from
1091 * @param buffers IntBuffer containing list of names that were unqueued
1092 */
1093 @ALvoid
1094 void alSourceUnqueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers);
1095
1096 @Alternate(value = "alSourceUnqueueBuffers", nativeAlt = true)
1097 @ALvoid
1098 void alSourceUnqueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Result @ALuint int buffer);
1099
1100 /**
1101 * <p>
1102 * Samples usually use the entire dynamic range of the chosen format/encoding,
1103 * independent of their real world intensity. In other words, a jet engine and a
1104 * clockwork both will have samples with full amplitude. The application will then
1105 * have to adjust Source AL_GAIN accordingly to account for relative differences.
1106 * </p>
1107 * <p>
1108 * Source AL_GAIN is then attenuated by distance. The effective attenuation of a Source
1109 * depends on many factors, among which distance attenuation and source and
1110 * Listener AL_GAIN are only some of the contributing factors. Even if the source and
1111 * Listener AL_GAIN exceed 1.0 (amplification beyond the guaranteed dynamic range),
1112 * distance and other attenuation might ultimately limit the overall AL_GAIN to a value
1113 * below 1.0.
1114 * </p>
1115 * <p>
1116 * AL currently supports three modes of operation with respect to distance
1117 * attenuation. It supports two distance-dependent attenuation models, one which is
1118 * similar to the IASIG I3DL2 (and DS3D) model. The application choses one of these
1119 * two models (or can chose to disable distance-dependent attenuation effects model)
1120 * on a per-context basis.
1121 * </p>
1122 * <p>
1123 * Legal arguments are AL_NONE, AL_INVERSE_DISTANCE, and
1124 * AL_INVERSE_DISTANCE_CLAMPED.
1125 * <br>
1126 * <br>
1127 * AL_NONE bypasses all distance attenuation
1128 * calculation for all Sources. The implementation is expected to optimize this
1129 * situation.
1130 * <br>
1131 * <br>
1132 * AL_INVERSE_DISTANCE_CLAMPED is the DS3D model, with
1133 * AL_REFERENCE_DISTANCE indicating both the reference distance and the distance
1134 * below which gain will be clamped.
1135 * <br>
1136 * <br>
1137 * AL_INVERSE_DISTANCE is equivalent to the DS3D
1138 * model with the exception that AL_REFERENCE_DISTANCE does not imply any
1139 * clamping.
1140 * <br>
1141 * <br>
1142 * The AL implementation is still free to apply any range clamping as
1143 * necessary. The current distance model chosen can be queried using GetIntegerv and
1144 * AL_DISTANCE_MODEL.
1145 * </p>
1146 *
1147 * @param value distance model to be set
1148 */
1149 @ALvoid
1150 void alDistanceModel(@ALenum int value);
1151
1152 /**
1153 * The Doppler Effect depends on the velocities of Source and Listener relative to the
1154 * medium, and the propagation speed of sound in that medium. The application
1155 * might want to emphasize or de-emphasize the Doppler Effect as physically accurate
1156 * calculation might not give the desired results. The amount of frequency shift (pitch
1157 * change) is proportional to the speed of listener and source along their line of sight.
1158 * The application can increase or decrease that frequency shift by specifying the
1159 * scaling factor AL should apply to the result of the calculation.
1160 * <br>
1161 * <br>
1162 * The Doppler Effect as implemented by AL is described by the formula below. Effects
1163 * of the medium (air, water) moving with respect to listener and source are ignored.
1164 * AL_DOPPLER_VELOCITY is the propagation speed relative to which the Source
1165 * velocities are interpreted.
1166 *
1167 * <p>
1168 * <pre>
1169 * VD: AL_DOPPLER_VELOCITY
1170 * DF: AL_DOPPLER_FACTOR
1171 * vl: Listener velocity (scalar, projected on source-listener vector)
1172 * vs: Source verlocity (scalar, projected on source-listener vector)
1173 * f: Frequency in sample
1174 * f': effective Doppler shifted frequency
1175 *
1176 * f' = DF * f * (VD-vl)/(VD+vs)
1177 *
1178 * vl<0, vs>0 : source and listener approaching each other
1179 * vl>0, vs<0 : source and listener moving away from each other
1180 * </pre>
1181 * </p>
1182 * <p>
1183 * The implementation has to clamp the projected Listener velocity vl, if abs(vl) is
1184 * greater or equal VD. It similarly has to clamp the projected Source velocity vs if
1185 * abs(vs) is greater or equal VD.
1186 * </p>
1187 * <p>
1188 * There are two API calls global to the current context that provide control of the two
1189 * related parameters.
1190 * </p>
1191 * <p>
1192 * AL_DOPPLER_FACTOR is a simple scaling to exaggerate or
1193 * deemphasize the Doppler (pitch) shift resulting from the calculation.
1194 * </p>
1195 * <p>
1196 * A negative value will result in an AL_INVALID_VALUE error, the command is then
1197 * ignored. The default value is 1. The current setting can be queried using GetFloatv
1198 * and AL_DOPPLER_FACTOR. The implementation is free to optimize the case of
1199 * AL_DOPPLER_FACTOR being set to zero, as this effectively disables the effect.
1200 * </p>
1201 *
1202 * @param value Doppler scale value to set
1203 */
1204 @ALvoid
1205 void alDopplerFactor(float value);
1206
1207 /**
1208 * The Doppler Effect depends on the velocities of Source and Listener relative to the
1209 * medium, and the propagation speed of sound in that medium. The application
1210 * might want to emphasize or de-emphasize the Doppler Effect as physically accurate
1211 * calculation might not give the desired results. The amount of frequency shift (pitch
1212 * change) is proportional to the speed of listener and source along their line of sight.
1213 * The application can increase or decrease that frequency shift by specifying the
1214 * scaling factor AL should apply to the result of the calculation.
1215 * <br>
1216 * <br>
1217 * The Doppler Effect as implemented by AL is described by the formula below. Effects
1218 * of the medium (air, water) moving with respect to listener and source are ignored.
1219 * AL_DOPPLER_VELOCITY is the propagation speed relative to which the Source
1220 * velocities are interpreted.
1221 *
1222 * <p>
1223 * <pre>
1224 * VD: AL_DOPPLER_VELOCITY
1225 * DF: AL_DOPPLER_FACTOR
1226 * vl: Listener velocity (scalar, projected on source-listener vector)
1227 * vs: Source verlocity (scalar, projected on source-listener vector)
1228 * f: Frequency in sample
1229 * f': effective Doppler shifted frequency
1230 *
1231 * f' = DF * f * (VD-vl)/(VD+vs)
1232 *
1233 * vl<0, vs>0 : source and listener approaching each other
1234 * vl>0, vs<0 : source and listener moving away from each other
1235 * </pre>
1236 * </p>
1237 * <p>
1238 * The implementation has to clamp the projected Listener velocity vl, if abs(vl) is
1239 * greater or equal VD. It similarly has to clamp the projected Source velocity vs if
1240 * abs(vs) is greater or equal VD.
1241 * </p>
1242 * <p>
1243 * There are two API calls global to the current context that provide control of the two
1244 * related parameters.
1245 * </p>
1246 * <p>
1247 * AL_DOPPLER_VELOCITY allows the application to change the reference (propagation)
1248 * velocity used in the Doppler Effect calculation. This permits the application to use a
1249 * velocity scale appropriate to its purposes.
1250 * </p>
1251 * <p>
1252 * A negative or zero value will result in an AL_INVALID_VALUE error, the command is
1253 * then ignored. The default value is 1. The current setting can be queried using
1254 * GetFloatv and AL_DOPPLER_VELOCITY.
1255 * </p>
1256 *
1257 * @param value Doppler velocity value to set
1258 */
1259 @ALvoid
1260 void alDopplerVelocity(float value);
1261 }
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.openal;
32
33 import java.nio.Buffer;
34 import java.nio.IntBuffer;
35 import java.nio.FloatBuffer;
36 import java.nio.DoubleBuffer;
37
38 import org.lwjgl.openal.AL10;
39 import org.lwjgl.util.generator.*;
40
41 /**
42 * <br>
43 * This is the core OpenAL class. This class implements
44 * AL.h version 1.1
45 *
46 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 2286 $
48 * $Id: AL10.java 2286 2006-03-23 19:32:21Z matzon $
49 */
50 public interface AL11 {
51
52 /** Source buffer position information in seconds */
53 public static final int AL_SEC_OFFSET = 0x1024;
54
55 /** Source buffer position information in samples */
56 public static final int AL_SAMPLE_OFFSET = 0x1025;
57
58 /** Source buffer position information in bytes */
59 public static final int AL_BYTE_OFFSET = 0x1026;
60
61 /** Type of source: Buffer has been attached using AL_BUFFER */
62 public static final int AL_STATIC = 0x1028;
63
64 /** Type of source: if one or more Buffers have been attached using alSourceQueueBuffers */
65 public static final int AL_STREAMING = 0x1029;
66
67 /** Type of source: when it has the NULL buffer attached */
68 public static final int AL_UNDETERMINED = 0x1030;
69
70 /** @see AL10#AL_INVALID_OPERATION */
71 public static final int AL_ILLEGAL_COMMAND = 0xA004;
72
73 /** Speed of Sound in units per second */
74 public static final int AL_SPEED_OF_SOUND = 0xC003;
75
76 public static final int AL_LINEAR_DISTANCE = 0xD003;
77 public static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004;
78 public static final int AL_EXPONENT_DISTANCE = 0xD005;
79 public static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006;
80
81 /**
82 * Listener attributes are changed using the Listener group of commands.
83 *
84 * @param pname name of the attribute to be set
85 * @param v1 value value 1
86 * @param v2 value value 2
87 * @param v3 value value 3
88 */
89 @ALvoid
90 void alListener3i(@ALenum int pname, int v1, int v2, int v3);
91
92 /**
93 * Listener state is maintained inside the AL implementation and can be queried in
94 * full.
95 *
96 * @param pname name of the attribute to be retrieved
97 * @param intdata Buffer to write ints to
98 */
99 // TODO: What's the real minimum number of elements?
100 @StripPostfix("intdata")
101 @ALvoid
102 void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata);
103
104 /**
105 * Specifies the position and other properties as taken into account during
106 * sound processing.
107 *
108 * @param source Source to set property on
109 * @param pname property to set
110 * @param v1 value 1 of property
111 * @param v2 value 2 of property
112 * @param v3 value 3 of property
113 */
114 @ALvoid
115 void alSource3i(@ALuint int source, @ALenum int pname, int v1, int v2, int v3);
116
117 /**
118 * Specifies the position and other properties as taken into account during
119 * sound processing.
120 *
121 * @param source Source to set property on
122 * @param pname property to set
123 * @param value IntBuffer containing value of property
124 */
125 // TODO: What's the correct minimum value?
126 @StripPostfix("value")
127 @ALvoid
128 void alSourceiv(@ALuint int source, @ALenum int pname, @Check("1") @Const IntBuffer value);
129
130 /**
131 * This function sets a floating point property of a buffer.
132 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
133 * this call, but this function may be used by OpenAL extensions.</i>
134 *
135 * @param buffer Buffer to set property on
136 * @param pname property to set
137 * @param value value of property
138 */
139 @ALvoid
140 void alBufferf(@ALuint int buffer, @ALenum int pname, float value);
141
142 /**
143 * This function sets a floating point property of a buffer.
144 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
145 * this call, but this function may be used by OpenAL extensions.</i>
146 *
147 * @param buffer Buffer to set property on
148 * @param pname property to set
149 * @param v1 value of property
150 * @param v2 value of property
151 * @param v3 value of property
152 */
153 @ALvoid
154 void alBuffer3f(@ALuint int buffer, @ALenum int pname, float v1, float v2, float v3);
155
156 /**
157 * This function sets a floating point property of a buffer.
158 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
159 * this call, but this function may be used by OpenAL extensions.</i>
160 *
161 * @param buffer Buffer to set property on
162 * @param pname property to set
163 * @param value FloatBuffer containing value of property
164 */
165 // TODO: What's the correct minimum value?
166 @StripPostfix("value")
167 @ALvoid
168 void alBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const FloatBuffer value);
169
170 /**
171 * This function sets an integer property of a buffer.
172 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
173 * this call, but this function may be used by OpenAL extensions.</i>
174 *
175 * @param buffer Buffer to set property on
176 * @param pname property to set
177 * @param value value of property
178 */
179 @ALvoid
180 void alBufferi(@ALuint int buffer, @ALenum int pname, int value);
181
182 /**
183 * This function sets an integer property of a buffer.
184 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
185 * this call, but this function may be used by OpenAL extensions.</i>
186 *
187 * @param buffer Buffer to set property on
188 * @param pname property to set
189 * @param v1 value of property
190 * @param v2 value of property
191 * @param v3 value of property
192 */
193 @ALvoid
194 void alBuffer3i(@ALuint int buffer, @ALenum int pname, int v1, int v2, int v3);
195
196 /**
197 * This function sets an integer property of a buffer.
198 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
199 * this call, but this function may be used by OpenAL extensions.</i>
200 *
201 * @param buffer Buffer to set property on
202 * @param pname property to set
203 * @param value IntBuffer containing value of property
204 */
205 // TODO: What's the correct minimum value?
206 @StripPostfix("value")
207 @ALvoid
208 void alBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const IntBuffer value);
209
210 /**
211 * This function retrieves an integer property of a buffer.
212 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
213 * this call, but this function may be used by OpenAL extensions.</i>
214 *
215 * @param buffer Buffer to get property from
216 * @param pname name of property
217 * @return int
218 */
219 @ALvoid
220 void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value);
221
222 /**
223 * This function retrieves an integer property of a buffer.
224 *
225 * @param buffer Buffer to get property from
226 * @param pname name of property
227 */
228 // TODO: What's the correct minimum value?
229 @StripPostfix("values")
230 @ALvoid
231 void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") IntBuffer values);
232
233 /**
234 * This function retrieves a floating point property of a buffer.
235 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
236 * this call, but this function may be used by OpenAL extensions.</i>
237 *
238 * @param buffer Buffer to get property from
239 * @param pname name of property
240 * @return floating point property
241 */
242 @ALvoid
243 void alGetBufferf(@ALuint int buffer, @ALenum int pname, @Result float value);
244
245 /**
246 * This function retrieves a floating point property of a buffer.
247 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
248 * this call, but this function may be used by OpenAL extensions.</i>
249 *
250 * @param buffer Buffer to get property from
251 * @param pname name of property
252 */
253 // TODO: What's the correct minimum value?
254 @StripPostfix("values")
255 @ALvoid
256 void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values);
257
258 /**
259 * <p>
260 * AL_SPEED_OF_SOUND allows the application to change the reference (propagation)
261 * speed used in the Doppler calculation. The source and listener velocities should be
262 * expressed in the same units as the speed of sound.
263 * </p>
264 * <p>
265 * A negative or zero value will result in an AL_INVALID_VALUE error, and the
266 * command is ignored. The default value is 343.3 (appropriate for velocity units of meters
267 * and air as the propagation medium). The current setting can be queried using
268 * alGetFloat{v} and AL_SPEED_OF_SOUND.
269 * Distance and velocity units are completely independent of one another (so you could use
270 * different units for each if desired).
271 * </p>
272 *
273 * @param value distance model to be set
274 */
275 @ALvoid
276 void alSpeedOfSound(float value);
277 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface AMD_conservative_depth {
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 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface AMD_draw_buffers_blend {
37
38 void glBlendFuncIndexedAMD(@GLuint int buf, @GLenum int src, @GLenum int dst);
39
40 void glBlendFuncSeparateIndexedAMD(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB,
41 @GLenum int srcAlpha, @GLenum int dstAlpha);
42
43 void glBlendEquationIndexedAMD(@GLuint int buf, @GLenum int mode);
44
45 void glBlendEquationSeparateIndexedAMD(@GLuint int buf, @GLenum int modeRGB,
46 @GLenum int modeAlpha);
47
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 public interface AMD_performance_monitor {
39
40 /** Accepted by the &lt;pame&gt; parameter of GetPerfMonitorCounterInfoAMD */
41 int GL_COUNTER_TYPE_AMD = 0x8BC0;
42 int GL_COUNTER_RANGE_AMD = 0x8BC1;
43
44 /**
45 * Returned as a valid value in &lt;data&gt; parameter of
46 * GetPerfMonitorCounterInfoAMD if &lt;pname&gt; = COUNTER_TYPE_AMD
47 */
48 int GL_UNSIGNED_INT = 0x1405;
49 int GL_FLOAT = 0x1406;
50 int GL_UNSIGNED_INT64_AMD = 0x8BC2;
51 int GL_PERCENTAGE_AMD = 0x8BC3;
52
53 /** Accepted by the &lt;pname&gt; parameter of GetPerfMonitorCounterDataAMD */
54
55 int GL_PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4;
56 int GL_PERFMON_RESULT_SIZE_AMD = 0x8BC5;
57 int GL_PERFMON_RESULT_AMD = 0x8BC6;
58
59 void glGetPerfMonitorGroupsAMD(@OutParameter @Check(value = "1", canBeNull = true) @GLint IntBuffer numGroups,
60 @AutoSize("groups") @GLsizei int groupsSize, @GLuint IntBuffer groups);
61
62 void glGetPerfMonitorCountersAMD(@GLuint int group,
63 @OutParameter @Check(value = "1") @GLint IntBuffer numCounters,
64 @OutParameter @Check(value = "1") @GLint IntBuffer maxActiveCounters,
65 @AutoSize("counters") @GLsizei int countersSize,
66 @GLuint IntBuffer counters);
67
68 void glGetPerfMonitorGroupStringAMD(@GLuint int group,
69 @AutoSize("groupString") @GLsizei int bufSize,
70 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
71 @OutParameter @GLchar ByteBuffer groupString);
72
73 @Alternate("glGetPerfMonitorGroupStringAMD")
74 @GLreturn(value = "groupString", maxLength = "bufSize")
75 void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize,
76 @OutParameter @GLsizei @Constant("groupString_length, 0") IntBuffer length,
77 @OutParameter @GLchar ByteBuffer groupString);
78
79 void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize,
80 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
81 @OutParameter @GLchar ByteBuffer counterString);
82
83 @Alternate("glGetPerfMonitorCounterStringAMD")
84 @GLreturn(value = "counterString", maxLength = "bufSize")
85 void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize,
86 @OutParameter @GLsizei @Constant("counterString_length, 0") IntBuffer length,
87 @OutParameter @GLchar ByteBuffer counterString);
88
89 void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data);
90
91 void glGenPerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors);
92
93 @Alternate("glGenPerfMonitorsAMD")
94 @GLreturn("monitors")
95 void glGenPerfMonitorsAMD2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors);
96
97 void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors);
98
99 @Alternate("glDeletePerfMonitorsAMD")
100 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor);
101
102 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList);
103
104 @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);
106
107 void glBeginPerfMonitorAMD(@GLuint int monitor);
108
109 void glEndPerfMonitorAMD(@GLuint int monitor);
110
111 void glGetPerfMonitorCounterDataAMD(@GLuint int monitor, @GLenum int pname, @AutoSize("data") @GLsizei int dataSize,
112 @OutParameter @GLuint IntBuffer data,
113 @OutParameter @GLint @Check(value = "1", canBeNull = true) IntBuffer bytesWritten);
114
115 @Alternate("glGetPerfMonitorCounterDataAMD")
116 @GLreturn("data")
117 void glGetPerfMonitorCounterDataAMD2(@GLuint int monitor, @GLenum int pname, @Constant("4") @GLsizei int dataSize,
118 @OutParameter @GLuint IntBuffer data,
119 @OutParameter @GLint @Constant("null, 0") IntBuffer bytesWritten);
120
121 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface AMD_seamless_cubemap_per_texture {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of TexParameterf, TexParameteri,
37 * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv:
38 */
39 int GL_TEXTURE_CUBE_MAP_SEAMLESS = ARB_seamless_cube_map.GL_TEXTURE_CUBE_MAP_SEAMLESS;
40
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.opengl;
32
33 public interface AMD_shader_stencil_export {
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 AMD_texture_texture4 {
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 import org.lwjgl.util.generator.GLenum;
34
35 public interface AMD_vertex_shader_tessellator {
36
37 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
38 int GL_SAMPLER_BUFFER_AMD = 0x9001;
39 int GL_INT_SAMPLER_BUFFER_AMD = 0x9002;
40 int GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD = 0x9003;
41
42 /** Accepted by TessellationModeAMD */
43 int GL_DISCRETE_AMD = 0x9006;
44 int GL_CONTINUOUS_AMD = 0x9007;
45
46 /** Accepted by GetIntegerv */
47 int GL_TESSELLATION_MODE_AMD = 0x9004;
48
49 /** Accepted by GetFloatv */
50 int GL_TESSELLATION_FACTOR_AMD = 0x9005;
51
52 void glTessellationFactorAMD(float factor);
53
54 void glTessellationModeAMD(@GLenum int mode);
55
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.opengl;
32
33 public interface APPLE_aux_depth_stencil {
34
35 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv. */
36 int GL_AUX_DEPTH_STENCIL_APPLE = 0x8A14;
37
38 }
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 APPLE_client_storage {
34
35 /** Accepted by the &lt;pname&gt; parameters of PixelStore: */
36 int GL_UNPACK_CLIENT_STORAGE_APPLE = 0x85B2;
37
38 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.IntBuffer;
37
38 public interface APPLE_element_array {
39
40 /**
41 * Accepted by the &lt;array&gt; parameter of EnableClientState and
42 * DisableClientState and the &lt;value&gt; parameter of IsEnabled:
43 */
44 int GL_ELEMENT_ARRAY_APPLE = 0x8768;
45
46 /**
47 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
48 * GetFloatv, and GetDoublev:
49 */
50 int GL_ELEMENT_ARRAY_TYPE_APPLE = 0x8769;
51
52 /** Accepted by the &lt;pname&gt; parameter of GetPointerv: */
53 int GL_ELEMENT_ARRAY_POINTER_APPLE = 0x876A;
54
55 void glElementPointerAPPLE(@AutoType("pointer") @GLenum int type,
56 @Check
57 @Const
58 @GLubyte
59 @GLushort
60 @GLuint Buffer pointer);
61
62 void glDrawElementArrayAPPLE(@GLenum int mode, int first, @GLsizei int count);
63
64 void glDrawRangeElementArrayAPPLE(@GLenum int mode, @GLuint int start, @GLuint int end, int first, @GLsizei int count);
65
66 void glMultiDrawElementArrayAPPLE(@GLenum int mode,
67 @Const IntBuffer first,
68 @Const @Check("first.remaining()") @GLsizei IntBuffer count,
69 @AutoSize("first") @GLsizei int primcount);
70
71 void glMultiDrawRangeElementArrayAPPLE(@GLenum int mode, @GLuint int start, @GLuint int end,
72 @Const IntBuffer first,
73 @Const @Check("first.remaining()") @GLsizei IntBuffer count,
74 @AutoSize("first") @GLsizei int primcount);
75
76 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface APPLE_fence {
38
39 /** Accepted by the &lt;object&gt; parameter of TestObjectAPPLE and FinishObjectAPPLE: */
40 int GL_DRAW_PIXELS_APPLE = 0x8A0A;
41 int GL_FENCE_APPLE = 0x8A0B;
42
43 void glGenFencesAPPLE(@AutoSize("fences") @GLsizei int n, @OutParameter @GLuint IntBuffer fences);
44
45 @Alternate("glGenFencesAPPLE")
46 @GLreturn("fences")
47 void glGenFencesAPPLE2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer fences);
48
49 void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences);
50
51 @Alternate("glDeleteFencesAPPLE")
52 void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
53
54 void glSetFenceAPPLE(@GLuint int fence);
55
56 boolean glIsFenceAPPLE(@GLuint int fence);
57
58 boolean glTestFenceAPPLE(@GLuint int fence);
59
60 void glFinishFenceAPPLE(@GLuint int fence);
61
62 boolean glTestObjectAPPLE(@GLenum int object, @GLuint int name);
63
64 void glFinishObjectAPPLE(@GLenum int object, int name);
65
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 package org.lwjgl.opengl;
32
33 public interface APPLE_float_pixels {
34
35 /**
36 * Accepted by the parameters of DrawPixels, ReadPixels, TexImage1D,
37 * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and
38 * GetTexImage:
39 */
40 int GL_HALF_APPLE = 0x140B;
41
42 /** Accepted by the GetBooleanv: */
43 int GL_COLOR_FLOAT_APPLE = 0x8A0F;
44
45 /**
46 * Accepted by the parameter of TexImage1D,
47 * TexImage2D, and TexImage3D:
48 */
49 int GL_RGBA_FLOAT32_APPLE = 0x8814;
50 int GL_RGB_FLOAT32_APPLE = 0x8815;
51 int GL_ALPHA_FLOAT32_APPLE = 0x8816;
52 int GL_INTENSITY_FLOAT32_APPLE = 0x8817;
53 int GL_LUMINANCE_FLOAT32_APPLE = 0x8818;
54 int GL_LUMINANCE_ALPHA_FLOAT32_APPLE = 0x8819;
55 int GL_RGBA_FLOAT16_APPLE = 0x881A;
56 int GL_RGB_FLOAT16_APPLE = 0x881B;
57 int GL_ALPHA_FLOAT16_APPLE = 0x881C;
58 int GL_INTENSITY_FLOAT16_APPLE = 0x881D;
59 int GL_LUMINANCE_FLOAT16_APPLE = 0x881E;
60 int GL_LUMINANCE_ALPHA_FLOAT16_APPLE = 0x881F;
61
62 }
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.GLenum;
34 import org.lwjgl.util.generator.GLintptr;
35 import org.lwjgl.util.generator.GLsizeiptr;
36
37 public interface APPLE_flush_buffer_range {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameter of BufferParameteriAPPLE and
41 * GetBufferParameteriv:
42 */
43 int GL_BUFFER_SERIALIZED_MODIFY_APPLE = 0x8A12;
44 int GL_BUFFER_FLUSHING_UNMAP_APPLE = 0x8A13;
45
46 void glBufferParameteriAPPLE(@GLenum int target, @GLenum int pname, int param);
47
48 void glFlushMappedBufferRangeAPPLE(@GLenum int target, @GLintptr long offset, @GLsizeiptr long size);
49
50 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface APPLE_object_purgeable {
38
39 /**
40 * Accepted by the &lt;option&gt; parameter of ObjectPurgeable, and returned
41 * by ObjectPurgeable:
42 */
43 int GL_RELEASED_APPLE = 0x8A19;
44 int GL_VOLATILE_APPLE = 0x8A1A;
45
46 /**
47 * Accepted by the &lt;option&gt; parameters of ObjectUnpurgeable, and
48 * returned by ObjectUnpurgeable:
49 */
50 int GL_RETAINED_APPLE = 0x8A1B;
51 int GL_UNDEFINED_APPLE = 0x8A1C;
52
53 /** Accepted by the &lt;pname&gt; parameters of GetObjectParameteriv: */
54 int GL_PURGEABLE_APPLE = 0x8A1D;
55
56 /**
57 * Accepted by the &lt;objectType&gt; parameters of ObjectPurgeableAPPLE,
58 * ObjectUnpurgeableAPPLE and GetObjectParameteriv:
59 */
60 int GL_BUFFER_OBJECT_APPLE = 0x85B3;
61
62 @GLenum
63 int glObjectPurgeableAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int option);
64
65 @GLenum
66 int glObjectUnpurgeableAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int option);
67
68 @StripPostfix("params")
69 void glGetObjectParameterivAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
70
71 @Alternate("glGetObjectParameterivAPPLE")
72 @GLreturn("params")
73 @StripPostfix("params")
74 void glGetObjectParameterivAPPLE2(@GLenum int objectType, @GLuint int name, @GLenum int pname, @OutParameter IntBuffer params);
75
76 }
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 APPLE_packed_pixels {
34
35 /**
36 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
37 * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D,
38 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
39 * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D,
40 * GetConvolutionFilter, SeparableFilter2D, SeparableFilter3D,
41 * GetSeparableFilter, ColorTable, GetColorTable, TexImage4DSGIS,
42 * and TexSubImage4DSGIS:
43 */
44 int GL_UNSIGNED_BYTE_3_3_2 = 0x8032;
45 int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362;
46 int GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
47 int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364;
48 int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
49 int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365;
50 int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
51 int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366;
52 int GL_UNSIGNED_INT_8_8_8_8 = 0x8035;
53 int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
54 int GL_UNSIGNED_INT_10_10_10_2 = 0x8036;
55 int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
56
57 }
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 APPLE_rgb_422 {
34
35 /**
36 * Accepted by the &lt;format&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
37 * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
38 * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
39 * ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D,
40 * GetSeparableFilter, ColorTable, GetColorTable:
41 */
42 int GL_RGB_422_APPLE = 0x8A1F;
43
44 /**
45 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
46 * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
47 * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
48 * ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D,
49 * GetSeparableFilter, ColorTable, GetColorTable:
50 */
51 int GL_UNSIGNED_SHORT_8_8_APPLE = 0x85BA;
52 int GL_UNSIGNED_SHORT_8_8_REV_APPLE = 0x85BB;
53
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface APPLE_row_bytes {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of PixelStorei and the &lt;pname&gt;
37 * parameter of GetIntegerv:
38 */
39 int GL_PACK_ROW_BYTES_APPLE = 0x8A15;
40 int GL_UNPACK_ROW_BYTES_APPLE = 0x8A16;
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37
38 public interface APPLE_texture_range {
39
40 /**
41 * Accepted by the <pname> parameters of TexParameteri, TexParameterf,
42 * TexParameteriv, TexParameterfv, GetTexParameteriv, and
43 * GetTexParameterfv:
44 */
45 int GL_TEXTURE_STORAGE_HINT_APPLE = 0x85BC;
46
47 /**
48 * Accepted by the <param> parameters of TexParameteri, TexParameterf,
49 * TexParameteriv, and TexParameterfv:
50 */
51 int GL_STORAGE_PRIVATE_APPLE = 0x85BD;
52 int GL_STORAGE_CACHED_APPLE = 0x85BE;
53 int GL_STORAGE_SHARED_APPLE = 0x85BF;
54
55 /**
56 * Accepted by the <pname> parameters of GetTexParameteriv and
57 * GetTexParameterfv:
58 */
59 int GL_TEXTURE_RANGE_LENGTH_APPLE = 0x85B7;
60
61 /** Accepted by the <pname> parameters of GetTexParameterPointerv: */
62 int GL_TEXTURE_RANGE_POINTER_APPLE = 0x85B8;
63
64 void glTextureRangeAPPLE(@GLenum int target, @AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer);
65
66 void glGetTexParameterPointervAPPLE(@GLenum int target, @GLenum int pname, @Result @GLvoid Buffer params);
67
68 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface APPLE_vertex_array_object {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
41 * and GetDoublev:
42 */
43 int GL_VERTEX_ARRAY_BINDING_APPLE = 0x85B5;
44
45 void glBindVertexArrayAPPLE(@GLuint int array);
46
47 void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
48
49 @Alternate("glDeleteVertexArraysAPPLE")
50 void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
51
52 void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
53
54 @Alternate("glGenVertexArraysAPPLE")
55 @GLreturn("arrays")
56 void glGenVertexArraysAPPLE2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
57
58 boolean glIsVertexArrayAPPLE(@GLuint int array);
59
60 }
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.AutoSize;
34 import org.lwjgl.util.generator.GLenum;
35 import org.lwjgl.util.generator.GLsizei;
36 import org.lwjgl.util.generator.GLvoid;
37
38 import java.nio.ByteBuffer;
39
40 public interface APPLE_vertex_array_range {
41
42 /**
43 * Accepted by the &lt;cap&gt; parameter of EnableClientState, DisableClientState,
44 * and IsEnabled:
45 */
46 int GL_VERTEX_ARRAY_RANGE_APPLE = 0x851D;
47
48 /**
49 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
50 * and GetDoublev:
51 */
52
53 int GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE = 0x851E;
54 int GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE = 0x8520;
55
56 /** Accepted by the &lt;pname&gt; parameter of GetPointerv: */
57
58 int GL_VERTEX_ARRAY_RANGE_POINTER_APPLE = 0x8521;
59
60 /**
61 * Accepted by the &lt;pname&gt; parameter of VertexArrayParameteriAPPLE,
62 * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
63 */
64
65 int GL_VERTEX_ARRAY_STORAGE_HINT_APPLE = 0x851F;
66
67 /** Accepted by the &lt;param&gt; parameter of VertexArrayParameteriAPPLE: */
68
69 int GL_STORAGE_CACHED_APPLE = 0x85BE;
70 int GL_STORAGE_SHARED_APPLE = 0x85BF;
71
72 /** Accepted by the &lt;object&gt; parameter of TestObjectAPPLE and FinishObjectAPPLE: */
73 int GL_DRAW_PIXELS_APPLE = 0x8A0A;
74 int GL_FENCE_APPLE = 0x8A0B;
75
76 void glVertexArrayRangeAPPLE(@AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer);
77
78 void glFlushVertexArrayRangeAPPLE(@AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer);
79
80 void glVertexArrayParameteriAPPLE(@GLenum int pname, int param);
81
82 }
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.Check;
34 import org.lwjgl.util.generator.Const;
35 import org.lwjgl.util.generator.GLenum;
36 import org.lwjgl.util.generator.GLuint;
37
38 import java.nio.DoubleBuffer;
39 import java.nio.FloatBuffer;
40
41 public interface APPLE_vertex_program_evaluators {
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of EnableVertexAttribAPPLE,
45 * DisableVertexAttribAPPLE, and IsVertexAttribEnabledAPPLE.
46 */
47 int GL_VERTEX_ATTRIB_MAP1_APPLE = 0x8A00;
48 int GL_VERTEX_ATTRIB_MAP2_APPLE = 0x8A01;
49
50 /**
51 * Accepted by the &lt;pname&gt; parameter of GetVertexAttribdvARB,
52 * GetVertexAttribfvARB, and GetVertexAttribivARB.
53 */
54 int GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE = 0x8A02;
55 int GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE = 0x8A03;
56 int GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE = 0x8A04;
57 int GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE = 0x8A05;
58 int GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE = 0x8A06;
59 int GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE = 0x8A07;
60 int GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE = 0x8A08;
61 int GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE = 0x8A09;
62
63 void glEnableVertexAttribAPPLE(@GLuint int index, @GLenum int pname);
64
65 void glDisableVertexAttribAPPLE(@GLuint int index, @GLenum int pname);
66
67 boolean glIsVertexAttribEnabledAPPLE(@GLuint int index, @GLenum int pname);
68
69 void glMapVertexAttrib1dAPPLE(@GLuint int index, @GLuint int size, double u1, double u2,
70 int stride, int order, @Check @Const DoubleBuffer points);
71
72 void glMapVertexAttrib1fAPPLE(@GLuint int index, @GLuint int size, float u1, float u2,
73 int stride, int order, @Check @Const FloatBuffer points);
74
75 void glMapVertexAttrib2dAPPLE(@GLuint int index, @GLuint int size, double u1, double u2,
76 int ustride, int uorder, double v1, double v2, int vstride, int vorder,
77 @Check @Const DoubleBuffer points);
78
79 void glMapVertexAttrib2fAPPLE(@GLuint int index, @GLuint int size, float u1, float u2,
80 int ustride, int uorder, float v1, float v2, int vstride, int vorder,
81 @Check @Const FloatBuffer points);
82
83 }
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 APPLE_ycbcr_422 {
34
35 /**
36 * Accepted by the &lt;format&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
37 * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
38 * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
39 * ConvolutionFilter2D, ConvolutionFilter3D, GetConvolutionFilter,
40 * SeparableFilter2D, SeparableFilter3D, GetSeparableFilter, ColorTable,
41 * GetColorTable:
42 */
43 int GL_YCBCR_422_APPLE = 0x85B9;
44
45 /**
46 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
47 * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
48 * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
49 * ConvolutionFilter2D, ConvolutionFilter3D, GetConvolutionFilter,
50 * SeparableFilter2D, SeparableFilter3D, GetSeparableFilter, ColorTable,
51 * GetColorTable:
52 */
53 int GL_UNSIGNED_SHORT_8_8_APPLE = 0x85BA;
54 int GL_UNSIGNED_SHORT_8_8_REV_APPLE = 0x85BB;
55
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36
37 public interface ARB_blend_func_extended {
38
39 /**
40 * Accepted by the &lt;src&gt; and &lt;dst&gt; parameters of BlendFunc and
41 * BlendFunci, and by the &lt;srcRGB&gt;, &lt;dstRGB&gt;, &lt;srcAlpha&gt; and &lt;dstAlpha&gt;
42 * parameters of BlendFuncSeparate and BlendFuncSeparatei:
43 */
44 int GL_SRC1_COLOR = 0x88F9;
45 int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA;
46 int GL_ONE_MINUS_SRC1_COLOR = 0x88FA;
47 int GL_ONE_MINUS_SRC1_ALPHA = 0x88FB;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv
51 * and GetDoublev:
52 */
53 int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC;
54
55 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name);
56
57 @Alternate("glBindFragDataLocationIndexed")
58 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name);
59
60 int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
61
62 @Alternate("glGetFragDataIndex")
63 int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name);
64
65 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 @Extension(postfix = "ARB", isFinal = false)
40 public interface ARB_buffer_object {
41
42 /** Accepted by the &lt;usage&gt; parameter of BufferDataARB: */
43 int GL_STREAM_DRAW_ARB = 0x88E0;
44 int GL_STREAM_READ_ARB = 0x88E1;
45 int GL_STREAM_COPY_ARB = 0x88E2;
46 int GL_STATIC_DRAW_ARB = 0x88E4;
47 int GL_STATIC_READ_ARB = 0x88E5;
48 int GL_STATIC_COPY_ARB = 0x88E6;
49 int GL_DYNAMIC_DRAW_ARB = 0x88E8;
50 int GL_DYNAMIC_READ_ARB = 0x88E9;
51 int GL_DYNAMIC_COPY_ARB = 0x88EA;
52
53 /** Accepted by the &lt;access&gt; parameter of MapBufferARB: */
54 int GL_READ_ONLY_ARB = 0x88B8;
55 int GL_WRITE_ONLY_ARB = 0x88B9;
56 int GL_READ_WRITE_ARB = 0x88BA;
57
58 /** Accepted by the &lt;pname&gt; parameter of GetBufferParameterivARB: */
59 int GL_BUFFER_SIZE_ARB = 0x8764;
60 int GL_BUFFER_USAGE_ARB = 0x8765;
61 int GL_BUFFER_ACCESS_ARB = 0x88BB;
62 int GL_BUFFER_MAPPED_ARB = 0x88BC;
63 int GL_BUFFER_MAP_POINTER_ARB = 0x88BD;
64
65 @Code(" StateTracker.bindBuffer(caps, target, buffer);")
66 void glBindBufferARB(@GLenum int target, @GLuint int buffer);
67
68 void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
69
70 @Alternate("glDeleteBuffersARB")
71 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
72
73 void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
74
75 @Alternate("glGenBuffersARB")
76 @GLreturn("buffers")
77 void glGenBuffersARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
78
79 boolean glIsBufferARB(@GLuint int buffer);
80
81 @GenerateAutos
82 void glBufferDataARB(@GLenum int target, @AutoSize("data") @GLsizeiptrARB long size,
83 @Const
84 @GLbyte
85 @GLshort
86 @GLint
87 @GLfloat
88 @GLdouble Buffer data, @GLenum int usage);
89
90 void glBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size,
91 @Check
92 @Const
93 @GLbyte
94 @GLshort
95 @GLint
96 @GLfloat
97 @GLdouble Buffer data);
98
99 void glGetBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size,
100 @OutParameter
101 @Check
102 @GLbyte
103 @GLshort
104 @GLint
105 @GLfloat
106 @GLdouble Buffer data);
107
108 /**
109 * glMapBufferARB maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null,
110 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
111 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
112 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferARB like this:
113 * <p/>
114 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., mapped_buffer);
115 * <p/>
116 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
117 * <p/>
118 * The version of this method without an explicit length argument calls glGetBufferParameterARB internally to
119 * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance.
120 * <p/>
121 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call
122 * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.<br>
123 * Security warning: The length argument should match the buffer object size. Reading from or writing to outside
124 * the memory region that corresponds to the mapped buffer object will cause native crashes.
125 *
126 * @param length the length of the mapped memory in bytes.
127 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
128 *
129 * @return A ByteBuffer representing the mapped buffer memory.
130 */
131 @CachedResult
132 @GLvoid
133 @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)")
134 ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access);
135
136 boolean glUnmapBufferARB(@GLenum int target);
137
138 @StripPostfix("params")
139 void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
140
141 @Alternate("glGetBufferParameterivARB")
142 @GLreturn("params")
143 @StripPostfix("params")
144 void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
145
146 @StripPostfix("pointer")
147 @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)")
148 void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
149 }
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.GLenum;
34
35 public interface ARB_color_buffer_float {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
39 * GetFloatv, and GetDoublev:
40 */
41 int GL_RGBA_FLOAT_MODE_ARB = 0x8820;
42
43 /**
44 * Accepted by the &lt;target&gt; parameter of ClampColorARB and the &lt;pname&gt;
45 * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.
46 */
47 int GL_CLAMP_VERTEX_COLOR_ARB = 0x891A;
48 int GL_CLAMP_FRAGMENT_COLOR_ARB = 0x891B;
49 int GL_CLAMP_READ_COLOR_ARB = 0x891C;
50
51 /** Accepted by the &lt;clamp&gt; parameter of ClampColorARB. */
52 int GL_FIXED_ONLY_ARB = 0x891D;
53
54 /**
55 * Accepted as a value in the &lt;piAttribIList&gt; and &lt;pfAttribFList&gt;
56 * parameter arrays of wglChoosePixelFormatARB, and returned in the
57 * &lt;piValues&gt; parameter array of wglGetPixelFormatAttribivARB, and the
58 * &lt;pfValues&gt; parameter array of wglGetPixelFormatAttribfvARB:
59 */
60 int WGL_TYPE_RGBA_FLOAT_ARB = 0x21A0;
61
62 /**
63 * Accepted as values of the &lt;render_type&gt; arguments in the
64 * glXCreateNewContext and glXCreateContext functions
65 */
66 int GLX_RGBA_FLOAT_TYPE = 0x20B9;
67
68 /** Accepted as a bit set in the GLX_RENDER_TYPE variable */
69 int GLX_RGBA_FLOAT_BIT = 0x00000004;
70
71 void glClampColorARB(@GLenum int target, @GLenum int clamp);
72
73 }
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_compatibility {
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 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLintptr;
35 import org.lwjgl.util.generator.GLsizeiptr;
36
37 public interface ARB_copy_buffer {
38
39 /**
40 * Accepted by the target parameters of BindBuffer, BufferData,
41 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
42 * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange,
43 * GetBufferParameteriv, BindBufferRange, BindBufferBase,
44 * and CopyBufferSubData:
45 */
46 int GL_COPY_READ_BUFFER = 0x8F36;
47 int GL_COPY_WRITE_BUFFER = 0x8F37;
48
49 void glCopyBufferSubData(@GLenum int readTarget, @GLenum int writeTarget,
50 @GLintptr long readOffset, @GLintptr long writeOffset,
51 @GLsizeiptr long size);
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.opengl;
32
33 public interface ARB_depth_buffer_float {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D, TexImage2D,
37 * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT,
38 * and returned in the &lt;data&gt; parameter of GetTexLevelParameter and
39 * GetRenderbufferParameterivEXT:
40 */
41 int GL_DEPTH_COMPONENT32F = 0x8CAC;
42 int GL_DEPTH32F_STENCIL8 = 0x8CAD;
43
44 /**
45 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
46 * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and
47 * GetTexImage:
48 */
49 int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD;
50
51 }
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_depth_clamp {
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 = 0x864F;
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 package org.lwjgl.opengl;
32
33 public interface ARB_depth_texture {
34
35 /**
36 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D, TexImage2D,
37 * CopyTexImage1D and CopyTexImage2D:
38 */
39 int GL_DEPTH_COMPONENT16_ARB = 0x81A5;
40 int GL_DEPTH_COMPONENT24_ARB = 0x81A6;
41 int GL_DEPTH_COMPONENT32_ARB = 0x81A7;
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetTexLevelParameterfv and
45 * GetTexLevelParameteriv:
46 */
47 int GL_TEXTURE_DEPTH_SIZE_ARB = 0x884A;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of TexParameterf, TexParameteri,
51 * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv:
52 */
53 int GL_DEPTH_TEXTURE_MODE_ARB = 0x884B;
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_draw_buffers {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
41 * and GetDoublev:
42 */
43 int GL_MAX_DRAW_BUFFERS_ARB = 0x8824;
44 int GL_DRAW_BUFFER0_ARB = 0x8825;
45 int GL_DRAW_BUFFER1_ARB = 0x8826;
46 int GL_DRAW_BUFFER2_ARB = 0x8827;
47 int GL_DRAW_BUFFER3_ARB = 0x8828;
48 int GL_DRAW_BUFFER4_ARB = 0x8829;
49 int GL_DRAW_BUFFER5_ARB = 0x882A;
50 int GL_DRAW_BUFFER6_ARB = 0x882B;
51 int GL_DRAW_BUFFER7_ARB = 0x882C;
52 int GL_DRAW_BUFFER8_ARB = 0x882D;
53 int GL_DRAW_BUFFER9_ARB = 0x882E;
54 int GL_DRAW_BUFFER10_ARB = 0x882F;
55 int GL_DRAW_BUFFER11_ARB = 0x8830;
56 int GL_DRAW_BUFFER12_ARB = 0x8831;
57 int GL_DRAW_BUFFER13_ARB = 0x8832;
58 int GL_DRAW_BUFFER14_ARB = 0x8833;
59 int GL_DRAW_BUFFER15_ARB = 0x8834;
60
61 void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
62
63 @Alternate("glDrawBuffersARB")
64 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
65 }
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.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface ARB_draw_buffers_blend {
37
38 void glBlendEquationiARB(@GLuint int buf, @GLenum int mode);
39
40 void glBlendEquationSeparateiARB(@GLuint int buf, @GLenum int modeRGB, @GLenum int modeAlpha);
41
42 void glBlendFunciARB(@GLuint int buf, @GLenum int src, @GLenum int dst);
43
44 void glBlendFuncSeparateiARB(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha);
45
46 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36
37 public interface ARB_draw_elements_base_vertex {
38
39 void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
40 @BufferObject(BufferKind.ElementVBO)
41 @Const
42 @GLubyte
43 @GLushort
44 @GLuint Buffer indices, int basevertex);
45
46 void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
47 @BufferObject(BufferKind.ElementVBO)
48 @Const
49 @GLubyte
50 @GLushort
51 @GLuint Buffer indices, int basevertex);
52
53 void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
54 @BufferObject(BufferKind.ElementVBO)
55 @Const
56 @GLubyte
57 @GLushort
58 @GLuint Buffer indices, @GLsizei int primcount, int basevertex);
59
60 //void glMultiDrawElementsBaseVertex(@GLenum int mode, @GLsizei*count, @GLenum int type, void**indices, @GLsizei int primcount, int*basevertex)
61
62 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 import com.sun.mirror.type.PrimitiveType;
38
39 public interface ARB_draw_indirect {
40
41 /**
42 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
43 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
44 * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange,
45 * GetBufferParameteriv, BindBufferRange, BindBufferBase, and
46 * CopyBufferSubData:
47 */
48 int GL_DRAW_INDIRECT_BUFFER = 0x8F3F;
49
50 /**
51 * Accepted by the &lt;value&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
52 * and GetDoublev:
53 */
54 int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43;
55
56 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
57
58 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
59
60 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36
37 public interface ARB_draw_instanced {
38
39 void glDrawArraysInstancedARB(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount);
40
41 void glDrawElementsInstancedARB(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
42 @BufferObject(BufferKind.ElementVBO)
43 @Const
44 @GLubyte
45 @GLushort
46 @GLuint Buffer indices, @GLsizei int primcount);
47
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.opengl;
32
33 public interface ARB_explicit_attrib_location {
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_fragment_coord_conventions {
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_fragment_program extends ARB_program {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, by the
37 * &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev,
38 * and by the &lt;target&gt; parameter of ProgramStringARB, BindProgramARB,
39 * ProgramEnvParameter4[df][v]ARB, ProgramLocalParameter4[df][v]ARB,
40 * GetProgramEnvParameter[df]vARB, GetProgramLocalParameter[df]vARB,
41 * GetProgramivARB and GetProgramStringARB.
42 */
43 int GL_FRAGMENT_PROGRAM_ARB = 0x8804;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetProgramivARB:
47 */
48 int GL_PROGRAM_ALU_INSTRUCTIONS_ARB = 0x8805;
49 int GL_PROGRAM_TEX_INSTRUCTIONS_ARB = 0x8806;
50 int GL_PROGRAM_TEX_INDIRECTIONS_ARB = 0x8807;
51 int GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = 0x8808;
52 int GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = 0x8809;
53 int GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = 0x880A;
54 int GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB = 0x880B;
55 int GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB = 0x880C;
56 int GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB = 0x880D;
57 int GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = 0x880E;
58 int GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = 0x880F;
59 int GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = 0x8810;
60
61 /**
62 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
63 * and GetDoublev:
64 */
65 int GL_MAX_TEXTURE_COORDS_ARB = 0x8871;
66 int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872;
67 }
68
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_fragment_program_shadow {
34
35 }
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_fragment_shader {
34
35 /**
36 * Accepted by the &lt;shaderType&gt; argument of CreateShaderObjectARB and
37 * returned by the &lt;params&gt; parameter of GetObjectParameter{fi}vARB:
38 */
39 int GL_FRAGMENT_SHADER_ARB = 0x8B30;
40
41 /**
42 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
43 * GetFloatv, and GetDoublev:
44 */
45 int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB = 0x8B49;
46 int GL_MAX_TEXTURE_COORDS_ARB = 0x8871;
47 int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872;
48
49 /**
50 * Accepted by the &lt;target&gt; parameter of Hint and the &lt;pname&gt; parameter of
51 * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
52 */
53 int GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB = 0x8B8B;
54 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 @Extension(postfix = "")
38 public interface ARB_framebuffer_object {
39
40 /**
41 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
42 * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D},
43 * FramebufferRenderbuffer, and
44 * GetFramebufferAttachmentParameteriv:
45 */
46 int GL_FRAMEBUFFER = 0x8D40;
47 int GL_READ_FRAMEBUFFER = 0x8CA8;
48 int GL_DRAW_FRAMEBUFFER = 0x8CA9;
49
50 /**
51 * Accepted by the &lt;target&gt; parameter of BindRenderbuffer,
52 * RenderbufferStorage, and GetRenderbufferParameteriv, and
53 * returned by GetFramebufferAttachmentParameteriv:
54 */
55 int GL_RENDERBUFFER = 0x8D41;
56
57 /**
58 * Accepted by the &lt;internalformat&gt; parameter of
59 * RenderbufferStorage:
60 */
61 int GL_STENCIL_INDEX1 = 0x8D46;
62 int GL_STENCIL_INDEX4 = 0x8D47;
63 int GL_STENCIL_INDEX8 = 0x8D48;
64 int GL_STENCIL_INDEX16 = 0x8D49;
65
66 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
67 int GL_RENDERBUFFER_WIDTH = 0x8D42;
68 int GL_RENDERBUFFER_HEIGHT = 0x8D43;
69 int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
70 int GL_RENDERBUFFER_RED_SIZE = 0x8D50;
71 int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51;
72 int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52;
73 int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53;
74 int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54;
75 int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55;
76 int GL_RENDERBUFFER_SAMPLES = 0x8CAB;
77
78 /**
79 * Accepted by the &lt;pname&gt; parameter of
80 * GetFramebufferAttachmentParameteriv:
81 */
82 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
83 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
84 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
85 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
86 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4;
87 int GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210;
88 int GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211;
89 int GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212;
90 int GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213;
91 int GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214;
92 int GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215;
93 int GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216;
94 int GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217;
95
96 /** Returned in &lt;params&gt; by GetFramebufferAttachmentParameteriv: */
97 int GL_SRGB = 0x8C40;
98 int GL_UNSIGNED_NORMALIZED = 0x8C17;
99 int GL_FRAMEBUFFER_DEFAULT = 0x8218;
100 int GL_INDEX = 0x8222;
101
102 /**
103 * Accepted by the &lt;attachment&gt; parameter of
104 * FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and
105 * GetFramebufferAttachmentParameteriv
106 */
107 int GL_COLOR_ATTACHMENT0 = 0x8CE0;
108 int GL_COLOR_ATTACHMENT1 = 0x8CE1;
109 int GL_COLOR_ATTACHMENT2 = 0x8CE2;
110 int GL_COLOR_ATTACHMENT3 = 0x8CE3;
111 int GL_COLOR_ATTACHMENT4 = 0x8CE4;
112 int GL_COLOR_ATTACHMENT5 = 0x8CE5;
113 int GL_COLOR_ATTACHMENT6 = 0x8CE6;
114 int GL_COLOR_ATTACHMENT7 = 0x8CE7;
115 int GL_COLOR_ATTACHMENT8 = 0x8CE8;
116 int GL_COLOR_ATTACHMENT9 = 0x8CE9;
117 int GL_COLOR_ATTACHMENT10 = 0x8CEA;
118 int GL_COLOR_ATTACHMENT11 = 0x8CEB;
119 int GL_COLOR_ATTACHMENT12 = 0x8CEC;
120 int GL_COLOR_ATTACHMENT13 = 0x8CED;
121 int GL_COLOR_ATTACHMENT14 = 0x8CEE;
122 int GL_COLOR_ATTACHMENT15 = 0x8CEF;
123 int GL_DEPTH_ATTACHMENT = 0x8D00;
124 int GL_STENCIL_ATTACHMENT = 0x8D20;
125 int GL_DEPTH_STENCIL_ATTACHMENT = 0x821A;
126
127 /**
128 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
129 * GetFloatv, and GetDoublev:
130 */
131 int GL_MAX_SAMPLES = 0x8D57;
132
133 /** Returned by CheckFramebufferStatus(): */
134 int GL_FRAMEBUFFER_COMPLETE = 0x8CD5;
135 int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
136 int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
137 int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB;
138 int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC;
139 int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
140 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56;
141 int GL_FRAMEBUFFER_UNDEFINED = 0x8219;
142
143 /**
144 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
145 * and GetDoublev:
146 */
147 int GL_FRAMEBUFFER_BINDING = 0x8CA6; // alias DRAW_FRAMEBUFFER_BINDING
148 int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6;
149 int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA;
150 int GL_RENDERBUFFER_BINDING = 0x8CA7;
151 int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF;
152 int GL_MAX_RENDERBUFFER_SIZE = 0x84E8;
153
154 /** Returned by GetError(): */
155 int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506;
156
157 /**
158 * Accepted by the &lt;format&gt; parameter of DrawPixels, ReadPixels,
159 * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
160 * TexSubImage3D, and GetTexImage, by the &lt;type&gt; parameter of
161 * CopyPixels, by the &lt;internalformat&gt; parameter of TexImage1D,
162 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
163 * RenderbufferStorage, and returned in the &lt;data&gt; parameter of
164 * GetTexLevelParameter and GetRenderbufferParameteriv:
165 */
166 int GL_DEPTH_STENCIL = 0x84F9;
167
168 /**
169 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
170 * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
171 * TexSubImage3D, and GetTexImage:
172 */
173 int GL_UNSIGNED_INT_24_8 = 0x84FA;
174
175 /**
176 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
177 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
178 * RenderbufferStorage, and returned in the &lt;data&gt; parameter of
179 * GetTexLevelParameter and GetRenderbufferParameteriv:
180 */
181 int GL_DEPTH24_STENCIL8 = 0x88F0;
182
183 /** Accepted by the &lt;value&gt; parameter of GetTexLevelParameter: */
184 int GL_TEXTURE_STENCIL_SIZE = 0x88F1;
185
186 boolean glIsRenderbuffer(@GLuint int renderbuffer);
187
188 void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer);
189
190 void glDeleteRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @Const @GLuint IntBuffer renderbuffers);
191
192 @Alternate("glDeleteRenderbuffers")
193 void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
194
195 void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
196
197 @Alternate("glGenRenderbuffers")
198 @GLreturn("renderbuffers")
199 void glGenRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
200
201 void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat,
202 @GLsizei int width, @GLsizei int height);
203
204 void glRenderbufferStorageMultisample(@GLenum int target, @GLsizei int samples,
205 @GLenum int internalformat,
206 @GLsizei int width, @GLsizei int height);
207
208 @StripPostfix("params")
209 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
210
211 @Alternate("glGetRenderbufferParameteriv")
212 @GLreturn("params")
213 @StripPostfix("params")
214 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
215
216 boolean glIsFramebuffer(@GLuint int framebuffer);
217
218 void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer);
219
220 void glDeleteFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @Const @GLuint IntBuffer framebuffers);
221
222 @Alternate("glDeleteFramebuffers")
223 void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
224
225 void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
226
227 @Alternate("glGenFramebuffers")
228 @GLreturn("framebuffers")
229 void glGenFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
230
231 @GLenum
232 int glCheckFramebufferStatus(@GLenum int target);
233
234 void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment,
235 @GLenum int textarget, @GLuint int texture, int level);
236
237 void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment,
238 @GLenum int textarget, @GLuint int texture, int level);
239
240 void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment,
241 @GLenum int textarget, @GLuint int texture,
242 int level, int layer);
243
244 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment,
245 @GLuint int texture, int level, int layer);
246
247 void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment,
248 @GLenum int renderbuffertarget, @GLuint int renderbuffer);
249
250 @StripPostfix("params")
251 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment,
252 @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
253
254 @Alternate("glGetFramebufferAttachmentParameteriv")
255 @GLreturn("params")
256 @StripPostfix("params")
257 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment,
258 @GLenum int pname, @OutParameter IntBuffer params);
259
260 void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
261 int dstX0, int dstY0, int dstX1, int dstY1,
262 @GLbitfield int mask, @GLenum int filter);
263
264 void glGenerateMipmap(@GLenum int target);
265
266 }
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_framebuffer_sRGB {
34
35 /**
36 * Accepted by the &lt;attribList&gt; parameter of glXChooseVisual, and by
37 * the &lt;attrib&gt; parameter of glXGetConfig:
38 */
39 int GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20B2;
40
41 /**
42 * Accepted by the &lt;piAttributes&gt; parameter of
43 * wglGetPixelFormatAttribivEXT, wglGetPixelFormatAttribfvEXT, and
44 * the &lt;piAttribIList&gt; and &lt;pfAttribIList&gt; of wglChoosePixelFormatEXT:
45 */
46 int WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20A9;
47
48 /**
49 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
50 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
51 * and GetDoublev:
52 */
53 int GL_FRAMEBUFFER_SRGB_ARB = 0x8DB9;
54
55 /**
56 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
57 * GetFloatv, and GetDoublev:
58 */
59 int GL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x8DBA;
60
61 }
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.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface ARB_geometry_shader4 {
37
38 /**
39 * Accepted by the &lt;type&gt; parameter of CreateShader and returned by the
40 * &lt;params&gt; parameter of GetShaderiv:
41 */
42 int GL_GEOMETRY_SHADER_ARB = 0x8DD9;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of ProgramParameteriEXT and
46 * GetProgramiv:
47 */
48 int GL_GEOMETRY_VERTICES_OUT_ARB = 0x8DDA;
49 int GL_GEOMETRY_INPUT_TYPE_ARB = 0x8DDB;
50 int GL_GEOMETRY_OUTPUT_TYPE_ARB = 0x8DDC;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
54 * GetFloatv, and GetDoublev:
55 */
56 int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB = 0x8C29;
57 int GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB = 0x8DDD;
58 int GL_MAX_VERTEX_VARYING_COMPONENTS_ARB = 0x8DDE;
59 int GL_MAX_VARYING_COMPONENTS_ARB = 0x8B4B;
60 int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB = 0x8DDF;
61 int GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB = 0x8DE0;
62 int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB = 0x8DE1;
63
64 /**
65 * Accepted by the &lt;mode&gt; parameter of Begin, DrawArrays,
66 * MultiDrawArrays, DrawElements, MultiDrawElements, and
67 * DrawRangeElements:
68 */
69 int GL_LINES_ADJACENCY_ARB = 0xA;
70 int GL_LINE_STRIP_ADJACENCY_ARB = 0xB;
71 int GL_TRIANGLES_ADJACENCY_ARB = 0xC;
72 int GL_TRIANGLE_STRIP_ADJACENCY_ARB = 0xD;
73
74 /** Returned by CheckFramebufferStatusEXT: */
75 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB = 0x8DA8;
76 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB = 0x8DA9;
77
78 /**
79 * Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachment-
80 * ParameterivEXT:
81 */
82 int GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB = 0x8DA7;
83 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_ARB = 0x8CD4;
84
85 /**
86 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
87 * and by the &lt;pname&gt; parameter of GetIntegerv, GetFloatv, GetDoublev,
88 * and GetBooleanv:
89 */
90 int GL_PROGRAM_POINT_SIZE_ARB = 0x8642;
91
92 void glProgramParameteriARB(@GLuint int program, @GLenum int pname, int value);
93
94 void glFramebufferTextureARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
95
96 void glFramebufferTextureLayerARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
97
98 void glFramebufferTextureFaceARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
99
100 }
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_gpu_shader5 {
34
35 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
36 int GL_GEOMETRY_SHADER_INVOCATIONS = 0x887F;
37
38 /**
39 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
40 * GetDoublev, and GetInteger64v:
41 */
42 int GL_MAX_GEOMETRY_SHADER_INVOCATIONS = 0x8E5A;
43 int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5B;
44 int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5C;
45 int GL_FRAGMENT_INTERPOLATION_OFFSET_BITS = 0x8E5D;
46 int GL_MAX_VERTEX_STREAMS = 0x8E71;
47
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 @Dependent
38 @Extension(postfix = "")
39 public interface ARB_gpu_shader_fp64 {
40
41 /**
42 * Returned in the &lt;type&gt; parameter of GetActiveUniform, and
43 * GetTransformFeedbackVarying:
44 */
45 int GL_DOUBLE = GL11.GL_DOUBLE;
46 int GL_DOUBLE_VEC2 = 0x8FFC;
47 int GL_DOUBLE_VEC3 = 0x8FFD;
48 int GL_DOUBLE_VEC4 = 0x8FFE;
49 int GL_DOUBLE_MAT2 = 0x8F46;
50 int GL_DOUBLE_MAT3 = 0x8F47;
51 int GL_DOUBLE_MAT4 = 0x8F48;
52 int GL_DOUBLE_MAT2x3 = 0x8F49;
53 int GL_DOUBLE_MAT2x4 = 0x8F4A;
54 int GL_DOUBLE_MAT3x2 = 0x8F4B;
55 int GL_DOUBLE_MAT3x4 = 0x8F4C;
56 int GL_DOUBLE_MAT4x2 = 0x8F4D;
57 int GL_DOUBLE_MAT4x3 = 0x8F4E;
58
59 void glUniform1d(int location, double x);
60
61 void glUniform2d(int location, double x, double y);
62
63 void glUniform3d(int location, double x, double y, double z);
64
65 void glUniform4d(int location, double x, double y, double z, double w);
66
67 @StripPostfix("value")
68 void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value);
69
70 @StripPostfix("value")
71 void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
72
73 @StripPostfix("value")
74 void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
75
76 @StripPostfix("value")
77 void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
78
79 @StripPostfix("value")
80 void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
81
82 @StripPostfix("value")
83 void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
84
85 @StripPostfix("value")
86 void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
87
88 @StripPostfix("value")
89 void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
90
91 @StripPostfix("value")
92 void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
93
94 @StripPostfix("value")
95 void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
96
97 @StripPostfix("value")
98 void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
99
100 @StripPostfix("value")
101 void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
102
103 @StripPostfix("value")
104 void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
105
106 @StripPostfix("params")
107 void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params);
108
109 // ----
110
111 @Dependent("GL_EXT_direct_state_access")
112 void glProgramUniform1dEXT(@GLuint int program, int location, double x);
113
114 @Dependent("GL_EXT_direct_state_access")
115 void glProgramUniform2dEXT(@GLuint int program, int location, double x, double y);
116
117 @Dependent("GL_EXT_direct_state_access")
118 void glProgramUniform3dEXT(@GLuint int program, int location, double x, double y, double z);
119
120 @Dependent("GL_EXT_direct_state_access")
121 void glProgramUniform4dEXT(@GLuint int program, int location, double x, double y, double z, double w);
122
123 @Dependent("GL_EXT_direct_state_access")
124 @StripPostfix(value="value", extension="EXT")
125 void glProgramUniform1dvEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const DoubleBuffer value);
126
127 @Dependent("GL_EXT_direct_state_access")
128 @StripPostfix(value = "value", extension = "EXT")
129 void glProgramUniform2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
130
131 @Dependent("GL_EXT_direct_state_access")
132 @StripPostfix(value = "value", extension = "EXT")
133 void glProgramUniform3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
134
135 @Dependent("GL_EXT_direct_state_access")
136 @StripPostfix(value = "value", extension = "EXT")
137 void glProgramUniform4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
138
139 @Dependent("GL_EXT_direct_state_access")
140 @StripPostfix(value = "value", extension = "EXT")
141 void glProgramUniformMatrix2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
142
143 @Dependent("GL_EXT_direct_state_access")
144 @StripPostfix(value = "value", extension = "EXT")
145 void glProgramUniformMatrix3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
146
147 @Dependent("GL_EXT_direct_state_access")
148 @StripPostfix(value = "value", extension = "EXT")
149 void glProgramUniformMatrix4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
150
151 @Dependent("GL_EXT_direct_state_access")
152 @StripPostfix(value = "value", extension = "EXT")
153 void glProgramUniformMatrix2x3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
154
155 @Dependent("GL_EXT_direct_state_access")
156 @StripPostfix(value = "value", extension = "EXT")
157 void glProgramUniformMatrix2x4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
158
159 @Dependent("GL_EXT_direct_state_access")
160 @StripPostfix(value = "value", extension = "EXT")
161 void glProgramUniformMatrix3x2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
162
163 @Dependent("GL_EXT_direct_state_access")
164 @StripPostfix(value = "value", extension = "EXT")
165 void glProgramUniformMatrix3x4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
166
167 @Dependent("GL_EXT_direct_state_access")
168 @StripPostfix(value = "value", extension = "EXT")
169 void glProgramUniformMatrix4x2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
170
171 @Dependent("GL_EXT_direct_state_access")
172 @StripPostfix(value = "value", extension = "EXT")
173 void glProgramUniformMatrix4x3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
174
175 }
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_half_float_pixel {
34
35 /**
36 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
37 * TexImage1D, TexImage2D, TexImage3D, GetTexImage, TexSubImage1D,
38 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
39 * ConvolutionFilter1D, ConvolutionFilter2D, GetConvolutionFilter,
40 * SeparableFilter2D, GetSeparableFilter, ColorTable, ColorSubTable,
41 * and GetColorTable:
42 */
43 int GL_HALF_FLOAT_ARB = 0x140B;
44 }
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_half_float_vertex {
34
35 /**
36 * Accepted by the &lt;type&gt; argument of VertexPointer, NormalPointer,
37 * ColorPointer, SecondaryColorPointer, FogCoordPointer, TexCoordPointer,
38 * and VertexAttribPointer:
39 */
40 int GL_HALF_FLOAT = 0x140B;
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 /**
38 * <p/>
39 * The GL12 imaging subset extension.
40 *
41 * @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 $
44 */
45
46 @Extension(postfix = "")
47 @DeprecatedGL
48 public interface ARB_imaging {
49
50 int GL_CONSTANT_COLOR = 0x8001;
51 int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
52 int GL_CONSTANT_ALPHA = 0x8003;
53 int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;
54 int GL_BLEND_COLOR = 0x8005;
55 int GL_FUNC_ADD = 0x8006;
56 int GL_MIN = 0x8007;
57 int GL_MAX = 0x8008;
58 int GL_BLEND_EQUATION = 0x8009;
59 int GL_FUNC_SUBTRACT = 0x800A;
60 int GL_FUNC_REVERSE_SUBTRACT = 0x800B;
61 int GL_COLOR_MATRIX = 0x80B1;
62 int GL_COLOR_MATRIX_STACK_DEPTH = 0x80B2;
63 int GL_MAX_COLOR_MATRIX_STACK_DEPTH = 0x80B3;
64 int GL_POST_COLOR_MATRIX_RED_SCALE = 0x80B4;
65 int GL_POST_COLOR_MATRIX_GREEN_SCALE = 0x80B5;
66 int GL_POST_COLOR_MATRIX_BLUE_SCALE = 0x80B6;
67 int GL_POST_COLOR_MATRIX_ALPHA_SCALE = 0x80B7;
68 int GL_POST_COLOR_MATRIX_RED_BIAS = 0x80B8;
69 int GL_POST_COLOR_MATRIX_GREEN_BIAS = 0x80B9;
70 int GL_POST_COLOR_MATRIX_BLUE_BIAS = 0x80BA;
71 int GL_POST_COLOR_MATRIX_ALPHA_BIAS = 0x80BB;
72 int GL_COLOR_TABLE = 0x80D0;
73 int GL_POST_CONVOLUTION_COLOR_TABLE = 0x80D1;
74 int GL_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D2;
75 int GL_PROXY_COLOR_TABLE = 0x80D3;
76 int GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = 0x80D4;
77 int GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D5;
78 int GL_COLOR_TABLE_SCALE = 0x80D6;
79 int GL_COLOR_TABLE_BIAS = 0x80D7;
80 int GL_COLOR_TABLE_FORMAT = 0x80D8;
81 int GL_COLOR_TABLE_WIDTH = 0x80D9;
82 int GL_COLOR_TABLE_RED_SIZE = 0x80DA;
83 int GL_COLOR_TABLE_GREEN_SIZE = 0x80DB;
84 int GL_COLOR_TABLE_BLUE_SIZE = 0x80DC;
85 int GL_COLOR_TABLE_ALPHA_SIZE = 0x80DD;
86 int GL_COLOR_TABLE_LUMINANCE_SIZE = 0x80DE;
87 int GL_COLOR_TABLE_INTENSITY_SIZE = 0x80DF;
88 int GL_CONVOLUTION_1D = 0x8010;
89 int GL_CONVOLUTION_2D = 0x8011;
90 int GL_SEPARABLE_2D = 0x8012;
91 int GL_CONVOLUTION_BORDER_MODE = 0x8013;
92 int GL_CONVOLUTION_FILTER_SCALE = 0x8014;
93 int GL_CONVOLUTION_FILTER_BIAS = 0x8015;
94 int GL_REDUCE = 0x8016;
95 int GL_CONVOLUTION_FORMAT = 0x8017;
96 int GL_CONVOLUTION_WIDTH = 0x8018;
97 int GL_CONVOLUTION_HEIGHT = 0x8019;
98 int GL_MAX_CONVOLUTION_WIDTH = 0x801A;
99 int GL_MAX_CONVOLUTION_HEIGHT = 0x801B;
100 int GL_POST_CONVOLUTION_RED_SCALE = 0x801C;
101 int GL_POST_CONVOLUTION_GREEN_SCALE = 0x801D;
102 int GL_POST_CONVOLUTION_BLUE_SCALE = 0x801E;
103 int GL_POST_CONVOLUTION_ALPHA_SCALE = 0x801F;
104 int GL_POST_CONVOLUTION_RED_BIAS = 0x8020;
105 int GL_POST_CONVOLUTION_GREEN_BIAS = 0x8021;
106 int GL_POST_CONVOLUTION_BLUE_BIAS = 0x8022;
107 int GL_POST_CONVOLUTION_ALPHA_BIAS = 0x8023;
108 int GL_IGNORE_BORDER = 0x8150;
109 int GL_CONSTANT_BORDER = 0x8151;
110 int GL_REPLICATE_BORDER = 0x8153;
111 int GL_CONVOLUTION_BORDER_COLOR = 0x8154;
112 int GL_HISTOGRAM = 0x8024;
113 int GL_PROXY_HISTOGRAM = 0x8025;
114 int GL_HISTOGRAM_WIDTH = 0x8026;
115 int GL_HISTOGRAM_FORMAT = 0x8027;
116 int GL_HISTOGRAM_RED_SIZE = 0x8028;
117 int GL_HISTOGRAM_GREEN_SIZE = 0x8029;
118 int GL_HISTOGRAM_BLUE_SIZE = 0x802A;
119 int GL_HISTOGRAM_ALPHA_SIZE = 0x802B;
120 int GL_HISTOGRAM_LUMINANCE_SIZE = 0x802C;
121 int GL_HISTOGRAM_SINK = 0x802D;
122 int GL_MINMAX = 0x802E;
123 int GL_MINMAX_FORMAT = 0x802F;
124 int GL_MINMAX_SINK = 0x8030;
125 int GL_TABLE_TOO_LARGE = 0x8031;
126
127 @DeprecatedGL
128 void glColorTable(@GLenum int target, @GLenum int internalFormat, @GLsizei int width, @GLenum int format, @GLenum int type,
129 @BufferObject(BufferKind.UnpackPBO)
130 @Check("256")
131 @Const
132 @GLbyte
133 @GLfloat
134 @GLdouble Buffer data);
135
136 @DeprecatedGL
137 void glColorSubTable(@GLenum int target, @GLsizei int start, @GLsizei int count, @GLenum int format, @GLenum int type,
138 @BufferObject(BufferKind.UnpackPBO)
139 @Check("256")
140 @Const
141 @GLbyte
142 @GLfloat
143 @GLdouble Buffer data);
144
145 @StripPostfix("params")
146 @DeprecatedGL
147 void glColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
148
149 @StripPostfix("params")
150 @DeprecatedGL
151 void glColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params);
152
153 @DeprecatedGL
154 void glCopyColorSubTable(@GLenum int target, @GLsizei int start, int x, int y, @GLsizei int width);
155
156 @DeprecatedGL
157 void glCopyColorTable(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width);
158
159 @DeprecatedGL
160 void glGetColorTable(@GLenum int target, @GLenum int format, @GLenum int type,
161 @OutParameter
162 @Check("256")
163 @GLbyte
164 @GLfloat
165 @GLdouble Buffer data);
166
167 @StripPostfix("params")
168 @DeprecatedGL
169 void glGetColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params);
170
171 @StripPostfix("params")
172 @DeprecatedGL
173 void glGetColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params);
174
175 void glBlendEquation(@GLenum int mode);
176
177 void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
178
179 @DeprecatedGL
180 void glHistogram(@GLenum int target, @GLsizei int width, @GLenum int internalformat, boolean sink);
181
182 @DeprecatedGL
183 void glResetHistogram(@GLenum int target);
184
185 @DeprecatedGL
186 void glGetHistogram(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type,
187 @OutParameter
188 @BufferObject(BufferKind.PackPBO)
189 @Check("256")
190 @GLbyte
191 @GLshort
192 @GLint
193 @GLfloat
194 @GLdouble Buffer values);
195
196 @StripPostfix("params")
197 @DeprecatedGL
198 void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") FloatBuffer params);
199
200 @StripPostfix("params")
201 @DeprecatedGL
202 void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") IntBuffer params);
203
204 @DeprecatedGL
205 void glMinmax(@GLenum int target, @GLenum int internalformat, boolean sink);
206
207 @DeprecatedGL
208 void glResetMinmax(@GLenum int target);
209
210 @DeprecatedGL
211 void glGetMinmax(@GLenum int target, boolean reset, @GLenum int format, @GLenum int types,
212 @OutParameter
213 @BufferObject(BufferKind.PackPBO)
214 @Check("4")
215 @GLbyte
216 @GLshort
217 @GLint
218 @GLfloat
219 @GLdouble Buffer values);
220
221 @StripPostfix("params")
222 @DeprecatedGL
223 void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
224
225 @StripPostfix("params")
226 @DeprecatedGL
227 void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
228
229 @DeprecatedGL
230 void glConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLenum int format, @GLenum int type,
231 @BufferObject(BufferKind.UnpackPBO)
232 @Check("GLChecks.calculateImageStorage(image, format, type, width, 1, 1)")
233 @Const
234 @GLbyte
235 @GLshort
236 @GLint
237 @GLfloat
238 @GLdouble Buffer image);
239
240 @DeprecatedGL
241 void glConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
242 @BufferObject(BufferKind.UnpackPBO)
243 @Check("GLChecks.calculateImageStorage(image, format, type, width, height, 1)")
244 @Const
245 @GLbyte
246 @GLshort
247 @GLint Buffer image);
248
249 @DeprecatedGL
250 void glConvolutionParameterf(@GLenum int target, @GLenum int pname, float params);
251
252 @StripPostfix("params")
253 @DeprecatedGL
254 void glConvolutionParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params);
255
256 @DeprecatedGL
257 void glConvolutionParameteri(@GLenum int target, @GLenum int pname, int params);
258
259 @StripPostfix("params")
260 @DeprecatedGL
261 void glConvolutionParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
262
263 @DeprecatedGL
264 void glCopyConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width);
265
266 @DeprecatedGL
267 void glCopyConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height);
268
269 // TODO: check buffer size valid
270 @DeprecatedGL
271 void glGetConvolutionFilter(@GLenum int target, @GLenum int format, @GLenum int type,
272 @OutParameter
273 @BufferObject(BufferKind.PackPBO)
274 @Check
275 @GLbyte
276 @GLshort
277 @GLint
278 @GLfloat
279 @GLdouble Buffer image);
280
281 @StripPostfix("params")
282 @DeprecatedGL
283 void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
284
285 @StripPostfix("params")
286 @DeprecatedGL
287 void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
288
289 // TODO: check buffer size valid
290 @DeprecatedGL
291 void glSeparableFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
292 @BufferObject(BufferKind.UnpackPBO)
293 @Check
294 @Const
295 @GLbyte
296 @GLshort
297 @GLint
298 @GLfloat
299 @GLdouble Buffer row,
300 @BufferObject(BufferKind.UnpackPBO)
301 @Check
302 @Const
303 @GLbyte
304 @GLshort
305 @GLint
306 @GLfloat
307 @GLdouble Buffer column);
308
309 // TODO: check buffer size valid
310 @DeprecatedGL
311 void glGetSeparableFilter(@GLenum int target, @GLenum int format, @GLenum int type,
312 @OutParameter
313 @BufferObject(BufferKind.PackPBO)
314 @Check
315 @GLbyte
316 @GLshort
317 @GLint
318 @GLfloat
319 @GLdouble Buffer row,
320 @BufferObject(BufferKind.PackPBO)
321 @Check
322 @GLbyte
323 @GLshort
324 @GLint
325 @GLdouble Buffer column,
326 @BufferObject(BufferKind.PackPBO)
327 @Check
328 @GLbyte
329 @GLshort
330 @GLint
331 @GLdouble Buffer span);
332 }
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.GLuint;
34
35 public interface ARB_instanced_arrays {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameters of GetVertexAttribdv,
39 * GetVertexAttribfv, and GetVertexAttribiv:
40 */
41 int GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB = 0x88FE;
42
43 void glVertexAttribDivisorARB(@GLuint int index, @GLuint int divisor);
44
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36
37 public interface ARB_map_buffer_range {
38
39 /** Accepted by the &lt;access&gt; parameter of MapBufferRange: */
40 int GL_MAP_READ_BIT = 0x0001;
41 int GL_MAP_WRITE_BIT = 0x0002;
42 int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004;
43 int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008;
44 int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010;
45 int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020;
46
47 /**
48 * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null,
49 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
50 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
51 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this:
52 * <p/>
53 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer);
54 * <p/>
55 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
56 *
57 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
58 *
59 * @return A ByteBuffer representing the mapped buffer memory.
60 */
61 @CachedResult(isRange = true)
62 @GLvoid
63 @AutoResultSize("length")
64 ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
65
66 void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
67
68 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_matrix_palette {
38
39 int GL_MATRIX_PALETTE_ARB = 0x8840;
40 int GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB = 0x8841;
41 int GL_MAX_PALETTE_MATRICES_ARB = 0x8842;
42 int GL_CURRENT_PALETTE_MATRIX_ARB = 0x8843;
43 int GL_MATRIX_INDEX_ARRAY_ARB = 0x8844;
44 int GL_CURRENT_MATRIX_INDEX_ARB = 0x8845;
45 int GL_MATRIX_INDEX_ARRAY_SIZE_ARB = 0x8846;
46 int GL_MATRIX_INDEX_ARRAY_TYPE_ARB = 0x8847;
47 int GL_MATRIX_INDEX_ARRAY_STRIDE_ARB = 0x8848;
48 int GL_MATRIX_INDEX_ARRAY_POINTER_ARB = 0x8849;
49
50 void glCurrentPaletteMatrixARB(int index);
51
52 void glMatrixIndexPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
53 @CachedReference
54 @BufferObject(BufferKind.ArrayVBO)
55 @Check
56 @Const
57 @GLubyte
58 @GLushort
59 @GLuint Buffer pPointer);
60
61 @StripPostfix("pIndices")
62 void glMatrixIndexubvARB(@AutoSize("pIndices") int size, @GLubyte ByteBuffer pIndices);
63
64 @StripPostfix("pIndices")
65 void glMatrixIndexusvARB(@AutoSize("pIndices") int size, @GLushort ShortBuffer pIndices);
66
67 @StripPostfix("pIndices")
68 void glMatrixIndexuivARB(@AutoSize("pIndices") int size, @GLuint IntBuffer pIndices);
69 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface ARB_multisample {
36
37 int GL_MULTISAMPLE_ARB = 0x809D;
38 int GL_SAMPLE_ALPHA_TO_COVERAGE_ARB = 0x809E;
39 int GL_SAMPLE_ALPHA_TO_ONE_ARB = 0x809F;
40 int GL_SAMPLE_COVERAGE_ARB = 0x80A0;
41 int GL_SAMPLE_BUFFERS_ARB = 0x80A8;
42 int GL_SAMPLES_ARB = 0x80A9;
43 int GL_SAMPLE_COVERAGE_VALUE_ARB = 0x80AA;
44 int GL_SAMPLE_COVERAGE_INVERT_ARB = 0x80AB;
45 int GL_MULTISAMPLE_BIT_ARB = 0x20000000;
46
47 void glSampleCoverageARB(@GLclampf float value, boolean invert);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface ARB_multitexture {
36
37 int GL_TEXTURE0_ARB = 0x84C0;
38 int GL_TEXTURE1_ARB = 0x84C1;
39 int GL_TEXTURE2_ARB = 0x84C2;
40 int GL_TEXTURE3_ARB = 0x84C3;
41 int GL_TEXTURE4_ARB = 0x84C4;
42 int GL_TEXTURE5_ARB = 0x84C5;
43 int GL_TEXTURE6_ARB = 0x84C6;
44 int GL_TEXTURE7_ARB = 0x84C7;
45 int GL_TEXTURE8_ARB = 0x84C8;
46 int GL_TEXTURE9_ARB = 0x84C9;
47 int GL_TEXTURE10_ARB = 0x84CA;
48 int GL_TEXTURE11_ARB = 0x84CB;
49 int GL_TEXTURE12_ARB = 0x84CC;
50 int GL_TEXTURE13_ARB = 0x84CD;
51 int GL_TEXTURE14_ARB = 0x84CE;
52 int GL_TEXTURE15_ARB = 0x84CF;
53 int GL_TEXTURE16_ARB = 0x84D0;
54 int GL_TEXTURE17_ARB = 0x84D1;
55 int GL_TEXTURE18_ARB = 0x84D2;
56 int GL_TEXTURE19_ARB = 0x84D3;
57 int GL_TEXTURE20_ARB = 0x84D4;
58 int GL_TEXTURE21_ARB = 0x84D5;
59 int GL_TEXTURE22_ARB = 0x84D6;
60 int GL_TEXTURE23_ARB = 0x84D7;
61 int GL_TEXTURE24_ARB = 0x84D8;
62 int GL_TEXTURE25_ARB = 0x84D9;
63 int GL_TEXTURE26_ARB = 0x84DA;
64 int GL_TEXTURE27_ARB = 0x84DB;
65 int GL_TEXTURE28_ARB = 0x84DC;
66 int GL_TEXTURE29_ARB = 0x84DD;
67 int GL_TEXTURE30_ARB = 0x84DE;
68 int GL_TEXTURE31_ARB = 0x84DF;
69 int GL_ACTIVE_TEXTURE_ARB = 0x84E0;
70 int GL_CLIENT_ACTIVE_TEXTURE_ARB = 0x84E1;
71 int GL_MAX_TEXTURE_UNITS_ARB = 0x84E2;
72
73 void glClientActiveTextureARB(@GLenum int texture);
74
75 void glActiveTextureARB(@GLenum int texture);
76
77 @NoErrorCheck
78 void glMultiTexCoord1fARB(@GLenum int target, float s);
79
80 @NoErrorCheck
81 void glMultiTexCoord1dARB(@GLenum int target, double s);
82
83 @NoErrorCheck
84 void glMultiTexCoord1iARB(@GLenum int target, int s);
85
86 @NoErrorCheck
87 void glMultiTexCoord1sARB(@GLenum int target, short s);
88
89 @NoErrorCheck
90 void glMultiTexCoord2fARB(@GLenum int target, float s, float t);
91
92 @NoErrorCheck
93 void glMultiTexCoord2dARB(@GLenum int target, double s, double t);
94
95 @NoErrorCheck
96 void glMultiTexCoord2iARB(@GLenum int target, int s, int t);
97
98 @NoErrorCheck
99 void glMultiTexCoord2sARB(@GLenum int target, short s, short t);
100
101 @NoErrorCheck
102 void glMultiTexCoord3fARB(@GLenum int target, float s, float t, float r);
103
104 @NoErrorCheck
105 void glMultiTexCoord3dARB(@GLenum int target, double s, double t, double r);
106
107 @NoErrorCheck
108 void glMultiTexCoord3iARB(@GLenum int target, int s, int t, int r);
109
110 @NoErrorCheck
111 void glMultiTexCoord3sARB(@GLenum int target, short s, short t, short r);
112
113 @NoErrorCheck
114 void glMultiTexCoord4fARB(@GLenum int target, float s, float t, float r, float q);
115
116 @NoErrorCheck
117 void glMultiTexCoord4dARB(@GLenum int target, double s, double t, double r, double q);
118
119 @NoErrorCheck
120 void glMultiTexCoord4iARB(@GLenum int target, int s, int t, int r, int q);
121
122 @NoErrorCheck
123 void glMultiTexCoord4sARB(@GLenum int target, short s, short t, short r, short q);
124 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface ARB_occlusion_query {
38
39 /**
40 * Accepted by the &lt;target&gt; parameter of BeginQueryARB, EndQueryARB,
41 * and GetQueryivARB:
42 */
43 int GL_SAMPLES_PASSED_ARB = 0x8914;
44
45 /** Accepted by the &lt;pname&gt; parameter of GetQueryivARB: */
46 int GL_QUERY_COUNTER_BITS_ARB = 0x8864;
47 int GL_CURRENT_QUERY_ARB = 0x8865;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectivARB and
51 * GetQueryObjectuivARB:
52 */
53 int GL_QUERY_RESULT_ARB = 0x8866;
54 int GL_QUERY_RESULT_AVAILABLE_ARB = 0x8867;
55
56 void glGenQueriesARB(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
57
58 @Alternate("glGenQueriesARB")
59 @GLreturn("ids")
60 void glGenQueriesARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
61
62 void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
63
64 @Alternate("glDeleteQueriesARB")
65 void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
66
67 boolean glIsQueryARB(@GLuint int id);
68
69 void glBeginQueryARB(@GLenum int target, @GLuint int id);
70
71 void glEndQueryARB(@GLenum int target);
72
73 @StripPostfix("params")
74 void glGetQueryivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
75
76 @Alternate("glGetQueryivARB")
77 @GLreturn("params")
78 @StripPostfix("params")
79 void glGetQueryivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
80
81 @StripPostfix("params")
82 void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
83
84 @Alternate("glGetQueryObjectivARB")
85 @GLreturn("params")
86 @StripPostfix(value = "params", postfix = "v")
87 void glGetQueryObjectivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
88
89 @StripPostfix("params")
90 void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
91
92 @Alternate("glGetQueryObjectuivARB")
93 @GLreturn("params")
94 @StripPostfix(value = "params", postfix = "v")
95 void glGetQueryObjectuivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
96 }
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_occlusion_query2 {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
37 * and GetQueryiv:
38 */
39 int GL_ANY_SAMPLES_PASSED = 0x8C2F;
40
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.opengl;
32
33 public interface ARB_pixel_buffer_object extends ARB_buffer_object {
34
35 /**
36 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
37 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
38 * GetBufferParameteriv, and GetBufferPointerv:
39 */
40 int GL_PIXEL_PACK_BUFFER_ARB = 0x88EB;
41 int GL_PIXEL_UNPACK_BUFFER_ARB = 0x88EC;
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
45 * GetFloatv, and GetDoublev:
46 */
47 int GL_PIXEL_PACK_BUFFER_BINDING_ARB = 0x88ED;
48 int GL_PIXEL_UNPACK_BUFFER_BINDING_ARB = 0x88EF;
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_point_parameters {
38
39 int GL_POINT_SIZE_MIN_ARB = 0x8126;
40 int GL_POINT_SIZE_MAX_ARB = 0x8127;
41 int GL_POINT_FADE_THRESHOLD_SIZE_ARB = 0x8128;
42 int GL_POINT_DISTANCE_ATTENUATION_ARB = 0x8129;
43
44 void glPointParameterfARB(@GLenum int pname, float param);
45
46 @StripPostfix("pfParams")
47 void glPointParameterfvARB(@GLenum int pname, @Check("4") @Const FloatBuffer pfParams);
48
49 }
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_point_sprite {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, by
37 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
38 * GetDoublev, and by the &lt;target&gt; parameter of TexEnvi, TexEnviv,
39 * TexEnvf, TexEnvfv, GetTexEnviv, and GetTexEnvfv:
40 */
41 int GL_POINT_SPRITE_ARB = 0x8861;
42
43 /**
44 * When the &lt;target&gt; parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv,
45 * GetTexEnvfv, or GetTexEnviv is POINT_SPRITE_ARB, then the value of
46 * &lt;pname&gt; may be:
47 */
48 int GL_COORD_REPLACE_ARB = 0x8862;
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 @Extension(postfix = "ARB", isFinal = false)
38 public interface ARB_program {
39
40 /** Accepted by the &lt;format&gt; parameter of ProgramStringARB: */
41 int GL_PROGRAM_FORMAT_ASCII_ARB = 0x8875;
42
43 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
44 int GL_PROGRAM_LENGTH_ARB = 0x8627;
45 int GL_PROGRAM_FORMAT_ARB = 0x8876;
46 int GL_PROGRAM_BINDING_ARB = 0x8677;
47 int GL_PROGRAM_INSTRUCTIONS_ARB = 0x88A0;
48 int GL_MAX_PROGRAM_INSTRUCTIONS_ARB = 0x88A1;
49 int GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB = 0x88A2;
50 int GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB = 0x88A3;
51 int GL_PROGRAM_TEMPORARIES_ARB = 0x88A4;
52 int GL_MAX_PROGRAM_TEMPORARIES_ARB = 0x88A5;
53 int GL_PROGRAM_NATIVE_TEMPORARIES_ARB = 0x88A6;
54 int GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB = 0x88A7;
55 int GL_PROGRAM_PARAMETERS_ARB = 0x88A8;
56 int GL_MAX_PROGRAM_PARAMETERS_ARB = 0x88A9;
57 int GL_PROGRAM_NATIVE_PARAMETERS_ARB = 0x88AA;
58 int GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB = 0x88AB;
59 int GL_PROGRAM_ATTRIBS_ARB = 0x88AC;
60 int GL_MAX_PROGRAM_ATTRIBS_ARB = 0x88AD;
61 int GL_PROGRAM_NATIVE_ATTRIBS_ARB = 0x88AE;
62 int GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB = 0x88AF;
63 int GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB = 0x88B4;
64 int GL_MAX_PROGRAM_ENV_PARAMETERS_ARB = 0x88B5;
65 int GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB = 0x88B6;
66
67 /** Accepted by the &lt;pname&gt; parameter of GetProgramStringARB: */
68 int GL_PROGRAM_STRING_ARB = 0x8628;
69
70 /**
71 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
72 * GetFloatv, and GetDoublev:
73 */
74 int GL_PROGRAM_ERROR_POSITION_ARB = 0x864B;
75 int GL_CURRENT_MATRIX_ARB = 0x8641;
76 int GL_TRANSPOSE_CURRENT_MATRIX_ARB = 0x88B7;
77 int GL_CURRENT_MATRIX_STACK_DEPTH_ARB = 0x8640;
78 int GL_MAX_PROGRAM_MATRICES_ARB = 0x862F;
79 int GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB = 0x862E;
80
81 /** Accepted by the &lt;name&gt; parameter of GetString: */
82 int GL_PROGRAM_ERROR_STRING_ARB = 0x8874;
83
84 /** Accepted by the &lt;mode&gt; parameter of MatrixMode: */
85 int GL_MATRIX0_ARB = 0x88C0;
86 int GL_MATRIX1_ARB = 0x88C1;
87 int GL_MATRIX2_ARB = 0x88C2;
88 int GL_MATRIX3_ARB = 0x88C3;
89 int GL_MATRIX4_ARB = 0x88C4;
90 int GL_MATRIX5_ARB = 0x88C5;
91 int GL_MATRIX6_ARB = 0x88C6;
92 int GL_MATRIX7_ARB = 0x88C7;
93 int GL_MATRIX8_ARB = 0x88C8;
94 int GL_MATRIX9_ARB = 0x88C9;
95 int GL_MATRIX10_ARB = 0x88CA;
96 int GL_MATRIX11_ARB = 0x88CB;
97 int GL_MATRIX12_ARB = 0x88CC;
98 int GL_MATRIX13_ARB = 0x88CD;
99 int GL_MATRIX14_ARB = 0x88CE;
100 int GL_MATRIX15_ARB = 0x88CF;
101 int GL_MATRIX16_ARB = 0x88D0;
102 int GL_MATRIX17_ARB = 0x88D1;
103 int GL_MATRIX18_ARB = 0x88D2;
104 int GL_MATRIX19_ARB = 0x88D3;
105 int GL_MATRIX20_ARB = 0x88D4;
106 int GL_MATRIX21_ARB = 0x88D5;
107 int GL_MATRIX22_ARB = 0x88D6;
108 int GL_MATRIX23_ARB = 0x88D7;
109 int GL_MATRIX24_ARB = 0x88D8;
110 int GL_MATRIX25_ARB = 0x88D9;
111 int GL_MATRIX26_ARB = 0x88DA;
112 int GL_MATRIX27_ARB = 0x88DB;
113 int GL_MATRIX28_ARB = 0x88DC;
114 int GL_MATRIX29_ARB = 0x88DD;
115 int GL_MATRIX30_ARB = 0x88DE;
116 int GL_MATRIX31_ARB = 0x88DF;
117
118 void glProgramStringARB(@GLenum int target, @GLenum int format, @AutoSize("string") @GLsizei int length, @Const @GLbyte Buffer string);
119
120 @Alternate("glProgramStringARB")
121 void glProgramStringARB(@GLenum int target, @GLenum int format, @Constant("string.length()") @GLsizei int length, CharSequence string);
122
123 void glBindProgramARB(@GLenum int target, @GLuint int program);
124
125 void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
126
127 @Alternate("glDeleteProgramsARB")
128 void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program);
129
130 void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
131
132 @Alternate("glGenProgramsARB")
133 @GLreturn("programs")
134 void glGenProgramsARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
135
136 void glProgramEnvParameter4fARB(int target, int index, float x, float y, float z, float w);
137
138 void glProgramEnvParameter4dARB(int target, int index, double x, double y, double z, double w);
139
140 @StripPostfix("params")
141 void glProgramEnvParameter4fvARB(@GLenum int target, @GLuint int index, @Check("4") @Const FloatBuffer params);
142
143 @StripPostfix("params")
144 void glProgramEnvParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params);
145
146 void glProgramLocalParameter4fARB(@GLenum int target, @GLuint int index, float x, float y, float z, float w);
147
148 void glProgramLocalParameter4dARB(@GLenum int target, @GLuint int index, double x, double y, double z, double w);
149
150 @StripPostfix("params")
151 void glProgramLocalParameter4fvARB(@GLenum int target, @GLuint int index, @Check("4") @Const FloatBuffer params);
152
153 @StripPostfix("params")
154 void glProgramLocalParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params);
155
156 @StripPostfix("params")
157 void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params);
158
159 @StripPostfix("params")
160 void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params);
161
162 @StripPostfix("params")
163 void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params);
164
165 @StripPostfix("params")
166 void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params);
167
168 @StripPostfix("params")
169 void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params);
170
171 @Alternate("glGetProgramivARB")
172 @GLreturn("params")
173 @StripPostfix("params")
174 void glGetProgramivARB2(@GLenum int target, @GLenum int parameterName, @OutParameter IntBuffer params);
175
176 void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check @GLbyte Buffer paramString);
177
178 @Alternate("glGetProgramStringARB")
179 @Code("\t\tint programLength = glGetProgramARB(target, GL_PROGRAM_LENGTH_ARB);")
180 @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true)
181 void glGetProgramStringARB2(@GLenum int target, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString);
182
183 boolean glIsProgramARB(@GLuint int program);
184 }
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.GLenum;
34
35 public interface ARB_provoking_vertex {
36
37 /** Accepted by the &lt;mode&gt; parameter of ProvokingVertex: */
38 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D;
39 int GL_LAST_VERTEX_CONVENTION = 0x8E4E;
40
41 /**
42 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
43 * GetFloatv, and GetDoublev:
44 */
45 int GL_PROVOKING_VERTEX = 0x8E4F;
46 int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C;
47
48 void glProvokingVertex(@GLenum int mode);
49
50 }
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.GLclampf;
34
35 public interface ARB_sample_shading {
36
37 /**
38 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
39 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
40 * and GetDoublev:
41 */
42 int GL_SAMPLE_SHADING_ARB = 0x8C36;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
46 * GetIntegerv, and GetFloatv:
47 */
48 int GL_MIN_SAMPLE_SHADING_VALUE_ARB = 0x8C37;
49
50 void glMinSampleShadingARB(@GLclampf float value);
51
52 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.FloatBuffer;
36 import java.nio.IntBuffer;
37
38 @Extension(postfix = "")
39 public interface ARB_sampler_objects {
40
41 /**
42 * Accepted by the &lt;value&gt; parameter of the GetBooleanv, GetIntegerv,
43 * GetInteger64v, GetFloatv and GetDoublev functions:
44 */
45 int GL_SAMPLER_BINDING = 0x8919;
46
47 void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
48
49 @Alternate("glGenSamplers")
50 @GLreturn("samplers")
51 void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
52
53 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
54
55 @Alternate("glDeleteSamplers")
56 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
57
58 boolean glIsSampler(@GLuint int sampler);
59
60 void glBindSampler(@GLenum int unit, @GLuint int sampler);
61
62 void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param);
63
64 void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param);
65
66 @StripPostfix("params")
67 void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
68
69 @StripPostfix("params")
70 void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params);
71
72 @StripPostfix("params")
73 void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
74
75 @StripPostfix("params")
76 void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params);
77
78 @StripPostfix("params")
79 void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
80
81 @Alternate("glGetSamplerParameteriv")
82 @GLreturn("params")
83 @StripPostfix(value = "params", postfix = "v")
84 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
85
86 @StripPostfix("params")
87 void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
88
89 @Alternate("glGetSamplerParameterfv")
90 @GLreturn("params")
91 @StripPostfix(value = "params", postfix = "v")
92 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
93
94 @StripPostfix("params")
95 void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
96
97 @Alternate("glGetSamplerParameterIiv")
98 @GLreturn("params")
99 @StripPostfix(value = "params", postfix = "v")
100 void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
101
102 @StripPostfix("params")
103 void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
104
105 @Alternate("glGetSamplerParameterIuiv")
106 @GLreturn("params")
107 @StripPostfix(value = "params", postfix = "v")
108 void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
109
110 }
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_seamless_cube_map {
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, GetFloatv
38 * and GetDoublev:
39 */
40 int GL_TEXTURE_CUBE_MAP_SEAMLESS = 0x884F;
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 package org.lwjgl.opengl;
32
33 public interface ARB_shader_bit_encoding {
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 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38
39 public interface ARB_shader_objects {
40
41 /** Accepted by the &lt;pname&gt; argument of GetHandleARB: */
42 int GL_PROGRAM_OBJECT_ARB = 0x8B40;
43
44 /** Accepted by the &lt;pname&gt; parameter of GetObjectParameter{fi}vARB: */
45 int GL_OBJECT_TYPE_ARB = 0x8B4E;
46 int GL_OBJECT_SUBTYPE_ARB = 0x8B4F;
47 int GL_OBJECT_DELETE_STATUS_ARB = 0x8B80;
48 int GL_OBJECT_COMPILE_STATUS_ARB = 0x8B81;
49 int GL_OBJECT_LINK_STATUS_ARB = 0x8B82;
50 int GL_OBJECT_VALIDATE_STATUS_ARB = 0x8B83;
51 int GL_OBJECT_INFO_LOG_LENGTH_ARB = 0x8B84;
52 int GL_OBJECT_ATTACHED_OBJECTS_ARB = 0x8B85;
53 int GL_OBJECT_ACTIVE_UNIFORMS_ARB = 0x8B86;
54 int GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = 0x8B87;
55 int GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = 0x8B88;
56
57 /** Returned by the &lt;params&gt; parameter of GetObjectParameter{fi}vARB: */
58 int GL_SHADER_OBJECT_ARB = 0x8B48;
59
60 /** Returned by the &lt;type&gt; parameter of GetActiveUniformARB: */
61 int GL_FLOAT = 0x1406;
62 int GL_FLOAT_VEC2_ARB = 0x8B50;
63 int GL_FLOAT_VEC3_ARB = 0x8B51;
64 int GL_FLOAT_VEC4_ARB = 0x8B52;
65 int GL_INT = 0x1404;
66 int GL_INT_VEC2_ARB = 0x8B53;
67 int GL_INT_VEC3_ARB = 0x8B54;
68 int GL_INT_VEC4_ARB = 0x8B55;
69 int GL_BOOL_ARB = 0x8B56;
70 int GL_BOOL_VEC2_ARB = 0x8B57;
71 int GL_BOOL_VEC3_ARB = 0x8B58;
72 int GL_BOOL_VEC4_ARB = 0x8B59;
73 int GL_FLOAT_MAT2_ARB = 0x8B5A;
74 int GL_FLOAT_MAT3_ARB = 0x8B5B;
75 int GL_FLOAT_MAT4_ARB = 0x8B5C;
76 int GL_SAMPLER_1D_ARB = 0x8B5D;
77 int GL_SAMPLER_2D_ARB = 0x8B5E;
78 int GL_SAMPLER_3D_ARB = 0x8B5F;
79 int GL_SAMPLER_CUBE_ARB = 0x8B60;
80 int GL_SAMPLER_1D_SHADOW_ARB = 0x8B61;
81 int GL_SAMPLER_2D_SHADOW_ARB = 0x8B62;
82 int GL_SAMPLER_2D_RECT_ARB = 0x8B63;
83 int GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64;
84
85 void glDeleteObjectARB(@GLhandleARB int obj);
86
87 @GLhandleARB
88 int glGetHandleARB(@GLenum int pname);
89
90 void glDetachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int attachedObj);
91
92 @GLhandleARB
93 int glCreateShaderObjectARB(@GLenum int shaderType);
94
95 /**
96 * The ARB_shader_objects extension allows multiple, optionally null-terminated, source strings to define a shader program.
97 * <p/>
98 * This method uses just a single string, that should NOT be null-terminated.
99 */
100 void glShaderSourceARB(@GLhandleARB int shader, @Constant("1") @GLsizei int count,
101 @Indirect @Const @GLcharARB @Check ByteBuffer string,
102 @AutoSize("string") @Indirect @Const @GLint int length);
103
104 @Alternate("glShaderSourceARB")
105 void glShaderSourceARB2(@GLhandleARB int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length);
106
107 @Alternate(value = "glShaderSourceARB", nativeAlt = true)
108 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
112 void glCompileShaderARB(@GLhandleARB int shaderObj);
113
114 @GLhandleARB
115 int glCreateProgramObjectARB();
116
117 void glAttachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int obj);
118
119 void glLinkProgramARB(@GLhandleARB int programObj);
120
121 void glUseProgramObjectARB(@GLhandleARB int programObj);
122
123 void glValidateProgramARB(@GLhandleARB int programObj);
124
125 void glUniform1fARB(int location, float v0);
126
127 void glUniform2fARB(int location, float v0, float v1);
128
129 void glUniform3fARB(int location, float v0, float v1, float v2);
130
131 void glUniform4fARB(int location, float v0, float v1, float v2, float v3);
132
133 void glUniform1iARB(int location, int v0);
134
135 void glUniform2iARB(int location, int v0, int v1);
136
137 void glUniform3iARB(int location, int v0, int v1, int v2);
138
139 void glUniform4iARB(int location, int v0, int v1, int v2, int v3);
140
141 @StripPostfix("values")
142 void glUniform1fvARB(int location, @AutoSize("values") @GLsizei int count, @Const FloatBuffer values);
143
144 @StripPostfix("values")
145 void glUniform2fvARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const FloatBuffer values);
146
147 @StripPostfix("values")
148 void glUniform3fvARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const FloatBuffer values);
149
150 @StripPostfix("values")
151 void glUniform4fvARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const FloatBuffer values);
152
153 @StripPostfix("values")
154 void glUniform1ivARB(int location, @AutoSize(value = "values") @GLsizei int count, @Const IntBuffer values);
155
156 @StripPostfix("values")
157 void glUniform2ivARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const IntBuffer values);
158
159 @StripPostfix("values")
160 void glUniform3ivARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const IntBuffer values);
161
162 @StripPostfix("values")
163 void glUniform4ivARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const IntBuffer values);
164
165 @StripPostfix("matrices")
166 void glUniformMatrix2fvARB(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
167
168 @StripPostfix("matrices")
169 void glUniformMatrix3fvARB(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
170
171 @StripPostfix("matrices")
172 void glUniformMatrix4fvARB(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices);
173
174 @StripPostfix("params")
175 void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params);
176
177 @Alternate("glGetObjectParameterfvARB")
178 @GLreturn("params")
179 @StripPostfix(value = "params", postfix = "v")
180 void glGetObjectParameterfvARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter FloatBuffer params);
181
182 @StripPostfix("params")
183 void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params);
184
185 @Alternate("glGetObjectParameterivARB")
186 @GLreturn("params")
187 @StripPostfix(value = "params", postfix = "v")
188 void glGetObjectParameterivARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter IntBuffer params);
189
190 void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength,
191 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
192 @OutParameter @GLcharARB ByteBuffer infoLog);
193
194 @Alternate("glGetInfoLogARB")
195 @GLreturn(value = "infoLog", maxLength = "maxLength")
196 void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength,
197 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
198 @OutParameter @GLcharARB ByteBuffer infoLog);
199
200 void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount,
201 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count,
202 @OutParameter @GLhandleARB IntBuffer obj);
203
204 /**
205 * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a <b>null-terminated</b> string.
206 *
207 * @param programObj
208 * @param name
209 */
210 int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
211
212 @Alternate("glGetUniformLocationARB")
213 int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name);
214
215 void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength,
216 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
217 @OutParameter @Check("1") IntBuffer size,
218 @OutParameter @GLenum @Check("1") IntBuffer type,
219 @OutParameter @GLcharARB ByteBuffer name);
220
221 /** Overloads glGetActiveUniformARB. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
222 @Alternate("glGetActiveUniformARB")
223 @GLreturn(value = "name", maxLength = "maxLength")
224 void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
225 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
226 @OutParameter @Check("2") IntBuffer sizeType,
227 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
228 @OutParameter @GLcharARB ByteBuffer name);
229
230 /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
231 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
232 @GLreturn(value = "name", maxLength = "maxLength")
233 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,
235 @OutParameter @GLcharARB ByteBuffer name);
236
237 /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */
238 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
239 @GLreturn(value = "size")
240 void glGetActiveUniformSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
241 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
242 @OutParameter IntBuffer size,
243 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
244 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
245
246 /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */
247 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
248 @GLreturn(value = "type")
249 void glGetActiveUniformTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
250 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
251 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
252 @OutParameter @GLenum IntBuffer type,
253 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
254
255 @StripPostfix("params")
256 void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params);
257
258 @StripPostfix("params")
259 void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params);
260
261 void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength,
262 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
263 @OutParameter @GLcharARB ByteBuffer source);
264
265 @Alternate("glGetShaderSourceARB")
266 @GLreturn(value = "source", maxLength = "maxLength")
267 void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength,
268 @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length,
269 @OutParameter @GLcharARB ByteBuffer source);
270
271 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 @Extension(postfix = "")
39 public interface ARB_shader_subroutine {
40
41 /** Accepted by the &lt;pname&gt; parameter of GetProgramStageiv: */
42 int GL_ACTIVE_SUBROUTINES = 0x8DE5;
43 int GL_ACTIVE_SUBROUTINE_UNIFORMS = 0x8DE6;
44 int GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS = 0x8E47;
45 int GL_ACTIVE_SUBROUTINE_MAX_LENGTH = 0x8E48;
46 int GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH = 0x8E49;
47
48 /**
49 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
50 * GetFloatv, GetDoublev, and GetInteger64v:
51 */
52 int GL_MAX_SUBROUTINES = 0x8DE7;
53 int GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS = 0x8DE8;
54
55 /** Accepted by the &lt;pname&gt; parameter of GetActiveSubroutineUniformiv: */
56 int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A;
57 int GL_COMPATIBLE_SUBROUTINES = 0x8E4B;
58 int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE;
59 int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH;
60
61 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
62
63 @GLuint
64 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
65
66 @StripPostfix("values")
67 void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
68 @Check("1") @OutParameter IntBuffer values);
69
70 @Alternate("glGetActiveSubroutineUniformiv")
71 @GLreturn("values")
72 @StripPostfix("values")
73 void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
74 @OutParameter IntBuffer values);
75
76 void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
77 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
78 @OutParameter ByteBuffer name);
79
80 @Alternate("glGetActiveSubroutineUniformName")
81 @GLreturn(value = "name", maxLength = "bufsize")
82 void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
83 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
84 @OutParameter @GLchar ByteBuffer name);
85
86 void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
87 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
88 @OutParameter ByteBuffer name);
89
90 @Alternate("glGetActiveSubroutineName")
91 @GLreturn(value = "name", maxLength = "bufsize")
92 void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
93 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
94 @OutParameter @GLchar ByteBuffer name);
95
96 @StripPostfix("indices")
97 void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices);
98
99 @StripPostfix("params")
100 void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params);
101
102 @Alternate("glGetUniformSubroutineuiv")
103 @GLreturn("params")
104 @StripPostfix("params")
105 void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
106
107 @StripPostfix("values")
108 void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values);
109
110 @Alternate("glGetProgramStageiv")
111 @GLreturn("values")
112 @StripPostfix("values")
113 void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values);
114
115 }
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_texture_lod {
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_shading_language_100 {
34
35 /**
36 * Accepted by the &lt;name&gt; parameter of GetString:
37 */
38 int GL_SHADING_LANGUAGE_VERSION_ARB = 0x8B8C;
39 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 public interface ARB_shading_language_include {
39
40 /** Accepted by the &lt;type&gt; parameter of NamedStringARB: */
41 int GL_SHADER_INCLUDE_ARB = 0x8DAE;
42
43 /** Accepted by the &lt;pname&gt; parameter of GetNamedStringivARB: */
44 int GL_NAMED_STRING_LENGTH_ARB = 0x8DE9;
45 int GL_NAMED_STRING_TYPE_ARB = 0x8DEA;
46
47 void glNamedStringARB(@GLenum int type,
48 @AutoSize("name") int namelen, @Const @GLchar ByteBuffer name,
49 @AutoSize("string") int stringlen, @Const @GLchar ByteBuffer string);
50
51 @Alternate("glNamedStringARB")
52 void glNamedStringARB(@GLenum int type,
53 @Constant("name.length()") int namelen, CharSequence name,
54 @Constant("string.length()") int stringlen, CharSequence string);
55
56 void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name);
57
58 @Alternate("glDeleteNamedStringARB")
59 void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name);
60
61 void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count,
62 @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path,
63 @Constant("null, 0") @Const IntBuffer length);
64
65 @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true)
66 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
70 boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name);
71
72 @Alternate("glIsNamedStringARB")
73 boolean glIsNamedStringARB(@Constant("name.length()") int namelen, CharSequence name);
74
75 void glGetNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name,
76 @AutoSize("string") @GLsizei int bufSize,
77 @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen,
78 @OutParameter @GLchar ByteBuffer string);
79
80 @Alternate("glGetNamedStringARB")
81 void glGetNamedStringARB(@Constant("name.length()") int namelen, CharSequence name,
82 @AutoSize("string") @GLsizei int bufSize,
83 @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen,
84 @OutParameter @GLchar ByteBuffer string);
85
86 @Alternate("glGetNamedStringARB")
87 @GLreturn(value = "string", maxLength = "bufSize")
88 void glGetNamedStringARB2(@Constant("name.length()") int namelen, CharSequence name,
89 @GLsizei int bufSize,
90 @OutParameter @Constant("string_length, 0") IntBuffer stringlen,
91 @OutParameter @GLchar ByteBuffer string);
92
93 @StripPostfix("params")
94 void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
95
96 @Alternate("glGetNamedStringivARB")
97 @StripPostfix(value = "params", postfix = "v")
98 void glGetNamedStringivARB(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
99
100 @Alternate("glGetNamedStringivARB")
101 @GLreturn("params")
102 @StripPostfix(value = "params", postfix = "v")
103 void glGetNamedStringivARB2(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter IntBuffer params);
104
105 }
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_shadow {
34 int GL_TEXTURE_COMPARE_MODE_ARB = 0x884C;
35 int GL_TEXTURE_COMPARE_FUNC_ARB = 0x884D;
36 int GL_COMPARE_R_TO_TEXTURE_ARB = 0x884E;
37 }
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_shadow_ambient {
34 int GL_TEXTURE_COMPARE_FAIL_VALUE_ARB = 0x80BF;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36 import java.nio.LongBuffer;
37
38 @Extension(postfix = "")
39 public interface ARB_sync {
40
41 /** Accepted as the &lt;pname&gt; parameter of GetInteger64v: */
42 int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111;
43
44 /** Accepted as the &lt;pname&gt; parameter of GetSynciv: */
45 int GL_OBJECT_TYPE = 0x9112;
46 int GL_SYNC_CONDITION = 0x9113;
47 int GL_SYNC_STATUS = 0x9114;
48 int GL_SYNC_FLAGS = 0x9115;
49
50 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; OBJECT_TYPE: */
51 int GL_SYNC_FENCE = 0x9116;
52
53 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_CONDITION: */
54 int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117;
55
56 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_STATUS: */
57 int GL_UNSIGNALED = 0x9118;
58 int GL_SIGNALED = 0x9119;
59
60 /** Accepted in the &lt;flags&gt; parameter of ClientWaitSync: */
61 int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
62
63 /** Accepted in the &lt;timeout&gt; parameter of WaitSync: */
64 long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl;
65
66 /** Returned by ClientWaitSync: */
67 int GL_ALREADY_SIGNALED = 0x911A;
68 int GL_TIMEOUT_EXPIRED = 0x911B;
69 int GL_CONDITION_SATISFIED = 0x911C;
70 int GL_WAIT_FAILED = 0x911D;
71
72 @GLpointer("GLsync")
73 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
74
75 boolean glIsSync(@GLpointer("GLsync") GLSync sync);
76
77 void glDeleteSync(@GLpointer("GLsync") GLSync sync);
78
79 @GLenum
80 int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
81
82 void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
83
84 @StripPostfix(value = "params", postfix = "64")
85 void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
86
87 @Alternate("glGetInteger64v")
88 @GLreturn("params")
89 @StripPostfix(value = "params", postfix = "64")
90 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params);
91
92 @StripPostfix("values")
93 void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
94 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
95 @OutParameter IntBuffer values);
96
97 @Alternate("glGetSynciv")
98 @GLreturn("values")
99 @StripPostfix("values")
100 void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
101 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
102 @OutParameter IntBuffer values);
103 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.FloatBuffer;
36
37 @Extension(postfix = "")
38 public interface ARB_tessellation_shader {
39
40 /**
41 * Accepted by the &lt;mode&gt; parameter of Begin and all vertex array functions
42 * that implicitly call Begin:
43 */
44 int GL_PATCHES = 0xE;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of PatchParameteri, GetBooleanv,
48 * GetDoublev, GetFloatv, GetIntegerv, and GetInteger64v:
49 */
50 int GL_PATCH_VERTICES = 0x8E72;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of PatchParameterfv, GetBooleanv,
54 * GetDoublev, GetFloatv, and GetIntegerv, and GetInteger64v:
55 */
56 int GL_PATCH_DEFAULT_INNER_LEVEL = 0x8E73;
57 int GL_PATCH_DEFAULT_OUTER_LEVEL = 0x8E74;
58
59 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
60 int GL_TESS_CONTROL_OUTPUT_VERTICES = 0x8E75;
61 int GL_TESS_GEN_MODE = 0x8E76;
62 int GL_TESS_GEN_SPACING = 0x8E77;
63 int GL_TESS_GEN_VERTEX_ORDER = 0x8E78;
64 int GL_TESS_GEN_POINT_MODE = 0x8E79;
65
66 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_MODE: */
67 int GL_TRIANGLES = GL11.GL_TRIANGLES;
68 int GL_QUADS = GL11.GL_QUADS;
69 int GL_ISOLINES = 0x8E7A;
70
71 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_SPACING: */
72 int GL_EQUAL = GL11.GL_EQUAL;
73 int GL_FRACTIONAL_ODD = 0x8E7B;
74 int GL_FRACTIONAL_EVEN = 0x8E7C;
75
76 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_VERTEX_ORDER: */
77 int GL_CCW = GL11.GL_CCW;
78 int GL_CW = GL11.GL_CW;
79
80 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_POINT_MODE: */
81 int GL_FALSE = GL11.GL_FALSE;
82 int GL_TRUE = GL11.GL_TRUE;
83
84 /**
85 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetFloatv,
86 * GetIntegerv, and GetInteger64v:
87 */
88 int GL_MAX_PATCH_VERTICES = 0x8E7D;
89 int GL_MAX_TESS_GEN_LEVEL = 0x8E7E;
90 int GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E7F;
91 int GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E80;
92 int GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS = 0x8E81;
93 int GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS = 0x8E82;
94 int GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83;
95 int GL_MAX_TESS_PATCH_COMPONENTS = 0x8E84;
96 int GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS = 0x8E85;
97 int GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS = 0x8E86;
98 int GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS = 0x8E89;
99 int GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS = 0x8E8A;
100 int GL_MAX_TESS_CONTROL_INPUT_COMPONENTS = 0x886C;
101 int GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS = 0x886D;
102 int GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E1E;
103 int GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E1F;
104
105 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockiv: */
106 int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0;
107 int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1;
108
109 /**
110 * Accepted by the &lt;type&gt; parameter of CreateShader and returned by the
111 * &lt;params&gt; parameter of GetShaderiv:
112 */
113 int GL_TESS_EVALUATION_SHADER = 0x8E87;
114 int GL_TESS_CONTROL_SHADER = 0x8E88;
115
116 void glPatchParameteri(@GLenum int pname, int value);
117
118 @StripPostfix("values")
119 void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values);
120
121 }
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_texture_border_clamp {
34 int GL_CLAMP_TO_BORDER_ARB = 0x812D;
35 }
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.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface ARB_texture_buffer_object {
37
38 /**
39 * Accepted by the &lt;target&gt; parameter of BindBuffer, BufferData,
40 * BufferSubData, MapBuffer, MapBufferRangeARB, BindTexture, UnmapBuffer,
41 * GetBufferSubData, GetBufferParameteriv, GetBufferPointerv, and TexBufferARB,
42 * and the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv, and
43 * GetIntegerv:
44 */
45 int GL_TEXTURE_BUFFER_ARB = 0x8C2A;
46
47 /**
48 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetDoublev,
49 * GetFloatv, and GetIntegerv:
50 */
51 int GL_MAX_TEXTURE_BUFFER_SIZE_ARB = 0x8C2B;
52 int GL_TEXTURE_BINDING_BUFFER_ARB = 0x8C2C;
53 int GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB = 0x8C2D;
54 int GL_TEXTURE_BUFFER_FORMAT_ARB = 0x8C2E;
55
56 void glTexBufferARB(@GLenum int target, @GLenum int internalformat, @GLuint int buffer);
57 }
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_texture_buffer_object_rgb32 {
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 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_texture_compression {
38 int GL_COMPRESSED_ALPHA_ARB = 0x84E9;
39 int GL_COMPRESSED_LUMINANCE_ARB = 0x84EA;
40 int GL_COMPRESSED_LUMINANCE_ALPHA_ARB = 0x84EB;
41 int GL_COMPRESSED_INTENSITY_ARB = 0x84EC;
42 int GL_COMPRESSED_RGB_ARB = 0x84ED;
43 int GL_COMPRESSED_RGBA_ARB = 0x84EE;
44 int GL_TEXTURE_COMPRESSION_HINT_ARB = 0x84EF;
45 int GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB = 0x86A0;
46 int GL_TEXTURE_COMPRESSED_ARB = 0x86A1;
47 int GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = 0x86A2;
48 int GL_COMPRESSED_TEXTURE_FORMATS_ARB = 0x86A3;
49
50 void glCompressedTexImage1DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("pData") @GLsizei int imageSize,
51 @BufferObject(BufferKind.UnpackPBO)
52 @Check
53 @Const
54 @GLvoid
55 ByteBuffer pData);
56
57 void glCompressedTexImage2DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("pData") @GLsizei int imageSize,
58 @BufferObject(BufferKind.UnpackPBO)
59 @Check
60 @Const
61 @GLvoid
62 ByteBuffer pData);
63
64 void glCompressedTexImage3DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("pData") @GLsizei int imageSize,
65 @BufferObject(BufferKind.UnpackPBO)
66 @Check
67 @Const
68 @GLvoid
69 ByteBuffer pData);
70
71 void glCompressedTexSubImage1DARB(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize,
72 @BufferObject(BufferKind.UnpackPBO)
73 @Check
74 @Const
75 @GLvoid
76 ByteBuffer pData);
77
78 void glCompressedTexSubImage2DARB(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize,
79 @BufferObject(BufferKind.UnpackPBO)
80 @Check
81 @Const
82 @GLvoid
83 ByteBuffer pData);
84
85 void glCompressedTexSubImage3DARB(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize,
86 @BufferObject(BufferKind.UnpackPBO)
87 @Check
88 @Const
89 @GLvoid
90 ByteBuffer pData);
91
92 void glGetCompressedTexImageARB(@GLenum int target, int lod,
93 @OutParameter
94 @BufferObject(BufferKind.PackPBO)
95 @Check
96 @GLvoid
97 ByteBuffer pImg);
98 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "ARB", className = "ARBTextureCompressionBPTC")
36 public interface ARB_texture_compression_bptc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D, TexImage3D,
40 * CopyTexImage2D, CopyTexImage3D, CompressedTexImage2DARB, and
41 * CompressedTexImage3DARB and the &lt;format&gt; parameter of
42 * CompressedTexSubImage2DARB and CompressedTexSubImage3DARB:
43 */
44 int GL_COMPRESSED_RGBA_BPTC_UNORM_ARB = 0x8E8C;
45 int GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB = 0x8E8D;
46 int GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB = 0x8E8E;
47 int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB = 0x8E8F;
48
49 }
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.Extension;
34
35 @Extension(postfix = "ARB", className = "ARBTextureCompressionRGTC")
36 public interface ARB_texture_compression_rgtc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D,
40 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
41 * of CompressedTexSubImage2D:
42 */
43 int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
44 int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC;
45 int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD;
46 int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE;
47
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.opengl;
32
33 public interface ARB_texture_cube_map {
34 int GL_NORMAL_MAP_ARB = 0x8511;
35 int GL_REFLECTION_MAP_ARB = 0x8512;
36 int GL_TEXTURE_CUBE_MAP_ARB = 0x8513;
37 int GL_TEXTURE_BINDING_CUBE_MAP_ARB = 0x8514;
38 int GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x8515;
39 int GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x8516;
40 int GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x8517;
41 int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x8518;
42 int GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x8519;
43 int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x851A;
44 int GL_PROXY_TEXTURE_CUBE_MAP_ARB = 0x851B;
45 int GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = 0x851C;
46 }
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_texture_cube_map_array {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of TexParameteri, TexParameteriv,
37 * TexParameterf, TexParameterfv, BindTexture, and GenerateMipmap:
38 * <p/>
39 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
40 * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D:
41 * <p/>
42 * Accepted by the &lt;tex&gt; parameter of GetTexImage:
43 */
44 int GL_TEXTURE_CUBE_MAP_ARRAY_ARB = 0x9009;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
48 * GetIntegerv and GetFloatv:
49 */
50 int GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB = 0x900A;
51
52 /**
53 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
54 * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D:
55 */
56 int GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB = 0x900B;
57
58 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
59 int GL_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900C;
60 int GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB = 0x900D;
61 int GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900E;
62 int GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900F;
63
64 }
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_texture_env_add {
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_texture_env_combine {
34 int GL_COMBINE_ARB = 0x8570;
35
36 int GL_COMBINE_RGB_ARB = 0x8571;
37 int GL_COMBINE_ALPHA_ARB = 0x8572;
38
39 int GL_SOURCE0_RGB_ARB = 0x8580;
40 int GL_SOURCE1_RGB_ARB = 0x8581;
41 int GL_SOURCE2_RGB_ARB = 0x8582;
42 int GL_SOURCE0_ALPHA_ARB = 0x8588;
43 int GL_SOURCE1_ALPHA_ARB = 0x8589;
44 int GL_SOURCE2_ALPHA_ARB = 0x858A;
45
46 int GL_OPERAND0_RGB_ARB = 0x8590;
47 int GL_OPERAND1_RGB_ARB = 0x8591;
48 int GL_OPERAND2_RGB_ARB = 0x8592;
49 int GL_OPERAND0_ALPHA_ARB = 0x8598;
50 int GL_OPERAND1_ALPHA_ARB = 0x8599;
51 int GL_OPERAND2_ALPHA_ARB = 0x859A;
52
53 int GL_RGB_SCALE_ARB = 0x8573;
54
55 int GL_ADD_SIGNED_ARB = 0x8574;
56 int GL_INTERPOLATE_ARB = 0x8575;
57 int GL_SUBTRACT_ARB = 0x84E7;
58
59 int GL_CONSTANT_ARB = 0x8576;
60 int GL_PRIMARY_COLOR_ARB = 0x8577;
61 int GL_PREVIOUS_ARB = 0x8578;
62 }
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_texture_env_crossbar {
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_texture_env_dot3 {
34 int GL_DOT3_RGB_ARB = 0x86AE;
35 int GL_DOT3_RGBA_ARB = 0x86AF;
36 }
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_texture_float {
34
35 /**
36 * Accepted by the &lt;value&gt; parameter of GetTexLevelParameter:
37 */
38 int GL_TEXTURE_RED_TYPE_ARB = 0x8C10;
39 int GL_TEXTURE_GREEN_TYPE_ARB = 0x8C11;
40 int GL_TEXTURE_BLUE_TYPE_ARB = 0x8C12;
41 int GL_TEXTURE_ALPHA_TYPE_ARB = 0x8C13;
42 int GL_TEXTURE_LUMINANCE_TYPE_ARB = 0x8C14;
43 int GL_TEXTURE_INTENSITY_TYPE_ARB = 0x8C15;
44 int GL_TEXTURE_DEPTH_TYPE_ARB = 0x8C16;
45
46 /**
47 * Returned by the &lt;params&gt; parameter of GetTexLevelParameter:
48 */
49 int GL_UNSIGNED_NORMALIZED_ARB = 0x8C17;
50
51 /**
52 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
53 * TexImage2D, and TexImage3D:
54 */
55 int GL_RGBA32F_ARB = 0x8814;
56 int GL_RGB32F_ARB = 0x8815;
57 int GL_ALPHA32F_ARB = 0x8816;
58 int GL_INTENSITY32F_ARB = 0x8817;
59 int GL_LUMINANCE32F_ARB = 0x8818;
60 int GL_LUMINANCE_ALPHA32F_ARB = 0x8819;
61 int GL_RGBA16F_ARB = 0x881A;
62 int GL_RGB16F_ARB = 0x881B;
63 int GL_ALPHA16F_ARB = 0x881C;
64 int GL_INTENSITY16F_ARB = 0x881D;
65 int GL_LUMINANCE16F_ARB = 0x881E;
66 int GL_LUMINANCE_ALPHA16F_ARB = 0x881F;
67 }
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_texture_gather {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
37 * GetFloatv, and GetDoublev:
38 */
39 int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5E;
40 int GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5F;
41 int GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB = 0x8F9F;
42
43 }
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_texture_mirrored_repeat {
34 int GL_MIRRORED_REPEAT_ARB = 0x8370;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.FloatBuffer;
36
37 @Extension(postfix = "")
38 public interface ARB_texture_multisample {
39
40 /** Accepted by the &lt;pname&gt; parameter of GetMultisamplefv: */
41 int GL_SAMPLE_POSITION = 0x8E50;
42
43 /**
44 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
45 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
46 * GetDoublev:
47 */
48 int GL_SAMPLE_MASK = 0x8E51;
49
50 /**
51 * Accepted by the &lt;target&gt; parameter of GetBooleani_v and
52 * GetIntegeri_v:
53 */
54 int GL_SAMPLE_MASK_VALUE = 0x8E52;
55
56 /**
57 * Accepted by the &lt;target&gt; parameter of BindTexture and
58 * TexImage2DMultisample:
59 */
60 int GL_TEXTURE_2D_MULTISAMPLE = 0x9100;
61
62 /** Accepted by the &lt;target&gt; parameter of TexImage2DMultisample: */
63 int GL_PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101;
64
65 /**
66 * Accepted by the &lt;target&gt; parameter of BindTexture and
67 * TexImage3DMultisample:
68 */
69 int GL_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102;
70
71 /** Accepted by the &lt;target&gt; parameter of TexImage3DMultisample: */
72 int GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103;
73
74 /**
75 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
76 * and GetFloatv:
77 */
78 int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59;
79 int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E;
80 int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F;
81 int GL_MAX_INTEGER_SAMPLES = 0x9110;
82 int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104;
83 int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105;
84
85 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter */
86 int GL_TEXTURE_SAMPLES = 0x9106;
87 int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107;
88
89 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
90 int GL_SAMPLER_2D_MULTISAMPLE = 0x9108;
91 int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109;
92 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A;
93 int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B;
94 int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C;
95 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D;
96
97 void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
98 @GLsizei int width, @GLsizei int height,
99 boolean fixedsamplelocations);
100
101 void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
102 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
103 boolean fixedsamplelocations);
104
105 @StripPostfix("val")
106 void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val);
107
108 void glSampleMaski(@GLuint int index, @GLbitfield int mask);
109
110 }
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_texture_non_power_of_two {
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_texture_query_lod {
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_texture_rectangle {
34
35 /**
36 Accepted by the &lt;cap&gt; parameter of Enable, Disable and IsEnabled;
37 by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv
38 and GetDoublev; and by the &lt;target&gt; parameter of BindTexture,
39 GetTexParameterfv, GetTexParameteriv, TexParameterf, TexParameteri,
40 TexParameterfv and TexParameteriv:
41 Accepted by the &lt;target&gt; parameter of GetTexImage,
42 GetTexLevelParameteriv, GetTexLevelParameterfv, TexImage2D,
43 CopyTexImage2D, TexSubImage2D and CopySubTexImage2D:
44 */
45 int GL_TEXTURE_RECTANGLE_ARB = 0x84F5;
46
47 /**
48 Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
49 GetFloatv and GetDoublev:
50 */
51 int GL_TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6;
52
53 /**
54 Accepted by the &lt;target&gt; parameter of GetTexLevelParameteriv,
55 GetTexLevelParameterfv, GetTexParameteriv and TexImage2D:
56 */
57 int GL_PROXY_TEXTURE_RECTANGLE_ARB = 0x84F7;
58
59 /**
60 Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
61 GetIntegerv and GetFloatv:
62 */
63 int GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB = 0x84F8;
64
65 /**
66 Returned by &lt;type&gt; parameter of GetActiveUniform when the location
67 &lt;index&gt; for program object &lt;program&gt; is of type sampler2DRect:
68 */
69 int GL_SAMPLER_2D_RECT_ARB = 0x8B63;
70
71 /**
72 Returned by &lt;type&gt; parameter of GetActiveUniform when the location
73 &lt;index&gt; for program object &lt;program&gt; is of type sampler2DRectShadow:
74 */
75 int GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64;
76
77 }
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_texture_rg {
34
35 /**
36 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D, TexImage2D,
37 * TexImage3D, CopyTexImage1D, and CopyTexImage2D:
38 */
39 int GL_R8 = 0x8229;
40 int GL_R16 = 0x822A;
41
42 int GL_RG8 = 0x822B;
43 int GL_RG16 = 0x822C;
44
45 int GL_R16F = 0x822D;
46 int GL_R32F = 0x822E;
47
48 int GL_RG16F = 0x822F;
49 int GL_RG32F = 0x8230;
50
51 int GL_R8I = 0x8231;
52 int GL_R8UI = 0x8232;
53 int GL_R16I = 0x8233;
54 int GL_R16UI = 0x8234;
55 int GL_R32I = 0x8235;
56 int GL_R32UI = 0x8236;
57
58 int GL_RG8I = 0x8237;
59 int GL_RG8UI = 0x8238;
60 int GL_RG16I = 0x8239;
61 int GL_RG16UI = 0x823A;
62 int GL_RG32I = 0x823B;
63 int GL_RG32UI = 0x823C;
64
65 /**
66 * Accepted by the &lt;format&gt; parameter of TexImage3D, TexImage2D,
67 * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D,
68 * DrawPixels and ReadPixels:
69 */
70 int GL_RG = 0x8227;
71 int GL_RG_INTEGER = 0x8228;
72
73 /**
74 * Accepted by the &lt;param&gt; parameter of the TexParameter{if}*
75 * functions when &lt;pname&gt; is DEPTH_TEXTURE_MODE:
76 */
77 int GL_RED = 0x1903;
78
79 }
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.Extension;
34
35 @Extension(postfix = "ARB", className = "ARBTextureRGB10_A2UI")
36 public interface ARB_texture_rgb10_a2ui {
37
38 /**
39 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D, TexImage2D,
40 * TexImage3D, CopyTexImage1D, CopyTexImage2D, RenderbufferStorage and
41 * RenderbufferStorageMultisample:
42 */
43 int GL_RGB10_A2UI = 0x906F;
44
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.opengl;
32
33 public interface ARB_texture_swizzle {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameters of TexParameteri,
37 * TexParameterf, TexParameteriv, TexParameterfv,
38 * GetTexParameterfv, and GetTexParameteriv:
39 */
40 int GL_TEXTURE_SWIZZLE_R = 0x8E42;
41 int GL_TEXTURE_SWIZZLE_G = 0x8E43;
42 int GL_TEXTURE_SWIZZLE_B = 0x8E44;
43 int GL_TEXTURE_SWIZZLE_A = 0x8E45;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameters of TexParameteriv,
47 * TexParameterfv, GetTexParameterfv, and GetTexParameteriv:
48 */
49 int GL_TEXTURE_SWIZZLE_RGBA = 0x8E46;
50
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.LongBuffer;
36
37 @Extension(postfix = "")
38 public interface ARB_timer_query {
39
40 /**
41 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
42 * GetQueryiv:
43 */
44 int GL_TIME_ELAPSED = 0x88BF;
45
46 /**
47 * Accepted by the &lt;target&gt; parameter of GetQueryiv and QueryCounter.
48 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
49 * GetInteger64v, GetFloatv, and GetDoublev:
50 */
51 int GL_TIMESTAMP = 0x8E28;
52
53 void glQueryCounter(@GLuint int id, @GLenum int target);
54
55 @StripPostfix("params")
56 void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
57
58 @Alternate("glGetQueryObjecti64v")
59 @GLreturn("params")
60 @StripPostfix("params")
61 void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
62
63 @StripPostfix("params")
64 void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params);
65
66 @Alternate("glGetQueryObjectui64v")
67 @GLreturn("params")
68 @StripPostfix("params")
69 void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params);
70
71 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface ARB_transform_feedback2 {
38
39 /** Accepted by the &lt;target&gt; parameter of BindTransformFeedback: */
40 int GL_TRANSFORM_FEEDBACK = 0x8E22;
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
44 * and GetFloatv:
45 */
46 int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23;
47 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24;
48 int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25;
49
50 void glBindTransformFeedback(@GLenum int target, @GLuint int id);
51
52 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
53
54 @Alternate("glDeleteTransformFeedbacks")
55 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
56
57 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
58
59 @Alternate("glGenTransformFeedbacks")
60 @GLreturn("ids")
61 void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
62
63 boolean glIsTransformFeedback(@GLuint int id);
64
65 void glPauseTransformFeedback();
66
67 void glResumeTransformFeedback();
68
69 void glDrawTransformFeedback(@GLenum int mode, @GLuint int id);
70
71 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 @Extension(postfix = "")
38 public interface ARB_transform_feedback3 {
39
40 /**
41 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
42 * and GetFloatv:
43 */
44 int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70;
45 int GL_MAX_VERTEX_STREAMS = 0x8E71;
46
47 void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream);
48
49 void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id);
50
51 void glEndQueryIndexed(@GLenum int target, @GLuint int index);
52
53 @StripPostfix("params")
54 void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
55
56 @Alternate("glGetQueryIndexediv")
57 @GLreturn("params")
58 @StripPostfix("params")
59 void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params);
60
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_transpose_matrix {
38 int GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = 0x84E3;
39 int GL_TRANSPOSE_PROJECTION_MATRIX_ARB = 0x84E4;
40 int GL_TRANSPOSE_TEXTURE_MATRIX_ARB = 0x84E5;
41 int GL_TRANSPOSE_COLOR_MATRIX_ARB = 0x84E6;
42
43 @StripPostfix("pfMtx")
44 void glLoadTransposeMatrixfARB(@Check("16") @Const FloatBuffer pfMtx);
45
46 @StripPostfix("pfMtx")
47 void glMultTransposeMatrixfARB(@Check("16") @Const FloatBuffer pfMtx);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 @Extension(postfix = "")
39 public interface ARB_uniform_buffer_object {
40
41 /**
42 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
43 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
44 * GetBufferPointerv:
45 */
46 int GL_UNIFORM_BUFFER = 0x8A11;
47
48 /**
49 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleanv,
50 * GetIntegerv, GetFloatv, and GetDoublev:
51 */
52 int GL_UNIFORM_BUFFER_BINDING = 0x8A28;
53
54 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
55 int GL_UNIFORM_BUFFER_START = 0x8A29;
56 int GL_UNIFORM_BUFFER_SIZE = 0x8A2A;
57
58 /**
59 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
60 * GetFloatv, and GetDoublev:
61 */
62 int GL_MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B;
63 int GL_MAX_GEOMETRY_UNIFORM_BLOCKS = 0x8A2C;
64 int GL_MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D;
65 int GL_MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E;
66 int GL_MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F;
67 int GL_MAX_UNIFORM_BLOCK_SIZE = 0x8A30;
68 int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31;
69 int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = 0x8A32;
70 int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33;
71 int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34;
72
73 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
74 int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35;
75 int GL_ACTIVE_UNIFORM_BLOCKS = 0x8A36;
76
77 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformsivARB: */
78 int GL_UNIFORM_TYPE = 0x8A37;
79 int GL_UNIFORM_SIZE = 0x8A38;
80 int GL_UNIFORM_NAME_LENGTH = 0x8A39;
81 int GL_UNIFORM_BLOCK_INDEX = 0x8A3A;
82 int GL_UNIFORM_OFFSET = 0x8A3B;
83 int GL_UNIFORM_ARRAY_STRIDE = 0x8A3C;
84 int GL_UNIFORM_MATRIX_STRIDE = 0x8A3D;
85 int GL_UNIFORM_IS_ROW_MAJOR = 0x8A3E;
86
87 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockivARB: */
88 int GL_UNIFORM_BLOCK_BINDING = 0x8A3F;
89 int GL_UNIFORM_BLOCK_DATA_SIZE = 0x8A40;
90 int GL_UNIFORM_BLOCK_NAME_LENGTH = 0x8A41;
91 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42;
92 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43;
93 int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44;
94 int GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45;
95 int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46;
96
97 /** Returned by GetActiveUniformsivARB and GetUniformBlockIndexARB */
98 int GL_INVALID_INDEX = 0xFFFFFFFF;
99
100 void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
101 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames,
102 @OutParameter @GLuint IntBuffer uniformIndices);
103
104 @Alternate(value = "glGetUniformIndices")
105 void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount,
106 @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames,
107 @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices);
108
109 @StripPostfix("params")
110 void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
111 @Const @GLuint IntBuffer uniformIndices,
112 @GLenum int pname,
113 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
114
115 @Alternate("glGetActiveUniformsiv")
116 @GLreturn("params")
117 @StripPostfix("params")
118 void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
119 @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer
120 @GLenum int pname,
121 @OutParameter @GLint IntBuffer params);
122
123 void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize,
124 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
125 @OutParameter @GLchar ByteBuffer uniformName);
126
127 @Alternate("glGetActiveUniformName")
128 @GLreturn(value = "uniformName", maxLength = "bufSize")
129 void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize,
130 @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length,
131 @OutParameter @GLchar ByteBuffer uniformName);
132
133 @GLuint
134 int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName);
135
136 @Alternate("glGetUniformBlockIndex")
137 @GLuint
138 int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName);
139
140 @StripPostfix("params")
141 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
142 @OutParameter @Check(value = "16") @GLint IntBuffer params);
143
144 @Alternate("glGetActiveUniformBlockiv")
145 @GLreturn("params")
146 @StripPostfix("params")
147 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
148 @OutParameter @GLint IntBuffer params);
149
150 void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize,
151 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
152 @OutParameter @GLchar ByteBuffer uniformBlockName);
153
154 @Alternate("glGetActiveUniformBlockName")
155 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
156 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
157 @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length,
158 @OutParameter @GLchar ByteBuffer uniformBlockName);
159
160 void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
161
162 void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer);
163
164 @StripPostfix(value = "data", extension = "")
165 void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
166
167 @Alternate("glGetIntegeri_v")
168 @GLreturn("data")
169 @StripPostfix("data")
170 void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
171
172 void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding);
173
174 }
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_vertex_array_bgra {
34
35 /**
36 * Accepted by the &lt;size&gt; parameter of ColorPointer,
37 * SecondaryColorPointer, and VertexAttribPointer:
38 */
39 int GL_BGRA = 0x80E1;
40
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface ARB_vertex_array_object {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
41 * GetFloatv, and GetDoublev:
42 */
43 int GL_VERTEX_ARRAY_BINDING = 0x85B5;
44
45 void glBindVertexArray(@GLuint int array);
46
47 void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
48
49 @Alternate("glDeleteVertexArrays")
50 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
51
52 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
53
54 @Alternate("glGenVertexArrays")
55 @GLreturn("arrays")
56 void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
57
58 boolean glIsVertexArray(@GLuint int array);
59
60 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_vertex_blend {
38
39 int GL_MAX_VERTEX_UNITS_ARB = 0x86A4;
40 int GL_ACTIVE_VERTEX_UNITS_ARB = 0x86A5;
41 int GL_WEIGHT_SUM_UNITY_ARB = 0x86A6;
42 int GL_VERTEX_BLEND_ARB = 0x86A7;
43 int GL_CURRENT_WEIGHT_ARB = 0x86A8;
44 int GL_WEIGHT_ARRAY_TYPE_ARB = 0x86A9;
45 int GL_WEIGHT_ARRAY_STRIDE_ARB = 0x86AA;
46 int GL_WEIGHT_ARRAY_SIZE_ARB = 0x86AB;
47 int GL_WEIGHT_ARRAY_POINTER_ARB = 0x86AC;
48 int GL_WEIGHT_ARRAY_ARB = 0x86AD;
49 int GL_MODELVIEW0_ARB = 0x1700;
50 int GL_MODELVIEW1_ARB = 0x850a;
51 int GL_MODELVIEW2_ARB = 0x8722;
52 int GL_MODELVIEW3_ARB = 0x8723;
53 int GL_MODELVIEW4_ARB = 0x8724;
54 int GL_MODELVIEW5_ARB = 0x8725;
55 int GL_MODELVIEW6_ARB = 0x8726;
56 int GL_MODELVIEW7_ARB = 0x8727;
57 int GL_MODELVIEW8_ARB = 0x8728;
58 int GL_MODELVIEW9_ARB = 0x8729;
59 int GL_MODELVIEW10_ARB = 0x872A;
60 int GL_MODELVIEW11_ARB = 0x872B;
61 int GL_MODELVIEW12_ARB = 0x872C;
62 int GL_MODELVIEW13_ARB = 0x872D;
63 int GL_MODELVIEW14_ARB = 0x872E;
64 int GL_MODELVIEW15_ARB = 0x872F;
65 int GL_MODELVIEW16_ARB = 0x8730;
66 int GL_MODELVIEW17_ARB = 0x8731;
67 int GL_MODELVIEW18_ARB = 0x8732;
68 int GL_MODELVIEW19_ARB = 0x8733;
69 int GL_MODELVIEW20_ARB = 0x8734;
70 int GL_MODELVIEW21_ARB = 0x8735;
71 int GL_MODELVIEW22_ARB = 0x8736;
72 int GL_MODELVIEW23_ARB = 0x8737;
73 int GL_MODELVIEW24_ARB = 0x8738;
74 int GL_MODELVIEW25_ARB = 0x8739;
75 int GL_MODELVIEW26_ARB = 0x873A;
76 int GL_MODELVIEW27_ARB = 0x873B;
77 int GL_MODELVIEW28_ARB = 0x873C;
78 int GL_MODELVIEW29_ARB = 0x873D;
79 int GL_MODELVIEW30_ARB = 0x873E;
80 int GL_MODELVIEW31_ARB = 0x873F;
81
82 @StripPostfix("pWeights")
83 void glWeightbvARB(@AutoSize("pWeights") int size, ByteBuffer pWeights);
84
85 @StripPostfix("pWeights")
86 void glWeightsvARB(@AutoSize("pWeights") int size, ShortBuffer pWeights);
87
88 @StripPostfix("pWeights")
89 void glWeightivARB(@AutoSize("pWeights") int size, IntBuffer pWeights);
90
91 @StripPostfix("pWeights")
92 void glWeightfvARB(@AutoSize("pWeights") int size, FloatBuffer pWeights);
93
94 @StripPostfix("pWeights")
95 void glWeightdvARB(@AutoSize("pWeights") int size, DoubleBuffer pWeights);
96
97 @StripPostfix("pWeights")
98 void glWeightubvARB(@AutoSize("pWeights") int size, @GLubyte ByteBuffer pWeights);
99
100 @StripPostfix("pWeights")
101 void glWeightusvARB(@AutoSize("pWeights") int size, @GLushort ShortBuffer pWeights);
102
103 @StripPostfix("pWeights")
104 void glWeightuivARB(@AutoSize("pWeights") int size, @GLuint IntBuffer pWeights);
105
106 void glWeightPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
107 @CachedReference
108 @BufferObject(BufferKind.ArrayVBO)
109 @Check
110 @Const
111 @GLbyte
112 @GLubyte
113 @GLshort
114 @GLushort
115 @GLint
116 @GLuint
117 @GLfloat
118 @GLdouble Buffer pPointer);
119
120 void glVertexBlendARB(int count);
121 }
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_vertex_buffer_object extends ARB_buffer_object {
34
35 /**
36 * Accepted by the &lt;target&gt; parameters of BindBufferARB, BufferDataARB,
37 * BufferSubDataARB, MapBufferARB, UnmapBufferARB,
38 * GetBufferSubDataARB, GetBufferParameterivARB, and
39 * GetBufferPointervARB:
40 */
41 int GL_ARRAY_BUFFER_ARB = 0x8892;
42 int GL_ELEMENT_ARRAY_BUFFER_ARB = 0x8893;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
46 * GetFloatv, and GetDoublev:
47 */
48 int GL_ARRAY_BUFFER_BINDING_ARB = 0x8894;
49 int GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB = 0x8895;
50 int GL_VERTEX_ARRAY_BUFFER_BINDING_ARB = 0x8896;
51 int GL_NORMAL_ARRAY_BUFFER_BINDING_ARB = 0x8897;
52 int GL_COLOR_ARRAY_BUFFER_BINDING_ARB = 0x8898;
53 int GL_INDEX_ARRAY_BUFFER_BINDING_ARB = 0x8899;
54 int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB = 0x889A;
55 int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB = 0x889B;
56 int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB = 0x889C;
57 int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB = 0x889D;
58 int GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB = 0x889E;
59
60 /**
61 * Accepted by the &lt;pname&gt; parameter of GetVertexAttribivARB:
62 */
63 int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB = 0x889F;
64 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_vertex_program extends ARB_program {
38
39 /**
40 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, by the
41 * &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev,
42 * and by the &lt;target&gt; parameter of ProgramStringARB, BindProgramARB,
43 * ProgramEnvParameter4[df][v]ARB, ProgramLocalParameter4[df][v]ARB,
44 * GetProgramEnvParameter[df]vARB, GetProgramLocalParameter[df]vARB,
45 * GetProgramivARB, and GetProgramStringARB.
46 */
47 int GL_VERTEX_PROGRAM_ARB = 0x8620;
48
49 /**
50 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and by
51 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
52 * GetDoublev:
53 */
54 int GL_VERTEX_PROGRAM_POINT_SIZE_ARB = 0x8642;
55 int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643;
56 int GL_COLOR_SUM_ARB = 0x8458;
57
58 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib[dfi]vARB: */
59 int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622;
60 int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623;
61 int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624;
62 int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625;
63 int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = 0x886A;
64 int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626;
65
66 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttribPointervARB: */
67 int GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = 0x8645;
68
69 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
70 int GL_PROGRAM_ADDRESS_REGISTERS_ARB = 0x88B0;
71 int GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB = 0x88B1;
72 int GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = 0x88B2;
73 int GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = 0x88B3;
74
75 /**
76 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
77 * GetFloatv, and GetDoublev:
78 */
79 int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869;
80
81 @NoErrorCheck
82 void glVertexAttrib1sARB(@GLuint int index, short x);
83
84 @NoErrorCheck
85 void glVertexAttrib1fARB(@GLuint int index, float x);
86
87 @NoErrorCheck
88 void glVertexAttrib1dARB(@GLuint int index, double x);
89
90 @NoErrorCheck
91 void glVertexAttrib2sARB(@GLuint int index, short x, short y);
92
93 @NoErrorCheck
94 void glVertexAttrib2fARB(@GLuint int index, float x, float y);
95
96 @NoErrorCheck
97 void glVertexAttrib2dARB(@GLuint int index, double x, double y);
98
99 @NoErrorCheck
100 void glVertexAttrib3sARB(@GLuint int index, short x, short y, short z);
101
102 @NoErrorCheck
103 void glVertexAttrib3fARB(@GLuint int index, float x, float y, float z);
104
105 @NoErrorCheck
106 void glVertexAttrib3dARB(@GLuint int index, double x, double y, double z);
107
108 @NoErrorCheck
109 void glVertexAttrib4sARB(@GLuint int index, short x, short y, short z, short w);
110
111 @NoErrorCheck
112 void glVertexAttrib4fARB(@GLuint int index, float x, float y, float z, float w);
113
114 @NoErrorCheck
115 void glVertexAttrib4dARB(@GLuint int index, double x, double y, double z, double w);
116
117 @NoErrorCheck
118 void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
119
120 void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
121 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
122 @BufferObject(BufferKind.ArrayVBO)
123 @Check
124 @Const
125 @GLbyte
126 @GLubyte
127 @GLshort
128 @GLushort
129 @GLint
130 @GLuint
131 @GLfloat
132 @GLdouble Buffer buffer);
133
134 void glEnableVertexAttribArrayARB(@GLuint int index);
135
136 void glDisableVertexAttribArrayARB(@GLuint int index);
137
138 @StripPostfix("params")
139 void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
140
141 @StripPostfix("params")
142 void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
143
144 @StripPostfix("params")
145 void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
146
147 @StripPostfix("result")
148 void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result);
149 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ARB_vertex_shader {
38
39 /**
40 * Accepted by the &lt;shaderType&gt; argument of CreateShaderObjectARB and
41 * returned by the &lt;params&gt; parameter of GetObjectParameter{if}vARB:
42 */
43 int GL_VERTEX_SHADER_ARB = 0x8B31;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
47 * GetFloatv, and GetDoublev:
48 */
49 int GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = 0x8B4A;
50 int GL_MAX_VARYING_FLOATS_ARB = 0x8B4B;
51 int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869;
52 int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872;
53 int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C;
54 int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB = 0x8B4D;
55 int GL_MAX_TEXTURE_COORDS_ARB = 0x8871;
56
57 /**
58 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and
59 * by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
60 * GetDoublev:
61 */
62 int GL_VERTEX_PROGRAM_POINT_SIZE_ARB = 0x8642;
63 int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643;
64
65 /** Accepted by the &lt;pname&gt; parameter GetObjectParameter{if}vARB: */
66 int GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = 0x8B89;
67 int GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB = 0x8B8A;
68
69 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib{dfi}vARB: */
70 int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622;
71 int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623;
72 int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624;
73 int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625;
74 int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = 0x886A;
75 int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626;
76
77 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttribPointervARB: */
78 int GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = 0x8645;
79
80 /** Returned by the &lt;type&gt; parameter of GetActiveAttribARB: */
81 int GL_FLOAT = 0x1406;
82 int GL_FLOAT_VEC2_ARB = 0x8B50;
83 int GL_FLOAT_VEC3_ARB = 0x8B51;
84 int GL_FLOAT_VEC4_ARB = 0x8B52;
85 int GL_FLOAT_MAT2_ARB = 0x8B5A;
86 int GL_FLOAT_MAT3_ARB = 0x8B5B;
87 int GL_FLOAT_MAT4_ARB = 0x8B5C;
88
89 @NoErrorCheck
90 void glVertexAttrib1sARB(@GLuint int index, short v0);
91
92 @NoErrorCheck
93 void glVertexAttrib1fARB(@GLuint int index, float v0);
94
95 @NoErrorCheck
96 void glVertexAttrib1dARB(@GLuint int index, double v0);
97
98 @NoErrorCheck
99 void glVertexAttrib2sARB(@GLuint int index, short v0, short v1);
100
101 @NoErrorCheck
102 void glVertexAttrib2fARB(@GLuint int index, float v0, float v1);
103
104 @NoErrorCheck
105 void glVertexAttrib2dARB(@GLuint int index, double v0, double v1);
106
107 @NoErrorCheck
108 void glVertexAttrib3sARB(@GLuint int index, short v0, short v1, short v2);
109
110 @NoErrorCheck
111 void glVertexAttrib3fARB(@GLuint int index, float v0, float v1, float v2);
112
113 @NoErrorCheck
114 void glVertexAttrib3dARB(@GLuint int index, double v0, double v1, double v2);
115
116 @NoErrorCheck
117 void glVertexAttrib4sARB(@GLuint int index, short v0, short v1, short v2, short v3);
118
119 @NoErrorCheck
120 void glVertexAttrib4fARB(@GLuint int index, float v0, float v1, float v2, float v3);
121
122 @NoErrorCheck
123 void glVertexAttrib4dARB(@GLuint int index, double v0, double v1, double v2, double v3);
124
125 @NoErrorCheck
126 void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
127
128 void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
129 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
130 @BufferObject(BufferKind.ArrayVBO)
131 @Check
132 @Const
133 @GLbyte
134 @GLubyte
135 @GLshort
136 @GLushort
137 @GLint
138 @GLuint
139 @GLfloat
140 @GLdouble Buffer buffer);
141
142 void glEnableVertexAttribArrayARB(@GLuint int index);
143
144 void glDisableVertexAttribArrayARB(@GLuint int index);
145
146 void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated @Const @GLcharARB ByteBuffer name);
147
148 @Alternate("glBindAttribLocationARB")
149 void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated CharSequence name);
150
151 void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength,
152 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
153 @OutParameter @Check("1") IntBuffer size,
154 @OutParameter @GLenum @Check("1") IntBuffer type,
155 @OutParameter @GLcharARB ByteBuffer name);
156
157 /** Overloads glGetActiveAttribARB. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
158 @Alternate("glGetActiveAttribARB")
159 @GLreturn(value = "name", maxLength = "maxLength")
160 void glGetActiveAttribARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
161 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
162 @OutParameter @Check("2") IntBuffer sizeType,
163 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
164 @OutParameter @GLcharARB ByteBuffer name);
165
166 /** Overloads glGetActiveAttribARB. This version returns only the attrib name. */
167 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
168 @GLreturn(value = "name", maxLength = "maxLength")
169 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,
171 @OutParameter @GLcharARB ByteBuffer name);
172
173 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
174 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
175 @GLreturn(value = "size")
176 void glGetActiveAttribSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
177 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
178 @OutParameter IntBuffer size,
179 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
180 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
181
182 /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */
183 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
184 @GLreturn(value = "type")
185 void glGetActiveAttribTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
186 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
187 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
188 @OutParameter @GLenum IntBuffer type,
189 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
190
191 int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
192
193 @Alternate("glGetAttribLocationARB")
194 int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name);
195
196 @StripPostfix("params")
197 void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
198
199 @StripPostfix("params")
200 void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
201
202 @StripPostfix("params")
203 void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
204
205 @StripPostfix("result")
206 void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result);
207
208 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 @Extension(postfix = "", className = "ARBVertexType2_10_10_10_REV")
38 public interface ARB_vertex_type_2_10_10_10_rev {
39
40 /**
41 * Accepted by the &lt;type&gt; parameter of VertexAttribPointer, VertexPointer,
42 * NormalPointer, ColorPointer, SecondaryColorPointer, TexCoordPointer,
43 * VertexAttribP{1234}ui, VertexP*, TexCoordP*, MultiTexCoordP*, NormalP3ui,
44 * ColorP*, SecondaryColorP* and VertexAttribP*
45 */
46 int GL_UNSIGNED_INT_2_10_10_10_REV = GL12.GL_UNSIGNED_INT_2_10_10_10_REV;
47 int GL_INT_2_10_10_10_REV = 0x8D9F;
48
49 @NoErrorCheck
50 void glVertexP2ui(@GLenum int type, @GLuint int value);
51
52 @NoErrorCheck
53 void glVertexP3ui(@GLenum int type, @GLuint int value);
54
55 @NoErrorCheck
56 void glVertexP4ui(@GLenum int type, @GLuint int value);
57
58 @NoErrorCheck
59 @StripPostfix("value")
60 void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value);
61
62 @NoErrorCheck
63 @StripPostfix("value")
64 void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value);
65
66 @NoErrorCheck
67 @StripPostfix("value")
68 void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value);
69
70 @NoErrorCheck
71 void glTexCoordP1ui(@GLenum int type, @GLuint int coords);
72
73 @NoErrorCheck
74 void glTexCoordP2ui(@GLenum int type, @GLuint int coords);
75
76 @NoErrorCheck
77 void glTexCoordP3ui(@GLenum int type, @GLuint int coords);
78
79 @NoErrorCheck
80 void glTexCoordP4ui(@GLenum int type, @GLuint int coords);
81
82 @NoErrorCheck
83 @StripPostfix("coords")
84 void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
85
86 @NoErrorCheck
87 @StripPostfix("coords")
88 void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
89
90 @NoErrorCheck
91 @StripPostfix("coords")
92 void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
93
94 @NoErrorCheck
95 @StripPostfix("coords")
96 void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
97
98 @NoErrorCheck
99 void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
100
101 @NoErrorCheck
102 void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
103
104 @NoErrorCheck
105 void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
106
107 @NoErrorCheck
108 void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
109
110 @NoErrorCheck
111 @StripPostfix("coords")
112 void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
113
114 @NoErrorCheck
115 @StripPostfix("coords")
116 void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
117
118 @NoErrorCheck
119 @StripPostfix("coords")
120 void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
121
122 @NoErrorCheck
123 @StripPostfix("coords")
124 void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
125
126 @NoErrorCheck
127 void glNormalP3ui(@GLenum int type, @GLuint int coords);
128
129 @NoErrorCheck
130 @StripPostfix("coords")
131 void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
132
133 @NoErrorCheck
134 void glColorP3ui(@GLenum int type, @GLuint int color);
135
136 @NoErrorCheck
137 void glColorP4ui(@GLenum int type, @GLuint int color);
138
139 @NoErrorCheck
140 @StripPostfix("color")
141 void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
142
143 @NoErrorCheck
144 @StripPostfix("color")
145 void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color);
146
147 @NoErrorCheck
148 void glSecondaryColorP3ui(@GLenum int type, @GLuint int color);
149
150 @NoErrorCheck
151 @StripPostfix("color")
152 void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
153
154 @NoErrorCheck
155 void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
156
157 @NoErrorCheck
158 void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
159
160 @NoErrorCheck
161 void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
162
163 @NoErrorCheck
164 void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
165
166 @NoErrorCheck
167 @StripPostfix("value")
168 void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value);
169
170 @NoErrorCheck
171 @StripPostfix("value")
172 void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value);
173
174 @NoErrorCheck
175 @StripPostfix("value")
176 void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value);
177
178 @NoErrorCheck
179 @StripPostfix("value")
180 void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value);
181
182 }
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.DeprecatedGL;
34
35 @DeprecatedGL
36 public interface ARB_window_pos {
37
38 @DeprecatedGL
39 void glWindowPos2fARB(float x, float y);
40
41 @DeprecatedGL
42 void glWindowPos2dARB(double x, double y);
43
44 @DeprecatedGL
45 void glWindowPos2iARB(int x, int y);
46
47 @DeprecatedGL
48 void glWindowPos2sARB(short x, short y);
49
50 @DeprecatedGL
51 void glWindowPos3fARB(float x, float y, float z);
52
53 @DeprecatedGL
54 void glWindowPos3dARB(double x, double y, double z);
55
56 @DeprecatedGL
57 void glWindowPos3iARB(int x, int y, int z);
58
59 @DeprecatedGL
60 void glWindowPos3sARB(short x, short y, short z);
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_draw_buffers {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
41 * and GetDoublev:
42 */
43 int GL_MAX_DRAW_BUFFERS_ATI = 0x8824;
44 int GL_DRAW_BUFFER0_ATI = 0x8825;
45 int GL_DRAW_BUFFER1_ATI = 0x8826;
46 int GL_DRAW_BUFFER2_ATI = 0x8827;
47 int GL_DRAW_BUFFER3_ATI = 0x8828;
48 int GL_DRAW_BUFFER4_ATI = 0x8829;
49 int GL_DRAW_BUFFER5_ATI = 0x882A;
50 int GL_DRAW_BUFFER6_ATI = 0x882B;
51 int GL_DRAW_BUFFER7_ATI = 0x882C;
52 int GL_DRAW_BUFFER8_ATI = 0x882D;
53 int GL_DRAW_BUFFER9_ATI = 0x882E;
54 int GL_DRAW_BUFFER10_ATI = 0x882F;
55 int GL_DRAW_BUFFER11_ATI = 0x8830;
56 int GL_DRAW_BUFFER12_ATI = 0x8831;
57 int GL_DRAW_BUFFER13_ATI = 0x8832;
58 int GL_DRAW_BUFFER14_ATI = 0x8833;
59 int GL_DRAW_BUFFER15_ATI = 0x8834;
60
61 void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
62
63 @Alternate("glDrawBuffersATI")
64 void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
65 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_element_array {
38 int GL_ELEMENT_ARRAY_ATI = 0x8768;
39 int GL_ELEMENT_ARRAY_TYPE_ATI = 0x8769;
40 int GL_ELEMENT_ARRAY_POINTER_ATI = 0x876A;
41
42 void glElementPointerATI(@AutoType("pPointer") @GLenum int type,
43 @Check
44 @Const
45 @GLubyte
46 @GLushort
47 @GLuint Buffer pPointer);
48
49 void glDrawElementArrayATI(@GLenum int mode, @GLsizei int count);
50
51 void glDrawRangeElementArrayATI(@GLenum int mode, @GLuint int start, @GLuint int end, @GLsizei int count);
52 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_envmap_bumpmap {
38 int GL_BUMP_ROT_MATRIX_ATI = 0x8775;
39 int GL_BUMP_ROT_MATRIX_SIZE_ATI = 0x8776;
40 int GL_BUMP_NUM_TEX_UNITS_ATI = 0x8777;
41 int GL_BUMP_TEX_UNITS_ATI = 0x8778;
42 int GL_DUDV_ATI = 0x8779;
43 int GL_DU8DV8_ATI = 0x877A;
44 int GL_BUMP_ENVMAP_ATI = 0x877B;
45 int GL_BUMP_TARGET_ATI = 0x877C;
46
47 @StripPostfix("param")
48 void glTexBumpParameterfvATI(@GLenum int pname, @Check("4") @Const FloatBuffer param);
49
50 @StripPostfix("param")
51 void glTexBumpParameterivATI(@GLenum int pname, @Check("4") @Const IntBuffer param);
52
53 @StripPostfix("param")
54 void glGetTexBumpParameterfvATI(@GLenum int pname, @OutParameter @Check("4") FloatBuffer param);
55
56 @StripPostfix("param")
57 void glGetTexBumpParameterivATI(@GLenum int pname, @OutParameter @Check("4") IntBuffer param);
58 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_fragment_shader {
38
39 int GL_FRAGMENT_SHADER_ATI = 0x8920;
40 int GL_REG_0_ATI = 0x8921;
41 int GL_REG_1_ATI = 0x8922;
42 int GL_REG_2_ATI = 0x8923;
43 int GL_REG_3_ATI = 0x8924;
44 int GL_REG_4_ATI = 0x8925;
45 int GL_REG_5_ATI = 0x8926;
46 int GL_REG_6_ATI = 0x8927;
47 int GL_REG_7_ATI = 0x8928;
48 int GL_REG_8_ATI = 0x8929;
49 int GL_REG_9_ATI = 0x892A;
50 int GL_REG_10_ATI = 0x892B;
51 int GL_REG_11_ATI = 0x892C;
52 int GL_REG_12_ATI = 0x892D;
53 int GL_REG_13_ATI = 0x892E;
54 int GL_REG_14_ATI = 0x892F;
55 int GL_REG_15_ATI = 0x8930;
56 int GL_REG_16_ATI = 0x8931;
57 int GL_REG_17_ATI = 0x8932;
58 int GL_REG_18_ATI = 0x8933;
59 int GL_REG_19_ATI = 0x8934;
60 int GL_REG_20_ATI = 0x8935;
61 int GL_REG_21_ATI = 0x8936;
62 int GL_REG_22_ATI = 0x8937;
63 int GL_REG_23_ATI = 0x8938;
64 int GL_REG_24_ATI = 0x8939;
65 int GL_REG_25_ATI = 0x893A;
66 int GL_REG_26_ATI = 0x893B;
67 int GL_REG_27_ATI = 0x893C;
68 int GL_REG_28_ATI = 0x893D;
69 int GL_REG_29_ATI = 0x893E;
70 int GL_REG_30_ATI = 0x893F;
71 int GL_REG_31_ATI = 0x8940;
72 int GL_CON_0_ATI = 0x8941;
73 int GL_CON_1_ATI = 0x8942;
74 int GL_CON_2_ATI = 0x8943;
75 int GL_CON_3_ATI = 0x8944;
76 int GL_CON_4_ATI = 0x8945;
77 int GL_CON_5_ATI = 0x8946;
78 int GL_CON_6_ATI = 0x8947;
79 int GL_CON_7_ATI = 0x8948;
80 int GL_CON_8_ATI = 0x8949;
81 int GL_CON_9_ATI = 0x894A;
82 int GL_CON_10_ATI = 0x894B;
83 int GL_CON_11_ATI = 0x894C;
84 int GL_CON_12_ATI = 0x894D;
85 int GL_CON_13_ATI = 0x894E;
86 int GL_CON_14_ATI = 0x894F;
87 int GL_CON_15_ATI = 0x8950;
88 int GL_CON_16_ATI = 0x8951;
89 int GL_CON_17_ATI = 0x8952;
90 int GL_CON_18_ATI = 0x8953;
91 int GL_CON_19_ATI = 0x8954;
92 int GL_CON_20_ATI = 0x8955;
93 int GL_CON_21_ATI = 0x8956;
94 int GL_CON_22_ATI = 0x8957;
95 int GL_CON_23_ATI = 0x8958;
96 int GL_CON_24_ATI = 0x8959;
97 int GL_CON_25_ATI = 0x895A;
98 int GL_CON_26_ATI = 0x895B;
99 int GL_CON_27_ATI = 0x895C;
100 int GL_CON_28_ATI = 0x895D;
101 int GL_CON_29_ATI = 0x895E;
102 int GL_CON_30_ATI = 0x895F;
103 int GL_CON_31_ATI = 0x8960;
104 int GL_MOV_ATI = 0x8961;
105 int GL_ADD_ATI = 0x8963;
106 int GL_MUL_ATI = 0x8964;
107 int GL_SUB_ATI = 0x8965;
108 int GL_DOT3_ATI = 0x8966;
109 int GL_DOT4_ATI = 0x8967;
110 int GL_MAD_ATI = 0x8968;
111 int GL_LERP_ATI = 0x8969;
112 int GL_CND_ATI = 0x896A;
113 int GL_CND0_ATI = 0x896B;
114 int GL_DOT2_ADD_ATI = 0x896C;
115 int GL_SECONDARY_INTERPOLATOR_ATI = 0x896D;
116 int GL_NUM_FRAGMENT_REGISTERS_ATI = 0x896E;
117 int GL_NUM_FRAGMENT_CONSTANTS_ATI = 0x896F;
118 int GL_NUM_PASSES_ATI = 0x8970;
119 int GL_NUM_INSTRUCTIONS_PER_PASS_ATI = 0x8971;
120 int GL_NUM_INSTRUCTIONS_TOTAL_ATI = 0x8972;
121 int GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI = 0x8973;
122 int GL_NUM_LOOPBACK_COMPONENTS_ATI = 0x8974;
123 int GL_COLOR_ALPHA_PAIRING_ATI = 0x8975;
124 int GL_SWIZZLE_STR_ATI = 0x8976;
125 int GL_SWIZZLE_STQ_ATI = 0x8977;
126 int GL_SWIZZLE_STR_DR_ATI = 0x8978;
127 int GL_SWIZZLE_STQ_DQ_ATI = 0x8979;
128 int GL_SWIZZLE_STRQ_ATI = 0x897A;
129 int GL_SWIZZLE_STRQ_DQ_ATI = 0x897B;
130 int GL_RED_BIT_ATI = 0x00000001;
131 int GL_GREEN_BIT_ATI = 0x00000002;
132 int GL_BLUE_BIT_ATI = 0x00000004;
133 int GL_2X_BIT_ATI = 0x00000001;
134 int GL_4X_BIT_ATI = 0x00000002;
135 int GL_8X_BIT_ATI = 0x00000004;
136 int GL_HALF_BIT_ATI = 0x00000008;
137 int GL_QUARTER_BIT_ATI = 0x00000010;
138 int GL_EIGHTH_BIT_ATI = 0x00000020;
139 int GL_SATURATE_BIT_ATI = 0x00000040;
140 int GL_COMP_BIT_ATI = 0x00000002;
141 int GL_NEGATE_BIT_ATI = 0x00000004;
142 int GL_BIAS_BIT_ATI = 0x00000008;
143
144 @GLuint
145 int glGenFragmentShadersATI(@GLuint int range);
146
147 void glBindFragmentShaderATI(@GLuint int id);
148
149 void glDeleteFragmentShaderATI(@GLuint int id);
150
151 void glBeginFragmentShaderATI();
152
153 void glEndFragmentShaderATI();
154
155 void glPassTexCoordATI(@GLuint int dst, @GLuint int coord, @GLenum int swizzle);
156
157 void glSampleMapATI(@GLuint int dst, @GLuint int interp, @GLenum int swizzle);
158
159 void glColorFragmentOp1ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod);
160
161 void glColorFragmentOp2ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod);
162
163 void glColorFragmentOp3ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod, @GLuint int arg3, @GLuint int arg3Rep, @GLuint int arg3Mod);
164
165 void glAlphaFragmentOp1ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod);
166
167 void glAlphaFragmentOp2ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod);
168
169 void glAlphaFragmentOp3ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod, @GLuint int arg3, @GLuint int arg3Rep, @GLuint int arg3Mod);
170
171 // TODO:is the @Check correct?
172 void glSetFragmentShaderConstantATI(@GLuint int dst, @Check("4") @Const FloatBuffer pfValue);
173 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_map_object_buffer {
38
39 /**
40 * glMapObjectBufferATI maps an ATI vertex array object to a ByteBuffer. The old_buffer argument can be null,
41 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
42 * it will be returned if it points to the same mapped memory and has the same capacity as the vertex array object,
43 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapObjectBufferATI like this:
44 * <p/>
45 * ByteBuffer mapped_buffer; mapped_buffer = glMapObjectBufferATI(..., null); ... // Another map on the same buffer mapped_buffer = glMapObjectBufferATI(..., mapped_buffer);
46 * <p/>
47 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
48 * <p/>
49 * The version of this method without an explicit length argument calls glGetObjectBufferATI internally to
50 * retrieve the current vertex array object size, which may cause a pipeline flush and reduce application performance.
51 * <p/>
52 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call
53 * is made to retrieve the vertex array object size, so the user is responsible for tracking and using the appropriate length.<br>
54 * Security warning: The length argument should match the vertex array object size. Reading from or writing to outside
55 * the memory region that corresponds to the mapped vertex array object will cause native crashes.
56 *
57 * @param length the length of the mapped memory in bytes.
58 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
59 *
60 * @return A ByteBuffer representing the mapped buffer memory.
61 */
62 @CachedResult
63 @GLvoid
64 @AutoResultSize("GLChecks.getBufferObjectSizeATI(caps, buffer)")
65 ByteBuffer glMapObjectBufferATI(@GLuint int buffer);
66
67 void glUnmapObjectBufferATI(@GLuint int buffer);
68
69 }
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 ATI_meminfo {
34
35 /** Accepted by the &lt;value&gt; parameter of GetIntegerv: */
36 int GL_VBO_FREE_MEMORY_ATI = 0x87FB;
37 int GL_TEXTURE_FREE_MEMORY_ATI = 0x87FC;
38 int GL_RENDERBUFFER_FREE_MEMORY_ATI = 0x87FD;
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface ATI_pn_triangles {
36 int GL_PN_TRIANGLES_ATI = 0x87F0;
37 int GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F1;
38 int GL_PN_TRIANGLES_POINT_MODE_ATI = 0x87F2;
39 int GL_PN_TRIANGLES_NORMAL_MODE_ATI = 0x87F3;
40 int GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F4;
41 int GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI = 0x87F5;
42 int GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI = 0x87F6;
43 int GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI = 0x87F7;
44 int GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI = 0x87F8;
45
46 void glPNTrianglesfATI(@GLenum int pname, float param);
47
48 void glPNTrianglesiATI(@GLenum int pname, int param);
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface ATI_separate_stencil {
36 int GL_STENCIL_BACK_FUNC_ATI = 0x8800;
37 int GL_STENCIL_BACK_FAIL_ATI = 0x8801;
38 int GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI = 0x8802;
39 int GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI = 0x8803;
40
41 void glStencilOpSeparateATI(@GLenum int face, @GLenum int sfail, @GLenum int dpfail, @GLenum int dppass);
42
43 void glStencilFuncSeparateATI(@GLenum int frontfunc, @GLenum int backfunc, int ref, @GLuint int mask);
44 }
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 ATI_shader_texture_lod {
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 ATI_text_fragment_shader {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled,
37 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
38 * and GetDoublev, and by the &lt;target&gt; parameter of ProgramStringARB,
39 * BindProgramARB, ProgramEnvParameter4{d,dv,f,fv}ARB,
40 * ProgramLocalParameter4{d,dv,f,fv}ARB,
41 * GetProgramEnvParameter{dv,fv}ARB, GetProgramLocalParameter{dv,fv}ARB,
42 * GetProgramivARB, GetProgramfvATI, and GetProgramStringARB.
43 */
44 int GL_TEXT_FRAGMENT_SHADER_ATI = 0x8200;
45
46 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @Extension(postfix = "ATI", className = "ATITextureCompression3DC")
36 public interface ATI_texture_compression_3dc {
37 int GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI = 0x8837;
38 }
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 ATI_texture_env_combine3 {
34
35 /**
36 * Accepted by the &lt;params&gt; parameter of TexEnvf, TexEnvi, TexEnvfv,
37 * and TexEnviv when the &lt;pname&gt; parameter value is COMBINE_RGB_ARB
38 * or COMBINE_ALPHA_ARB
39 */
40 int GL_MODULATE_ADD_ATI = 0x8744;
41 int GL_MODULATE_SIGNED_ADD_ATI = 0x8745;
42 int GL_MODULATE_SUBTRACT_ATI = 0x8746;
43
44 }
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 ATI_texture_float {
34
35 /**
36 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
37 * TexImage2D, and TexImage3D:
38 */
39 int GL_RGBA_FLOAT32_ATI = 0x8814;
40 int GL_RGB_FLOAT32_ATI = 0x8815;
41 int GL_ALPHA_FLOAT32_ATI = 0x8816;
42 int GL_INTENSITY_FLOAT32_ATI = 0x8817;
43 int GL_LUMINANCE_FLOAT32_ATI = 0x8818;
44 int GL_LUMINANCE_ALPHA_FLOAT32_ATI = 0x8819;
45 int GL_RGBA_FLOAT16_ATI = 0x881A;
46 int GL_RGB_FLOAT16_ATI = 0x881B;
47 int GL_ALPHA_FLOAT16_ATI = 0x881C;
48 int GL_INTENSITY_FLOAT16_ATI = 0x881D;
49 int GL_LUMINANCE_FLOAT16_ATI = 0x881E;
50 int GL_LUMINANCE_ALPHA_FLOAT16_ATI = 0x881F;
51 }
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 ATI_texture_mirror_once {
34 int GL_MIRROR_CLAMP_ATI = 0x8742;
35 int GL_MIRROR_CLAMP_TO_EDGE_ATI = 0x8743;
36 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_vertex_array_object {
38 int GL_STATIC_ATI = 0x8760;
39 int GL_DYNAMIC_ATI = 0x8761;
40 int GL_PRESERVE_ATI = 0x8762;
41 int GL_DISCARD_ATI = 0x8763;
42 int GL_OBJECT_BUFFER_SIZE_ATI = 0x8764;
43 int GL_OBJECT_BUFFER_USAGE_ATI = 0x8765;
44 int GL_ARRAY_OBJECT_BUFFER_ATI = 0x8766;
45 int GL_ARRAY_OBJECT_OFFSET_ATI = 0x8767;
46
47 @GenerateAutos
48 @GLuint
49 int glNewObjectBufferATI(@AutoSize("pPointer") @GLsizei int size,
50 @Const
51 @GLbyte
52 @GLshort
53 @GLint
54 @GLfloat
55 @GLdouble Buffer pPointer, @GLenum int usage);
56
57 boolean glIsObjectBufferATI(@GLuint int buffer);
58
59 void glUpdateObjectBufferATI(@GLuint int buffer, @GLuint int offset, @AutoSize("pPointer") @GLsizei int size,
60 @Const
61 @GLbyte
62 @GLshort
63 @GLint
64 @GLfloat
65 @GLdouble Buffer pPointer, @GLenum int preserve);
66
67 @StripPostfix("params")
68 void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check FloatBuffer params);
69
70 @StripPostfix("params")
71 void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params);
72
73 void glFreeObjectBufferATI(@GLuint int buffer);
74
75 void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset);
76
77 @StripPostfix("params")
78 void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
79
80 @StripPostfix("params")
81 void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
82
83 void glVariantArrayObjectATI(@GLuint int id, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset);
84
85 @StripPostfix("params")
86 void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
87
88 @StripPostfix("params")
89 void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
90 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface ATI_vertex_attrib_array_object {
38 void glVertexAttribArrayObjectATI(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLuint int buffer, @GLuint int offset);
39
40 @StripPostfix("params")
41 void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
42
43 @StripPostfix("params")
44 void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface ATI_vertex_streams {
36 int GL_MAX_VERTEX_STREAMS_ATI = 0x876B;
37 int GL_VERTEX_SOURCE_ATI = 0x876C;
38 int GL_VERTEX_STREAM0_ATI = 0x876D;
39 int GL_VERTEX_STREAM1_ATI = 0x876E;
40 int GL_VERTEX_STREAM2_ATI = 0x876F;
41 int GL_VERTEX_STREAM3_ATI = 0x8770;
42 int GL_VERTEX_STREAM4_ATI = 0x8771;
43 int GL_VERTEX_STREAM5_ATI = 0x8772;
44 int GL_VERTEX_STREAM6_ATI = 0x8773;
45 int GL_VERTEX_STREAM7_ATI = 0x8774;
46
47 @NoErrorCheck
48 void glVertexStream2fATI(@GLenum int stream, float x, float y);
49
50 @NoErrorCheck
51 void glVertexStream2dATI(@GLenum int stream, double x, double y);
52
53 @NoErrorCheck
54 void glVertexStream2iATI(@GLenum int stream, int x, int y);
55
56 @NoErrorCheck
57 void glVertexStream2sATI(@GLenum int stream, short x, short y);
58
59 @NoErrorCheck
60 void glVertexStream3fATI(@GLenum int stream, float x, float y, float z);
61
62 @NoErrorCheck
63 void glVertexStream3dATI(@GLenum int stream, double x, double y, double z);
64
65 @NoErrorCheck
66 void glVertexStream3iATI(@GLenum int stream, int x, int y, int z);
67
68 @NoErrorCheck
69 void glVertexStream3sATI(@GLenum int stream, short x, short y, short z);
70
71 @NoErrorCheck
72 void glVertexStream4fATI(@GLenum int stream, float x, float y, float z, float w);
73
74 @NoErrorCheck
75 void glVertexStream4dATI(@GLenum int stream, double x, double y, double z, double w);
76
77 @NoErrorCheck
78 void glVertexStream4iATI(@GLenum int stream, int x, int y, int z, int w);
79
80 @NoErrorCheck
81 void glVertexStream4sATI(@GLenum int stream, short x, short y, short z, short w);
82
83 @NoErrorCheck
84 void glNormalStream3bATI(@GLenum int stream, byte x, byte y, byte z);
85
86 @NoErrorCheck
87 void glNormalStream3fATI(@GLenum int stream, float x, float y, float z);
88
89 @NoErrorCheck
90 void glNormalStream3dATI(@GLenum int stream, double x, double y, double z);
91
92 @NoErrorCheck
93 void glNormalStream3iATI(@GLenum int stream, int x, int y, int z);
94
95 @NoErrorCheck
96 void glNormalStream3sATI(@GLenum int stream, short x, short y, short z);
97
98 void glClientActiveVertexStreamATI(@GLenum int stream);
99
100 void glVertexBlendEnvfATI(@GLenum int pname, float param);
101
102 void glVertexBlendEnviATI(@GLenum int pname, int param);
103 }
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 EXT_abgr {
34 int GL_ABGR_EXT = 0x8000;
35 }
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 EXT_bgra {
34 int GL_BGR_EXT = 0x80E0;
35 int GL_BGRA_EXT = 0x80E1;
36 }
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.GLintptr;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface EXT_bindable_uniform {
37
38 /**
39 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
40 * and GetDoublev:
41 */
42 int GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT = 0x8DE2;
43 int GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT = 0x8DE3;
44 int GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT = 0x8DE4;
45 int GL_MAX_BINDABLE_UNIFORM_SIZE_EXT = 0x8DED;
46 int GL_UNIFORM_BUFFER_BINDING_EXT = 0x8DEF;
47
48 /**
49 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
50 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
51 * GetBufferPointerv:
52 */
53 int GL_UNIFORM_BUFFER_EXT = 0x8DEE;
54
55 void glUniformBufferEXT(@GLuint int program, int location, @GLuint int buffer);
56
57 int glGetUniformBufferSizeEXT(@GLuint int program, int location);
58
59 @GLintptr
60 long glGetUniformOffsetEXT(@GLuint int program, int location);
61
62 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_blend_color {
36
37 /** Accepted by the &lt;sfactor&gt; and &lt;dfactor&gt; parameters of BlendFunc. */
38 int GL_CONSTANT_COLOR_EXT = 0x8001;
39 int GL_ONE_MINUS_CONSTANT_COLOR_EXT = 0x8002;
40 int GL_CONSTANT_ALPHA_EXT = 0x8003;
41 int GL_ONE_MINUS_CONSTANT_ALPHA_EXT = 0x8004;
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
45 * GetFloatv, and GetDoublev.
46 */
47 int GL_BLEND_COLOR_EXT = 0x8005;
48
49 void glBlendColorEXT(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
50
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_blend_equation_separate {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
39 * GetFloatv, and GetDoublev:
40 */
41 int GL_BLEND_EQUATION_RGB_EXT = 0x8009;
42 int GL_BLEND_EQUATION_ALPHA_EXT = 0x883D;
43
44 void glBlendEquationSeparateEXT(@GLenum int modeRGB, @GLenum int modeAlpha);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_blend_func_separate {
36 int GL_BLEND_DST_RGB_EXT = 0x80C8;
37 int GL_BLEND_SRC_RGB_EXT = 0x80C9;
38 int GL_BLEND_DST_ALPHA_EXT = 0x80CA;
39 int GL_BLEND_SRC_ALPHA_EXT = 0x80CB;
40
41 void glBlendFuncSeparateEXT(@GLenum int sfactorRGB, @GLenum int dfactorRGB, @GLenum int sfactorAlpha, @GLenum int dfactorAlpha);
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_blend_minmax {
36
37 /** Accepted by the &lt;mode&gt; parameter of BlendEquationEXT. */
38 int GL_FUNC_ADD_EXT = 0x8006;
39 int GL_MIN_EXT = 0x8007;
40 int GL_MAX_EXT = 0x8008;
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
44 * GetFloatv, and GetDoublev.
45 */
46 int GL_BLEND_EQUATION_EXT = 0x8009;
47
48 void glBlendEquationEXT(@GLenum int mode);
49
50 }
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 EXT_blend_subtract {
34 int GL_FUNC_SUBTRACT_EXT = 0x800A;
35 int GL_FUNC_REVERSE_SUBTRACT_EXT = 0x800B;
36 }
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 EXT_Cg_shader {
34
35 /**
36 * You can pass GL_CG_VERTEX_SHADER_EXT to glCreateShaderARB instead of GL_VERTEX_SHADER_ARB to create a vertex shader object
37 * that will parse and compile its shader source with the Cg compiler front-end rather than the GLSL front-end. Likewise, you
38 * can pass GL_CG_FRAGMENT_SHADER_EXT to glCreateShaderARB instead of GL_FRAGMENT_SHADER_ARB to create a fragment shader object
39 * that will parse and compile its shader source with the Cg front-end rather than the GLSL front-end.
40 */
41 int GL_CG_VERTEX_SHADER_EXT = 0x890E;
42 int GL_CG_FRAGMENT_SHADER_EXT = 0x890F;
43 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_compiled_vertex_array {
36 int GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = 0x81A8;
37 int GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = 0x81A9;
38
39 void glLockArraysEXT(int first, @GLsizei int count);
40
41 void glUnlockArraysEXT();
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_depth_bounds_test {
36
37 /**
38 Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
39 and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
40 GetFloatv, and GetDoublev:
41 */
42 int GL_DEPTH_BOUNDS_TEST_EXT = 0x8890;
43
44 /**
45 Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
46 GetFloatv, and GetDoublev:
47 */
48 int GL_DEPTH_BOUNDS_EXT = 0x8891;
49
50 void glDepthBoundsEXT(@GLclampd double zmin, @GLclampd double zmax);
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 @ForceInit
38 @Dependent
39 @DeprecatedGL
40 public interface EXT_direct_state_access {
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetBooleanIndexedvEXT,
44 * GetIntegerIndexedvEXT, GetFloatIndexedvEXT, GetDoubleIndexedvEXT:
45 * GetBooleani_v, GetIntegeri_v, GetFloati_vEXT, GetDoublei_vEXT:
46 */
47 int GL_PROGRAM_MATRIX_EXT = 0x8E2D;
48 int GL_TRANSPOSE_PROGRAM_MATRIX_EXT = 0x8E2E;
49 int GL_PROGRAM_MATRIX_STACK_DEPTH_EXT = 0x8E2F;
50
51 /*
52 OpenGL 1.1: New client commands
53 */
54
55 @DeprecatedGL
56 void glClientAttribDefaultEXT(@GLbitfield int mask);
57
58 @DeprecatedGL
59 void glPushClientAttribDefaultEXT(@GLbitfield int mask);
60
61 /*
62 OpenGL 1.0: New matrix commands add "Matrix" prefix to name,
63 drops "Matrix" suffix from name, and add initial "enum matrixMode"
64 parameter
65 */
66
67 @StripPostfix("m")
68 @DeprecatedGL
69 void glMatrixLoadfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m);
70
71 @StripPostfix("m")
72 @DeprecatedGL
73 void glMatrixLoaddEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m);
74
75 @StripPostfix("m")
76 @DeprecatedGL
77 void glMatrixMultfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m);
78
79 @StripPostfix("m")
80 @DeprecatedGL
81 void glMatrixMultdEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m);
82
83 @DeprecatedGL
84 void glMatrixLoadIdentityEXT(@GLenum int matrixMode);
85
86 @DeprecatedGL
87 void glMatrixRotatefEXT(@GLenum int matrixMode, float angle, float x, float y, float z);
88
89 @DeprecatedGL
90 void glMatrixRotatedEXT(@GLenum int matrixMode, double angle, double x, double y, double z);
91
92 @DeprecatedGL
93 void glMatrixScalefEXT(@GLenum int matrixMode, float x, float y, float z);
94
95 @DeprecatedGL
96 void glMatrixScaledEXT(@GLenum int matrixMode, double x, double y, double z);
97
98 @DeprecatedGL
99 void glMatrixTranslatefEXT(@GLenum int matrixMode, float x, float y, float z);
100
101 @DeprecatedGL
102 void glMatrixTranslatedEXT(@GLenum int matrixMode, double x, double y, double z);
103
104 @DeprecatedGL
105 void glMatrixOrthoEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f);
106
107 @DeprecatedGL
108 void glMatrixFrustumEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f);
109
110 @DeprecatedGL
111 void glMatrixPushEXT(@GLenum int matrixMode);
112
113 @DeprecatedGL
114 void glMatrixPopEXT(@GLenum int matrixMode);
115
116 /*
117 OpenGL 1.1: New texture object commands and queries replace "Tex"
118 in name with "Texture" and add initial "uint texture" parameter
119 */
120
121 void glTextureParameteriEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, int param);
122
123 @StripPostfix("param")
124 void glTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param);
125
126 void glTextureParameterfEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, float param);
127
128 @StripPostfix("param")
129 void glTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param);
130
131 void glTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level,
132 int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type,
133 @BufferObject(BufferKind.UnpackPBO)
134 @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true)
135 @Const
136 @GLbyte
137 @GLshort
138 @GLint
139 @GLfloat
140 @GLdouble Buffer pixels);
141
142 void glTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level,
143 int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type,
144 @BufferObject(BufferKind.UnpackPBO)
145 @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true)
146 @Const
147 @GLbyte
148 @GLshort
149 @GLint
150 @GLfloat
151 @GLdouble Buffer pixels);
152
153 void glTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level,
154 int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type,
155 @BufferObject(BufferKind.UnpackPBO)
156 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)")
157 @Const
158 @GLbyte
159 @GLshort
160 @GLint
161 @GLfloat
162 @GLdouble Buffer pixels);
163
164 void glTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level,
165 int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
166 @BufferObject(BufferKind.UnpackPBO)
167 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
168 @Const
169 @GLbyte
170 @GLshort
171 @GLint
172 @GLfloat
173 @GLdouble Buffer pixels);
174
175 void glCopyTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border);
176
177 void glCopyTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border);
178
179 void glCopyTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width);
180
181 void glCopyTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height);
182
183 void glGetTextureImageEXT(@GLuint int texture, @GLenum int target, int level,
184 @GLenum int format, @GLenum int type,
185 @OutParameter
186 @BufferObject(BufferKind.PackPBO)
187 @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)")
188 @GLbyte
189 @GLshort
190 @GLint
191 @GLfloat
192 @GLdouble Buffer pixels);
193
194 @StripPostfix("params")
195 void glGetTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
196
197 @Alternate("glGetTextureParameterfvEXT")
198 @GLreturn("params")
199 @StripPostfix(value = "params", postfix = "v")
200 void glGetTextureParameterfvEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
201
202 @StripPostfix("params")
203 void glGetTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
204
205 @Alternate("glGetTextureParameterivEXT")
206 @GLreturn("params")
207 @StripPostfix(value = "params", postfix = "v")
208 void glGetTextureParameterivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
209
210 @StripPostfix("params")
211 void glGetTextureLevelParameterfvEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
212
213 @Alternate("glGetTextureLevelParameterfvEXT")
214 @GLreturn("params")
215 @StripPostfix(value = "params", postfix = "v")
216 void glGetTextureLevelParameterfvEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
217
218 @StripPostfix("params")
219 void glGetTextureLevelParameterivEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
220
221 @Alternate("glGetTextureLevelParameterivEXT")
222 @GLreturn("params")
223 @StripPostfix(value = "params", postfix = "v")
224 void glGetTextureLevelParameterivEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
225
226 /*
227 OpenGL 1.2: New 3D texture object commands replace "Tex" in name with
228 "Texture" and adds initial "uint texture" parameter
229 */
230
231 @Dependent("OpenGL12")
232 void glTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level,
233 int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type,
234 @BufferObject(BufferKind.UnpackPBO)
235 @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true)
236 @Const
237 @GLbyte
238 @GLshort
239 @GLint
240 @GLfloat
241 @GLdouble Buffer pixels);
242
243 @Dependent("OpenGL12")
244 void glTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level,
245 int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type,
246 @BufferObject(BufferKind.UnpackPBO)
247 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
248 @Const
249 @GLbyte
250 @GLshort
251 @GLint
252 @GLfloat
253 @GLdouble Buffer pixels);
254
255 @Dependent("OpenGL12")
256 void glCopyTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level,
257 int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
258
259 /*
260 OpenGL 1.2.1: New multitexture commands and queries prefix "Multi"
261 before "Tex" and add an initial "enum texunit" parameter (to identify
262 the texture unit
263 */
264
265 @Dependent("OpenGL13")
266 void glBindMultiTextureEXT(@GLenum int texunit, @GLenum int target, @GLuint int texture);
267
268 @Dependent("OpenGL13")
269 @DeprecatedGL
270 void glMultiTexCoordPointerEXT(@GLenum int texunit, int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
271 @BufferObject(BufferKind.ArrayVBO)
272 @Check
273 @Const
274 @GLfloat
275 @GLdouble
276 Buffer pointer);
277
278 @Dependent("OpenGL13")
279 @DeprecatedGL
280 void glMultiTexEnvfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param);
281
282 @Dependent("OpenGL13")
283 @StripPostfix("params")
284 @DeprecatedGL
285 void glMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params);
286
287 @Dependent("OpenGL13")
288 @DeprecatedGL
289 void glMultiTexEnviEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param);
290
291 @Dependent("OpenGL13")
292 @StripPostfix("params")
293 @DeprecatedGL
294 void glMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
295
296 @Dependent("OpenGL13")
297 @DeprecatedGL
298 void glMultiTexGendEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, double param);
299
300 @Dependent("OpenGL13")
301 @StripPostfix("params")
302 @DeprecatedGL
303 void glMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params);
304
305 @Dependent("OpenGL13")
306 @DeprecatedGL
307 void glMultiTexGenfEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, float param);
308
309 @Dependent("OpenGL13")
310 @StripPostfix("params")
311 @DeprecatedGL
312 void glMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params);
313
314 @Dependent("OpenGL13")
315 @DeprecatedGL
316 void glMultiTexGeniEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, int param);
317
318 @Dependent("OpenGL13")
319 @StripPostfix("params")
320 @DeprecatedGL
321 void glMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params);
322
323 @Dependent("OpenGL13")
324 @StripPostfix("params")
325 @DeprecatedGL
326 void glGetMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
327
328 @Dependent("OpenGL13")
329 @StripPostfix("params")
330 @DeprecatedGL
331 void glGetMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
332
333 @Dependent("OpenGL13")
334 @StripPostfix("params")
335 @DeprecatedGL
336 void glGetMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter DoubleBuffer params);
337
338 @Dependent("OpenGL13")
339 @StripPostfix("params")
340 @DeprecatedGL
341 void glGetMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
342
343 @Dependent("OpenGL13")
344 @StripPostfix("params")
345 @DeprecatedGL
346 void glGetMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
347
348 @Dependent("OpenGL13")
349 void glMultiTexParameteriEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param);
350
351 @Dependent("OpenGL13")
352 @StripPostfix("param")
353 void glMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param);
354
355 @Dependent("OpenGL13")
356 void glMultiTexParameterfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param);
357
358 @Dependent("OpenGL13")
359 @StripPostfix("param")
360 void glMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param);
361
362 @Dependent("OpenGL13")
363 void glMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level,
364 int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type,
365 @BufferObject(BufferKind.UnpackPBO)
366 @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true)
367 @Const
368 @GLbyte
369 @GLshort
370 @GLint
371 @GLfloat
372 @GLdouble Buffer pixels);
373
374 @Dependent("OpenGL13")
375 void glMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level,
376 int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type,
377 @BufferObject(BufferKind.UnpackPBO)
378 @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true)
379 @Const
380 @GLbyte
381 @GLshort
382 @GLint
383 @GLfloat
384 @GLdouble Buffer pixels);
385
386 @Dependent("OpenGL13")
387 void glMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level,
388 int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type,
389 @BufferObject(BufferKind.UnpackPBO)
390 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)")
391 @Const
392 @GLbyte
393 @GLshort
394 @GLint
395 @GLfloat
396 @GLdouble Buffer pixels);
397
398 @Dependent("OpenGL13")
399 void glMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level,
400 int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
401 @BufferObject(BufferKind.UnpackPBO)
402 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
403 @Const
404 @GLbyte
405 @GLshort
406 @GLint
407 @GLfloat
408 @GLdouble Buffer pixels);
409
410 @Dependent("OpenGL13")
411 void glCopyMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border);
412
413 @Dependent("OpenGL13")
414 void glCopyMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border);
415
416 @Dependent("OpenGL13")
417 void glCopyMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width);
418
419 @Dependent("OpenGL13")
420 void glCopyMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height);
421
422 @Dependent("OpenGL13")
423 void glGetMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int format, @GLenum int type,
424 @OutParameter
425 @BufferObject(BufferKind.PackPBO)
426 @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)")
427 @GLbyte
428 @GLshort
429 @GLint
430 @GLfloat
431 @GLdouble Buffer pixels);
432
433 @Dependent("OpenGL13")
434 @StripPostfix("params")
435 void glGetMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
436
437 @Alternate("glGetMultiTexParameterfvEXT")
438 @GLreturn("params")
439 @StripPostfix(value = "params", postfix = "v")
440 void glGetMultiTexParameterfvEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
441
442 @Dependent("OpenGL13")
443 @StripPostfix("params")
444 void glGetMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
445
446 @Alternate("glGetMultiTexParameterivEXT")
447 @GLreturn("params")
448 @Dependent("OpenGL13")
449 @StripPostfix(value = "params", postfix = "v")
450 void glGetMultiTexParameterivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
451
452 @Dependent("OpenGL13")
453 @StripPostfix("params")
454 void glGetMultiTexLevelParameterfvEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
455
456 @Alternate("glGetMultiTexLevelParameterfvEXT")
457 @GLreturn("params")
458 @Dependent("OpenGL13")
459 @StripPostfix(value = "params", postfix = "v")
460 void glGetMultiTexLevelParameterfvEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
461
462 @Dependent("OpenGL13")
463 @StripPostfix("params")
464 void glGetMultiTexLevelParameterivEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
465
466 @Alternate("glGetMultiTexLevelParameterivEXT")
467 @GLreturn("params")
468 @Dependent("OpenGL13")
469 @StripPostfix(value = "params", postfix = "v")
470 void glGetMultiTexLevelParameterivEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
471
472 @Dependent("OpenGL13")
473 void glMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level,
474 int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type,
475 @BufferObject(BufferKind.UnpackPBO)
476 @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true)
477 @Const
478 @GLbyte
479 @GLshort
480 @GLint
481 @GLfloat
482 @GLdouble Buffer pixels);
483
484 @Dependent("OpenGL13")
485 void glMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level,
486 int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type,
487 @BufferObject(BufferKind.UnpackPBO)
488 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
489 @Const
490 @GLbyte
491 @GLshort
492 @GLint
493 @GLfloat
494 @GLdouble Buffer pixels);
495
496 @Dependent("OpenGL13")
497 void glCopyMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
498
499 /*
500 OpenGL 1.2.1: New indexed texture commands and queries append
501 "Indexed" to name and add "uint index" parameter (to identify the
502 texture unit index) after state name parameters (if any) and before
503 state value parameters
504 */
505
506 @Dependent("OpenGL13")
507 @DeprecatedGL
508 void glEnableClientStateIndexedEXT(@GLenum int array, @GLuint int index);
509
510 @Dependent("OpenGL13")
511 @DeprecatedGL
512 void glDisableClientStateIndexedEXT(@GLenum int array, @GLuint int index);
513
514 /*
515 OpenGL 3.0: New indexed texture commands and queries append "i"
516 to name and add "uint index" parameter (to identify the texture
517 unit index) after state name parameters (if any) and before state
518 value parameters
519 */
520
521 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
522 @Dependent("OpenGL30")
523 void glEnableClientStateiEXT(@GLenum int array, @GLuint int index);
524
525 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
526 @Dependent("OpenGL30")
527 void glDisableClientStateiEXT(@GLenum int array, @GLuint int index);
528
529 /*
530 OpenGL 1.2.1: New indexed generic queries (added for indexed texture
531 state) append "Indexed" to name and add "uint index" parameter
532 (to identify the texture unit) after state name parameters (if any)
533 and before state value parameters
534 */
535
536 @Dependent("OpenGL13")
537 @StripPostfix("params")
538 void glGetFloatIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
539
540 @Alternate("glGetFloatIndexedvEXT")
541 @GLreturn("params")
542 @Dependent("OpenGL13")
543 @StripPostfix("params")
544 void glGetFloatIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
545
546 @Dependent("OpenGL13")
547 @StripPostfix(value = "params", hasPostfix = false)
548 void glGetDoubleIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
549
550 @Alternate("glGetDoubleIndexedvEXT")
551 @GLreturn("params")
552 @Dependent("OpenGL13")
553 @StripPostfix(value = "params", hasPostfix = false)
554 void glGetDoubleIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
555
556 @Dependent("OpenGL13")
557 @StripPostfix("params")
558 void glGetPointerIndexedvEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
559
560 /*
561 OpenGL 3.0: New indexed generic queries (added for indexed texture
562 state) replace "v" for "i_v" to name and add "uint index" parameter
563 (to identify the texture unit) after state name parameters (if any)
564 and before state value parameters
565 */
566
567 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
568 @Dependent("OpenGL30")
569 @StripPostfix("params")
570 void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
571
572 @Alternate("glGetFloati_vEXT")
573 @GLreturn("params")
574 @Dependent("OpenGL30")
575 @StripPostfix("params")
576 void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
577
578 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
579 @Dependent("OpenGL30")
580 @StripPostfix("params")
581 void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
582
583 @Alternate("glGetDoublei_vEXT")
584 @GLreturn("params")
585 @Dependent("OpenGL30")
586 @StripPostfix("params")
587 void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
588
589 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
590 @Dependent("OpenGL30")
591 @StripPostfix(value = "params", hasPostfix = false)
592 void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
593
594 /*
595 OpenGL 1.2.1: Extend the functionality of these EXT_draw_buffers2
596 commands and queries for multitexture
597 TODO: Why 1.2.1 and not EXT_draw_buffers2?
598 */
599
600 @Dependent("GL_EXT_draw_buffers2")
601 void glEnableIndexedEXT(@GLenum int cap, @GLuint int index);
602
603 @Dependent("GL_EXT_draw_buffers2")
604 void glDisableIndexedEXT(@GLenum int cap, @GLuint int index);
605
606 @Dependent("GL_EXT_draw_buffers2")
607 boolean glIsEnabledIndexedEXT(@GLenum int cap, @GLuint int index);
608
609 @Dependent("GL_EXT_draw_buffers2")
610 @StripPostfix("params")
611 void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer params);
612
613 @Alternate("glGetIntegerIndexedvEXT")
614 @GLreturn("params")
615 @Dependent("GL_EXT_draw_buffers2")
616 @StripPostfix("params")
617 void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer params);
618
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
623 @Alternate("glGetBooleanIndexedvEXT")
624 @GLreturn("params")
625 @Dependent("GL_EXT_draw_buffers2")
626 @StripPostfix("params")
627 void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer params);
628
629 /*
630 ARB_vertex_program: New program commands and queries add "Named"
631 prefix to name and adds initial "uint program" parameter
632 */
633
634 @Dependent("GL_ARB_vertex_program")
635 void glNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int format, @AutoSize("string") @GLsizei int len, @Const @GLvoid Buffer string);
636
637 @Alternate("glNamedProgramStringEXT")
638 @Dependent("GL_ARB_vertex_program")
639 void glNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int format, @Constant("string.length()") @GLsizei int length, CharSequence string);
640
641 @Dependent("GL_ARB_vertex_program")
642 void glNamedProgramLocalParameter4dEXT(@GLuint int program, @GLenum int target, @GLuint int index, double x, double y, double z, double w);
643
644 @Dependent("GL_ARB_vertex_program")
645 @StripPostfix("params")
646 void glNamedProgramLocalParameter4dvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4") DoubleBuffer params);
647
648 @Dependent("GL_ARB_vertex_program")
649 void glNamedProgramLocalParameter4fEXT(@GLuint int program, @GLenum int target, @GLuint int index, float x, float y, float z, float w);
650
651 @Dependent("GL_ARB_vertex_program")
652 @StripPostfix("params")
653 void glNamedProgramLocalParameter4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4") FloatBuffer params);
654
655 @Dependent("GL_ARB_vertex_program")
656 @StripPostfix("params")
657 void glGetNamedProgramLocalParameterdvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params);
658
659 @Dependent("GL_ARB_vertex_program")
660 @StripPostfix("params")
661 void glGetNamedProgramLocalParameterfvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params);
662
663 @Dependent("GL_ARB_vertex_program")
664 @StripPostfix("params")
665 void glGetNamedProgramivEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
666
667 @Alternate("glGetNamedProgramivEXT")
668 @GLreturn("params")
669 @Dependent("GL_ARB_vertex_program")
670 @StripPostfix("params")
671 void glGetNamedProgramivEXT2(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
672
673 @Dependent("GL_ARB_vertex_program")
674 void glGetNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check @GLvoid ByteBuffer string);
675
676 @Alternate("glGetNamedProgramStringEXT")
677 @Code("\t\tint programLength = glGetNamedProgramEXT(program, target, ARBProgram.GL_PROGRAM_LENGTH_ARB);")
678 @GLreturn(value = "paramString", maxLength = "programLength", forceMaxLength = true)
679 void glGetNamedProgramStringEXT2(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @GLchar ByteBuffer paramString);
680
681 /*
682 OpenGL 1.3: New compressed texture object commands replace "Tex"
683 in name with "Texture" and add initial "uint texture" parameter
684 */
685
686 @Dependent("OpenGL13")
687 void glCompressedTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level,
688 @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize,
689 @BufferObject(BufferKind.UnpackPBO)
690 @Check
691 @Const
692 @GLvoid
693 ByteBuffer data);
694
695 @Dependent("OpenGL13")
696 void glCompressedTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level,
697 @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize,
698 @BufferObject(BufferKind.UnpackPBO)
699 @Check
700 @Const
701 @GLvoid
702 ByteBuffer data);
703
704 @Dependent("OpenGL13")
705 void glCompressedTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level,
706 @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize,
707 @BufferObject(BufferKind.UnpackPBO)
708 @Check
709 @Const
710 @GLvoid
711 ByteBuffer data);
712
713 @Dependent("OpenGL13")
714 void glCompressedTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level,
715 int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth,
716 @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
717 @BufferObject(BufferKind.UnpackPBO)
718 @Check
719 @Const
720 @GLvoid
721 ByteBuffer data);
722
723 @Dependent("OpenGL13")
724 void glCompressedTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level,
725 int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
726 @BufferObject(BufferKind.UnpackPBO)
727 @Check
728 @Const
729 @GLvoid
730 ByteBuffer data);
731
732 @Dependent("OpenGL13")
733 void glCompressedTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level,
734 int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
735 @BufferObject(BufferKind.UnpackPBO)
736 @Check
737 @Const
738 @GLvoid
739 ByteBuffer data);
740
741 @Dependent("OpenGL13")
742 void glGetCompressedTextureImageEXT(@GLuint int texture, @GLenum int target, int level,
743 @OutParameter
744 @BufferObject(BufferKind.PackPBO)
745 @Check
746 @GLbyte
747 @GLshort
748 @GLint Buffer img);
749
750 /*
751 OpenGL 1.3: New multitexture compressed texture commands and queries
752 prefix "Multi" before "Tex" and add an initial "enum texunit"
753 parameter (to identify the texture unit)
754 */
755
756 @Dependent("OpenGL13")
757 void glCompressedMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level,
758 @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize,
759 @BufferObject(BufferKind.UnpackPBO)
760 @Check
761 @Const
762 @GLvoid
763 ByteBuffer data);
764
765 @Dependent("OpenGL13")
766 void glCompressedMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level,
767 @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize,
768 @BufferObject(BufferKind.UnpackPBO)
769 @Check
770 @Const
771 @GLvoid
772 ByteBuffer data);
773
774 @Dependent("OpenGL13")
775 void glCompressedMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level,
776 @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize,
777 @BufferObject(BufferKind.UnpackPBO)
778 @Check
779 @Const
780 @GLvoid
781 ByteBuffer data);
782
783 @Dependent("OpenGL13")
784 void glCompressedMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level,
785 int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth,
786 @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
787 @BufferObject(BufferKind.UnpackPBO)
788 @Check
789 @Const
790 @GLvoid
791 ByteBuffer data);
792
793 @Dependent("OpenGL13")
794 void glCompressedMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level,
795 int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
796 @BufferObject(BufferKind.UnpackPBO)
797 @Check
798 @Const
799 @GLvoid
800 ByteBuffer data);
801
802 @Dependent("OpenGL13")
803 void glCompressedMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level,
804 int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
805 @BufferObject(BufferKind.UnpackPBO)
806 @Check
807 @Const
808 @GLvoid
809 ByteBuffer data);
810
811 @Dependent("OpenGL13")
812 void glGetCompressedMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level,
813 @OutParameter
814 @BufferObject(BufferKind.PackPBO)
815 @Check
816 @GLbyte
817 @GLshort
818 @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);
828
829 /*
830 OpenGL 1.3: New transpose matrix commands add "Matrix" suffix
831 to name, drops "Matrix" suffix from name, and add initial "enum
832 matrixMode" parameter
833 */
834
835 @Dependent("OpenGL13")
836 @StripPostfix("m")
837 @DeprecatedGL
838 void glMatrixLoadTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m);
839
840 @Dependent("OpenGL13")
841 @StripPostfix("m")
842 @DeprecatedGL
843 void glMatrixLoadTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m);
844
845 @Dependent("OpenGL13")
846 @StripPostfix("m")
847 @DeprecatedGL
848 void glMatrixMultTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m);
849
850 @Dependent("OpenGL13")
851 @StripPostfix("m")
852 @DeprecatedGL
853 void glMatrixMultTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m);
854
855 /*
856 OpenGL 1.5: New buffer commands and queries replace "Buffer" with
857 "NamedBuffer" in name and replace "enum target" parameter with
858 "uint buffer"
859 */
860
861 @Dependent("OpenGL15")
862 @GenerateAutos
863 void glNamedBufferDataEXT(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
864 @Const
865 @GLbyte
866 @GLshort
867 @GLint
868 @GLfloat
869 @GLdouble Buffer data, @GLenum int usage);
870
871 @Dependent("OpenGL15")
872 void glNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
873 @Check
874 @Const
875 @GLbyte
876 @GLshort
877 @GLint
878 @GLfloat
879 @GLdouble Buffer data);
880
881 /**
882 * glMapNamedBufferEXT maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null,
883 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
884 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
885 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapNamedBufferEXT like this:
886 * <p/>
887 * ByteBuffer mapped_buffer; mapped_buffer = glMapNamedBufferEXT(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapNamedBufferEXT(..., ..., mapped_buffer);
888 * <p/>
889 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
890 * <p/>
891 * The version of this method without an explicit length argument calls glGetNamedBufferParameterEXT internally to
892 * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance.
893 * <p/>
894 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call
895 * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.<br>
896 * Security warning: The length argument should match the buffer object size. Reading from or writing to outside
897 * the memory region that corresponds to the mapped buffer object will cause native crashes.
898 *
899 * @param length the length of the mapped memory in bytes.
900 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
901 *
902 * @return A ByteBuffer representing the mapped buffer memory.
903 */
904 @Dependent("OpenGL15")
905 @CachedResult
906 @GLvoid
907 @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
908 ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access);
909
910 @Dependent("OpenGL15")
911 boolean glUnmapNamedBufferEXT(@GLuint int buffer);
912
913 @Dependent("OpenGL15")
914 @StripPostfix("params")
915 void glGetNamedBufferParameterivEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
916
917 @Alternate("glGetNamedBufferParameterivEXT")
918 @GLreturn("params")
919 @Dependent("OpenGL15")
920 @StripPostfix("params")
921 void glGetNamedBufferParameterivEXT2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params);
922
923 @Dependent("OpenGL15")
924 @StripPostfix("params")
925 @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
926 void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params);
927
928 @Dependent("OpenGL15")
929 void glGetNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
930 @OutParameter
931 @Check
932 @GLbyte
933 @GLshort
934 @GLint
935 @GLfloat
936 @GLdouble Buffer data);
937
938 /*
939 OpenGL 2.0: New uniform commands add "Program" prefix to name and
940 add initial "uint program" parameter
941 */
942
943 @Dependent("OpenGL20")
944 void glProgramUniform1fEXT(@GLuint int program, int location, float v0);
945
946 @Dependent("OpenGL20")
947 void glProgramUniform2fEXT(@GLuint int program, int location, float v0, float v1);
948
949 @Dependent("OpenGL20")
950 void glProgramUniform3fEXT(@GLuint int program, int location, float v0, float v1, float v2);
951
952 @Dependent("OpenGL20")
953 void glProgramUniform4fEXT(@GLuint int program, int location, float v0, float v1, float v2, float v3);
954
955 @Dependent("OpenGL20")
956 void glProgramUniform1iEXT(@GLuint int program, int location, int v0);
957
958 @Dependent("OpenGL20")
959 void glProgramUniform2iEXT(@GLuint int program, int location, int v0, int v1);
960
961 @Dependent("OpenGL20")
962 void glProgramUniform3iEXT(@GLuint int program, int location, int v0, int v1, int v2);
963
964 @Dependent("OpenGL20")
965 void glProgramUniform4iEXT(@GLuint int program, int location, int v0, int v1, int v2, int v3);
966
967 @Dependent("OpenGL20")
968 @StripPostfix("value")
969 void glProgramUniform1fvEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const FloatBuffer value);
970
971 @Dependent("OpenGL20")
972 @StripPostfix("value")
973 void glProgramUniform2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value);
974
975 @Dependent("OpenGL20")
976 @StripPostfix("value")
977 void glProgramUniform3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value);
978
979 @Dependent("OpenGL20")
980 @StripPostfix("value")
981 void glProgramUniform4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value);
982
983 @Dependent("OpenGL20")
984 @StripPostfix("value")
985 void glProgramUniform1ivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const IntBuffer value);
986
987 @Dependent("OpenGL20")
988 @StripPostfix("value")
989 void glProgramUniform2ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
990
991 @Dependent("OpenGL20")
992 @StripPostfix("value")
993 void glProgramUniform3ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
994
995 @Dependent("OpenGL20")
996 @StripPostfix("value")
997 void glProgramUniform4ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
998
999 @Dependent("OpenGL20")
1000 @StripPostfix("value")
1001 void glProgramUniformMatrix2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1002
1003 @Dependent("OpenGL20")
1004 @StripPostfix("value")
1005 void glProgramUniformMatrix3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1006
1007 @Dependent("OpenGL20")
1008 @StripPostfix("value")
1009 void glProgramUniformMatrix4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1010
1011 /*
1012 OpenGL 2.1: New uniform matrix commands add "Program" prefix to
1013 name and add initial "uint program" parameter
1014 */
1015
1016 @Dependent("OpenGL21")
1017 @StripPostfix("value")
1018 void glProgramUniformMatrix2x3fvEXT(@GLuint int program, int location,
1019 @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1020
1021 @Dependent("OpenGL21")
1022 @StripPostfix("value")
1023 void glProgramUniformMatrix3x2fvEXT(@GLuint int program, int location,
1024 @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1025
1026 @Dependent("OpenGL21")
1027 @StripPostfix("value")
1028 void glProgramUniformMatrix2x4fvEXT(@GLuint int program, int location,
1029 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1030
1031 @Dependent("OpenGL21")
1032 @StripPostfix("value")
1033 void glProgramUniformMatrix4x2fvEXT(@GLuint int program, int location,
1034 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1035
1036 @Dependent("OpenGL21")
1037 @StripPostfix("value")
1038 void glProgramUniformMatrix3x4fvEXT(@GLuint int program, int location,
1039 @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1040
1041 @Dependent("OpenGL21")
1042 @StripPostfix("value")
1043 void glProgramUniformMatrix4x3fvEXT(@GLuint int program, int location,
1044 @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
1045
1046 /*
1047 EXT_texture_buffer_object: New texture buffer object command
1048 replaces "Tex" in name with "Texture" and adds initial "uint texture"
1049 parameter
1050 */
1051
1052 @Dependent("GL_EXT_texture_buffer_object")
1053 void glTextureBufferEXT(@GLuint int texture, @GLenum int target, @GLenum int internalformat, @GLuint int buffer);
1054
1055 /*
1056 EXT_texture_buffer_object: New multitexture texture buffer command
1057 prefixes "Multi" before "Tex" and add an initial "enum texunit"
1058 parameter (to identify the texture unit)
1059 */
1060
1061 @Dependent("GL_EXT_texture_buffer_object")
1062 void glMultiTexBufferEXT(@GLenum int texunit, @GLenum int target, @GLenum int internalformat, @GLuint int buffer);
1063
1064 /*
1065 EXT_texture_integer: New integer texture object commands and queries
1066 replace "Tex" in name with "Texture" and add initial "uint texture"
1067 parameter
1068 */
1069
1070 @Dependent("GL_EXT_texture_integer")
1071 @StripPostfix("params")
1072 void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
1073
1074 @Alternate("glTextureParameterIivEXT")
1075 @Dependent("GL_EXT_texture_integer")
1076 @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);
1078
1079 @Dependent("GL_EXT_texture_integer")
1080 @StripPostfix("params")
1081 void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params);
1082
1083 @Alternate("glTextureParameterIuivEXT")
1084 @Dependent("GL_EXT_texture_integer")
1085 @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);
1087
1088 @Dependent("GL_EXT_texture_integer")
1089 @StripPostfix("params")
1090 void glGetTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
1091
1092 @Alternate("glGetTextureParameterIivEXT")
1093 @GLreturn("params")
1094 @Dependent("GL_EXT_texture_integer")
1095 @StripPostfix(value = "params", postfix = "v")
1096 void glGetTextureParameterIivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
1097
1098 @Dependent("GL_EXT_texture_integer")
1099 @StripPostfix("params")
1100 void glGetTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params);
1101
1102 @Alternate("glGetTextureParameterIuivEXT")
1103 @GLreturn("params")
1104 @Dependent("GL_EXT_texture_integer")
1105 @StripPostfix(value = "params", postfix = "v")
1106 void glGetTextureParameterIuivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
1107
1108 /*
1109 EXT_texture_integer: New multitexture integer texture commands and
1110 queries prefix "Multi" before "Tex" and add an initial "enum texunit"
1111 parameter (to identify the texture unit)
1112 */
1113
1114 @Dependent("GL_EXT_texture_integer")
1115 @StripPostfix("params")
1116 void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
1117
1118 @Alternate("glMultiTexParameterIivEXT")
1119 @Dependent("GL_EXT_texture_integer")
1120 @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);
1122
1123 @Dependent("GL_EXT_texture_integer")
1124 @StripPostfix("params")
1125 void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params);
1126
1127 @Alternate("glMultiTexParameterIuivEXT")
1128 @Dependent("GL_EXT_texture_integer")
1129 @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);
1131
1132 @Dependent("GL_EXT_texture_integer")
1133 @StripPostfix("params")
1134 void glGetMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
1135
1136 @Alternate("glGetMultiTexParameterIivEXT")
1137 @GLreturn("params")
1138 @Dependent("GL_EXT_texture_integer")
1139 @StripPostfix(value = "params", postfix = "v")
1140 void glGetMultiTexParameterIivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
1141
1142 @Dependent("GL_EXT_texture_integer")
1143 @StripPostfix("params")
1144 void glGetMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params);
1145
1146 @Alternate("glGetMultiTexParameterIuivEXT")
1147 @GLreturn("params")
1148 @Dependent("GL_EXT_texture_integer")
1149 @StripPostfix(value = "params", postfix = "v")
1150 void glGetMultiTexParameterIuivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
1151
1152 /*
1153 EXT_gpu_shader4: New integer uniform commands add "Program" prefix
1154 to name and add initial "uint program" parameter
1155 */
1156
1157 @Dependent("GL_EXT_gpu_shader4")
1158 void glProgramUniform1uiEXT(@GLuint int program, int location, @GLuint int v0);
1159
1160 @Dependent("GL_EXT_gpu_shader4")
1161 void glProgramUniform2uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1);
1162
1163 @Dependent("GL_EXT_gpu_shader4")
1164 void glProgramUniform3uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2);
1165
1166 @Dependent("GL_EXT_gpu_shader4")
1167 void glProgramUniform4uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3);
1168
1169 @Dependent("GL_EXT_gpu_shader4")
1170 @StripPostfix("value")
1171 void glProgramUniform1uivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const @GLuint IntBuffer value);
1172
1173 @Dependent("GL_EXT_gpu_shader4")
1174 @StripPostfix("value")
1175 void glProgramUniform2uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value);
1176
1177 @Dependent("GL_EXT_gpu_shader4")
1178 @StripPostfix("value")
1179 void glProgramUniform3uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value);
1180
1181 @Dependent("GL_EXT_gpu_shader4")
1182 @StripPostfix("value")
1183 void glProgramUniform4uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value);
1184
1185 /*
1186 EXT_gpu_program_parameters: New program command adds "Named" prefix
1187 to name and adds "uint program" parameter
1188 */
1189
1190 @Dependent("GL_EXT_gpu_program_parameters")
1191 @StripPostfix("params")
1192 void glNamedProgramLocalParameters4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index,
1193 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const FloatBuffer params);
1194
1195 /*
1196 NV_gpu_program4: New program commands and queries add "Named"
1197 prefix to name and replace "enum target" with "uint program"
1198 */
1199
1200 @Dependent("GL_NV_gpu_program4")
1201 void glNamedProgramLocalParameterI4iEXT(@GLuint int program, @GLenum int target, @GLuint int index, int x, int y, int z, int w);
1202
1203 @Dependent("GL_NV_gpu_program4")
1204 @StripPostfix("params")
1205 void glNamedProgramLocalParameterI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params);
1206
1207 @Dependent("GL_NV_gpu_program4")
1208 @StripPostfix("params")
1209 void glNamedProgramLocalParametersI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index,
1210 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params);
1211
1212 @Dependent("GL_NV_gpu_program4")
1213 void glNamedProgramLocalParameterI4uiEXT(@GLuint int program, @GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
1214
1215 @Dependent("GL_NV_gpu_program4")
1216 @StripPostfix("params")
1217 void glNamedProgramLocalParameterI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params);
1218
1219 @Dependent("GL_NV_gpu_program4")
1220 @StripPostfix("params")
1221 void glNamedProgramLocalParametersI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index,
1222 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params);
1223
1224 @Dependent("GL_NV_gpu_program4")
1225 @StripPostfix("params")
1226 void glGetNamedProgramLocalParameterIivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter IntBuffer params);
1227
1228 @Dependent("GL_NV_gpu_program4")
1229 @StripPostfix("params")
1230 void glGetNamedProgramLocalParameterIuivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter @GLuint IntBuffer params);
1231
1232 /*
1233 OpenGL 3.0: New renderbuffer commands add "Named" prefix to name
1234 and replace "enum target" with "uint renderbuffer"
1235 */
1236
1237 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1238 void glNamedRenderbufferStorageEXT(@GLuint int renderbuffer, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
1239
1240 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1241 @StripPostfix("params")
1242 void glGetNamedRenderbufferParameterivEXT(@GLuint int renderbuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
1243
1244 @Alternate("glGetNamedRenderbufferParameterivEXT")
1245 @GLreturn("params")
1246 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1247 @StripPostfix("params")
1248 void glGetNamedRenderbufferParameterivEXT2(@GLuint int renderbuffer, @GLenum int pname, @OutParameter IntBuffer params);
1249
1250 /*
1251 EXT_framebuffer_multisample: New renderbuffer commands add "Named"
1252 prefix to name and replace "enum target" with "uint renderbuffer"
1253 */
1254
1255 @Dependent("OpenGL30,GL_EXT_framebuffer_multisample")
1256 void glNamedRenderbufferStorageMultisampleEXT(@GLuint int renderbuffer, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
1257
1258 /*
1259 NV_framebuffer_multisample_coverage: New renderbuffer commands
1260 add "Named" prefix to name and replace "enum target" with "uint
1261 renderbuffer"
1262 */
1263
1264 @Dependent("GL_NV_framebuffer_multisample_coverage")
1265 void glNamedRenderbufferStorageMultisampleCoverageEXT(@GLuint int renderbuffer, @GLsizei int coverageSamples, @GLsizei int colorSamples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
1266
1267 /*
1268 OpenGL 3.0: New framebuffer commands add "Named" prefix to name
1269 and replace "enum target" with "uint framebuffer"
1270 */
1271
1272 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1273 @GLenum
1274 int glCheckNamedFramebufferStatusEXT(@GLuint int framebuffer, @GLenum int target);
1275
1276 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1277 void glNamedFramebufferTexture1DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
1278
1279 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1280 void glNamedFramebufferTexture2DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
1281
1282 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1283 void glNamedFramebufferTexture3DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset);
1284
1285 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1286 void glNamedFramebufferRenderbufferEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
1287
1288 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1289 @StripPostfix("params")
1290 void glGetNamedFramebufferAttachmentParameterivEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
1291
1292 @Alternate("glGetNamedFramebufferAttachmentParameterivEXT")
1293 @GLreturn("params")
1294 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1295 @StripPostfix("params")
1296 void glGetNamedFramebufferAttachmentParameterivEXT2(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
1297
1298 /*
1299 OpenGL 3.0: New texture commands add "Texture" within name and
1300 replace "enum target" with "uint texture"
1301 */
1302
1303 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1304 void glGenerateTextureMipmapEXT(@GLuint int texture, @GLenum int target);
1305
1306 /*
1307 OpenGL 3.0: New texture commands add "MultiTex" within name and
1308 replace "enum target" with "enum texunit"
1309 */
1310
1311 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1312 void glGenerateMultiTexMipmapEXT(@GLenum int texunit, @GLenum int target);
1313
1314 /*
1315 OpenGL 3.0: New framebuffer commands
1316 */
1317
1318 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1319 void glFramebufferDrawBufferEXT(@GLuint int framebuffer, @GLenum int mode);
1320
1321 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1322 void glFramebufferDrawBuffersEXT(@GLuint int framebuffer, @AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs);
1323
1324 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1325 void glFramebufferReadBufferEXT(@GLuint int framebuffer, @GLenum int mode);
1326
1327 /*
1328 OpenGL 3.0: New framebuffer query
1329 */
1330
1331 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1332 @StripPostfix("param")
1333 void glGetFramebufferParameterivEXT(@GLuint int framebuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer param);
1334
1335 @Alternate("glGetFramebufferParameterivEXT")
1336 @GLreturn("param")
1337 @Dependent("OpenGL30,GL_EXT_framebuffer_object")
1338 @StripPostfix("param")
1339 void glGetFramebufferParameterivEXT2(@GLuint int framebuffer, @GLenum int pname, @OutParameter IntBuffer param);
1340
1341 /*
1342 OpenGL 3.1: New buffer data copy command
1343 */
1344
1345 @Dependent("OpenGL31,GL_ARB_copy_buffer")
1346 void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
1347
1348 /*
1349 EXT_geometry_shader4 or NV_geometry_program4: New framebuffer commands
1350 add "Named" prefix to name and replace "enum target" with "uint
1351 framebuffer"
1352 */
1353
1354 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1355 void glNamedFramebufferTextureEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level);
1356
1357 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1358 void glNamedFramebufferTextureLayerEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer);
1359
1360 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1361 void glNamedFramebufferTextureFaceEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
1362
1363 /*
1364 NV_explicit_multisample: New texture renderbuffer object command
1365 replaces "Tex" in name with "Texture" and add initial "uint texture"
1366 parameter
1367 */
1368
1369 @Dependent("GL_NV_explicit_multisample")
1370 void glTextureRenderbufferEXT(@GLuint int texture, @GLenum int target, @GLuint int renderbuffer);
1371
1372 /*
1373 NV_explicit_multisample: New multitexture texture renderbuffer command
1374 prefixes "Multi" before "Tex" and add an initial "enum texunit"
1375 parameter (to identify the texture unit)
1376 */
1377
1378 @Dependent("GL_NV_explicit_multisample")
1379 void glMultiTexRenderbufferEXT(@GLenum int texunit, @GLenum int target, @GLuint int renderbuffer);
1380
1381 /*
1382 OpenGL 3.0: New vertex array specification commands for vertex
1383 array objects prefix "VertexArray", add initial "uint vaobj" and
1384 "uint buffer" parameters, change "Pointer" suffix to "Offset",
1385 and change the final parameter from "const void *" to "intptr offset"
1386 */
1387
1388 @Dependent("OpenGL30")
1389 @DeprecatedGL
1390 void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1391
1392 @Dependent("OpenGL30")
1393 @DeprecatedGL
1394 void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1395
1396 @Dependent("OpenGL30")
1397 @DeprecatedGL
1398 void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset);
1399
1400 @Dependent("OpenGL30")
1401 void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1402
1403 @Dependent("OpenGL30")
1404 @DeprecatedGL
1405 void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1406
1407 @Dependent("OpenGL30")
1408 @DeprecatedGL
1409 void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1410
1411 @Dependent("OpenGL30")
1412 @DeprecatedGL
1413 void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1414
1415 @Dependent("OpenGL30")
1416 @DeprecatedGL
1417 void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1418
1419 @Dependent("OpenGL30")
1420 @DeprecatedGL
1421 void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1422
1423 @Dependent("OpenGL30")
1424 void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset);
1425
1426 @Dependent("OpenGL30")
1427 void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
1428
1429 /*
1430 OpenGL 3.0: New vertex array enable commands for vertex array
1431 objects change "ClientState" to "VertexArray" and add an initial
1432 "uint vaobj" parameter
1433 */
1434
1435 @Dependent("OpenGL30")
1436 void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
1437
1438 @Dependent("OpenGL30")
1439 void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
1440
1441 /*
1442 OpenGL 3.0: New vertex attrib array enable commands for vertex
1443 array objects change "VertexAttribArray" to "VertexArrayAttrib"
1444 and add an initial "uint vaobj" parameter
1445 */
1446
1447 @Dependent("OpenGL30")
1448 void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
1449
1450 @Dependent("OpenGL30")
1451 void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
1452
1453 /*
1454 OpenGL 3.0: New queries for vertex array objects
1455 */
1456
1457 @Dependent("OpenGL30")
1458 @StripPostfix("param")
1459 void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
1460
1461 @Alternate("glGetVertexArrayIntegervEXT")
1462 @GLreturn("param")
1463 @Dependent("OpenGL30")
1464 @StripPostfix("param")
1465 void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
1466
1467 @Dependent("OpenGL30")
1468 @StripPostfix("param")
1469 void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param);
1470
1471 @Dependent("OpenGL30")
1472 @StripPostfix(value = "param")
1473 void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
1474
1475 @Alternate("glGetVertexArrayIntegeri_vEXT")
1476 @GLreturn("param")
1477 @Dependent("OpenGL30")
1478 @StripPostfix(value = "param", postfix = "_v")
1479 void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
1480
1481 @Dependent("OpenGL30")
1482 @StripPostfix(value = "param")
1483 void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param);
1484
1485 /*
1486 OpenGL 3.0: New buffer commands replace "Buffer" with "NamedBuffer"
1487 in name and replace "enum target" parameter with "uint buffer"
1488 */
1489
1490 /**
1491 * glMapNamedBufferRangeEXT maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null,
1492 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
1493 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
1494 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapNamedBufferRangeEXT like this:
1495 * <p/>
1496 * ByteBuffer mapped_buffer; mapped_buffer = glMapNamedBufferRangeEXT(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapNamedBufferRangeEXT(..., ..., ..., ..., mapped_buffer);
1497 * <p/>
1498 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
1499 *
1500 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
1501 *
1502 * @return A ByteBuffer representing the mapped buffer memory.
1503 */
1504 @Dependent("OpenGL30")
1505 @CachedResult(isRange = true)
1506 @GLvoid
1507 @AutoResultSize("length")
1508 ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
1509
1510 @Dependent("OpenGL30")
1511 void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
1512
1513 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36 import java.nio.ByteBuffer;
37
38 public interface EXT_draw_buffers2 {
39
40 void glColorMaskIndexedEXT(@GLuint int buf, boolean r, boolean g, boolean b, boolean a);
41
42 @StripPostfix("data")
43 void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data);
44
45 @Alternate("glGetBooleanIndexedvEXT")
46 @GLreturn("data")
47 @StripPostfix("data")
48 void glGetBooleanIndexedvEXT2(@GLenum int value, @GLuint int index, @OutParameter @GLboolean ByteBuffer data);
49
50 @StripPostfix("data")
51 void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
52
53 @Alternate("glGetIntegerIndexedvEXT")
54 @GLreturn("data")
55 @StripPostfix("data")
56 void glGetIntegerIndexedvEXT2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
57
58 void glEnableIndexedEXT(@GLenum int target, @GLuint int index);
59
60 void glDisableIndexedEXT(@GLenum int target, @GLuint int index);
61
62 boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index);
63
64 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36
37 public interface EXT_draw_instanced {
38
39 void glDrawArraysInstancedEXT(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount);
40
41 void glDrawElementsInstancedEXT(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
42 @BufferObject(BufferKind.ElementVBO)
43 @Const
44 @GLubyte
45 @GLushort
46 @GLuint Buffer indices, @GLsizei int primcount);
47
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_draw_range_elements {
38 int GL_MAX_ELEMENTS_VERTICES_EXT = 0x80E8;
39 int GL_MAX_ELEMENTS_INDICES_EXT = 0x80E9;
40
41 void glDrawRangeElementsEXT(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("pIndices") @GLsizei int count, @AutoType("pIndices") @GLenum int type,
42 @BufferObject(BufferKind.ElementVBO)
43 @Const
44 @GLubyte
45 @GLushort
46 @GLuint Buffer pIndices);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_fog_coord {
38 int GL_FOG_COORDINATE_SOURCE_EXT = 0x8450;
39 int GL_FOG_COORDINATE_EXT = 0x8451;
40 int GL_FRAGMENT_DEPTH_EXT = 0x8452;
41 int GL_CURRENT_FOG_COORDINATE_EXT = 0x8453;
42 int GL_FOG_COORDINATE_ARRAY_TYPE_EXT = 0x8454;
43 int GL_FOG_COORDINATE_ARRAY_STRIDE_EXT = 0x8455;
44 int GL_FOG_COORDINATE_ARRAY_POINTER_EXT = 0x8456;
45 int GL_FOG_COORDINATE_ARRAY_EXT = 0x8457;
46
47 void glFogCoordfEXT(float coord);
48
49 void glFogCoorddEXT(double coord);
50
51 void glFogCoordPointerEXT(@AutoType("data") @GLenum int type, @GLsizei int stride,
52 @CachedReference
53 @BufferObject(BufferKind.ArrayVBO)
54 @Check
55 @Const
56 @GLfloat
57 @GLdouble Buffer data);
58 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_framebuffer_blit {
36
37 /**
38 Accepted by the &lt;target&gt; parameter of BindFramebufferEXT,
39 CheckFramebufferStatusEXT, FramebufferTexture{1D|2D|3D}EXT,
40 FramebufferRenderbufferEXT, and
41 GetFramebufferAttachmentParameterivEXT.
42 */
43 int GL_READ_FRAMEBUFFER_EXT = 0x8CA8;
44 int GL_DRAW_FRAMEBUFFER_EXT = 0x8CA9;
45
46 /**
47 Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv, and GetDoublev.
48 */
49 int GL_DRAW_FRAMEBUFFER_BINDING_EXT = 0x8CA6; // alias FRAMEBUFFER_BINDING_EXT
50 int GL_READ_FRAMEBUFFER_BINDING_EXT = 0x8CAA;
51
52 /**
53 Transfers a rectangle of pixel values from one
54 region of the read framebuffer to another in the draw framebuffer.
55 &lt;mask&gt; is the bitwise OR of a number of values indicating which
56 buffers are to be copied. The values are COLOR_BUFFER_BIT,
57 DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT.
58 The pixels corresponding to these buffers are
59 copied from the source rectangle, bound by the locations (srcX0,
60 srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle,
61 bound by the locations (dstX0, dstY0) and (dstX1, dstY1)
62 inclusive.
63 If the source and destination rectangle dimensions do not match,
64 the source image is stretched to fit the destination
65 rectangle. &lt;filter&gt; must be LINEAR or NEAREST and specifies the
66 method of interpolation to be applied if the image is
67 stretched.
68 */
69 void glBlitFramebufferEXT(
70 @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1,
71 @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1,
72 @GLbitfield int mask, @GLenum int filter);
73
74 }
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.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
35
36 public interface EXT_framebuffer_multisample {
37
38 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameterivEXT. */
39 int GL_RENDERBUFFER_SAMPLES_EXT = 0x8CAB;
40
41 /** Returned by CheckFramebufferStatusEXT. */
42 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8D56;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
46 * GetFloatv, and GetDoublev.
47 */
48 int GL_MAX_SAMPLES_EXT = 0x8D57;
49
50 /**
51 * Establishes the data storage, format, dimensions, and number of
52 * samples of a renderbuffer object's image.
53 */
54 void glRenderbufferStorageMultisampleEXT(
55 @GLenum int target, @GLsizei int samples,
56 @GLenum int internalformat,
57 @GLsizei int width, @GLsizei int height);
58 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface EXT_framebuffer_object {
38
39 /**
40 * Accepted by the &lt;target&gt; parameter of BindFramebufferEXT,
41 * CheckFramebufferStatusEXT, FramebufferTexture{1D|2D|3D}EXT, and
42 * FramebufferRenderbufferEXT:
43 */
44 int GL_FRAMEBUFFER_EXT = 0x8D40;
45
46 /**
47 * Accepted by the &lt;target&gt; parameter of BindRenderbufferEXT,
48 * RenderbufferStorageEXT, and GetRenderbufferParameterivEXT, and
49 * returned by GetFramebufferAttachmentParameterivEXT:
50 */
51 int GL_RENDERBUFFER_EXT = 0x8D41;
52
53 /**
54 * Accepted by the &lt;internalformat&gt; parameter of
55 * RenderbufferStorageEXT:
56 */
57 int GL_STENCIL_INDEX1_EXT = 0x8D46;
58 int GL_STENCIL_INDEX4_EXT = 0x8D47;
59 int GL_STENCIL_INDEX8_EXT = 0x8D48;
60 int GL_STENCIL_INDEX16_EXT = 0x8D49;
61
62 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameterivEXT: */
63 int GL_RENDERBUFFER_WIDTH_EXT = 0x8D42;
64 int GL_RENDERBUFFER_HEIGHT_EXT = 0x8D43;
65 int GL_RENDERBUFFER_INTERNAL_FORMAT_EXT = 0x8D44;
66 int GL_RENDERBUFFER_RED_SIZE_EXT = 0x8D50;
67 int GL_RENDERBUFFER_GREEN_SIZE_EXT = 0x8D51;
68 int GL_RENDERBUFFER_BLUE_SIZE_EXT = 0x8D52;
69 int GL_RENDERBUFFER_ALPHA_SIZE_EXT = 0x8D53;
70 int GL_RENDERBUFFER_DEPTH_SIZE_EXT = 0x8D54;
71 int GL_RENDERBUFFER_STENCIL_SIZE_EXT = 0x8D55;
72
73 /**
74 * Accepted by the &lt;pname&gt; parameter of
75 * GetFramebufferAttachmentParameterivEXT:
76 */
77 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT = 0x8CD0;
78 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT = 0x8CD1;
79 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT = 0x8CD2;
80 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT = 0x8CD3;
81 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT = 0x8CD4;
82
83 /**
84 * Accepted by the &lt;attachment&gt; parameter of
85 * FramebufferTexture{1D|2D|3D}EXT, FramebufferRenderbufferEXT, and
86 * GetFramebufferAttachmentParameterivEXT
87 */
88 int GL_COLOR_ATTACHMENT0_EXT = 0x8CE0;
89 int GL_COLOR_ATTACHMENT1_EXT = 0x8CE1;
90 int GL_COLOR_ATTACHMENT2_EXT = 0x8CE2;
91 int GL_COLOR_ATTACHMENT3_EXT = 0x8CE3;
92 int GL_COLOR_ATTACHMENT4_EXT = 0x8CE4;
93 int GL_COLOR_ATTACHMENT5_EXT = 0x8CE5;
94 int GL_COLOR_ATTACHMENT6_EXT = 0x8CE6;
95 int GL_COLOR_ATTACHMENT7_EXT = 0x8CE7;
96 int GL_COLOR_ATTACHMENT8_EXT = 0x8CE8;
97 int GL_COLOR_ATTACHMENT9_EXT = 0x8CE9;
98 int GL_COLOR_ATTACHMENT10_EXT = 0x8CEA;
99 int GL_COLOR_ATTACHMENT11_EXT = 0x8CEB;
100 int GL_COLOR_ATTACHMENT12_EXT = 0x8CEC;
101 int GL_COLOR_ATTACHMENT13_EXT = 0x8CED;
102 int GL_COLOR_ATTACHMENT14_EXT = 0x8CEE;
103 int GL_COLOR_ATTACHMENT15_EXT = 0x8CEF;
104 int GL_DEPTH_ATTACHMENT_EXT = 0x8D00;
105 int GL_STENCIL_ATTACHMENT_EXT = 0x8D20;
106
107 /** Returned by CheckFramebufferStatusEXT(): */
108 int GL_FRAMEBUFFER_COMPLETE_EXT = 0x8CD5;
109 int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT = 0x8CD6;
110 int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT = 0x8CD7;
111 int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT = 0x8CD9;
112 int GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT = 0x8CDA;
113 int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT = 0x8CDB;
114 int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT = 0x8CDC;
115 int GL_FRAMEBUFFER_UNSUPPORTED_EXT = 0x8CDD;
116
117 /** Accepted by GetIntegerv(): */
118 int GL_FRAMEBUFFER_BINDING_EXT = 0x8CA6;
119 int GL_RENDERBUFFER_BINDING_EXT = 0x8CA7;
120 int GL_MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF;
121 int GL_MAX_RENDERBUFFER_SIZE_EXT = 0x84E8;
122
123 /** Returned by GetError(): */
124 int GL_INVALID_FRAMEBUFFER_OPERATION_EXT = 0x0506;
125
126 boolean glIsRenderbufferEXT(@GLuint int renderbuffer);
127
128 void glBindRenderbufferEXT(@GLenum int target, @GLuint int renderbuffer);
129
130 void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
131
132 @Alternate("glDeleteRenderbuffersEXT")
133 void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
134
135 void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
136
137 @Alternate("glGenRenderbuffersEXT")
138 @GLreturn("renderbuffers")
139 void glGenRenderbuffersEXT2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers);
140
141 void glRenderbufferStorageEXT(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
142
143 @StripPostfix("params")
144 void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
145
146 @Alternate("glGetRenderbufferParameterivEXT")
147 @GLreturn("params")
148 @StripPostfix("params")
149 void glGetRenderbufferParameterivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
150
151 boolean glIsFramebufferEXT(@GLuint int framebuffer);
152
153 void glBindFramebufferEXT(@GLenum int target, @GLuint int framebuffer);
154
155 void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
156
157 @Alternate("glDeleteFramebuffersEXT")
158 void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
159
160 void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
161
162 @Alternate("glGenFramebuffersEXT")
163 @GLreturn("framebuffers")
164 void glGenFramebuffersEXT2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers);
165
166 @GLenum
167 int glCheckFramebufferStatusEXT(@GLenum int target);
168
169 void glFramebufferTexture1DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
170
171 void glFramebufferTexture2DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
172
173 void glFramebufferTexture3DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset);
174
175 void glFramebufferRenderbufferEXT(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
176
177 @StripPostfix("params")
178 void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
179
180 @Alternate("glGetFramebufferAttachmentParameterivEXT")
181 @GLreturn("params")
182 @StripPostfix("params")
183 void glGetFramebufferAttachmentParameterivEXT2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
184
185 void glGenerateMipmapEXT(@GLenum int target);
186 }
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 EXT_framebuffer_sRGB {
34
35 /**
36 * Accepted by the &lt;attribList&gt; parameter of glXChooseVisual, and by
37 * the &lt;attrib&gt; parameter of glXGetConfig:
38 */
39 int GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20B2;
40
41 /**
42 * Accepted by the &lt;piAttributes&gt; parameter of
43 * wglGetPixelFormatAttribivEXT, wglGetPixelFormatAttribfvEXT, and
44 * the &lt;piAttribIList&gt; and &lt;pfAttribIList&gt; of wglChoosePixelFormatEXT:
45 */
46 int WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20A9;
47
48 /**
49 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
50 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
51 * and GetDoublev:
52 */
53 int GL_FRAMEBUFFER_SRGB_EXT = 0x8DB9;
54
55 /**
56 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
57 * GetFloatv, and GetDoublev:
58 */
59 int GL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x8DBA;
60
61 }
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.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface EXT_geometry_shader4 {
37
38 /**
39 * Accepted by the &lt;type&gt; parameter of CreateShader and returned by the
40 * &lt;params&gt; parameter of GetShaderiv:
41 */
42 int GL_GEOMETRY_SHADER_EXT = 0x8DD9;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of ProgramParameteriEXT and
46 * GetProgramiv:
47 */
48 int GL_GEOMETRY_VERTICES_OUT_EXT = 0x8DDA;
49 int GL_GEOMETRY_INPUT_TYPE_EXT = 0x8DDB;
50 int GL_GEOMETRY_OUTPUT_TYPE_EXT = 0x8DDC;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
54 * GetFloatv, and GetDoublev:
55 */
56 int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT = 0x8C29;
57 int GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT = 0x8DDD;
58 int GL_MAX_VERTEX_VARYING_COMPONENTS_EXT = 0x8DDE;
59 int GL_MAX_VARYING_COMPONENTS_EXT = 0x8B4B;
60 int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT = 0x8DDF;
61 int GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT = 0x8DE0;
62 int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT = 0x8DE1;
63
64 /**
65 * Accepted by the &lt;mode&gt; parameter of Begin, DrawArrays,
66 * MultiDrawArrays, DrawElements, MultiDrawElements, and
67 * DrawRangeElements:
68 */
69 int GL_LINES_ADJACENCY_EXT = 0xA;
70 int GL_LINE_STRIP_ADJACENCY_EXT = 0xB;
71 int GL_TRIANGLES_ADJACENCY_EXT = 0xC;
72 int GL_TRIANGLE_STRIP_ADJACENCY_EXT = 0xD;
73
74 /** Returned by CheckFramebufferStatusEXT: */
75 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT = 0x8DA8;
76 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT = 0x8DA9;
77
78 /**
79 * Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachment-
80 * ParameterivEXT:
81 */
82 int GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT = 0x8DA7;
83 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT = 0x8CD4;
84
85 /**
86 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
87 * and by the &lt;pname&gt; parameter of GetIntegerv, GetFloatv, GetDoublev,
88 * and GetBooleanv:
89 */
90 int GL_PROGRAM_POINT_SIZE_EXT = 0x8642;
91
92 void glProgramParameteriEXT(@GLuint int program, @GLenum int pname, int value);
93
94 void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
95
96 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
97
98 void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
99
100 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_gpu_program_parameters {
38
39 @StripPostfix("params")
40 void glProgramEnvParameters4fvEXT(@GLenum int target, @GLuint int index, @GLsizei int count, @Check("count << 2") @Const FloatBuffer params);
41
42 @StripPostfix("params")
43 void glProgramLocalParameters4fvEXT(@GLenum int target, @GLuint int index, @GLsizei int count, @Check("count << 2") @Const FloatBuffer params);
44
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.ShortBuffer;
39
40 public interface EXT_gpu_shader4 {
41
42 /**
43 * Accepted by the &lt;pname&gt; parameters of GetVertexAttribdv,
44 * GetVertexAttribfv, GetVertexAttribiv, GetVertexAttribIivEXT, and
45 * GetVertexAttribIuivEXT:
46 */
47 int GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT = 0x88FD;
48
49 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
50
51 int GL_SAMPLER_1D_ARRAY_EXT = 0x8DC0;
52 int GL_SAMPLER_2D_ARRAY_EXT = 0x8DC1;
53 int GL_SAMPLER_BUFFER_EXT = 0x8DC2;
54 int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3;
55 int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4;
56 int GL_SAMPLER_CUBE_SHADOW_EXT = 0x8DC5;
57 int GL_UNSIGNED_INT = 0x1405;
58 int GL_UNSIGNED_INT_VEC2_EXT = 0x8DC6;
59 int GL_UNSIGNED_INT_VEC3_EXT = 0x8DC7;
60 int GL_UNSIGNED_INT_VEC4_EXT = 0x8DC8;
61 int GL_INT_SAMPLER_1D_EXT = 0x8DC9;
62 int GL_INT_SAMPLER_2D_EXT = 0x8DCA;
63 int GL_INT_SAMPLER_3D_EXT = 0x8DCB;
64 int GL_INT_SAMPLER_CUBE_EXT = 0x8DCC;
65 int GL_INT_SAMPLER_2D_RECT_EXT = 0x8DCD;
66 int GL_INT_SAMPLER_1D_ARRAY_EXT = 0x8DCE;
67 int GL_INT_SAMPLER_2D_ARRAY_EXT = 0x8DCF;
68 int GL_INT_SAMPLER_BUFFER_EXT = 0x8DD0;
69 int GL_UNSIGNED_INT_SAMPLER_1D_EXT = 0x8DD1;
70 int GL_UNSIGNED_INT_SAMPLER_2D_EXT = 0x8DD2;
71 int GL_UNSIGNED_INT_SAMPLER_3D_EXT = 0x8DD3;
72 int GL_UNSIGNED_INT_SAMPLER_CUBE_EXT = 0x8DD4;
73 int GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT = 0x8DD5;
74 int GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT = 0x8DD6;
75 int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT = 0x8DD7;
76 int GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT = 0x8DD8;
77
78 /**
79 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
80 * and GetDoublev:
81 */
82 int GL_MIN_PROGRAM_TEXEL_OFFSET_EXT = 0x8904;
83 int GL_MAX_PROGRAM_TEXEL_OFFSET_EXT = 0x8905;
84
85 @NoErrorCheck
86 void glVertexAttribI1iEXT(@GLuint int index, int x);
87
88 @NoErrorCheck
89 void glVertexAttribI2iEXT(@GLuint int index, int x, int y);
90
91 @NoErrorCheck
92 void glVertexAttribI3iEXT(@GLuint int index, int x, int y, int z);
93
94 @NoErrorCheck
95 void glVertexAttribI4iEXT(@GLuint int index, int x, int y, int z, int w);
96
97 @NoErrorCheck
98 void glVertexAttribI1uiEXT(@GLuint int index, @GLuint int x);
99
100 @NoErrorCheck
101 void glVertexAttribI2uiEXT(@GLuint int index, @GLuint int x, @GLuint int y);
102
103 @NoErrorCheck
104 void glVertexAttribI3uiEXT(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z);
105
106 @NoErrorCheck
107 void glVertexAttribI4uiEXT(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
108
109 @NoErrorCheck
110 @StripPostfix("v")
111 void glVertexAttribI1ivEXT(@GLuint int index, @Check("1") @Const IntBuffer v);
112
113 @NoErrorCheck
114 @StripPostfix("v")
115 void glVertexAttribI2ivEXT(@GLuint int index, @Check("2") @Const IntBuffer v);
116
117 @NoErrorCheck
118 @StripPostfix("v")
119 void glVertexAttribI3ivEXT(@GLuint int index, @Check("3") @Const IntBuffer v);
120
121 @NoErrorCheck
122 @StripPostfix("v")
123 void glVertexAttribI4ivEXT(@GLuint int index, @Check("4") @Const IntBuffer v);
124
125 @NoErrorCheck
126 @StripPostfix("v")
127 void glVertexAttribI1uivEXT(@GLuint int index, @Check("1") @Const @GLuint IntBuffer v);
128
129 @NoErrorCheck
130 @StripPostfix("v")
131 void glVertexAttribI2uivEXT(@GLuint int index, @Check("2") @Const @GLuint IntBuffer v);
132
133 @NoErrorCheck
134 @StripPostfix("v")
135 void glVertexAttribI3uivEXT(@GLuint int index, @Check("3") @Const @GLuint IntBuffer v);
136
137 @NoErrorCheck
138 @StripPostfix("v")
139 void glVertexAttribI4uivEXT(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v);
140
141 @NoErrorCheck
142 @StripPostfix("v")
143 void glVertexAttribI4bvEXT(@GLuint int index, @Check("4") @Const ByteBuffer v);
144
145 @NoErrorCheck
146 @StripPostfix("v")
147 void glVertexAttribI4svEXT(@GLuint int index, @Check("4") @Const ShortBuffer v);
148
149 @NoErrorCheck
150 @StripPostfix("v")
151 void glVertexAttribI4ubvEXT(@GLuint int index, @Check("4") @Const @GLubyte ByteBuffer v);
152
153 @NoErrorCheck
154 @StripPostfix("v")
155 void glVertexAttribI4usvEXT(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
156
157 void glVertexAttribIPointerEXT(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
158 @CachedReference
159 @BufferObject(BufferKind.ArrayVBO)
160 @Check
161 @Const
162 @GLbyte
163 @GLubyte
164 @GLshort
165 @GLushort
166 @GLint
167 @GLuint Buffer buffer);
168
169 @StripPostfix("params")
170 void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
171
172 @StripPostfix("params")
173 void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params);
174
175 void glUniform1uiEXT(int location, @GLuint int v0);
176
177 void glUniform2uiEXT(int location, @GLuint int v0, @GLuint int v1);
178
179 void glUniform3uiEXT(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2);
180
181 void glUniform4uiEXT(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3);
182
183 @StripPostfix("value")
184 void glUniform1uivEXT(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value);
185
186 @StripPostfix("value")
187 void glUniform2uivEXT(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value);
188
189 @StripPostfix("value")
190 void glUniform3uivEXT(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value);
191
192 @StripPostfix("value")
193 void glUniform4uivEXT(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value);
194
195 @StripPostfix("params")
196 void glGetUniformuivEXT(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params);
197
198 void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name);
199
200 @Alternate("glBindFragDataLocationEXT")
201 void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name);
202
203 int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
204
205 @Alternate("glGetFragDataLocationEXT")
206 int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated CharSequence name);
207
208 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_multi_draw_arrays {
38 void glMultiDrawArraysEXT(@GLenum int mode, IntBuffer piFirst, @Check("piFirst.remaining()") @GLsizei IntBuffer piCount, @AutoSize("piFirst") int primcount);
39 }
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 EXT_packed_depth_stencil {
34
35 /**
36 Accepted by the &lt;format&gt; parameter of DrawPixels, ReadPixels,
37 TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
38 TexSubImage3D, and GetTexImage, by the &lt;type&gt; parameter of
39 CopyPixels, by the &lt;internalformat&gt; parameter of TexImage1D,
40 TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
41 RenderbufferStorageEXT, and returned in the &lt;data&gt; parameter of
42 GetTexLevelParameter and GetRenderbufferParameterivEXT.
43 */
44 int GL_DEPTH_STENCIL_EXT = 0x84F9;
45
46 /**
47 Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
48 TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
49 TexSubImage3D, and GetTexImage.
50 */
51 int GL_UNSIGNED_INT_24_8_EXT = 0x84FA;
52
53 /**
54 Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
55 TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
56 RenderbufferStorageEXT, and returned in the &lt;data&gt; parameter of
57 GetTexLevelParameter and GetRenderbufferParameterivEXT.
58 */
59 int GL_DEPTH24_STENCIL8_EXT = 0x88F0;
60
61 /**
62 Accepted by the &lt;value&gt; parameter of GetTexLevelParameter.
63 */
64 int GL_TEXTURE_STENCIL_SIZE_EXT = 0x88F1;
65
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 package org.lwjgl.opengl;
32
33 public interface EXT_packed_float {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
37 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
38 * RenderbufferStorageEXT:
39 */
40 int GL_R11F_G11F_B10F_EXT = 0x8C3A;
41
42 /**
43 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
44 * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D,
45 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
46 * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D,
47 * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter,
48 * ColorTable, ColorSubTable, and GetColorTable:
49 */
50 int GL_UNSIGNED_INT_10F_11F_11F_REV_EXT = 0x8C3B;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv, and
54 * GetDoublev:
55 */
56 int GL_RGBA_SIGNED_COMPONENTS_EXT = 0x8C3C;
57
58 /**
59 * Accepted as a value in the &lt;piAttribIList&gt; and &lt;pfAttribFList&gt;
60 * parameter arrays of wglChoosePixelFormatARB, and returned in the
61 * &lt;piValues&gt; parameter array of wglGetPixelFormatAttribivARB, and the
62 * &lt;pfValues&gt; parameter array of wglGetPixelFormatAttribfvARB:
63 */
64 int WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT = 0x20A8;
65
66 /**
67 * Accepted as values of the &lt;render_type&gt; arguments in the
68 * glXCreateNewContext and glXCreateContext functions
69 */
70 int GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT = 0x20B1;
71
72 /**
73 * Returned by glXGetFBConfigAttrib (when &lt;attribute&gt; is set to
74 * GLX_RENDER_TYPE) and accepted by the &lt;attrib_list&gt; parameter of
75 * glXChooseFBConfig (following the GLX_RENDER_TYPE token):
76 */
77 int GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT = 0x00000008;
78
79 }
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 EXT_packed_pixels {
34 int GL_UNSIGNED_BYTE_3_3_2_EXT = 0x8032;
35 int GL_UNSIGNED_SHORT_4_4_4_4_EXT = 0x8033;
36 int GL_UNSIGNED_SHORT_5_5_5_1_EXT = 0x8034;
37 int GL_UNSIGNED_INT_8_8_8_8_EXT = 0x8035;
38 int GL_UNSIGNED_INT_10_10_10_2_EXT = 0x8036;
39 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_paletted_texture {
38
39 /**
40 * Accepted by the internalformat parameter of TexImage1D, TexImage2D and
41 * TexImage3DEXT:
42 */
43 int GL_COLOR_INDEX1_EXT = 0x80E2;
44 int GL_COLOR_INDEX2_EXT = 0x80E3;
45 int GL_COLOR_INDEX4_EXT = 0x80E4;
46 int GL_COLOR_INDEX8_EXT = 0x80E5;
47 int GL_COLOR_INDEX12_EXT = 0x80E6;
48 int GL_COLOR_INDEX16_EXT = 0x80E7;
49
50 /**
51 * Accepted by the pname parameter of GetColorTableParameterivEXT and
52 * GetColorTableParameterfvEXT:
53 */
54 int GL_COLOR_TABLE_FORMAT_EXT = 0x80D8;
55 int GL_COLOR_TABLE_WIDTH_EXT = 0x80D9;
56 int GL_COLOR_TABLE_RED_SIZE_EXT = 0x80DA;
57 int GL_COLOR_TABLE_GREEN_SIZE_EXT = 0x80DB;
58 int GL_COLOR_TABLE_BLUE_SIZE_EXT = 0x80DC;
59 int GL_COLOR_TABLE_ALPHA_SIZE_EXT = 0x80DD;
60 int GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE;
61 int GL_COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF;
62
63 /**
64 * Accepted by the value parameter of GetTexLevelParameter{if}v:
65 */
66 int GL_TEXTURE_INDEX_SIZE_EXT = 0x80ED;
67
68 void glColorTableEXT(@GLenum int target, @GLenum int internalFormat, @GLsizei int width, @GLenum int format, @GLenum int type,
69 @Check("GLChecks.calculateImageStorage(data, format, type, width, 1, 1)")
70 @Const
71 @GLbyte
72 @GLshort
73 @GLint
74 @GLfloat
75 @GLdouble Buffer data);
76
77 void glColorSubTableEXT(@GLenum int target, @GLsizei int start, @GLsizei int count, @GLenum int format, @GLenum int type,
78 @Check("GLChecks.calculateImageStorage(data, format, type, count, 1, 1)")
79 @Const
80 @GLbyte
81 @GLshort
82 @GLint
83 @GLfloat
84 @GLdouble Buffer data);
85
86 void glGetColorTableEXT(@GLenum int target, @GLenum int format, @GLenum int type,
87 @OutParameter
88 @Check
89 @GLbyte
90 @GLshort
91 @GLint
92 @GLfloat
93 @GLdouble Buffer data);
94
95 @StripPostfix("params")
96 void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
97
98 @StripPostfix("params")
99 void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
100 }
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 EXT_pixel_buffer_object extends ARB_buffer_object {
34
35 /**
36 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
37 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
38 * GetBufferParameteriv, and GetBufferPointerv:
39 */
40 int GL_PIXEL_PACK_BUFFER_EXT = 0x88EB;
41 int GL_PIXEL_UNPACK_BUFFER_EXT = 0x88EC;
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
45 * GetFloatv, and GetDoublev:
46 */
47 int GL_PIXEL_PACK_BUFFER_BINDING_EXT = 0x88ED;
48 int GL_PIXEL_UNPACK_BUFFER_BINDING_EXT = 0x88EF;
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_point_parameters {
38 int GL_POINT_SIZE_MIN_EXT = 0x8126;
39 int GL_POINT_SIZE_MAX_EXT = 0x8127;
40 int GL_POINT_FADE_THRESHOLD_SIZE_EXT = 0x8128;
41 int GL_DISTANCE_ATTENUATION_EXT = 0x8129;
42
43 void glPointParameterfEXT(@GLenum int pname, float param);
44
45 @StripPostfix("pfParams")
46 void glPointParameterfvEXT(@GLenum int pname, @Check("4") @Const FloatBuffer pfParams);
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.opengl;
32
33 import org.lwjgl.util.generator.GLenum;
34
35 public interface EXT_provoking_vertex {
36
37 /** Accepted by the &lt;mode&gt; parameter of ProvokingVertexEXT: */
38 int GL_FIRST_VERTEX_CONVENTION_EXT = 0x8E4D;
39 int GL_LAST_VERTEX_CONVENTION_EXT = 0x8E4E;
40
41 /**
42 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
43 * GetFloatv, and GetDoublev:
44 */
45 int GL_PROVOKING_VERTEX_EXT = 0x8E4F;
46 int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT = 0x8E4C;
47
48 void glProvokingVertexEXT(@GLenum int mode);
49
50 }
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 EXT_rescale_normal {
34 int GL_RESCALE_NORMAL_EXT = 0x803A;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36
37 public interface EXT_secondary_color {
38
39 int GL_COLOR_SUM_EXT = 0x8458;
40 int GL_CURRENT_SECONDARY_COLOR_EXT = 0x8459;
41 int GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = 0x845A;
42 int GL_SECONDARY_COLOR_ARRAY_TYPE_EXT = 0x845B;
43 int GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT = 0x845C;
44 int GL_SECONDARY_COLOR_ARRAY_POINTER_EXT = 0x845D;
45 int GL_SECONDARY_COLOR_ARRAY_EXT = 0x845E;
46
47 void glSecondaryColor3bEXT(byte red, byte green, byte blue);
48
49 void glSecondaryColor3fEXT(float red, float green, float blue);
50
51 void glSecondaryColor3dEXT(double red, double green, double blue);
52
53 void glSecondaryColor3ubEXT(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue);
54
55 void glSecondaryColorPointerEXT(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
56 @CachedReference
57 @BufferObject(BufferKind.ArrayVBO)
58 @Check
59 @Const
60 @GLbyte
61 @GLubyte
62 @GLfloat
63 @GLdouble Buffer pPointer);
64 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36
37 public interface EXT_separate_shader_objects {
38
39 /** Accepted by &lt;type&gt; parameter to GetIntegerv and GetFloatv: */
40 int GL_ACTIVE_PROGRAM_EXT = 0x8B8D;
41
42 void glUseShaderProgramEXT(@GLenum int type, @GLuint int program);
43
44 void glActiveProgramEXT(@GLuint int program);
45
46 @GLuint int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated @Const @GLchar ByteBuffer string);
47
48 @Alternate("glCreateShaderProgramEXT")
49 @GLuint
50 int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated CharSequence string);
51
52 }
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 EXT_separate_specular_color {
34 int GL_SINGLE_COLOR_EXT = 0x81F9;
35 int GL_SEPARATE_SPECULAR_COLOR_EXT = 0x81FA;
36 int GL_LIGHT_MODEL_COLOR_CONTROL_EXT = 0x81F8;
37 }
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.GLbitfield;
34 import org.lwjgl.util.generator.GLenum;
35 import org.lwjgl.util.generator.GLuint;
36
37 public interface EXT_shader_image_load_store {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
41 * GetFloatv, and GetDoublev:
42 */
43 int GL_MAX_IMAGE_UNITS_EXT = 0x8F38;
44 int GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT = 0x8F39;
45 int GL_MAX_IMAGE_SAMPLES_EXT = 0x906D;
46
47 /** Accepted by the &lt;target&gt; parameter of GetIntegeri_v and GetBooleani_v: */
48 int GL_IMAGE_BINDING_NAME_EXT = 0x8F3A;
49 int GL_IMAGE_BINDING_LEVEL_EXT = 0x8F3B;
50 int GL_IMAGE_BINDING_LAYERED_EXT = 0x8F3C;
51 int GL_IMAGE_BINDING_LAYER_EXT = 0x8F3D;
52 int GL_IMAGE_BINDING_ACCESS_EXT = 0x8F3E;
53 int GL_IMAGE_BINDING_FORMAT_EXT = 0x906E;
54
55 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrierEXT: */
56 int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT = 0x00000001;
57 int GL_ELEMENT_ARRAY_BARRIER_BIT_EXT = 0x00000002;
58 int GL_UNIFORM_BARRIER_BIT_EXT = 0x00000004;
59 int GL_TEXTURE_FETCH_BARRIER_BIT_EXT = 0x00000008;
60 int GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT = 0x00000020;
61 int GL_COMMAND_BARRIER_BIT_EXT = 0x00000040;
62 int GL_PIXEL_BUFFER_BARRIER_BIT_EXT = 0x00000080;
63 int GL_TEXTURE_UPDATE_BARRIER_BIT_EXT = 0x00000100;
64 int GL_BUFFER_UPDATE_BARRIER_BIT_EXT = 0x00000200;
65 int GL_FRAMEBUFFER_BARRIER_BIT_EXT = 0x00000400;
66 int GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT = 0x00000800;
67 int GL_ATOMIC_COUNTER_BARRIER_BIT_EXT = 0x00001000;
68 int GL_ALL_BARRIER_BITS_EXT = 0xFFFFFFFF;
69
70 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
71 int GL_IMAGE_1D_EXT = 0x904C;
72 int GL_IMAGE_2D_EXT = 0x904D;
73 int GL_IMAGE_3D_EXT = 0x904E;
74 int GL_IMAGE_2D_RECT_EXT = 0x904F;
75 int GL_IMAGE_CUBE_EXT = 0x9050;
76 int GL_IMAGE_BUFFER_EXT = 0x9051;
77 int GL_IMAGE_1D_ARRAY_EXT = 0x9052;
78 int GL_IMAGE_2D_ARRAY_EXT = 0x9053;
79 int GL_IMAGE_CUBE_MAP_ARRAY_EXT = 0x9054;
80 int GL_IMAGE_2D_MULTISAMPLE_EXT = 0x9055;
81 int GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x9056;
82 int GL_INT_IMAGE_1D_EXT = 0x9057;
83 int GL_INT_IMAGE_2D_EXT = 0x9058;
84 int GL_INT_IMAGE_3D_EXT = 0x9059;
85 int GL_INT_IMAGE_2D_RECT_EXT = 0x905A;
86 int GL_INT_IMAGE_CUBE_EXT = 0x905B;
87 int GL_INT_IMAGE_BUFFER_EXT = 0x905C;
88 int GL_INT_IMAGE_1D_ARRAY_EXT = 0x905D;
89 int GL_INT_IMAGE_2D_ARRAY_EXT = 0x905E;
90 int GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT = 0x905F;
91 int GL_INT_IMAGE_2D_MULTISAMPLE_EXT = 0x9060;
92 int GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x9061;
93 int GL_UNSIGNED_INT_IMAGE_1D_EXT = 0x9062;
94 int GL_UNSIGNED_INT_IMAGE_2D_EXT = 0x9063;
95 int GL_UNSIGNED_INT_IMAGE_3D_EXT = 0x9064;
96 int GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT = 0x9065;
97 int GL_UNSIGNED_INT_IMAGE_CUBE_EXT = 0x9066;
98 int GL_UNSIGNED_INT_IMAGE_BUFFER_EXT = 0x9067;
99 int GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT = 0x9068;
100 int GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT = 0x9069;
101 int GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT = 0x906A;
102 int GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT = 0x906B;
103 int GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x906C;
104
105 void glBindImageTextureEXT(@GLuint int index, @GLuint int texture, int level, boolean layered, int layer, @GLenum int access, int format);
106
107 void glMemoryBarrierEXT(@GLbitfield int barriers);
108
109 }
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 EXT_shadow_funcs {
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 EXT_shared_texture_palette {
34 int GL_SHARED_TEXTURE_PALETTE_EXT = 0x81FB;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_stencil_clear_tag {
36
37 /**
38 Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
39 GetFloatv, and GetDoublev.
40 */
41 int GL_STENCIL_TAG_BITS_EXT = 0x88F2;
42 int GL_STENCIL_CLEAR_TAG_VALUE_EXT = 0x88F3;
43
44 /**
45 Controls the stencil clear tag state. stencilTagBits is a count of
46 the number of most-significant stencil buffer bits involved in the
47 stencil clear tag update.
48 */
49 void glStencilClearTagEXT(@GLsizei int stencilTagBits, @GLuint int stencilClearTag);
50
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface EXT_stencil_two_side {
36 int GL_STENCIL_TEST_TWO_SIDE_EXT = 0x8910;
37 int GL_ACTIVE_STENCIL_FACE_EXT = 0x8911;
38
39 void glActiveStencilFaceEXT(@GLenum int face);
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 package org.lwjgl.opengl;
32
33 public interface EXT_stencil_wrap {
34 int GL_INCR_WRAP_EXT = 0x8507;
35 int GL_DECR_WRAP_EXT = 0x8508;
36 }
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 EXT_texture_3d {
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 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface EXT_texture_array {
37
38 /**
39 * Accepted by the &lt;target&gt; parameter of TexParameteri, TexParameteriv,
40 * TexParameterf, TexParameterfv, and BindTexture:
41 */
42 int GL_TEXTURE_1D_ARRAY_EXT = 0x8C18;
43 int GL_TEXTURE_2D_ARRAY_EXT = 0x8C1A;
44
45 /**
46 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
47 * CopyTexSubImage3D, CompressedTexImage3D, and CompressedTexSubImage3D:
48 */
49 int GL_PROXY_TEXTURE_2D_ARRAY_EXT = 0x8C1B;
50
51 /**
52 * Accepted by the &lt;target&gt; parameter of TexImage2D, TexSubImage2D,
53 * CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D, and
54 * CompressedTexSubImage2D:
55 */
56 int GL_PROXY_TEXTURE_1D_ARRAY_EXT = 0x8C19;
57
58 /**
59 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv
60 * and GetFloatv:
61 */
62 int GL_TEXTURE_BINDING_1D_ARRAY_EXT = 0x8C1C;
63 int GL_TEXTURE_BINDING_2D_ARRAY_EXT = 0x8C1D;
64 int GL_MAX_ARRAY_TEXTURE_LAYERS_EXT = 0x88FF;
65
66 /**
67 * Accepted by the &lt;param&gt; parameter of TexParameterf, TexParameteri,
68 * TexParameterfv, and TexParameteriv when the &lt;pname&gt; parameter is
69 * TEXTURE_COMPARE_MODE_ARB:
70 */
71 int GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT = 0x884E;
72
73 /**
74 * Accepted by the &lt;pname&gt; parameter of
75 * GetFramebufferAttachmentParameterivEXT:
76 */
77 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT = 0x8CD4;
78
79 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
80 int GL_SAMPLER_1D_ARRAY_EXT = 0x8DC0;
81 int GL_SAMPLER_2D_ARRAY_EXT = 0x8DC1;
82 int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3;
83 int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4;
84
85 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
86
87 }
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.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface EXT_texture_buffer_object {
37
38 /**
39 * Accepted by the &lt;target&gt; parameter of BindBuffer, BufferData,
40 * BufferSubData, MapBuffer, BindTexture, UnmapBuffer, GetBufferSubData,
41 * GetBufferParameteriv, GetBufferPointerv, and TexBufferEXT, and
42 * the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetFloatv, and
43 * GetIntegerv:
44 */
45 int GL_TEXTURE_BUFFER_EXT = 0x8C2A;
46
47 /**
48 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetDoublev,
49 * GetFloatv, and GetIntegerv:
50 */
51 int GL_MAX_TEXTURE_BUFFER_SIZE_EXT = 0x8C2B;
52 int GL_TEXTURE_BINDING_BUFFER_EXT = 0x8C2C;
53 int GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT = 0x8C2D;
54 int GL_TEXTURE_BUFFER_FORMAT_EXT = 0x8C2E;
55
56 void glTexBufferEXT(@GLenum int target, @GLenum int internalformat, @GLuint int buffer);
57
58 }
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.Extension;
34
35 @Extension(postfix = "EXT", className = "EXTTextureCompressionLATC")
36 public interface EXT_texture_compression_latc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D,
40 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
41 * of CompressedTexSubImage2D:
42 */
43 int GL_COMPRESSED_LUMINANCE_LATC1_EXT = 0x8C70;
44 int GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT = 0x8C71;
45 int GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C72;
46 int GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C73;
47
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.opengl;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "EXT", className = "EXTTextureCompressionRGTC")
36 public interface EXT_texture_compression_rgtc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D,
40 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
41 * of CompressedTexSubImage2D:
42 */
43 int GL_COMPRESSED_RED_RGTC1_EXT = 0x8DBB;
44 int GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8DBC;
45 int GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8DBD;
46 int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8DBE;
47
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @Extension(postfix = "EXT", className = "EXTTextureCompressionS3TC")
36 public interface EXT_texture_compression_s3tc {
37 int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
38 int GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
39 int GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
40 int GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
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.opengl;
32
33 public interface EXT_texture_env_combine {
34 int GL_COMBINE_EXT = 0x8570;
35 int GL_COMBINE_RGB_EXT = 0x8571;
36 int GL_COMBINE_ALPHA_EXT = 0x8572;
37 int GL_SOURCE0_RGB_EXT = 0x8580;
38 int GL_SOURCE1_RGB_EXT = 0x8581;
39 int GL_SOURCE2_RGB_EXT = 0x8582;
40 int GL_SOURCE0_ALPHA_EXT = 0x8588;
41 int GL_SOURCE1_ALPHA_EXT = 0x8589;
42 int GL_SOURCE2_ALPHA_EXT = 0x858A;
43 int GL_OPERAND0_RGB_EXT = 0x8590;
44 int GL_OPERAND1_RGB_EXT = 0x8591;
45 int GL_OPERAND2_RGB_EXT = 0x8592;
46 int GL_OPERAND0_ALPHA_EXT = 0x8598;
47 int GL_OPERAND1_ALPHA_EXT = 0x8599;
48 int GL_OPERAND2_ALPHA_EXT = 0x859A;
49 int GL_RGB_SCALE_EXT = 0x8573;
50 int GL_ADD_SIGNED_EXT = 0x8574;
51 int GL_INTERPOLATE_EXT = 0x8575;
52 int GL_CONSTANT_EXT = 0x8576;
53 int GL_PRIMARY_COLOR_EXT = 0x8577;
54 int GL_PREVIOUS_EXT = 0x8578;
55 }
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 EXT_texture_env_dot3 {
34 int GL_DOT3_RGB_EXT = 0x8740;
35 int GL_DOT3_RGBA_EXT = 0x8741;
36 }
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 EXT_texture_filter_anisotropic {
34 int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
35 int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
36 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface EXT_texture_integer {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
41 * GetFloatv, and GetDoublev:
42 */
43 int GL_RGBA_INTEGER_MODE_EXT = 0x8D9E;
44
45 /**
46 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
47 * TexImage2D, and TexImage3D:
48 */
49 int GL_RGBA32UI_EXT = 0x8D70;
50 int GL_RGB32UI_EXT = 0x8D71;
51 int GL_ALPHA32UI_EXT = 0x8D72;
52 int GL_INTENSITY32UI_EXT = 0x8D73;
53 int GL_LUMINANCE32UI_EXT = 0x8D74;
54 int GL_LUMINANCE_ALPHA32UI_EXT = 0x8D75;
55
56 int GL_RGBA16UI_EXT = 0x8D76;
57 int GL_RGB16UI_EXT = 0x8D77;
58 int GL_ALPHA16UI_EXT = 0x8D78;
59 int GL_INTENSITY16UI_EXT = 0x8D79;
60 int GL_LUMINANCE16UI_EXT = 0x8D7A;
61 int GL_LUMINANCE_ALPHA16UI_EXT = 0x8D7B;
62
63 int GL_RGBA8UI_EXT = 0x8D7C;
64 int GL_RGB8UI_EXT = 0x8D7D;
65 int GL_ALPHA8UI_EXT = 0x8D7E;
66 int GL_INTENSITY8UI_EXT = 0x8D7F;
67 int GL_LUMINANCE8UI_EXT = 0x8D80;
68 int GL_LUMINANCE_ALPHA8UI_EXT = 0x8D81;
69
70 int GL_RGBA32I_EXT = 0x8D82;
71 int GL_RGB32I_EXT = 0x8D83;
72 int GL_ALPHA32I_EXT = 0x8D84;
73 int GL_INTENSITY32I_EXT = 0x8D85;
74 int GL_LUMINANCE32I_EXT = 0x8D86;
75 int GL_LUMINANCE_ALPHA32I_EXT = 0x8D87;
76
77 int GL_RGBA16I_EXT = 0x8D88;
78 int GL_RGB16I_EXT = 0x8D89;
79 int GL_ALPHA16I_EXT = 0x8D8A;
80 int GL_INTENSITY16I_EXT = 0x8D8B;
81 int GL_LUMINANCE16I_EXT = 0x8D8C;
82 int GL_LUMINANCE_ALPHA16I_EXT = 0x8D8D;
83
84 int GL_RGBA8I_EXT = 0x8D8E;
85 int GL_RGB8I_EXT = 0x8D8F;
86 int GL_ALPHA8I_EXT = 0x8D90;
87 int GL_INTENSITY8I_EXT = 0x8D91;
88 int GL_LUMINANCE8I_EXT = 0x8D92;
89 int GL_LUMINANCE_ALPHA8I_EXT = 0x8D93;
90
91 /**
92 * Accepted by the &lt;format&gt; parameter of TexImage1D, TexImage2D,
93 * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D,
94 * DrawPixels and ReadPixels:
95 */
96 int GL_RED_INTEGER_EXT = 0x8D94;
97 int GL_GREEN_INTEGER_EXT = 0x8D95;
98 int GL_BLUE_INTEGER_EXT = 0x8D96;
99 int GL_ALPHA_INTEGER_EXT = 0x8D97;
100 int GL_RGB_INTEGER_EXT = 0x8D98;
101 int GL_RGBA_INTEGER_EXT = 0x8D99;
102 int GL_BGR_INTEGER_EXT = 0x8D9A;
103 int GL_BGRA_INTEGER_EXT = 0x8D9B;
104 int GL_LUMINANCE_INTEGER_EXT = 0x8D9C;
105 int GL_LUMINANCE_ALPHA_INTEGER_EXT = 0x8D9D;
106
107 void glClearColorIiEXT(int r, int g, int b, int a);
108
109 void glClearColorIuiEXT(@GLuint int r, @GLuint int g, @GLuint int b, @GLuint int a);
110
111 @StripPostfix("params")
112 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params);
113
114 @Alternate("glTexParameterIivEXT")
115 @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);
117
118 @StripPostfix("params")
119 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
120
121 @Alternate("glTexParameterIuivEXT")
122 @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);
124
125 @StripPostfix("params")
126 void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
127
128 @Alternate("glGetTexParameterIivEXT")
129 @GLreturn("params")
130 @StripPostfix(value = "params", postfix = "v")
131 void glGetTexParameterIivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
132
133 @StripPostfix("params")
134 void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params);
135
136 @Alternate("glGetTexParameterIuivEXT")
137 @GLreturn("params")
138 @StripPostfix(value = "params", postfix = "v")
139 void glGetTexParameterIuivEXT2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
140
141 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @Extension(postfix = "EXT", className = "EXTTextureLODBias")
36 public interface EXT_texture_lod_bias {
37 int GL_TEXTURE_FILTER_CONTROL_EXT = 0x8500;
38 int GL_TEXTURE_LOD_BIAS_EXT = 0x8501;
39 int GL_MAX_TEXTURE_LOD_BIAS_EXT = 0x84FD;
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 package org.lwjgl.opengl;
32
33 public interface EXT_texture_mirror_clamp {
34
35 /**
36 * Accepted by the &lt;param&gt; parameter of TexParameteri and TexParameterf,
37 * and by the &lt;params&gt; parameter of TexParameteriv and TexParameterfv,
38 * when their &lt;pname&gt; parameter is TEXTURE_WRAP_S, TEXTURE_WRAP_T,
39 * or TEXTURE_WRAP_R:
40 */
41 int GL_MIRROR_CLAMP_EXT = 0x8742;
42 int GL_MIRROR_CLAMP_TO_EDGE_EXT = 0x8743;
43 int GL_MIRROR_CLAMP_TO_BORDER_EXT = 0x8912;
44 }
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 EXT_texture_rectangle {
34 int GL_TEXTURE_RECTANGLE_EXT = 0x84F5;
35 int GL_TEXTURE_BINDING_RECTANGLE_EXT = 0x84F6;
36 int GL_PROXY_TEXTURE_RECTANGLE_EXT = 0x84F7;
37 int GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = 0x84F8;
38 }
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 EXT_texture_sRGB {
34
35 /**
36 Accepted by the &lt;internalformat&gt; parameter of TexImage1D, TexImage2D,
37 TexImage3D, CopyTexImage1D, CopyTexImage2D.
38 */
39 int GL_SRGB_EXT = 0x8C40;
40 int GL_SRGB8_EXT = 0x8C41;
41 int GL_SRGB_ALPHA_EXT = 0x8C42;
42 int GL_SRGB8_ALPHA8_EXT = 0x8C43;
43 int GL_SLUMINANCE_ALPHA_EXT = 0x8C44;
44 int GL_SLUMINANCE8_ALPHA8_EXT = 0x8C45;
45 int GL_SLUMINANCE_EXT = 0x8C46;
46 int GL_SLUMINANCE8_EXT = 0x8C47;
47 int GL_COMPRESSED_SRGB_EXT = 0x8C48;
48 int GL_COMPRESSED_SRGB_ALPHA_EXT = 0x8C49;
49 int GL_COMPRESSED_SLUMINANCE_EXT = 0x8C4A;
50 int GL_COMPRESSED_SLUMINANCE_ALPHA_EXT = 0x8C4B;
51
52 /**
53 Accepted by the &lt;internalformat&gt; parameter of TexImage2D,
54 CopyTexImage2D, and CompressedTexImage2DARB and the &lt;format&gt; parameter
55 of CompressedTexSubImage2DARB.
56 */
57 int GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
58 int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
59 int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
60 int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
61
62 }
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 EXT_texture_shared_exponent {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
37 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
38 * RenderbufferStorageEXT:
39 */
40 int GL_RGB9_E5_EXT = 0x8C3D;
41
42 /**
43 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
44 * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D,
45 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
46 * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D,
47 * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter,
48 * ColorTable, ColorSubTable, and GetColorTable:
49 */
50 int GL_UNSIGNED_INT_5_9_9_9_REV_EXT = 0x8C3E;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetTexLevelParameterfv and
54 * GetTexLevelParameteriv:
55 */
56 int GL_TEXTURE_SHARED_SIZE_EXT = 0x8C3F;
57
58 }
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 EXT_texture_snorm {
34
35 /**
36 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
37 * TexImage2D, and TexImage3D:
38 */
39 int GL_RED_SNORM = 0x8F90;
40 int GL_RG_SNORM = 0x8F91;
41 int GL_RGB_SNORM = 0x8F92;
42 int GL_RGBA_SNORM = 0x8F93;
43 int GL_ALPHA_SNORM = 0x9010;
44 int GL_LUMINANCE_SNORM = 0x9011;
45 int GL_LUMINANCE_ALPHA_SNORM = 0x9012;
46 int GL_INTENSITY_SNORM = 0x9013;
47
48 int GL_R8_SNORM = 0x8F94;
49 int GL_RG8_SNORM = 0x8F95;
50 int GL_RGB8_SNORM = 0x8F96;
51 int GL_RGBA8_SNORM = 0x8F97;
52 int GL_ALPHA8_SNORM = 0x9014;
53 int GL_LUMINANCE8_SNORM = 0x9015;
54 int GL_LUMINANCE8_ALPHA8_SNORM = 0x9016;
55 int GL_INTENSITY8_SNORM = 0x9017;
56
57 int GL_R16_SNORM = 0x8F98;
58 int GL_RG16_SNORM = 0x8F99;
59 int GL_RGB16_SNORM = 0x8F9A;
60 int GL_RGBA16_SNORM = 0x8F9B;
61 int GL_ALPHA16_SNORM = 0x9018;
62 int GL_LUMINANCE16_SNORM = 0x9019;
63 int GL_LUMINANCE16_ALPHA16_SNORM = 0x901A;
64 int GL_INTENSITY16_SNORM = 0x901B;
65
66 /** Returned by GetTexLevelParmeter */
67 int GL_SIGNED_NORMALIZED = 0x8F9C;
68
69 }
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 EXT_texture_swizzle {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameters of TexParameteri,
37 * TexParameterf, TexParameteriv, TexParameterfv,
38 * GetTexParameterfv, and GetTexParameteriv:
39 */
40 int GL_TEXTURE_SWIZZLE_R_EXT = 0x8E42;
41 int GL_TEXTURE_SWIZZLE_G_EXT = 0x8E43;
42 int GL_TEXTURE_SWIZZLE_B_EXT = 0x8E44;
43 int GL_TEXTURE_SWIZZLE_A_EXT = 0x8E45;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameters of TexParameteriv,
47 * TexParameterfv, GetTexParameterfv, and GetTexParameteriv:
48 */
49 int GL_TEXTURE_SWIZZLE_RGBA_EXT = 0x8E46;
50
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_timer_query {
38
39 /**
40 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
41 * GetQueryiv:
42 */
43 int GL_TIME_ELAPSED_EXT = 0x88BF;
44
45 @StripPostfix("params")
46 void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params);
47
48 @Alternate("glGetQueryObjecti64vEXT")
49 @GLreturn("params")
50 @StripPostfix("params")
51 void glGetQueryObjecti64vEXT2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64EXT LongBuffer params);
52
53 @StripPostfix("params")
54 void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
55
56 @Alternate("glGetQueryObjectui64vEXT")
57 @GLreturn("params")
58 @StripPostfix("params")
59 void glGetQueryObjectui64vEXT2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
60
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 public interface EXT_transform_feedback {
39
40 /**
41 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
42 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
43 * GetBufferPointerv, BindBufferRangeEXT, BindBufferOffsetEXT and
44 * BindBufferBaseEXT:
45 */
46 int GL_TRANSFORM_FEEDBACK_BUFFER_EXT = 0x8C8E;
47
48 /**
49 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedvEXT and
50 * GetBooleanIndexedvEXT:
51 */
52 int GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT = 0x8C84;
53 int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT = 0x8C85;
54
55 /**
56 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedvEXT and
57 * GetBooleanIndexedvEXT, and by the &lt;pname&gt; parameter of GetBooleanv,
58 * GetDoublev, GetIntegerv, and GetFloatv:
59 */
60 int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT = 0x8C8F;
61
62 /** Accepted by the &lt;bufferMode&gt; parameter of TransformFeedbackVaryingsEXT: */
63 int GL_INTERLEAVED_ATTRIBS_EXT = 0x8C8C;
64 int GL_SEPARATE_ATTRIBS_EXT = 0x8C8D;
65
66 /**
67 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
68 * GetQueryiv:
69 */
70 int GL_PRIMITIVES_GENERATED_EXT = 0x8C87;
71 int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT = 0x8C88;
72
73 /**
74 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
75 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
76 * GetDoublev:
77 */
78 int GL_RASTERIZER_DISCARD_EXT = 0x8C89;
79
80 /**
81 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
82 * and GetFloatv:
83 */
84 int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT = 0x8C8A;
85 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT = 0x8C8B;
86 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT = 0x8C80;
87
88 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
89 int GL_TRANSFORM_FEEDBACK_VARYINGS_EXT = 0x8C83;
90 int GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT = 0x8C7F;
91 int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT = 0x8C76;
92
93 void glBindBufferRangeEXT(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
94
95 void glBindBufferOffsetEXT(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset);
96
97 void glBindBufferBaseEXT(@GLenum int target, @GLuint int index, @GLuint int buffer);
98
99 void glBeginTransformFeedbackEXT(@GLenum int primitiveMode);
100
101 void glEndTransformFeedbackEXT();
102
103 void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count,
104 @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings,
105 @GLenum int bufferMode);
106
107 @Alternate("glTransformFeedbackVaryingsEXT")
108 void glTransformFeedbackVaryingsEXT(@GLuint int program, @Constant("varyings.length") @GLsizei int count,
109 @Const @NullTerminated @StringList("count") CharSequence[] varyings,
110 @GLenum int bufferMode);
111
112 void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
113 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
114 @OutParameter @GLsizei @Check("1") IntBuffer size,
115 @OutParameter @GLenum @Check("1") IntBuffer type,
116 @OutParameter @GLchar ByteBuffer name);
117
118 @Alternate("glGetTransformFeedbackVaryingEXT")
119 @GLreturn(value = "name", maxLength = "bufSize")
120 void glGetTransformFeedbackVaryingEXT2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
121 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
122 @OutParameter @GLsizei @Check("1") IntBuffer size,
123 @OutParameter @GLenum @Check("1") IntBuffer type,
124 @OutParameter @GLchar ByteBuffer name);
125
126 }
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 EXT_vertex_array_bgra {
34
35 /**
36 * Accepted by the &lt;size&gt; parameter of ColorPointer,
37 * SecondaryColorPointer, and VertexAttribPointer:
38 */
39 int GL_BGRA = 0x80E1;
40
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.DoubleBuffer;
37
38 @Dependent
39 public interface EXT_vertex_attrib_64bit {
40
41 /** Returned in the &lt;type&gt; parameter of GetActiveAttrib: */
42 int GL_DOUBLE_VEC2_EXT = 0x8FFC;
43 int GL_DOUBLE_VEC3_EXT = 0x8FFD;
44 int GL_DOUBLE_VEC4_EXT = 0x8FFE;
45 int GL_DOUBLE_MAT2_EXT = 0x8F46;
46 int GL_DOUBLE_MAT3_EXT = 0x8F47;
47 int GL_DOUBLE_MAT4_EXT = 0x8F48;
48 int GL_DOUBLE_MAT2x3_EXT = 0x8F49;
49 int GL_DOUBLE_MAT2x4_EXT = 0x8F4A;
50 int GL_DOUBLE_MAT3x2_EXT = 0x8F4B;
51 int GL_DOUBLE_MAT3x4_EXT = 0x8F4C;
52 int GL_DOUBLE_MAT4x2_EXT = 0x8F4D;
53 int GL_DOUBLE_MAT4x3_EXT = 0x8F4E;
54
55 void glVertexAttribL1dEXT(@GLuint int index, double x);
56
57 void glVertexAttribL2dEXT(@GLuint int index, double x, double y);
58
59 void glVertexAttribL3dEXT(@GLuint int index, double x, double y, double z);
60
61 void glVertexAttribL4dEXT(@GLuint int index, double x, double y, double z, double w);
62
63 @StripPostfix("v")
64 void glVertexAttribL1dvEXT(@GLuint int index, @Const @Check("1") DoubleBuffer v);
65
66 @StripPostfix("v")
67 void glVertexAttribL2dvEXT(@GLuint int index, @Const @Check("2") DoubleBuffer v);
68
69 @StripPostfix("v")
70 void glVertexAttribL3dvEXT(@GLuint int index, @Const @Check("3") DoubleBuffer v);
71
72 @StripPostfix("v")
73 void glVertexAttribL4dvEXT(@GLuint int index, @Const @Check("4") DoubleBuffer v);
74
75 void glVertexAttribLPointerEXT(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
76 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
77 @BufferObject(BufferKind.ArrayVBO)
78 @Check @Const @GLdouble Buffer pointer);
79
80 @StripPostfix("params")
81 void glGetVertexAttribLdvEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
82
83 @Dependent("EXT_direct_state_access")
84 void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
85
86 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_vertex_shader {
38 int GL_VERTEX_SHADER_EXT = 0x8780;
39 int GL_VERTEX_SHADER_BINDING_EXT = 0x8781;
40 int GL_OP_INDEX_EXT = 0x8782;
41 int GL_OP_NEGATE_EXT = 0x8783;
42 int GL_OP_DOT3_EXT = 0x8784;
43 int GL_OP_DOT4_EXT = 0x8785;
44 int GL_OP_MUL_EXT = 0x8786;
45 int GL_OP_ADD_EXT = 0x8787;
46 int GL_OP_MADD_EXT = 0x8788;
47 int GL_OP_FRAC_EXT = 0x8789;
48 int GL_OP_MAX_EXT = 0x878A;
49 int GL_OP_MIN_EXT = 0x878B;
50 int GL_OP_SET_GE_EXT = 0x878C;
51 int GL_OP_SET_LT_EXT = 0x878D;
52 int GL_OP_CLAMP_EXT = 0x878E;
53 int GL_OP_FLOOR_EXT = 0x878F;
54 int GL_OP_ROUND_EXT = 0x8790;
55 int GL_OP_EXP_BASE_2_EXT = 0x8791;
56 int GL_OP_LOG_BASE_2_EXT = 0x8792;
57 int GL_OP_POWER_EXT = 0x8793;
58 int GL_OP_RECIP_EXT = 0x8794;
59 int GL_OP_RECIP_SQRT_EXT = 0x8795;
60 int GL_OP_SUB_EXT = 0x8796;
61 int GL_OP_CROSS_PRODUCT_EXT = 0x8797;
62 int GL_OP_MULTIPLY_MATRIX_EXT = 0x8798;
63 int GL_OP_MOV_EXT = 0x8799;
64 int GL_OUTPUT_VERTEX_EXT = 0x879A;
65 int GL_OUTPUT_COLOR0_EXT = 0x879B;
66 int GL_OUTPUT_COLOR1_EXT = 0x879C;
67 int GL_OUTPUT_TEXTURE_COORD0_EXT = 0x879D;
68 int GL_OUTPUT_TEXTURE_COORD1_EXT = 0x879E;
69 int GL_OUTPUT_TEXTURE_COORD2_EXT = 0x879F;
70 int GL_OUTPUT_TEXTURE_COORD3_EXT = 0x87A0;
71 int GL_OUTPUT_TEXTURE_COORD4_EXT = 0x87A1;
72 int GL_OUTPUT_TEXTURE_COORD5_EXT = 0x87A2;
73 int GL_OUTPUT_TEXTURE_COORD6_EXT = 0x87A3;
74 int GL_OUTPUT_TEXTURE_COORD7_EXT = 0x87A4;
75 int GL_OUTPUT_TEXTURE_COORD8_EXT = 0x87A5;
76 int GL_OUTPUT_TEXTURE_COORD9_EXT = 0x87A6;
77 int GL_OUTPUT_TEXTURE_COORD10_EXT = 0x87A7;
78 int GL_OUTPUT_TEXTURE_COORD11_EXT = 0x87A8;
79 int GL_OUTPUT_TEXTURE_COORD12_EXT = 0x87A9;
80 int GL_OUTPUT_TEXTURE_COORD13_EXT = 0x87AA;
81 int GL_OUTPUT_TEXTURE_COORD14_EXT = 0x87AB;
82 int GL_OUTPUT_TEXTURE_COORD15_EXT = 0x87AC;
83 int GL_OUTPUT_TEXTURE_COORD16_EXT = 0x87AD;
84 int GL_OUTPUT_TEXTURE_COORD17_EXT = 0x87AE;
85 int GL_OUTPUT_TEXTURE_COORD18_EXT = 0x87AF;
86 int GL_OUTPUT_TEXTURE_COORD19_EXT = 0x87B0;
87 int GL_OUTPUT_TEXTURE_COORD20_EXT = 0x87B1;
88 int GL_OUTPUT_TEXTURE_COORD21_EXT = 0x87B2;
89 int GL_OUTPUT_TEXTURE_COORD22_EXT = 0x87B3;
90 int GL_OUTPUT_TEXTURE_COORD23_EXT = 0x87B4;
91 int GL_OUTPUT_TEXTURE_COORD24_EXT = 0x87B5;
92 int GL_OUTPUT_TEXTURE_COORD25_EXT = 0x87B6;
93 int GL_OUTPUT_TEXTURE_COORD26_EXT = 0x87B7;
94 int GL_OUTPUT_TEXTURE_COORD27_EXT = 0x87B8;
95 int GL_OUTPUT_TEXTURE_COORD28_EXT = 0x87B9;
96 int GL_OUTPUT_TEXTURE_COORD29_EXT = 0x87BA;
97 int GL_OUTPUT_TEXTURE_COORD30_EXT = 0x87BB;
98 int GL_OUTPUT_TEXTURE_COORD31_EXT = 0x87BC;
99 int GL_OUTPUT_FOG_EXT = 0x87BD;
100 int GL_SCALAR_EXT = 0x87BE;
101 int GL_VECTOR_EXT = 0x87BF;
102 int GL_MATRIX_EXT = 0x87C0;
103 int GL_VARIANT_EXT = 0x87C1;
104 int GL_INVARIANT_EXT = 0x87C2;
105 int GL_LOCAL_CONSTANT_EXT = 0x87C3;
106 int GL_LOCAL_EXT = 0x87C4;
107 int GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87C5;
108 int GL_MAX_VERTEX_SHADER_VARIANTS_EXT = 0x87C6;
109 int GL_MAX_VERTEX_SHADER_INVARIANTS_EXT = 0x87C7;
110 int GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87C8;
111 int GL_MAX_VERTEX_SHADER_LOCALS_EXT = 0x87C9;
112 int GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87CA;
113 int GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT = 0x87CB;
114 int GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT = 0x87CC;
115 int GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87CD;
116 int GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT = 0x87CE;
117 int GL_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87CF;
118 int GL_VERTEX_SHADER_VARIANTS_EXT = 0x87D0;
119 int GL_VERTEX_SHADER_INVARIANTS_EXT = 0x87D1;
120 int GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87D2;
121 int GL_VERTEX_SHADER_LOCALS_EXT = 0x87D3;
122 int GL_VERTEX_SHADER_OPTIMIZED_EXT = 0x87D4;
123 int GL_X_EXT = 0x87D5;
124 int GL_Y_EXT = 0x87D6;
125 int GL_Z_EXT = 0x87D7;
126 int GL_W_EXT = 0x87D8;
127 int GL_NEGATIVE_X_EXT = 0x87D9;
128 int GL_NEGATIVE_Y_EXT = 0x87DA;
129 int GL_NEGATIVE_Z_EXT = 0x87DB;
130 int GL_NEGATIVE_W_EXT = 0x87DC;
131 int GL_ZERO_EXT = 0x87DD;
132 int GL_ONE_EXT = 0x87DE;
133 int GL_NEGATIVE_ONE_EXT = 0x87DF;
134 int GL_NORMALIZED_RANGE_EXT = 0x87E0;
135 int GL_FULL_RANGE_EXT = 0x87E1;
136 int GL_CURRENT_VERTEX_EXT = 0x87E2;
137 int GL_MVP_MATRIX_EXT = 0x87E3;
138 int GL_VARIANT_VALUE_EXT = 0x87E4;
139 int GL_VARIANT_DATATYPE_EXT = 0x87E5;
140 int GL_VARIANT_ARRAY_STRIDE_EXT = 0x87E6;
141 int GL_VARIANT_ARRAY_TYPE_EXT = 0x87E7;
142 int GL_VARIANT_ARRAY_EXT = 0x87E8;
143 int GL_VARIANT_ARRAY_POINTER_EXT = 0x87E9;
144 int GL_INVARIANT_VALUE_EXT = 0x87EA;
145 int GL_INVARIANT_DATATYPE_EXT = 0x87EB;
146 int GL_LOCAL_CONSTANT_VALUE_EXT = 0x87EC;
147 int GL_LOCAL_CONSTANT_DATATYPE_EXT = 0x87ED;
148
149 void glBeginVertexShaderEXT();
150
151 void glEndVertexShaderEXT();
152
153 void glBindVertexShaderEXT(@GLuint int id);
154
155 @GLuint
156 int glGenVertexShadersEXT(@GLuint int range);
157
158 void glDeleteVertexShaderEXT(@GLuint int id);
159
160 void glShaderOp1EXT(@GLenum int op, @GLuint int res, @GLuint int arg1);
161
162 void glShaderOp2EXT(@GLenum int op, @GLuint int res, @GLuint int arg1, @GLuint int arg2);
163
164 void glShaderOp3EXT(@GLenum int op, @GLuint int res, @GLuint int arg1, @GLuint int arg2, @GLuint int arg3);
165
166 void glSwizzleEXT(@GLuint int res, @GLuint int in, @GLenum int outX, @GLenum int outY, @GLenum int outZ, @GLenum int outW);
167
168 void glWriteMaskEXT(@GLuint int res, @GLuint int in, @GLenum int outX, @GLenum int outY, @GLenum int outZ, @GLenum int outW);
169
170 void glInsertComponentEXT(@GLuint int res, @GLuint int src, @GLuint int num);
171
172 void glExtractComponentEXT(@GLuint int res, @GLuint int src, @GLuint int num);
173
174 @GLuint
175 int glGenSymbolsEXT(@GLenum int dataType, @GLenum int storageType, @GLenum int range, @GLuint int components);
176
177 void glSetInvariantEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type,
178 @Check("4")
179 @Const
180 @GLbyte
181 @GLubyte
182 @GLshort
183 @GLushort
184 @GLint
185 @GLuint
186 @GLfloat
187 @GLdouble Buffer pAddr);
188
189 void glSetLocalConstantEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type,
190 @Check("4")
191 @Const
192 @GLbyte
193 @GLubyte
194 @GLshort
195 @GLushort
196 @GLint
197 @GLuint
198 @GLfloat
199 @GLdouble Buffer pAddr);
200
201 @StripPostfix("pAddr")
202 void glVariantbvEXT(@GLuint int id, @Check("4") @Const ByteBuffer pAddr);
203
204 @StripPostfix("pAddr")
205 void glVariantsvEXT(@GLuint int id, @Check("4") @Const ShortBuffer pAddr);
206
207 @StripPostfix("pAddr")
208 void glVariantivEXT(@GLuint int id, @Check("4") @Const IntBuffer pAddr);
209
210 @StripPostfix("pAddr")
211 void glVariantfvEXT(@GLuint int id, @Check("4") @Const FloatBuffer pAddr);
212
213 @StripPostfix("pAddr")
214 void glVariantdvEXT(@GLuint int id, @Check("4") @Const DoubleBuffer pAddr);
215
216 @StripPostfix("pAddr")
217 void glVariantubvEXT(@GLuint int id, @Check("4") @Const @GLubyte ByteBuffer pAddr);
218
219 @StripPostfix("pAddr")
220 void glVariantusvEXT(@GLuint int id, @Check("4") @Const @GLushort ShortBuffer pAddr);
221
222 @StripPostfix("pAddr")
223 void glVariantuivEXT(@GLuint int id, @Check("4") @Const @GLuint IntBuffer pAddr);
224
225 void glVariantPointerEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type, @GLuint int stride,
226 @CachedReference
227 @BufferObject(BufferKind.ArrayVBO)
228 @Check
229 @Const
230 @GLbyte
231 @GLshort
232 @GLint
233 @GLubyte
234 @GLushort
235 @GLuint
236 @GLfloat
237 @GLdouble Buffer pAddr);
238
239 void glEnableVariantClientStateEXT(@GLuint int id);
240
241 void glDisableVariantClientStateEXT(@GLuint int id);
242
243 @GLuint
244 int glBindLightParameterEXT(@GLenum int light, @GLenum int value);
245
246 @GLuint
247 int glBindMaterialParameterEXT(@GLenum int face, @GLenum int value);
248
249 @GLuint
250 int glBindTexGenParameterEXT(@GLenum int unit, @GLenum int coord, @GLenum int value);
251
252 @GLuint
253 int glBindTextureUnitParameterEXT(@GLenum int unit, @GLenum int value);
254
255 @GLuint
256 int glBindParameterEXT(@GLenum int value);
257
258 boolean glIsVariantEnabledEXT(@GLuint int id, @GLenum int cap);
259
260 @StripPostfix("pbData")
261 void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData);
262
263 @StripPostfix("pbData")
264 void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData);
265
266 @StripPostfix("pbData")
267 void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData);
268
269 @StripPostfix("pbData")
270 void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @OutParameter @Result @GLvoid ByteBuffer pbData);
271
272 @StripPostfix("pbData")
273 void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData);
274
275 @StripPostfix("pbData")
276 void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData);
277
278 @StripPostfix("pbData")
279 void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData);
280
281 @StripPostfix("pbData")
282 void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData);
283
284 @StripPostfix("pbData")
285 void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData);
286
287 @StripPostfix("pbData")
288 void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData);
289 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface EXT_vertex_weighting {
38 int GL_MODELVIEW0_STACK_DEPTH_EXT = 0x0BA3;
39 int GL_MODELVIEW1_STACK_DEPTH_EXT = 0x8502;
40 int GL_MODELVIEW0_MATRIX_EXT = 0x0BA6;
41 int GL_MODELVIEW1_MATRIX_EXT = 0x8506;
42 int GL_VERTEX_WEIGHTING_EXT = 0x8509;
43 int GL_MODELVIEW0_EXT = 0x1700;
44 int GL_MODELVIEW1_EXT = 0x850A;
45 int GL_CURRENT_VERTEX_WEIGHT_EXT = 0x850B;
46 int GL_VERTEX_WEIGHT_ARRAY_EXT = 0x850C;
47 int GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT = 0x850D;
48 int GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT = 0x850E;
49 int GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT = 0x850F;
50 int GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT = 0x8510;
51
52 @NoErrorCheck
53 void glVertexWeightfEXT(float weight);
54
55 void glVertexWeightPointerEXT(@GLsizei int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
56 @CachedReference
57 @BufferObject(BufferKind.ArrayVBO)
58 @Check
59 @Const
60 @GLfloat Buffer pPointer);
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 /**
38 * The core OpenGL1.1 API.
39 *
40 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3316 $
42 * $Id: GL11.java 3316 2010-04-09 23:57:40Z spasi $
43 */
44 @DeprecatedGL
45 public interface GL11 {
46 /* AccumOp */
47 int GL_ACCUM = 0x0100;
48 int GL_LOAD = 0x0101;
49 int GL_RETURN = 0x0102;
50 int GL_MULT = 0x0103;
51 int GL_ADD = 0x0104;
52
53 /* AlphaFunction */
54 int GL_NEVER = 0x0200;
55 int GL_LESS = 0x0201;
56 int GL_EQUAL = 0x0202;
57 int GL_LEQUAL = 0x0203;
58 int GL_GREATER = 0x0204;
59 int GL_NOTEQUAL = 0x0205;
60 int GL_GEQUAL = 0x0206;
61 int GL_ALWAYS = 0x0207;
62
63 /* AttribMask */
64 int GL_CURRENT_BIT = 0x00000001;
65 int GL_POINT_BIT = 0x00000002;
66 int GL_LINE_BIT = 0x00000004;
67 int GL_POLYGON_BIT = 0x00000008;
68 int GL_POLYGON_STIPPLE_BIT = 0x00000010;
69 int GL_PIXEL_MODE_BIT = 0x00000020;
70 int GL_LIGHTING_BIT = 0x00000040;
71 int GL_FOG_BIT = 0x00000080;
72 int GL_DEPTH_BUFFER_BIT = 0x00000100;
73 int GL_ACCUM_BUFFER_BIT = 0x00000200;
74 int GL_STENCIL_BUFFER_BIT = 0x00000400;
75 int GL_VIEWPORT_BIT = 0x00000800;
76 int GL_TRANSFORM_BIT = 0x00001000;
77 int GL_ENABLE_BIT = 0x00002000;
78 int GL_COLOR_BUFFER_BIT = 0x00004000;
79 int GL_HINT_BIT = 0x00008000;
80 int GL_EVAL_BIT = 0x00010000;
81 int GL_LIST_BIT = 0x00020000;
82 int GL_TEXTURE_BIT = 0x00040000;
83 int GL_SCISSOR_BIT = 0x00080000;
84 int GL_ALL_ATTRIB_BITS = 0x000fffff;
85
86 /* BeginMode */
87 int GL_POINTS = 0x0000;
88 int GL_LINES = 0x0001;
89 int GL_LINE_LOOP = 0x0002;
90 int GL_LINE_STRIP = 0x0003;
91 int GL_TRIANGLES = 0x0004;
92 int GL_TRIANGLE_STRIP = 0x0005;
93 int GL_TRIANGLE_FAN = 0x0006;
94 int GL_QUADS = 0x0007;
95 int GL_QUAD_STRIP = 0x0008;
96 int GL_POLYGON = 0x0009;
97
98 /* BlendingFactorDest */
99 int GL_ZERO = 0;
100 int GL_ONE = 1;
101 int GL_SRC_COLOR = 0x0300;
102 int GL_ONE_MINUS_SRC_COLOR = 0x0301;
103 int GL_SRC_ALPHA = 0x0302;
104 int GL_ONE_MINUS_SRC_ALPHA = 0x0303;
105 int GL_DST_ALPHA = 0x0304;
106 int GL_ONE_MINUS_DST_ALPHA = 0x0305;
107
108 /* BlendingFactorSrc */
109 /* GL_ZERO */
110 /* GL_ONE */
111 int GL_DST_COLOR = 0x0306;
112 int GL_ONE_MINUS_DST_COLOR = 0x0307;
113 int GL_SRC_ALPHA_SATURATE = 0x0308;
114 int GL_CONSTANT_COLOR = 0x8001;
115 int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
116 int GL_CONSTANT_ALPHA = 0x8003;
117 int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;
118
119 /* Boolean */
120 int GL_TRUE = 1;
121 int GL_FALSE = 0;
122
123 /* ClipPlaneName */
124 int GL_CLIP_PLANE0 = 0x3000;
125 int GL_CLIP_PLANE1 = 0x3001;
126 int GL_CLIP_PLANE2 = 0x3002;
127 int GL_CLIP_PLANE3 = 0x3003;
128 int GL_CLIP_PLANE4 = 0x3004;
129 int GL_CLIP_PLANE5 = 0x3005;
130
131 /* DataType */
132 int GL_BYTE = 0x1400;
133 int GL_UNSIGNED_BYTE = 0x1401;
134 int GL_SHORT = 0x1402;
135 int GL_UNSIGNED_SHORT = 0x1403;
136 int GL_INT = 0x1404;
137 int GL_UNSIGNED_INT = 0x1405;
138 int GL_FLOAT = 0x1406;
139 int GL_2_BYTES = 0x1407;
140 int GL_3_BYTES = 0x1408;
141 int GL_4_BYTES = 0x1409;
142 int GL_DOUBLE = 0x140A;
143
144 /* DrawBufferMode */
145 int GL_NONE = 0;
146 int GL_FRONT_LEFT = 0x0400;
147 int GL_FRONT_RIGHT = 0x0401;
148 int GL_BACK_LEFT = 0x0402;
149 int GL_BACK_RIGHT = 0x0403;
150 int GL_FRONT = 0x0404;
151 int GL_BACK = 0x0405;
152 int GL_LEFT = 0x0406;
153 int GL_RIGHT = 0x0407;
154 int GL_FRONT_AND_BACK = 0x0408;
155 int GL_AUX0 = 0x0409;
156 int GL_AUX1 = 0x040A;
157 int GL_AUX2 = 0x040B;
158 int GL_AUX3 = 0x040C;
159
160 /* ErrorCode */
161 int GL_NO_ERROR = 0;
162 int GL_INVALID_ENUM = 0x0500;
163 int GL_INVALID_VALUE = 0x0501;
164 int GL_INVALID_OPERATION = 0x0502;
165 int GL_STACK_OVERFLOW = 0x0503;
166 int GL_STACK_UNDERFLOW = 0x0504;
167 int GL_OUT_OF_MEMORY = 0x0505;
168
169 /* FeedBackMode */
170 int GL_2D = 0x0600;
171 int GL_3D = 0x0601;
172 int GL_3D_COLOR = 0x0602;
173 int GL_3D_COLOR_TEXTURE = 0x0603;
174 int GL_4D_COLOR_TEXTURE = 0x0604;
175
176 /* FeedBackToken */
177 int GL_PASS_THROUGH_TOKEN = 0x0700;
178 int GL_POINT_TOKEN = 0x0701;
179 int GL_LINE_TOKEN = 0x0702;
180 int GL_POLYGON_TOKEN = 0x0703;
181 int GL_BITMAP_TOKEN = 0x0704;
182 int GL_DRAW_PIXEL_TOKEN = 0x0705;
183 int GL_COPY_PIXEL_TOKEN = 0x0706;
184 int GL_LINE_RESET_TOKEN = 0x0707;
185
186 /* FogMode */
187 /* GL_LINEAR */
188 int GL_EXP = 0x0800;
189 int GL_EXP2 = 0x0801;
190
191 /* FrontFaceDirection */
192 int GL_CW = 0x0900;
193 int GL_CCW = 0x0901;
194
195 /* GetMapTarget */
196 int GL_COEFF = 0x0A00;
197 int GL_ORDER = 0x0A01;
198 int GL_DOMAIN = 0x0A02;
199
200 /* GetTarget */
201 int GL_CURRENT_COLOR = 0x0B00;
202 int GL_CURRENT_INDEX = 0x0B01;
203 int GL_CURRENT_NORMAL = 0x0B02;
204 int GL_CURRENT_TEXTURE_COORDS = 0x0B03;
205 int GL_CURRENT_RASTER_COLOR = 0x0B04;
206 int GL_CURRENT_RASTER_INDEX = 0x0B05;
207 int GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06;
208 int GL_CURRENT_RASTER_POSITION = 0x0B07;
209 int GL_CURRENT_RASTER_POSITION_VALID = 0x0B08;
210 int GL_CURRENT_RASTER_DISTANCE = 0x0B09;
211 int GL_POINT_SMOOTH = 0x0B10;
212 int GL_POINT_SIZE = 0x0B11;
213 int GL_POINT_SIZE_RANGE = 0x0B12;
214 int GL_POINT_SIZE_GRANULARITY = 0x0B13;
215 int GL_LINE_SMOOTH = 0x0B20;
216 int GL_LINE_WIDTH = 0x0B21;
217 int GL_LINE_WIDTH_RANGE = 0x0B22;
218 int GL_LINE_WIDTH_GRANULARITY = 0x0B23;
219 int GL_LINE_STIPPLE = 0x0B24;
220 int GL_LINE_STIPPLE_PATTERN = 0x0B25;
221 int GL_LINE_STIPPLE_REPEAT = 0x0B26;
222 int GL_LIST_MODE = 0x0B30;
223 int GL_MAX_LIST_NESTING = 0x0B31;
224 int GL_LIST_BASE = 0x0B32;
225 int GL_LIST_INDEX = 0x0B33;
226 int GL_POLYGON_MODE = 0x0B40;
227 int GL_POLYGON_SMOOTH = 0x0B41;
228 int GL_POLYGON_STIPPLE = 0x0B42;
229 int GL_EDGE_FLAG = 0x0B43;
230 int GL_CULL_FACE = 0x0B44;
231 int GL_CULL_FACE_MODE = 0x0B45;
232 int GL_FRONT_FACE = 0x0B46;
233 int GL_LIGHTING = 0x0B50;
234 int GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51;
235 int GL_LIGHT_MODEL_TWO_SIDE = 0x0B52;
236 int GL_LIGHT_MODEL_AMBIENT = 0x0B53;
237 int GL_SHADE_MODEL = 0x0B54;
238 int GL_COLOR_MATERIAL_FACE = 0x0B55;
239 int GL_COLOR_MATERIAL_PARAMETER = 0x0B56;
240 int GL_COLOR_MATERIAL = 0x0B57;
241 int GL_FOG = 0x0B60;
242 int GL_FOG_INDEX = 0x0B61;
243 int GL_FOG_DENSITY = 0x0B62;
244 int GL_FOG_START = 0x0B63;
245 int GL_FOG_END = 0x0B64;
246 int GL_FOG_MODE = 0x0B65;
247 int GL_FOG_COLOR = 0x0B66;
248 int GL_DEPTH_RANGE = 0x0B70;
249 int GL_DEPTH_TEST = 0x0B71;
250 int GL_DEPTH_WRITEMASK = 0x0B72;
251 int GL_DEPTH_CLEAR_VALUE = 0x0B73;
252 int GL_DEPTH_FUNC = 0x0B74;
253 int GL_ACCUM_CLEAR_VALUE = 0x0B80;
254 int GL_STENCIL_TEST = 0x0B90;
255 int GL_STENCIL_CLEAR_VALUE = 0x0B91;
256 int GL_STENCIL_FUNC = 0x0B92;
257 int GL_STENCIL_VALUE_MASK = 0x0B93;
258 int GL_STENCIL_FAIL = 0x0B94;
259 int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95;
260 int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96;
261 int GL_STENCIL_REF = 0x0B97;
262 int GL_STENCIL_WRITEMASK = 0x0B98;
263 int GL_MATRIX_MODE = 0x0BA0;
264 int GL_NORMALIZE = 0x0BA1;
265 int GL_VIEWPORT = 0x0BA2;
266 int GL_MODELVIEW_STACK_DEPTH = 0x0BA3;
267 int GL_PROJECTION_STACK_DEPTH = 0x0BA4;
268 int GL_TEXTURE_STACK_DEPTH = 0x0BA5;
269 int GL_MODELVIEW_MATRIX = 0x0BA6;
270 int GL_PROJECTION_MATRIX = 0x0BA7;
271 int GL_TEXTURE_MATRIX = 0x0BA8;
272 int GL_ATTRIB_STACK_DEPTH = 0x0BB0;
273 int GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1;
274 int GL_ALPHA_TEST = 0x0BC0;
275 int GL_ALPHA_TEST_FUNC = 0x0BC1;
276 int GL_ALPHA_TEST_REF = 0x0BC2;
277 int GL_DITHER = 0x0BD0;
278 int GL_BLEND_DST = 0x0BE0;
279 int GL_BLEND_SRC = 0x0BE1;
280 int GL_BLEND = 0x0BE2;
281 int GL_LOGIC_OP_MODE = 0x0BF0;
282 int GL_INDEX_LOGIC_OP = 0x0BF1;
283 int GL_COLOR_LOGIC_OP = 0x0BF2;
284 int GL_AUX_BUFFERS = 0x0C00;
285 int GL_DRAW_BUFFER = 0x0C01;
286 int GL_READ_BUFFER = 0x0C02;
287 int GL_SCISSOR_BOX = 0x0C10;
288 int GL_SCISSOR_TEST = 0x0C11;
289 int GL_INDEX_CLEAR_VALUE = 0x0C20;
290 int GL_INDEX_WRITEMASK = 0x0C21;
291 int GL_COLOR_CLEAR_VALUE = 0x0C22;
292 int GL_COLOR_WRITEMASK = 0x0C23;
293 int GL_INDEX_MODE = 0x0C30;
294 int GL_RGBA_MODE = 0x0C31;
295 int GL_DOUBLEBUFFER = 0x0C32;
296 int GL_STEREO = 0x0C33;
297 int GL_RENDER_MODE = 0x0C40;
298 int GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50;
299 int GL_POINT_SMOOTH_HINT = 0x0C51;
300 int GL_LINE_SMOOTH_HINT = 0x0C52;
301 int GL_POLYGON_SMOOTH_HINT = 0x0C53;
302 int GL_FOG_HINT = 0x0C54;
303 int GL_TEXTURE_GEN_S = 0x0C60;
304 int GL_TEXTURE_GEN_T = 0x0C61;
305 int GL_TEXTURE_GEN_R = 0x0C62;
306 int GL_TEXTURE_GEN_Q = 0x0C63;
307 int GL_PIXEL_MAP_I_TO_I = 0x0C70;
308 int GL_PIXEL_MAP_S_TO_S = 0x0C71;
309 int GL_PIXEL_MAP_I_TO_R = 0x0C72;
310 int GL_PIXEL_MAP_I_TO_G = 0x0C73;
311 int GL_PIXEL_MAP_I_TO_B = 0x0C74;
312 int GL_PIXEL_MAP_I_TO_A = 0x0C75;
313 int GL_PIXEL_MAP_R_TO_R = 0x0C76;
314 int GL_PIXEL_MAP_G_TO_G = 0x0C77;
315 int GL_PIXEL_MAP_B_TO_B = 0x0C78;
316 int GL_PIXEL_MAP_A_TO_A = 0x0C79;
317 int GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0;
318 int GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1;
319 int GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2;
320 int GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3;
321 int GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4;
322 int GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5;
323 int GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6;
324 int GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7;
325 int GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8;
326 int GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9;
327 int GL_UNPACK_SWAP_BYTES = 0x0CF0;
328 int GL_UNPACK_LSB_FIRST = 0x0CF1;
329 int GL_UNPACK_ROW_LENGTH = 0x0CF2;
330 int GL_UNPACK_SKIP_ROWS = 0x0CF3;
331 int GL_UNPACK_SKIP_PIXELS = 0x0CF4;
332 int GL_UNPACK_ALIGNMENT = 0x0CF5;
333 int GL_PACK_SWAP_BYTES = 0x0D00;
334 int GL_PACK_LSB_FIRST = 0x0D01;
335 int GL_PACK_ROW_LENGTH = 0x0D02;
336 int GL_PACK_SKIP_ROWS = 0x0D03;
337 int GL_PACK_SKIP_PIXELS = 0x0D04;
338 int GL_PACK_ALIGNMENT = 0x0D05;
339 int GL_MAP_COLOR = 0x0D10;
340 int GL_MAP_STENCIL = 0x0D11;
341 int GL_INDEX_SHIFT = 0x0D12;
342 int GL_INDEX_OFFSET = 0x0D13;
343 int GL_RED_SCALE = 0x0D14;
344 int GL_RED_BIAS = 0x0D15;
345 int GL_ZOOM_X = 0x0D16;
346 int GL_ZOOM_Y = 0x0D17;
347 int GL_GREEN_SCALE = 0x0D18;
348 int GL_GREEN_BIAS = 0x0D19;
349 int GL_BLUE_SCALE = 0x0D1A;
350 int GL_BLUE_BIAS = 0x0D1B;
351 int GL_ALPHA_SCALE = 0x0D1C;
352 int GL_ALPHA_BIAS = 0x0D1D;
353 int GL_DEPTH_SCALE = 0x0D1E;
354 int GL_DEPTH_BIAS = 0x0D1F;
355 int GL_MAX_EVAL_ORDER = 0x0D30;
356 int GL_MAX_LIGHTS = 0x0D31;
357 int GL_MAX_CLIP_PLANES = 0x0D32;
358 int GL_MAX_TEXTURE_SIZE = 0x0D33;
359 int GL_MAX_PIXEL_MAP_TABLE = 0x0D34;
360 int GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35;
361 int GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36;
362 int GL_MAX_NAME_STACK_DEPTH = 0x0D37;
363 int GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38;
364 int GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39;
365 int GL_MAX_VIEWPORT_DIMS = 0x0D3A;
366 int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0x0D3B;
367 int GL_SUBPIXEL_BITS = 0x0D50;
368 int GL_INDEX_BITS = 0x0D51;
369 int GL_RED_BITS = 0x0D52;
370 int GL_GREEN_BITS = 0x0D53;
371 int GL_BLUE_BITS = 0x0D54;
372 int GL_ALPHA_BITS = 0x0D55;
373 int GL_DEPTH_BITS = 0x0D56;
374 int GL_STENCIL_BITS = 0x0D57;
375 int GL_ACCUM_RED_BITS = 0x0D58;
376 int GL_ACCUM_GREEN_BITS = 0x0D59;
377 int GL_ACCUM_BLUE_BITS = 0x0D5A;
378 int GL_ACCUM_ALPHA_BITS = 0x0D5B;
379 int GL_NAME_STACK_DEPTH = 0x0D70;
380 int GL_AUTO_NORMAL = 0x0D80;
381 int GL_MAP1_COLOR_4 = 0x0D90;
382 int GL_MAP1_INDEX = 0x0D91;
383 int GL_MAP1_NORMAL = 0x0D92;
384 int GL_MAP1_TEXTURE_COORD_1 = 0x0D93;
385 int GL_MAP1_TEXTURE_COORD_2 = 0x0D94;
386 int GL_MAP1_TEXTURE_COORD_3 = 0x0D95;
387 int GL_MAP1_TEXTURE_COORD_4 = 0x0D96;
388 int GL_MAP1_VERTEX_3 = 0x0D97;
389 int GL_MAP1_VERTEX_4 = 0x0D98;
390 int GL_MAP2_COLOR_4 = 0x0DB0;
391 int GL_MAP2_INDEX = 0x0DB1;
392 int GL_MAP2_NORMAL = 0x0DB2;
393 int GL_MAP2_TEXTURE_COORD_1 = 0x0DB3;
394 int GL_MAP2_TEXTURE_COORD_2 = 0x0DB4;
395 int GL_MAP2_TEXTURE_COORD_3 = 0x0DB5;
396 int GL_MAP2_TEXTURE_COORD_4 = 0x0DB6;
397 int GL_MAP2_VERTEX_3 = 0x0DB7;
398 int GL_MAP2_VERTEX_4 = 0x0DB8;
399 int GL_MAP1_GRID_DOMAIN = 0x0DD0;
400 int GL_MAP1_GRID_SEGMENTS = 0x0DD1;
401 int GL_MAP2_GRID_DOMAIN = 0x0DD2;
402 int GL_MAP2_GRID_SEGMENTS = 0x0DD3;
403 int GL_TEXTURE_1D = 0x0DE0;
404 int GL_TEXTURE_2D = 0x0DE1;
405 int GL_FEEDBACK_BUFFER_POINTER = 0x0DF0;
406 int GL_FEEDBACK_BUFFER_SIZE = 0x0DF1;
407 int GL_FEEDBACK_BUFFER_TYPE = 0x0DF2;
408 int GL_SELECTION_BUFFER_POINTER = 0x0DF3;
409 int GL_SELECTION_BUFFER_SIZE = 0x0DF4;
410
411 /* GetTextureParameter */
412 /* GL_TEXTURE_MAG_FILTER */
413 /* GL_TEXTURE_MIN_FILTER */
414 /* GL_TEXTURE_WRAP_S */
415 /* GL_TEXTURE_WRAP_T */
416 int GL_TEXTURE_WIDTH = 0x1000;
417 int GL_TEXTURE_HEIGHT = 0x1001;
418 int GL_TEXTURE_INTERNAL_FORMAT = 0x1003;
419 int GL_TEXTURE_BORDER_COLOR = 0x1004;
420 int GL_TEXTURE_BORDER = 0x1005;
421 /* GL_TEXTURE_RED_SIZE */
422 /* GL_TEXTURE_GREEN_SIZE */
423 /* GL_TEXTURE_BLUE_SIZE */
424 /* GL_TEXTURE_ALPHA_SIZE */
425 /* GL_TEXTURE_LUMINANCE_SIZE */
426 /* GL_TEXTURE_INTENSITY_SIZE */
427 /* GL_TEXTURE_PRIORITY */
428 /* GL_TEXTURE_RESIDENT */
429
430 /* HintMode */
431 int GL_DONT_CARE = 0x1100;
432 int GL_FASTEST = 0x1101;
433 int GL_NICEST = 0x1102;
434
435 /* LightName */
436 int GL_LIGHT0 = 0x4000;
437 int GL_LIGHT1 = 0x4001;
438 int GL_LIGHT2 = 0x4002;
439 int GL_LIGHT3 = 0x4003;
440 int GL_LIGHT4 = 0x4004;
441 int GL_LIGHT5 = 0x4005;
442 int GL_LIGHT6 = 0x4006;
443 int GL_LIGHT7 = 0x4007;
444
445 /* LightParameter */
446 int GL_AMBIENT = 0x1200;
447 int GL_DIFFUSE = 0x1201;
448 int GL_SPECULAR = 0x1202;
449 int GL_POSITION = 0x1203;
450 int GL_SPOT_DIRECTION = 0x1204;
451 int GL_SPOT_EXPONENT = 0x1205;
452 int GL_SPOT_CUTOFF = 0x1206;
453 int GL_CONSTANT_ATTENUATION = 0x1207;
454 int GL_LINEAR_ATTENUATION = 0x1208;
455 int GL_QUADRATIC_ATTENUATION = 0x1209;
456
457 /* ListMode */
458 int GL_COMPILE = 0x1300;
459 int GL_COMPILE_AND_EXECUTE = 0x1301;
460
461 /* LogicOp */
462 int GL_CLEAR = 0x1500;
463 int GL_AND = 0x1501;
464 int GL_AND_REVERSE = 0x1502;
465 int GL_COPY = 0x1503;
466 int GL_AND_INVERTED = 0x1504;
467 int GL_NOOP = 0x1505;
468 int GL_XOR = 0x1506;
469 int GL_OR = 0x1507;
470 int GL_NOR = 0x1508;
471 int GL_EQUIV = 0x1509;
472 int GL_INVERT = 0x150A;
473 int GL_OR_REVERSE = 0x150B;
474 int GL_COPY_INVERTED = 0x150C;
475 int GL_OR_INVERTED = 0x150D;
476 int GL_NAND = 0x150E;
477 int GL_SET = 0x150F;
478
479 /* MaterialParameter */
480 int GL_EMISSION = 0x1600;
481 int GL_SHININESS = 0x1601;
482 int GL_AMBIENT_AND_DIFFUSE = 0x1602;
483 int GL_COLOR_INDEXES = 0x1603;
484 /* GL_AMBIENT */
485 /* GL_DIFFUSE */
486 /* GL_SPECULAR */
487
488 /* MatrixMode */
489 int GL_MODELVIEW = 0x1700;
490 int GL_PROJECTION = 0x1701;
491 int GL_TEXTURE = 0x1702;
492
493 /* PixelCopyType */
494 int GL_COLOR = 0x1800;
495 int GL_DEPTH = 0x1801;
496 int GL_STENCIL = 0x1802;
497
498 /* PixelFormat */
499 int GL_COLOR_INDEX = 0x1900;
500 int GL_STENCIL_INDEX = 0x1901;
501 int GL_DEPTH_COMPONENT = 0x1902;
502 int GL_RED = 0x1903;
503 int GL_GREEN = 0x1904;
504 int GL_BLUE = 0x1905;
505 int GL_ALPHA = 0x1906;
506 int GL_RGB = 0x1907;
507 int GL_RGBA = 0x1908;
508 int GL_LUMINANCE = 0x1909;
509 int GL_LUMINANCE_ALPHA = 0x190A;
510
511 /* PixelType */
512 int GL_BITMAP = 0x1A00;
513 /* GL_BYTE */
514 /* GL_UNSIGNED_BYTE */
515 /* GL_SHORT */
516 /* GL_UNSIGNED_SHORT */
517 /* GL_INT */
518 /* GL_UNSIGNED_INT */
519 /* GL_FLOAT */
520
521 /* PolygonMode */
522 int GL_POINT = 0x1B00;
523 int GL_LINE = 0x1B01;
524 int GL_FILL = 0x1B02;
525
526 /* RenderingMode */
527 int GL_RENDER = 0x1C00;
528 int GL_FEEDBACK = 0x1C01;
529 int GL_SELECT = 0x1C02;
530
531 /* ShadingModel */
532 int GL_FLAT = 0x1D00;
533 int GL_SMOOTH = 0x1D01;
534
535 /* StencilOp */
536 /* GL_ZERO */
537 int GL_KEEP = 0x1E00;
538 int GL_REPLACE = 0x1E01;
539 int GL_INCR = 0x1E02;
540 int GL_DECR = 0x1E03;
541 /* GL_INVERT */
542
543 /* StringName */
544 int GL_VENDOR = 0x1F00;
545 int GL_RENDERER = 0x1F01;
546 int GL_VERSION = 0x1F02;
547 int GL_EXTENSIONS = 0x1F03;
548
549 /* TextureCoordName */
550 int GL_S = 0x2000;
551 int GL_T = 0x2001;
552 int GL_R = 0x2002;
553 int GL_Q = 0x2003;
554
555 /* TexCoordPointerType */
556 /* GL_SHORT */
557 /* GL_INT */
558 /* GL_FLOAT */
559 /* GL_DOUBLE */
560
561 /* TextureEnvMode */
562 int GL_MODULATE = 0x2100;
563 int GL_DECAL = 0x2101;
564 /* GL_BLEND */
565 /* GL_REPLACE */
566
567 /* TextureEnvParameter */
568 int GL_TEXTURE_ENV_MODE = 0x2200;
569 int GL_TEXTURE_ENV_COLOR = 0x2201;
570
571 /* TextureEnvTarget */
572 int GL_TEXTURE_ENV = 0x2300;
573
574 /* TextureGenMode */
575 int GL_EYE_LINEAR = 0x2400;
576 int GL_OBJECT_LINEAR = 0x2401;
577 int GL_SPHERE_MAP = 0x2402;
578
579 /* TextureGenParameter */
580 int GL_TEXTURE_GEN_MODE = 0x2500;
581 int GL_OBJECT_PLANE = 0x2501;
582 int GL_EYE_PLANE = 0x2502;
583
584 /* TextureMagFilter */
585 int GL_NEAREST = 0x2600;
586 int GL_LINEAR = 0x2601;
587
588 /* TextureMinFilter */
589 /* GL_NEAREST */
590 /* GL_LINEAR */
591 int GL_NEAREST_MIPMAP_NEAREST = 0x2700;
592 int GL_LINEAR_MIPMAP_NEAREST = 0x2701;
593 int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
594 int GL_LINEAR_MIPMAP_LINEAR = 0x2703;
595
596 /* TextureParameterName */
597 int GL_TEXTURE_MAG_FILTER = 0x2800;
598 int GL_TEXTURE_MIN_FILTER = 0x2801;
599 int GL_TEXTURE_WRAP_S = 0x2802;
600 int GL_TEXTURE_WRAP_T = 0x2803;
601 /* GL_TEXTURE_BORDER_COLOR */
602 /* GL_TEXTURE_PRIORITY */
603
604 /* TextureWrapMode */
605 int GL_CLAMP = 0x2900;
606 int GL_REPEAT = 0x2901;
607
608 /* ClientAttribMask */
609 int GL_CLIENT_PIXEL_STORE_BIT = 0x00000001;
610 int GL_CLIENT_VERTEX_ARRAY_BIT = 0x00000002;
611 int GL_ALL_CLIENT_ATTRIB_BITS = 0xffffffff;
612
613 /* polygon_offset */
614 int GL_POLYGON_OFFSET_FACTOR = 0x8038;
615 int GL_POLYGON_OFFSET_UNITS = 0x2A00;
616 int GL_POLYGON_OFFSET_POINT = 0x2A01;
617 int GL_POLYGON_OFFSET_LINE = 0x2A02;
618 int GL_POLYGON_OFFSET_FILL = 0x8037;
619
620 /* texture */
621 int GL_ALPHA4 = 0x803B;
622 int GL_ALPHA8 = 0x803C;
623 int GL_ALPHA12 = 0x803D;
624 int GL_ALPHA16 = 0x803E;
625 int GL_LUMINANCE4 = 0x803F;
626 int GL_LUMINANCE8 = 0x8040;
627 int GL_LUMINANCE12 = 0x8041;
628 int GL_LUMINANCE16 = 0x8042;
629 int GL_LUMINANCE4_ALPHA4 = 0x8043;
630 int GL_LUMINANCE6_ALPHA2 = 0x8044;
631 int GL_LUMINANCE8_ALPHA8 = 0x8045;
632 int GL_LUMINANCE12_ALPHA4 = 0x8046;
633 int GL_LUMINANCE12_ALPHA12 = 0x8047;
634 int GL_LUMINANCE16_ALPHA16 = 0x8048;
635 int GL_INTENSITY = 0x8049;
636 int GL_INTENSITY4 = 0x804A;
637 int GL_INTENSITY8 = 0x804B;
638 int GL_INTENSITY12 = 0x804C;
639 int GL_INTENSITY16 = 0x804D;
640 int GL_R3_G3_B2 = 0x2A10;
641 int GL_RGB4 = 0x804F;
642 int GL_RGB5 = 0x8050;
643 int GL_RGB8 = 0x8051;
644 int GL_RGB10 = 0x8052;
645 int GL_RGB12 = 0x8053;
646 int GL_RGB16 = 0x8054;
647 int GL_RGBA2 = 0x8055;
648 int GL_RGBA4 = 0x8056;
649 int GL_RGB5_A1 = 0x8057;
650 int GL_RGBA8 = 0x8058;
651 int GL_RGB10_A2 = 0x8059;
652 int GL_RGBA12 = 0x805A;
653 int GL_RGBA16 = 0x805B;
654 int GL_TEXTURE_RED_SIZE = 0x805C;
655 int GL_TEXTURE_GREEN_SIZE = 0x805D;
656 int GL_TEXTURE_BLUE_SIZE = 0x805E;
657 int GL_TEXTURE_ALPHA_SIZE = 0x805F;
658 int GL_TEXTURE_LUMINANCE_SIZE = 0x8060;
659 int GL_TEXTURE_INTENSITY_SIZE = 0x8061;
660 int GL_PROXY_TEXTURE_1D = 0x8063;
661 int GL_PROXY_TEXTURE_2D = 0x8064;
662
663 /* texture_object */
664 int GL_TEXTURE_PRIORITY = 0x8066;
665 int GL_TEXTURE_RESIDENT = 0x8067;
666 int GL_TEXTURE_BINDING_1D = 0x8068;
667 int GL_TEXTURE_BINDING_2D = 0x8069;
668
669 /* vertex_array */
670 int GL_VERTEX_ARRAY = 0x8074;
671 int GL_NORMAL_ARRAY = 0x8075;
672 int GL_COLOR_ARRAY = 0x8076;
673 int GL_INDEX_ARRAY = 0x8077;
674 int GL_TEXTURE_COORD_ARRAY = 0x8078;
675 int GL_EDGE_FLAG_ARRAY = 0x8079;
676 int GL_VERTEX_ARRAY_SIZE = 0x807A;
677 int GL_VERTEX_ARRAY_TYPE = 0x807B;
678 int GL_VERTEX_ARRAY_STRIDE = 0x807C;
679 int GL_NORMAL_ARRAY_TYPE = 0x807E;
680 int GL_NORMAL_ARRAY_STRIDE = 0x807F;
681 int GL_COLOR_ARRAY_SIZE = 0x8081;
682 int GL_COLOR_ARRAY_TYPE = 0x8082;
683 int GL_COLOR_ARRAY_STRIDE = 0x8083;
684 int GL_INDEX_ARRAY_TYPE = 0x8085;
685 int GL_INDEX_ARRAY_STRIDE = 0x8086;
686 int GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088;
687 int GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089;
688 int GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A;
689 int GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C;
690 int GL_VERTEX_ARRAY_POINTER = 0x808E;
691 int GL_NORMAL_ARRAY_POINTER = 0x808F;
692 int GL_COLOR_ARRAY_POINTER = 0x8090;
693 int GL_INDEX_ARRAY_POINTER = 0x8091;
694 int GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092;
695 int GL_EDGE_FLAG_ARRAY_POINTER = 0x8093;
696 int GL_V2F = 0x2A20;
697 int GL_V3F = 0x2A21;
698 int GL_C4UB_V2F = 0x2A22;
699 int GL_C4UB_V3F = 0x2A23;
700 int GL_C3F_V3F = 0x2A24;
701 int GL_N3F_V3F = 0x2A25;
702 int GL_C4F_N3F_V3F = 0x2A26;
703 int GL_T2F_V3F = 0x2A27;
704 int GL_T4F_V4F = 0x2A28;
705 int GL_T2F_C4UB_V3F = 0x2A29;
706 int GL_T2F_C3F_V3F = 0x2A2A;
707 int GL_T2F_N3F_V3F = 0x2A2B;
708 int GL_T2F_C4F_N3F_V3F = 0x2A2C;
709 int GL_T4F_C4F_N3F_V4F = 0x2A2D;
710
711 /* For compatibility with OpenGL v1.0 */
712 int GL_LOGIC_OP = GL_INDEX_LOGIC_OP;
713 int GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT;
714
715 @DeprecatedGL
716 void glAccum(@GLenum int op, float value);
717
718 @DeprecatedGL
719 void glAlphaFunc(@GLenum int func, @GLclampf float ref);
720
721 void glClearColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
722
723 @DeprecatedGL
724 void glClearAccum(float red, float green, float blue, float alpha);
725
726 void glClear(@GLbitfield int mask);
727
728 @DeprecatedGL
729 void glCallLists(@AutoSize("lists") @GLsizei int n, @AutoType("lists") @GLenum int type,
730 @Const
731 @GLubyte
732 @GLushort
733 @GLuint Buffer lists);
734
735 @DeprecatedGL
736 void glCallList(@GLuint int list);
737
738 void glBlendFunc(@GLenum int sfactor, @GLenum int dfactor);
739
740 @DeprecatedGL
741 void glBitmap(@GLsizei int width, @GLsizei int height, float xorig, float yorig, float xmove, float ymove,
742 @BufferObject(BufferKind.UnpackPBO)
743 @Check("(((width + 7)/8)*height)")
744 @Const
745 @GLubyte ByteBuffer bitmap);
746
747 void glBindTexture(@GLenum int target, @GLuint int texture);
748
749 @DeprecatedGL
750 void glPrioritizeTextures(@AutoSize("textures") @GLsizei int n,
751 @Const
752 @GLuint IntBuffer textures,
753 @Const
754 @Check("textures.remaining()")
755 @GLclampf FloatBuffer priorities);
756
757 @DeprecatedGL
758 boolean glAreTexturesResident(@AutoSize("textures") @GLsizei int n,
759 @Const
760 @GLuint IntBuffer textures,
761 @Check("textures.remaining()")
762 @GLboolean ByteBuffer residences);
763
764 @NoErrorCheck
765 @DeprecatedGL
766 @Code("\t\tif ( ContextCapabilities.DEBUG ) StateTracker.setBeginEnd(caps, true);")
767 void glBegin(@GLenum int mode);
768
769 @DeprecatedGL
770 @Code("\t\tif ( ContextCapabilities.DEBUG ) StateTracker.setBeginEnd(caps, false);")
771 void glEnd();
772
773 @NoErrorCheck
774 void glArrayElement(int i);
775
776 void glClearDepth(@GLclampd double depth);
777
778 @DeprecatedGL
779 void glDeleteLists(@GLuint int list, @GLsizei int range);
780
781 void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures);
782
783 @Alternate("glDeleteTextures")
784 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, texture), 0", keepParam = true) int texture);
785
786 void glCullFace(@GLenum int mode);
787
788 void glCopyTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height);
789
790 void glCopyTexSubImage1D(@GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width);
791
792 void glCopyTexImage2D(@GLenum int target, int level, int internalFormat, int x, int y, @GLsizei int width, @GLsizei int height, int border);
793
794 void glCopyTexImage1D(@GLenum int target, int level, int internalFormat, int x, int y, @GLsizei int width, int border);
795
796 void glCopyPixels(int x, int y, int width, int height, int type);
797
798 @DeprecatedGL
799 void glColorPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
800 @CachedReference
801 @Check
802 @BufferObject(BufferKind.ArrayVBO)
803 @Const
804 @GLfloat
805 @GLdouble
806 @GLubyte
807 @GLbyte Buffer pointer);
808
809 @DeprecatedGL
810 void glColorMaterial(@GLenum int face, @GLenum int mode);
811
812 void glColorMask(boolean red, boolean green, boolean blue, boolean alpha);
813
814 @NoErrorCheck
815 @DeprecatedGL
816 void glColor3b(byte red, byte green, byte blue);
817
818 @NoErrorCheck
819 @DeprecatedGL
820 void glColor3f(float red, float green, float blue);
821
822 @NoErrorCheck
823 @DeprecatedGL
824 void glColor3d(double red, double green, double blue);
825
826 @NoErrorCheck
827 @DeprecatedGL
828 void glColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue);
829
830 @NoErrorCheck
831 @DeprecatedGL
832 void glColor4b(byte red, byte green, byte blue, byte alpha);
833
834 @NoErrorCheck
835 @DeprecatedGL
836 void glColor4f(float red, float green, float blue, float alpha);
837
838 @NoErrorCheck
839 @DeprecatedGL
840 void glColor4d(double red, double green, double blue, double alpha);
841
842 @NoErrorCheck
843 @DeprecatedGL
844 void glColor4ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue, @GLubyte byte alpha);
845
846 void glClipPlane(@GLenum int plane, @Check("4") @Const DoubleBuffer equation);
847
848 void glClearStencil(int s);
849
850 // This function is only used in indexed color mode
851 // void glClearIndex(float c);
852
853 @DeprecatedGL
854 void glEvalPoint1(int i);
855
856 @DeprecatedGL
857 void glEvalPoint2(int i, int j);
858
859 @DeprecatedGL
860 void glEvalMesh1(@GLenum int mode, int i1, int i2);
861
862 @DeprecatedGL
863 void glEvalMesh2(@GLenum int mode, int i1, int i2, int j1, int j2);
864
865 @DeprecatedGL
866 void glEvalCoord1f(float u);
867
868 @DeprecatedGL
869 void glEvalCoord1d(double u);
870
871 @DeprecatedGL
872 void glEvalCoord2f(float u, float v);
873
874 @DeprecatedGL
875 void glEvalCoord2d(double u, double v);
876
877 @DeprecatedGL
878 void glEnableClientState(@GLenum int cap);
879
880 @DeprecatedGL
881 void glDisableClientState(@GLenum int cap);
882
883 void glEnable(@GLenum int cap);
884
885 void glDisable(@GLenum int cap);
886
887 @DeprecatedGL
888 void glEdgeFlagPointer(int stride,
889 @CachedReference
890 @BufferObject(BufferKind.ArrayVBO)
891 @Check
892 @Const
893 @GLbyte Buffer pointer);
894
895 @DeprecatedGL
896 void glEdgeFlag(boolean flag);
897
898 @DeprecatedGL
899 void glDrawPixels(@GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
900 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
901 @BufferObject(BufferKind.UnpackPBO)
902 @Const
903 @GLbyte
904 @GLshort
905 @GLint Buffer pixels);
906
907 void glDrawElements(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
908 @BufferObject(BufferKind.ElementVBO)
909 @Const
910 @GLubyte
911 @GLushort
912 @GLuint Buffer indices);
913
914 void glDrawBuffer(@GLenum int mode);
915
916 void glDrawArrays(@GLenum int mode, int first, @GLsizei int count);
917
918 void glDepthRange(@GLclampd double zNear, @GLclampd double zFar);
919
920 void glDepthMask(boolean flag);
921
922 void glDepthFunc(@GLenum int func);
923
924 @DeprecatedGL
925 void glFeedbackBuffer(@AutoSize("buffer") @GLsizei int size, @GLenum int type, FloatBuffer buffer);
926
927 @StripPostfix("values")
928 @DeprecatedGL
929 void glGetPixelMapfv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values);
930
931 @StripPostfix("values")
932 @DeprecatedGL
933 void glGetPixelMapuiv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values);
934
935 @StripPostfix("values")
936 @DeprecatedGL
937 void glGetPixelMapusv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values);
938
939 @StripPostfix("params")
940 @DeprecatedGL
941 void glGetMaterialfv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
942
943 @StripPostfix("params")
944 @DeprecatedGL
945 void glGetMaterialiv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
946
947 @StripPostfix("v")
948 @DeprecatedGL
949 void glGetMapfv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") FloatBuffer v);
950
951 @StripPostfix("v")
952 @DeprecatedGL
953 void glGetMapdv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") DoubleBuffer v);
954
955 @StripPostfix("v")
956 @DeprecatedGL
957 void glGetMapiv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") IntBuffer v);
958
959 @StripPostfix("params")
960 @DeprecatedGL
961 void glGetLightfv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
962
963 @StripPostfix("params")
964 @DeprecatedGL
965 void glGetLightiv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
966
967 @NoErrorCheck
968 int glGetError();
969
970 void glGetClipPlane(@GLenum int plane, @OutParameter @Check("4") DoubleBuffer equation);
971
972 @StripPostfix("params")
973 void glGetBooleanv(@GLenum int pname, @OutParameter @Check("16") @GLboolean ByteBuffer params);
974
975 @Alternate("glGetBooleanv")
976 @GLreturn("params")
977 @StripPostfix("params")
978 void glGetBooleanv2(@GLenum int pname, @OutParameter @GLboolean ByteBuffer params);
979
980 @StripPostfix("params")
981 void glGetDoublev(@GLenum int pname, @OutParameter @Check("16") DoubleBuffer params);
982
983 @Alternate("glGetDoublev")
984 @GLreturn("params")
985 @StripPostfix("params")
986 void glGetDoublev2(@GLenum int pname, @OutParameter DoubleBuffer params);
987
988 @StripPostfix("params")
989 void glGetFloatv(@GLenum int pname, @OutParameter @Check("16") FloatBuffer params);
990
991 @Alternate("glGetFloatv")
992 @GLreturn("params")
993 @StripPostfix("params")
994 void glGetFloatv2(@GLenum int pname, @OutParameter FloatBuffer params);
995
996 @StripPostfix("params")
997 void glGetIntegerv(@GLenum int pname, @OutParameter @Check("16") IntBuffer params);
998
999 @Alternate("glGetIntegerv")
1000 @GLreturn("params")
1001 @StripPostfix("params")
1002 void glGetIntegerv2(@GLenum int pname, @OutParameter IntBuffer params);
1003
1004 void glGenTextures(@AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
1005
1006 @Alternate("glGenTextures")
1007 @GLreturn("textures")
1008 void glGenTextures2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
1009
1010 @GLuint
1011 @DeprecatedGL
1012 int glGenLists(@GLsizei int range);
1013
1014 @DeprecatedGL
1015 void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar);
1016
1017 void glFrontFace(@GLenum int mode);
1018
1019 @DeprecatedGL
1020 void glFogf(@GLenum int pname, float param);
1021
1022 @DeprecatedGL
1023 void glFogi(@GLenum int pname, int param);
1024
1025 @StripPostfix("params")
1026 @DeprecatedGL
1027 void glFogfv(@GLenum int pname, @Check("4") @Const FloatBuffer params);
1028
1029 @StripPostfix("params")
1030 @DeprecatedGL
1031 void glFogiv(@GLenum int pname, @Check("4") @Const IntBuffer params);
1032
1033 void glFlush();
1034
1035 void glFinish();
1036
1037 @StripPostfix("result")
1038 void glGetPointerv(@GLenum int pname, @Result @GLvoid ByteBuffer result);
1039
1040 boolean glIsEnabled(@GLenum int cap);
1041
1042 void glInterleavedArrays(@GLenum int format, @GLsizei int stride,
1043 @BufferObject(BufferKind.ArrayVBO)
1044 @Check
1045 @Const
1046 @GLbyte
1047 @GLshort
1048 @GLint
1049 @GLfloat
1050 @GLdouble Buffer pointer);
1051
1052 @DeprecatedGL
1053 void glInitNames();
1054
1055 void glHint(@GLenum int target, @GLenum int mode);
1056
1057 @StripPostfix("params")
1058 void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
1059
1060 @Alternate("glGetTexParameterfv")
1061 @GLreturn("params")
1062 @StripPostfix(value = "params", postfix = "v")
1063 void glGetTexParameterfv2(@GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
1064
1065 @StripPostfix("params")
1066 void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
1067
1068 @Alternate("glGetTexParameteriv")
1069 @GLreturn("params")
1070 @StripPostfix(value = "params", postfix = "v")
1071 void glGetTexParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
1072
1073 @StripPostfix("params")
1074 void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
1075
1076 @Alternate("glGetTexLevelParameterfv")
1077 @GLreturn("params")
1078 @StripPostfix(value = "params", postfix = "v")
1079 void glGetTexLevelParameterfv2(@GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
1080
1081 @StripPostfix("params")
1082 void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
1083
1084 @Alternate("glGetTexLevelParameteriv")
1085 @GLreturn("params")
1086 @StripPostfix(value = "params", postfix = "v")
1087 void glGetTexLevelParameteriv2(@GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
1088
1089 void glGetTexImage(@GLenum int target, int level, @GLenum int format, @GLenum int type,
1090 @OutParameter
1091 @BufferObject(BufferKind.PackPBO)
1092 @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)")
1093 @GLbyte
1094 @GLshort
1095 @GLint
1096 @GLfloat
1097 @GLdouble Buffer pixels);
1098
1099 @StripPostfix("params")
1100 @DeprecatedGL
1101 void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
1102
1103 @Alternate("glGetTexGeniv")
1104 @GLreturn("params")
1105 @StripPostfix(value = "params", postfix = "v")
1106 @DeprecatedGL
1107 void glGetTexGeniv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params);
1108
1109 @StripPostfix("params")
1110 @DeprecatedGL
1111 void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
1112
1113 @Alternate("glGetTexGenfv")
1114 @GLreturn("params")
1115 @StripPostfix(value = "params", postfix = "v")
1116 @DeprecatedGL
1117 void glGetTexGenfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params);
1118
1119 @StripPostfix("params")
1120 @DeprecatedGL
1121 void glGetTexGendv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
1122
1123 @Alternate("glGetTexGendv")
1124 @GLreturn("params")
1125 @StripPostfix(value = "params", postfix = "v")
1126 @DeprecatedGL
1127 void glGetTexGendv2(@GLenum int coord, @GLenum int pname, @OutParameter DoubleBuffer params);
1128
1129 @StripPostfix("params")
1130 void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
1131
1132 @Alternate("glGetTexEnviv")
1133 @GLreturn("params")
1134 @StripPostfix(value = "params", postfix = "v")
1135 void glGetTexEnviv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params);
1136
1137 @StripPostfix("params")
1138 void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
1139
1140 @Alternate("glGetTexEnvfv")
1141 @GLreturn("params")
1142 @StripPostfix(value = "params", postfix = "v")
1143 void glGetTexEnvfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params);
1144
1145 @Const
1146 String glGetString(int name);
1147
1148 @DeprecatedGL
1149 void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask);
1150
1151 @DeprecatedGL
1152 boolean glIsList(@GLuint int list);
1153
1154 @DeprecatedGL
1155 void glMaterialf(@GLenum int face, @GLenum int pname, float param);
1156
1157 @DeprecatedGL
1158 void glMateriali(@GLenum int face, @GLenum int pname, int param);
1159
1160 @StripPostfix("params")
1161 @DeprecatedGL
1162 void glMaterialfv(@GLenum int face, @GLenum int pname, @Check("4") @Const FloatBuffer params);
1163
1164 @StripPostfix("params")
1165 @DeprecatedGL
1166 void glMaterialiv(@GLenum int face, @GLenum int pname, @Check("4") @Const IntBuffer params);
1167
1168 @DeprecatedGL
1169 void glMapGrid1f(int un, float u1, float u2);
1170
1171 @DeprecatedGL
1172 void glMapGrid1d(int un, double u1, double u2);
1173
1174 @DeprecatedGL
1175 void glMapGrid2f(int un, float u1, float u2, int vn, float v1, float v2);
1176
1177 @DeprecatedGL
1178 void glMapGrid2d(int un, double u1, double u2, int vn, double v1, double v2);
1179
1180 // TODO: check buffer size valid
1181
1182 @DeprecatedGL
1183 void glMap2f(@GLenum int target, float u1, float u2, int ustride, int uorder, float v1, float v2, int vstride, int vorder, @Check @Const FloatBuffer points);
1184
1185 @DeprecatedGL
1186 void glMap2d(@GLenum int target, double u1, double u2, int ustride, int uorder, double v1, double v2, int vstride, int vorder, @Check @Const DoubleBuffer points);
1187
1188 // TODO: check buffer size valid
1189
1190 @DeprecatedGL
1191 void glMap1f(@GLenum int target, float u1, float u2, int stride, int order, @Check @Const FloatBuffer points);
1192
1193 @DeprecatedGL
1194 void glMap1d(@GLenum int target, double u1, double u2, int stride, int order, @Check @Const DoubleBuffer points);
1195
1196 void glLogicOp(@GLenum int opcode);
1197
1198 @DeprecatedGL
1199 void glLoadName(@GLuint int name);
1200
1201 @StripPostfix("m")
1202 @DeprecatedGL
1203 void glLoadMatrixf(@Check("16") @Const FloatBuffer m);
1204
1205 @StripPostfix("m")
1206 @DeprecatedGL
1207 void glLoadMatrixd(@Check("16") @Const DoubleBuffer m);
1208
1209 @DeprecatedGL
1210 void glLoadIdentity();
1211
1212 @DeprecatedGL
1213 void glListBase(@GLuint int base);
1214
1215 void glLineWidth(float width);
1216
1217 @DeprecatedGL
1218 void glLineStipple(int factor, @GLushort short pattern);
1219
1220 @DeprecatedGL
1221 void glLightModelf(@GLenum int pname, float param);
1222
1223 @DeprecatedGL
1224 void glLightModeli(@GLenum int pname, int param);
1225
1226 @StripPostfix("params")
1227 @DeprecatedGL
1228 void glLightModelfv(@GLenum int pname, @Check("4") @Const FloatBuffer params);
1229
1230 @StripPostfix("params")
1231 @DeprecatedGL
1232 void glLightModeliv(@GLenum int pname, @Check("4") @Const IntBuffer params);
1233
1234 @DeprecatedGL
1235 void glLightf(@GLenum int light, @GLenum int pname, float param);
1236
1237 @DeprecatedGL
1238 void glLighti(@GLenum int light, @GLenum int pname, int param);
1239
1240 @StripPostfix("params")
1241 @DeprecatedGL
1242 void glLightfv(@GLenum int light, @GLenum int pname, @Check("4") @Const FloatBuffer params);
1243
1244 @StripPostfix("params")
1245 @DeprecatedGL
1246 void glLightiv(@GLenum int light, @GLenum int pname, @Check("4") @Const IntBuffer params);
1247
1248 boolean glIsTexture(@GLuint int texture);
1249
1250 @DeprecatedGL
1251 void glMatrixMode(@GLenum int mode);
1252
1253 @DeprecatedGL
1254 void glPolygonStipple(@BufferObject(BufferKind.UnpackPBO) @Check("1024") @Const @GLubyte ByteBuffer mask);
1255
1256 void glPolygonOffset(float factor, float units);
1257
1258 void glPolygonMode(@GLenum int face, @GLenum int mode);
1259
1260 void glPointSize(float size);
1261
1262 @DeprecatedGL
1263 void glPixelZoom(float xfactor, float yfactor);
1264
1265 @DeprecatedGL
1266 void glPixelTransferf(@GLenum int pname, float param);
1267
1268 @DeprecatedGL
1269 void glPixelTransferi(@GLenum int pname, int param);
1270
1271 void glPixelStoref(@GLenum int pname, float param);
1272
1273 void glPixelStorei(@GLenum int pname, int param);
1274
1275 @StripPostfix("values")
1276 @DeprecatedGL
1277 void glPixelMapfv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const FloatBuffer values);
1278
1279 @StripPostfix("values")
1280 @DeprecatedGL
1281 void glPixelMapuiv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLuint IntBuffer values);
1282
1283 @StripPostfix("values")
1284 @DeprecatedGL
1285 void glPixelMapusv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLushort ShortBuffer values);
1286
1287 @DeprecatedGL
1288 void glPassThrough(float token);
1289
1290 @DeprecatedGL
1291 void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar);
1292
1293 @DeprecatedGL
1294 void glNormalPointer(@AutoType("pointer") @GLenum int type, @GLsizei int stride,
1295 @CachedReference
1296 @BufferObject(BufferKind.ArrayVBO)
1297 @Check
1298 @Const
1299 @GLint
1300 @GLbyte
1301 @GLfloat
1302 @GLdouble Buffer pointer);
1303
1304 @NoErrorCheck
1305 @DeprecatedGL
1306 void glNormal3b(byte nx, byte ny, byte nz);
1307
1308 @NoErrorCheck
1309 @DeprecatedGL
1310 void glNormal3f(float nx, float ny, float nz);
1311
1312 @NoErrorCheck
1313 @DeprecatedGL
1314 void glNormal3d(double nx, double ny, double nz);
1315
1316 @NoErrorCheck
1317 @DeprecatedGL
1318 void glNormal3i(int nx, int ny, int nz);
1319
1320 @DeprecatedGL
1321 void glNewList(@GLuint int list, @GLenum int mode);
1322
1323 @DeprecatedGL
1324 void glEndList();
1325
1326 @StripPostfix("m")
1327 @DeprecatedGL
1328 void glMultMatrixf(@Check("16") @Const FloatBuffer m);
1329
1330 @StripPostfix("m")
1331 @DeprecatedGL
1332 void glMultMatrixd(@Check("16") @Const DoubleBuffer m);
1333
1334 void glShadeModel(@GLenum int mode);
1335
1336 @DeprecatedGL
1337 void glSelectBuffer(@AutoSize("buffer") @GLsizei int size, @GLuint IntBuffer buffer);
1338
1339 void glScissor(int x, int y, @GLsizei int width, @GLsizei int height);
1340
1341 @DeprecatedGL
1342 void glScalef(float x, float y, float z);
1343
1344 @DeprecatedGL
1345 void glScaled(double x, double y, double z);
1346
1347 @DeprecatedGL
1348 void glRotatef(float angle, float x, float y, float z);
1349
1350 @DeprecatedGL
1351 int glRenderMode(@GLenum int mode);
1352
1353 @DeprecatedGL
1354 void glRectf(float x1, float y1, float x2, float y2);
1355
1356 @DeprecatedGL
1357 void glRectd(double x1, double y1, double x2, double y2);
1358
1359 @DeprecatedGL
1360 void glRecti(int x1, int y1, int x2, int y2);
1361
1362 void glReadPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
1363 @OutParameter
1364 @BufferObject(BufferKind.PackPBO)
1365 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
1366 @GLbyte
1367 @GLshort
1368 @GLint
1369 @GLfloat
1370 @GLdouble Buffer pixels);
1371
1372 void glReadBuffer(@GLenum int mode);
1373
1374 @DeprecatedGL
1375 void glRasterPos2f(float x, float y);
1376
1377 @DeprecatedGL
1378 void glRasterPos2d(double x, double y);
1379
1380 @DeprecatedGL
1381 void glRasterPos2i(int x, int y);
1382
1383 @DeprecatedGL
1384 void glRasterPos3f(float x, float y, float z);
1385
1386 @DeprecatedGL
1387 void glRasterPos3d(double x, double y, double z);
1388
1389 @DeprecatedGL
1390 void glRasterPos3i(int x, int y, int z);
1391
1392 @DeprecatedGL
1393 void glRasterPos4f(float x, float y, float z, float w);
1394
1395 @DeprecatedGL
1396 void glRasterPos4d(double x, double y, double z, double w);
1397
1398 @DeprecatedGL
1399 void glRasterPos4i(int x, int y, int z, int w);
1400
1401 @DeprecatedGL
1402 void glPushName(@GLuint int name);
1403
1404 @DeprecatedGL
1405 void glPopName();
1406
1407 @DeprecatedGL
1408 void glPushMatrix();
1409
1410 @DeprecatedGL
1411 void glPopMatrix();
1412
1413 @Code(" StateTracker.pushAttrib(caps, mask);")
1414 @DeprecatedGL
1415 void glPushClientAttrib(@GLbitfield int mask);
1416
1417 @Code(" StateTracker.popAttrib(caps);")
1418 @DeprecatedGL
1419 void glPopClientAttrib();
1420
1421 @DeprecatedGL
1422 void glPushAttrib(@GLbitfield int mask);
1423
1424 @DeprecatedGL
1425 void glPopAttrib();
1426
1427 void glStencilFunc(@GLenum int func, int ref, @GLuint int mask);
1428
1429 @DeprecatedGL
1430 void glVertexPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
1431 @CachedReference
1432 @BufferObject(BufferKind.ArrayVBO)
1433 @Check
1434 @Const
1435 @GLshort
1436 @GLint
1437 @GLfloat
1438 @GLdouble Buffer pointer);
1439
1440 @NoErrorCheck
1441 @DeprecatedGL
1442 void glVertex2f(float x, float y);
1443
1444 @NoErrorCheck
1445 @DeprecatedGL
1446 void glVertex2d(double x, double y);
1447
1448 @NoErrorCheck
1449 @DeprecatedGL
1450 void glVertex2i(int x, int y);
1451
1452 @NoErrorCheck
1453 @DeprecatedGL
1454 void glVertex3f(float x, float y, float z);
1455
1456 @NoErrorCheck
1457 @DeprecatedGL
1458 void glVertex3d(double x, double y, double z);
1459
1460 @NoErrorCheck
1461 @DeprecatedGL
1462 void glVertex3i(int x, int y, int z);
1463
1464 @NoErrorCheck
1465 @DeprecatedGL
1466 void glVertex4f(float x, float y, float z, float w);
1467
1468 @NoErrorCheck
1469 @DeprecatedGL
1470 void glVertex4d(double x, double y, double z, double w);
1471
1472 @NoErrorCheck
1473 @DeprecatedGL
1474 void glVertex4i(int x, int y, int z, int w);
1475
1476 @DeprecatedGL
1477 void glTranslatef(float x, float y, float z);
1478
1479 @DeprecatedGL
1480 void glTranslated(double x, double y, double z);
1481
1482 void glTexImage1D(@GLenum int target, int level, int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type,
1483 @BufferObject(BufferKind.UnpackPBO)
1484 @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true)
1485 @Const
1486 @GLbyte
1487 @GLshort
1488 @GLint
1489 @GLfloat
1490 @GLdouble Buffer pixels);
1491
1492 void glTexImage2D(@GLenum int target, int level, int internalformat, int width, int height, int border, @GLenum int format, @GLenum int type,
1493 @BufferObject(BufferKind.UnpackPBO)
1494 @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true)
1495 @Const
1496 @GLbyte
1497 @GLshort
1498 @GLint
1499 @GLfloat
1500 @GLdouble Buffer pixels);
1501
1502 void glTexSubImage1D(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type,
1503 @BufferObject(BufferKind.UnpackPBO)
1504 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)")
1505 @Const
1506 @GLbyte
1507 @GLshort
1508 @GLint
1509 @GLfloat
1510 @GLdouble Buffer pixels);
1511
1512 void glTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
1513 @BufferObject(BufferKind.UnpackPBO)
1514 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
1515 @Const
1516 @GLbyte
1517 @GLshort
1518 @GLint
1519 @GLfloat
1520 @GLdouble Buffer pixels);
1521
1522 void glTexParameterf(@GLenum int target, @GLenum int pname, float param);
1523
1524 void glTexParameteri(@GLenum int target, @GLenum int pname, int param);
1525
1526 @StripPostfix("param")
1527 void glTexParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param);
1528
1529 @StripPostfix("param")
1530 void glTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param);
1531
1532 @DeprecatedGL
1533 void glTexGenf(@GLenum int coord, @GLenum int pname, float param);
1534
1535 @DeprecatedGL
1536 void glTexGend(@GLenum int coord, @GLenum int pname, double param);
1537
1538 @StripPostfix("params")
1539 @DeprecatedGL
1540 void glTexGenfv(@GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params);
1541
1542 @StripPostfix("params")
1543 @DeprecatedGL
1544 void glTexGendv(@GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params);
1545
1546 @DeprecatedGL
1547 void glTexGeni(@GLenum int coord, @GLenum int pname, int param);
1548
1549 @StripPostfix("params")
1550 @DeprecatedGL
1551 void glTexGeniv(@GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params);
1552
1553 void glTexEnvf(@GLenum int target, @GLenum int pname, float param);
1554
1555 void glTexEnvi(@GLenum int target, @GLenum int pname, int param);
1556
1557 @StripPostfix("params")
1558 void glTexEnvfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params);
1559
1560 @StripPostfix("params")
1561 void glTexEnviv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
1562
1563 @DeprecatedGL
1564 void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
1565 @CachedReference(index = "GLChecks.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
1566 @BufferObject(BufferKind.ArrayVBO)
1567 @Check
1568 @Const
1569 @GLint
1570 @GLshort
1571 @GLfloat
1572 @GLdouble Buffer pointer);
1573
1574 @NoErrorCheck
1575 @DeprecatedGL
1576 void glTexCoord1f(float s);
1577
1578 @NoErrorCheck
1579 @DeprecatedGL
1580 void glTexCoord1d(double s);
1581
1582 @NoErrorCheck
1583 @DeprecatedGL
1584 void glTexCoord2f(float s, float t);
1585
1586 @NoErrorCheck
1587 @DeprecatedGL
1588 void glTexCoord2d(double s, double t);
1589
1590 @NoErrorCheck
1591 @DeprecatedGL
1592 void glTexCoord3f(float s, float t, float r);
1593
1594 @NoErrorCheck
1595 @DeprecatedGL
1596 void glTexCoord3d(double s, double t, double r);
1597
1598 @NoErrorCheck
1599 @DeprecatedGL
1600 void glTexCoord4f(float s, float t, float r, float q);
1601
1602 @NoErrorCheck
1603 @DeprecatedGL
1604 void glTexCoord4d(double s, double t, double r, double q);
1605
1606 void glStencilOp(@GLenum int fail, @GLenum int zfail, @GLenum int zpass);
1607
1608 void glStencilMask(@GLuint int mask);
1609
1610 void glViewport(int x, int y, @GLsizei int width, @GLsizei int height);
1611 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36
37 /**
38 * <p/>
39 * The core OpenGL1.2.1 API, with the imaging subset.
40 *
41 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 2984 $
43 * $Id: GL12.java 2984 2008-04-07 18:39:53Z matzon $
44 */
45
46 public interface GL12 {
47
48 int GL_TEXTURE_BINDING_3D = 0x806A;
49 int GL_PACK_SKIP_IMAGES = 0x806B;
50 int GL_PACK_IMAGE_HEIGHT = 0x806C;
51 int GL_UNPACK_SKIP_IMAGES = 0x806D;
52 int GL_UNPACK_IMAGE_HEIGHT = 0x806E;
53 int GL_TEXTURE_3D = 0x806F;
54 int GL_PROXY_TEXTURE_3D = 0x8070;
55 int GL_TEXTURE_DEPTH = 0x8071;
56 int GL_TEXTURE_WRAP_R = 0x8072;
57 int GL_MAX_3D_TEXTURE_SIZE = 0x8073;
58 int GL_BGR = 0x80E0;
59 int GL_BGRA = 0x80E1;
60 int GL_UNSIGNED_BYTE_3_3_2 = 0x8032;
61 int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362;
62 int GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
63 int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364;
64 int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
65 int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365;
66 int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
67 int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366;
68 int GL_UNSIGNED_INT_8_8_8_8 = 0x8035;
69 int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
70 int GL_UNSIGNED_INT_10_10_10_2 = 0x8036;
71 int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
72 int GL_RESCALE_NORMAL = 0x803A;
73 int GL_LIGHT_MODEL_COLOR_CONTROL = 0x81F8;
74 int GL_SINGLE_COLOR = 0x81F9;
75 int GL_SEPARATE_SPECULAR_COLOR = 0x81FA;
76 int GL_CLAMP_TO_EDGE = 0x812F;
77 int GL_TEXTURE_MIN_LOD = 0x813A;
78 int GL_TEXTURE_MAX_LOD = 0x813B;
79 int GL_TEXTURE_BASE_LEVEL = 0x813C;
80 int GL_TEXTURE_MAX_LEVEL = 0x813D;
81 int GL_MAX_ELEMENTS_VERTICES = 0x80E8;
82 int GL_MAX_ELEMENTS_INDICES = 0x80E9;
83 int GL_ALIASED_POINT_SIZE_RANGE = 0x846D;
84 int GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;
85
86 int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12;
87 int GL_SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13;
88 int GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22;
89 int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23;
90
91 void glDrawRangeElements(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count,
92 @AutoType("indices")
93 @GLenum int type,
94 @BufferObject(BufferKind.ElementVBO)
95 @Const
96 @GLubyte
97 @GLushort
98 @GLuint Buffer indices);
99
100 void glTexImage3D(@GLenum int target, int level, int internalFormat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type,
101 @BufferObject(BufferKind.UnpackPBO)
102 @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true)
103 @Const
104 @GLbyte
105 @GLshort
106 @GLint
107 @GLfloat
108 @GLdouble Buffer pixels);
109
110 void glTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type,
111 @BufferObject(BufferKind.UnpackPBO)
112 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
113 @Const
114 @GLbyte
115 @GLshort
116 @GLint
117 @GLfloat
118 @GLdouble Buffer pixels);
119
120 void glCopyTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
121 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 /**
38 * <p/>
39 * The core OpenGL1.3 API.
40 *
41 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: GL13.java 3116 2008-08-19 16:46:03Z spasi $
44 */
45 @DeprecatedGL
46 public interface GL13 {
47 int GL_TEXTURE0 = 0x84C0;
48 int GL_TEXTURE1 = 0x84C1;
49 int GL_TEXTURE2 = 0x84C2;
50 int GL_TEXTURE3 = 0x84C3;
51 int GL_TEXTURE4 = 0x84C4;
52 int GL_TEXTURE5 = 0x84C5;
53 int GL_TEXTURE6 = 0x84C6;
54 int GL_TEXTURE7 = 0x84C7;
55 int GL_TEXTURE8 = 0x84C8;
56 int GL_TEXTURE9 = 0x84C9;
57 int GL_TEXTURE10 = 0x84CA;
58 int GL_TEXTURE11 = 0x84CB;
59 int GL_TEXTURE12 = 0x84CC;
60 int GL_TEXTURE13 = 0x84CD;
61 int GL_TEXTURE14 = 0x84CE;
62 int GL_TEXTURE15 = 0x84CF;
63 int GL_TEXTURE16 = 0x84D0;
64 int GL_TEXTURE17 = 0x84D1;
65 int GL_TEXTURE18 = 0x84D2;
66 int GL_TEXTURE19 = 0x84D3;
67 int GL_TEXTURE20 = 0x84D4;
68 int GL_TEXTURE21 = 0x84D5;
69 int GL_TEXTURE22 = 0x84D6;
70 int GL_TEXTURE23 = 0x84D7;
71 int GL_TEXTURE24 = 0x84D8;
72 int GL_TEXTURE25 = 0x84D9;
73 int GL_TEXTURE26 = 0x84DA;
74 int GL_TEXTURE27 = 0x84DB;
75 int GL_TEXTURE28 = 0x84DC;
76 int GL_TEXTURE29 = 0x84DD;
77 int GL_TEXTURE30 = 0x84DE;
78 int GL_TEXTURE31 = 0x84DF;
79 int GL_ACTIVE_TEXTURE = 0x84E0;
80 int GL_CLIENT_ACTIVE_TEXTURE = 0x84E1;
81 int GL_MAX_TEXTURE_UNITS = 0x84E2;
82
83 int GL_NORMAL_MAP = 0x8511;
84 int GL_REFLECTION_MAP = 0x8512;
85 int GL_TEXTURE_CUBE_MAP = 0x8513;
86 int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514;
87 int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
88 int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
89 int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
90 int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
91 int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
92 int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
93 int GL_PROXY_TEXTURE_CUBE_MAP = 0x851B;
94 int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
95
96 int GL_COMPRESSED_ALPHA = 0x84E9;
97 int GL_COMPRESSED_LUMINANCE = 0x84EA;
98 int GL_COMPRESSED_LUMINANCE_ALPHA = 0x84EB;
99 int GL_COMPRESSED_INTENSITY = 0x84EC;
100 int GL_COMPRESSED_RGB = 0x84ED;
101 int GL_COMPRESSED_RGBA = 0x84EE;
102 int GL_TEXTURE_COMPRESSION_HINT = 0x84EF;
103 int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0;
104 int GL_TEXTURE_COMPRESSED = 0x86A1;
105 int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
106 int GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
107
108 int GL_MULTISAMPLE = 0x809D;
109 int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
110 int GL_SAMPLE_ALPHA_TO_ONE = 0x809F;
111 int GL_SAMPLE_COVERAGE = 0x80A0;
112 int GL_SAMPLE_BUFFERS = 0x80A8;
113 int GL_SAMPLES = 0x80A9;
114 int GL_SAMPLE_COVERAGE_VALUE = 0x80AA;
115 int GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
116 int GL_MULTISAMPLE_BIT = 0x20000000;
117
118 int GL_TRANSPOSE_MODELVIEW_MATRIX = 0x84E3;
119 int GL_TRANSPOSE_PROJECTION_MATRIX = 0x84E4;
120 int GL_TRANSPOSE_TEXTURE_MATRIX = 0x84E5;
121 int GL_TRANSPOSE_COLOR_MATRIX = 0x84E6;
122
123 int GL_COMBINE = 0x8570;
124 int GL_COMBINE_RGB = 0x8571;
125 int GL_COMBINE_ALPHA = 0x8572;
126 int GL_SOURCE0_RGB = 0x8580;
127 int GL_SOURCE1_RGB = 0x8581;
128 int GL_SOURCE2_RGB = 0x8582;
129 int GL_SOURCE0_ALPHA = 0x8588;
130 int GL_SOURCE1_ALPHA = 0x8589;
131 int GL_SOURCE2_ALPHA = 0x858A;
132 int GL_OPERAND0_RGB = 0x8590;
133 int GL_OPERAND1_RGB = 0x8591;
134 int GL_OPERAND2_RGB = 0x8592;
135 int GL_OPERAND0_ALPHA = 0x8598;
136 int GL_OPERAND1_ALPHA = 0x8599;
137 int GL_OPERAND2_ALPHA = 0x859A;
138 int GL_RGB_SCALE = 0x8573;
139 int GL_ADD_SIGNED = 0x8574;
140 int GL_INTERPOLATE = 0x8575;
141 int GL_SUBTRACT = 0x84E7;
142 int GL_CONSTANT = 0x8576;
143 int GL_PRIMARY_COLOR = 0x8577;
144 int GL_PREVIOUS = 0x8578;
145 int GL_DOT3_RGB = 0x86AE;
146 int GL_DOT3_RGBA = 0x86AF;
147 int GL_CLAMP_TO_BORDER = 0x812D;
148
149 void glActiveTexture(@GLenum int texture);
150
151 @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
152 @DeprecatedGL
153 void glClientActiveTexture(@GLenum int texture);
154
155 void glCompressedTexImage1D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize,
156 @BufferObject(BufferKind.UnpackPBO)
157 @Check
158 @Const
159 @GLvoid
160 Buffer data);
161
162 void glCompressedTexImage2D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize,
163 @BufferObject(BufferKind.UnpackPBO)
164 @Check
165 @Const
166 @GLvoid
167 ByteBuffer data);
168
169 void glCompressedTexImage3D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize,
170 @BufferObject(BufferKind.UnpackPBO)
171 @Check
172 @Const
173 @GLvoid
174 ByteBuffer data);
175
176 void glCompressedTexSubImage1D(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
177 @BufferObject(BufferKind.UnpackPBO)
178 @Check
179 @Const
180 @GLvoid
181 ByteBuffer data);
182
183 void glCompressedTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
184 @BufferObject(BufferKind.UnpackPBO)
185 @Check
186 @Const
187 @GLvoid
188 ByteBuffer data);
189
190 void glCompressedTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
191 @BufferObject(BufferKind.UnpackPBO)
192 @Check
193 @Const
194 @GLvoid
195 ByteBuffer data);
196
197 // TODO: check buffer size valid
198 void glGetCompressedTexImage(@GLenum int target, int lod,
199 @OutParameter
200 @BufferObject(BufferKind.PackPBO)
201 @Check
202 @GLbyte
203 @GLshort
204 @GLint Buffer img);
205
206 @NoErrorCheck
207 @DeprecatedGL
208 void glMultiTexCoord1f(@GLenum int target, float s);
209
210 @NoErrorCheck
211 @DeprecatedGL
212 void glMultiTexCoord1d(@GLenum int target, double s);
213
214 @NoErrorCheck
215 @DeprecatedGL
216 void glMultiTexCoord2f(@GLenum int target, float s, float t);
217
218 @NoErrorCheck
219 @DeprecatedGL
220 void glMultiTexCoord2d(@GLenum int target, double s, double t);
221
222 @NoErrorCheck
223 @DeprecatedGL
224 void glMultiTexCoord3f(@GLenum int target, float s, float t, float r);
225
226 @NoErrorCheck
227 @DeprecatedGL
228 void glMultiTexCoord3d(@GLenum int target, double s, double t, double r);
229
230 @NoErrorCheck
231 @DeprecatedGL
232 void glMultiTexCoord4f(@GLenum int target, float s, float t, float r, float q);
233
234 @NoErrorCheck
235 @DeprecatedGL
236 void glMultiTexCoord4d(@GLenum int target, double s, double t, double r, double q);
237
238 @StripPostfix("m")
239 @DeprecatedGL
240 void glLoadTransposeMatrixf(@Check("16") @Const FloatBuffer m);
241
242 @StripPostfix("m")
243 @DeprecatedGL
244 void glLoadTransposeMatrixd(@Check("16") @Const DoubleBuffer m);
245
246 @StripPostfix("m")
247 @DeprecatedGL
248 void glMultTransposeMatrixf(@Check("16") @Const FloatBuffer m);
249
250 @StripPostfix("m")
251 @DeprecatedGL
252 void glMultTransposeMatrixd(@Check("16") @Const DoubleBuffer m);
253
254 void glSampleCoverage(@GLclampf float value, boolean invert);
255 }
256
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 /**
38 * <p/>
39 * The core OpenGL1.4 API.
40 *
41 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3287 $
43 * $Id: GL14.java 3287 2010-03-14 23:24:40Z spasi $
44 */
45 @DeprecatedGL
46 public interface GL14 {
47 int GL_GENERATE_MIPMAP = 0x8191;
48 int GL_GENERATE_MIPMAP_HINT = 0x8192;
49 int GL_DEPTH_COMPONENT16 = 0x81A5;
50 int GL_DEPTH_COMPONENT24 = 0x81A6;
51 int GL_DEPTH_COMPONENT32 = 0x81A7;
52 int GL_TEXTURE_DEPTH_SIZE = 0x884A;
53 int GL_DEPTH_TEXTURE_MODE = 0x884B;
54 int GL_TEXTURE_COMPARE_MODE = 0x884C;
55 int GL_TEXTURE_COMPARE_FUNC = 0x884D;
56 int GL_COMPARE_R_TO_TEXTURE = 0x884E;
57 int GL_FOG_COORDINATE_SOURCE = 0x8450;
58 int GL_FOG_COORDINATE = 0x8451;
59 int GL_FRAGMENT_DEPTH = 0x8452;
60 int GL_CURRENT_FOG_COORDINATE = 0x8453;
61 int GL_FOG_COORDINATE_ARRAY_TYPE = 0x8454;
62 int GL_FOG_COORDINATE_ARRAY_STRIDE = 0x8455;
63 int GL_FOG_COORDINATE_ARRAY_POINTER = 0x8456;
64 int GL_FOG_COORDINATE_ARRAY = 0x8457;
65 int GL_POINT_SIZE_MIN = 0x8126;
66 int GL_POINT_SIZE_MAX = 0x8127;
67 int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128;
68 int GL_POINT_DISTANCE_ATTENUATION = 0x8129;
69 int GL_COLOR_SUM = 0x8458;
70 int GL_CURRENT_SECONDARY_COLOR = 0x8459;
71 int GL_SECONDARY_COLOR_ARRAY_SIZE = 0x845A;
72 int GL_SECONDARY_COLOR_ARRAY_TYPE = 0x845B;
73 int GL_SECONDARY_COLOR_ARRAY_STRIDE = 0x845C;
74 int GL_SECONDARY_COLOR_ARRAY_POINTER = 0x845D;
75 int GL_SECONDARY_COLOR_ARRAY = 0x845E;
76 int GL_BLEND_DST_RGB = 0x80C8;
77 int GL_BLEND_SRC_RGB = 0x80C9;
78 int GL_BLEND_DST_ALPHA = 0x80CA;
79 int GL_BLEND_SRC_ALPHA = 0x80CB;
80 int GL_INCR_WRAP = 0x8507;
81 int GL_DECR_WRAP = 0x8508;
82 int GL_TEXTURE_FILTER_CONTROL = 0x8500;
83 int GL_TEXTURE_LOD_BIAS = 0x8501;
84 int GL_MAX_TEXTURE_LOD_BIAS = 0x84FD;
85 int GL_MIRRORED_REPEAT = 0x8370;
86
87 int GL_BLEND_COLOR = 0x8005;
88 int GL_BLEND_EQUATION = 0x8009;
89
90 int GL_FUNC_ADD = 0x8006;
91 int GL_FUNC_SUBTRACT = 0x800A;
92 int GL_FUNC_REVERSE_SUBTRACT = 0x800B;
93 int GL_MIN = 0x8007;
94 int GL_MAX = 0x8008;
95
96 void glBlendEquation(@GLenum int mode);
97
98 void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
99
100 @DeprecatedGL
101 void glFogCoordf(float coord);
102
103 @DeprecatedGL
104 void glFogCoordd(double coord);
105
106 @DeprecatedGL
107 void glFogCoordPointer(@AutoType("data") @GLenum int type, @GLsizei int stride,
108 @CachedReference
109 @BufferObject(BufferKind.ArrayVBO)
110 @Check
111 @Const
112 @GLfloat
113 @GLdouble Buffer data);
114
115 void glMultiDrawArrays(@GLenum int mode, IntBuffer piFirst, @Check("piFirst.remaining()") @GLsizei IntBuffer piCount, @AutoSize("piFirst") @GLsizei int primcount);
116
117 //void glMultiDrawElements(int mode, int piCount, int type, int pIndices, int primcount);
118
119 void glPointParameteri(@GLenum int pname, int param);
120
121 void glPointParameterf(@GLenum int pname, float param);
122
123 @StripPostfix("params")
124 void glPointParameteriv(@GLenum int pname, @Check("4") @Const IntBuffer params);
125
126 @StripPostfix("params")
127 void glPointParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer params);
128
129 @DeprecatedGL
130 void glSecondaryColor3b(byte red, byte green, byte blue);
131
132 @DeprecatedGL
133 void glSecondaryColor3f(float red, float green, float blue);
134
135 @DeprecatedGL
136 void glSecondaryColor3d(double red, double green, double blue);
137
138 @DeprecatedGL
139 void glSecondaryColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue);
140
141 @DeprecatedGL
142 void glSecondaryColorPointer(int size, @AutoType("data") @GLenum int type, @GLsizei int stride,
143 @BufferObject(BufferKind.ArrayVBO)
144 @Check
145 @Const
146 @GLbyte
147 @GLubyte
148 @GLfloat
149 @GLdouble Buffer data);
150
151 void glBlendFuncSeparate(@GLenum int sfactorRGB, @GLenum int dfactorRGB, @GLenum int sfactorAlpha, @GLenum int dfactorAlpha);
152
153 @DeprecatedGL
154 void glWindowPos2f(float x, float y);
155
156 @DeprecatedGL
157 void glWindowPos2d(double x, double y);
158
159 @DeprecatedGL
160 void glWindowPos2i(int x, int y);
161
162 @DeprecatedGL
163 void glWindowPos3f(float x, float y, float z);
164
165 @DeprecatedGL
166 void glWindowPos3d(double x, double y, double z);
167
168 @DeprecatedGL
169 void glWindowPos3i(int x, int y, int z);
170 }
171
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface GL15 {
40 // ----------------------------------------------------------------------
41 // ---------------------- ARB_vertex_buffer_object ----------------------
42 // ----------------------------------------------------------------------
43
44 int GL_ARRAY_BUFFER = 0x8892;
45 int GL_ELEMENT_ARRAY_BUFFER = 0x8893;
46 int GL_ARRAY_BUFFER_BINDING = 0x8894;
47 int GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
48 int GL_VERTEX_ARRAY_BUFFER_BINDING = 0x8896;
49 int GL_NORMAL_ARRAY_BUFFER_BINDING = 0x8897;
50 int GL_COLOR_ARRAY_BUFFER_BINDING = 0x8898;
51 int GL_INDEX_ARRAY_BUFFER_BINDING = 0x8899;
52 int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 0x889A;
53 int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 0x889B;
54 int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 0x889C;
55 int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889D;
56 int GL_WEIGHT_ARRAY_BUFFER_BINDING = 0x889E;
57 int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
58 int GL_STREAM_DRAW = 0x88E0;
59 int GL_STREAM_READ = 0x88E1;
60 int GL_STREAM_COPY = 0x88E2;
61 int GL_STATIC_DRAW = 0x88E4;
62 int GL_STATIC_READ = 0x88E5;
63 int GL_STATIC_COPY = 0x88E6;
64 int GL_DYNAMIC_DRAW = 0x88E8;
65 int GL_DYNAMIC_READ = 0x88E9;
66 int GL_DYNAMIC_COPY = 0x88EA;
67 int GL_READ_ONLY = 0x88B8;
68 int GL_WRITE_ONLY = 0x88B9;
69 int GL_READ_WRITE = 0x88BA;
70 int GL_BUFFER_SIZE = 0x8764;
71 int GL_BUFFER_USAGE = 0x8765;
72 int GL_BUFFER_ACCESS = 0x88BB;
73 int GL_BUFFER_MAPPED = 0x88BC;
74 int GL_BUFFER_MAP_POINTER = 0x88BD;
75
76 int FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE;
77 int GL_FOG_COORD = GL14.GL_FOG_COORDINATE;
78 int GL_CURRENT_FOG_COORD = GL14.GL_CURRENT_FOG_COORDINATE;
79 int GL_FOG_COORD_ARRAY_TYPE = GL14.GL_FOG_COORDINATE_ARRAY_TYPE;
80 int GL_FOG_COORD_ARRAY_STRIDE = GL14.GL_FOG_COORDINATE_ARRAY_STRIDE;
81 int GL_FOG_COORD_ARRAY_POINTER = GL14.GL_FOG_COORDINATE_ARRAY_POINTER;
82 int GL_FOG_COORD_ARRAY = GL14.GL_FOG_COORDINATE_ARRAY;
83 int GL_FOG_COORD_ARRAY_BUFFER_BINDING = GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING;
84 int GL_SRC0_RGB = GL13.GL_SOURCE0_RGB;
85 int GL_SRC1_RGB = GL13.GL_SOURCE1_RGB;
86 int GL_SRC2_RGB = GL13.GL_SOURCE2_RGB;
87 int GL_SRC0_ALPHA = GL13.GL_SOURCE0_ALPHA;
88 int GL_SRC1_ALPHA = GL13.GL_SOURCE1_ALPHA;
89 int GL_SRC2_ALPHA = GL13.GL_SOURCE2_ALPHA;
90
91 @Code(" StateTracker.bindBuffer(caps, target, buffer);")
92 void glBindBuffer(@GLenum int target, @GLuint int buffer);
93
94 void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
95
96 @Alternate("glDeleteBuffers")
97 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
98
99 void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
100
101 @Alternate("glGenBuffers")
102 @GLreturn("buffers")
103 void glGenBuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
104
105 boolean glIsBuffer(@GLuint int buffer);
106
107 @GenerateAutos
108 void glBufferData(@GLenum int target, @AutoSize("data") @GLsizeiptr long size,
109 @Const
110 @GLbyte
111 @GLshort
112 @GLint
113 @GLfloat
114 @GLdouble Buffer data, @GLenum int usage);
115
116 void glBufferSubData(@GLenum int target, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
117 @Check
118 @Const
119 @GLbyte
120 @GLshort
121 @GLint
122 @GLfloat
123 @GLdouble Buffer data);
124
125 void glGetBufferSubData(@GLenum int target, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
126 @OutParameter
127 @Check
128 @GLbyte
129 @GLshort
130 @GLint
131 @GLfloat
132 @GLdouble Buffer data);
133
134 /**
135 * glMapBuffer maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null,
136 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
137 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
138 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBuffer like this:
139 * <p/>
140 * ByteBuffer mapped_buffer; mapped_buffer = glMapBuffer(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBuffer(..., ..., mapped_buffer);
141 * <p/>
142 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
143 * <p/>
144 * The version of this method without an explicit length argument calls glGetBufferParameter internally to
145 * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance.
146 * <p/>
147 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call
148 * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.<br>
149 * Security warning: The length argument should match the buffer object size. Reading from or writing to outside
150 * the memory region that corresponds to the mapped buffer object will cause native crashes.
151 *
152 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
153 *
154 * @return A ByteBuffer representing the mapped buffer memory.
155 */
156 @CachedResult
157 @GLvoid
158 @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)")
159 ByteBuffer glMapBuffer(@GLenum int target, @GLenum int access);
160
161 boolean glUnmapBuffer(@GLenum int target);
162
163 @StripPostfix("params")
164 void glGetBufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
165
166 @Alternate("glGetBufferParameteriv")
167 @GLreturn("params")
168 @StripPostfix("params")
169 void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
170
171 @StripPostfix("pointer")
172 @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)")
173 void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer);
174
175 // -----------------------------------------------------------------
176 // ---------------------- ARB_occlusion_query ----------------------
177 // -----------------------------------------------------------------
178
179 /**
180 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
181 * and GetQueryiv:
182 */
183 int GL_SAMPLES_PASSED = 0x8914;
184
185 /** Accepted by the &lt;pname&gt; parameter of GetQueryiv: */
186 int GL_QUERY_COUNTER_BITS = 0x8864;
187 int GL_CURRENT_QUERY = 0x8865;
188
189 /**
190 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv and
191 * GetQueryObjectuiv:
192 */
193 int GL_QUERY_RESULT = 0x8866;
194 int GL_QUERY_RESULT_AVAILABLE = 0x8867;
195
196 void glGenQueries(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
197
198 @Alternate("glGenQueries")
199 @GLreturn("ids")
200 void glGenQueries2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
201
202 void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
203
204 @Alternate("glDeleteQueries")
205 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
206
207 boolean glIsQuery(@GLuint int id);
208
209 void glBeginQuery(@GLenum int target, @GLuint int id);
210
211 void glEndQuery(@GLenum int target);
212
213 @StripPostfix("params")
214 void glGetQueryiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
215
216 @Alternate("glGetQueryiv")
217 @GLreturn("params")
218 @StripPostfix("params")
219 void glGetQueryiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
220
221 @StripPostfix("params")
222 void glGetQueryObjectiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLint IntBuffer params);
223
224 @Alternate("glGetQueryObjectiv")
225 @GLreturn("params")
226 @StripPostfix(value = "params", postfix = "v")
227 void glGetQueryObjectiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLint IntBuffer params);
228
229 @StripPostfix("params")
230 void glGetQueryObjectuiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
231
232 @Alternate("glGetQueryObjectuiv")
233 @GLreturn("params")
234 @StripPostfix(value = "params", postfix = "v")
235 void glGetQueryObjectuiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
236 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface GL20 {
38 // ------------------------------------------------------------------
39 // -------------------[ ARB_shading_language_100 ]-------------------
40 // ------------------------------------------------------------------
41
42 /** Accepted by the &lt;name&gt; parameter of GetString: */
43 int GL_SHADING_LANGUAGE_VERSION = 0x8B8C;
44
45 // ------------------------------------------------------------------
46 // ----------------------[ ARB_shader_objects ]----------------------
47 // ------------------------------------------------------------------
48
49 /** Accepted by the &lt;pname&gt; argument of GetInteger: */
50 int GL_CURRENT_PROGRAM = 0x8B8D;
51
52 /** Accepted by the &lt;pname&gt; parameter of GetObjectParameter{fi}vARB: */
53 int GL_SHADER_TYPE = 0x8B4F;
54 int GL_DELETE_STATUS = 0x8B80;
55 int GL_COMPILE_STATUS = 0x8B81;
56 int GL_LINK_STATUS = 0x8B82;
57 int GL_VALIDATE_STATUS = 0x8B83;
58 int GL_INFO_LOG_LENGTH = 0x8B84;
59 int GL_ATTACHED_SHADERS = 0x8B85;
60 int GL_ACTIVE_UNIFORMS = 0x8B86;
61 int GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87;
62 int GL_ACTIVE_ATTRIBUTES = 0x8B89;
63 int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A;
64 int GL_SHADER_SOURCE_LENGTH = 0x8B88;
65
66 /** Returned by the &lt;params&gt; parameter of GetObjectParameter{fi}vARB: */
67 int GL_SHADER_OBJECT = 0x8B48;
68
69 /** Returned by the &lt;type&gt; parameter of GetActiveUniformARB: */
70 int GL_FLOAT_VEC2 = 0x8B50;
71 int GL_FLOAT_VEC3 = 0x8B51;
72 int GL_FLOAT_VEC4 = 0x8B52;
73 int GL_INT_VEC2 = 0x8B53;
74 int GL_INT_VEC3 = 0x8B54;
75 int GL_INT_VEC4 = 0x8B55;
76 int GL_BOOL = 0x8B56;
77 int GL_BOOL_VEC2 = 0x8B57;
78 int GL_BOOL_VEC3 = 0x8B58;
79 int GL_BOOL_VEC4 = 0x8B59;
80 int GL_FLOAT_MAT2 = 0x8B5A;
81 int GL_FLOAT_MAT3 = 0x8B5B;
82 int GL_FLOAT_MAT4 = 0x8B5C;
83 int GL_SAMPLER_1D = 0x8B5D;
84 int GL_SAMPLER_2D = 0x8B5E;
85 int GL_SAMPLER_3D = 0x8B5F;
86 int GL_SAMPLER_CUBE = 0x8B60;
87 int GL_SAMPLER_1D_SHADOW = 0x8B61;
88 int GL_SAMPLER_2D_SHADOW = 0x8B62;
89
90 /**
91 * The ARB_shader_objects extension allows multiple, optionally null-terminated, source strings to define a shader program.
92 * <p/>
93 * This method uses just a single string, that should NOT be null-terminated.
94 *
95 * @param shader
96 * @param string
97 */
98 void glShaderSource(@GLuint int shader, @Constant("1") @GLsizei int count,
99 @Indirect @Const @GLchar @Check ByteBuffer string,
100 @AutoSize("string") @Indirect @Const @GLint int length);
101
102 @Alternate("glShaderSource")
103 void glShaderSource2(@GLuint int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length);
104
105 @Alternate(value = "glShaderSource", nativeAlt = true)
106 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
110 int glCreateShader(@GLuint int type);
111
112 boolean glIsShader(@GLuint int shader);
113
114 void glCompileShader(@GLuint int shader);
115
116 void glDeleteShader(@GLuint int shader);
117
118 int glCreateProgram();
119
120 boolean glIsProgram(int program);
121
122 void glAttachShader(@GLuint int program, @GLuint int shader);
123
124 void glDetachShader(@GLuint int program, @GLuint int shader);
125
126 void glLinkProgram(@GLuint int program);
127
128 void glUseProgram(@GLuint int program);
129
130 void glValidateProgram(@GLuint int program);
131
132 void glDeleteProgram(@GLuint int program);
133
134 void glUniform1f(int location, float v0);
135
136 void glUniform2f(int location, float v0, float v1);
137
138 void glUniform3f(int location, float v0, float v1, float v2);
139
140 void glUniform4f(int location, float v0, float v1, float v2, float v3);
141
142 void glUniform1i(int location, int v0);
143
144 void glUniform2i(int location, int v0, int v1);
145
146 void glUniform3i(int location, int v0, int v1, int v2);
147
148 void glUniform4i(int location, int v0, int v1, int v2, int v3);
149
150 @StripPostfix("values")
151 void glUniform1fv(int location, @AutoSize("values") @GLsizei int count, @Const FloatBuffer values);
152
153 @StripPostfix("values")
154 void glUniform2fv(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const FloatBuffer values);
155
156 @StripPostfix("values")
157 void glUniform3fv(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const FloatBuffer values);
158
159 @StripPostfix("values")
160 void glUniform4fv(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const FloatBuffer values);
161
162 @StripPostfix("values")
163 void glUniform1iv(int location, @AutoSize("values") @GLsizei int count, @Const IntBuffer values);
164
165 @StripPostfix("values")
166 void glUniform2iv(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const IntBuffer values);
167
168 @StripPostfix("values")
169 void glUniform3iv(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const IntBuffer values);
170
171 @StripPostfix("values")
172 void glUniform4iv(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const IntBuffer values);
173
174 @StripPostfix("matrices")
175 void glUniformMatrix2fv(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count,
176 boolean transpose, @Const FloatBuffer matrices);
177
178 @StripPostfix("matrices")
179 void glUniformMatrix3fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count,
180 boolean transpose, @Const FloatBuffer matrices);
181
182 @StripPostfix("matrices")
183 void glUniformMatrix4fv(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count,
184 boolean transpose, @Const FloatBuffer matrices);
185
186 @StripPostfix("params")
187 void glGetShaderiv(@GLuint int shader, @GLenum int pname, @OutParameter @Check IntBuffer params);
188
189 @Alternate("glGetShaderiv")
190 @GLreturn("params")
191 @StripPostfix("params")
192 void glGetShaderiv2(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params);
193
194 @StripPostfix("params")
195 void glGetProgramiv(@GLuint int program, @GLenum int pname, @OutParameter @Check IntBuffer params);
196
197 @Alternate("glGetProgramiv")
198 @GLreturn("params")
199 @StripPostfix("params")
200 void glGetProgramiv2(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params);
201
202 void glGetShaderInfoLog(@GLuint int shader, @AutoSize("infoLog") @GLsizei int maxLength,
203 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
204 @OutParameter @GLchar ByteBuffer infoLog);
205
206 @Alternate("glGetShaderInfoLog")
207 @GLreturn(value = "infoLog", maxLength = "maxLength")
208 void glGetShaderInfoLog2(@GLuint int shader, @GLsizei int maxLength,
209 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
210 @OutParameter @GLchar ByteBuffer infoLog);
211
212 void glGetProgramInfoLog(@GLuint int program, @AutoSize("infoLog") @GLsizei int maxLength,
213 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
214 @OutParameter @GLchar ByteBuffer infoLog);
215
216 @Alternate("glGetProgramInfoLog")
217 @GLreturn(value = "infoLog", maxLength = "maxLength")
218 void glGetProgramInfoLog2(@GLuint int program, @GLsizei int maxLength,
219 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
220 @OutParameter @GLchar ByteBuffer infoLog);
221
222 void glGetAttachedShaders(@GLuint int program, @AutoSize("shaders") @GLsizei int maxCount,
223 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count,
224 @OutParameter @GLuint IntBuffer shaders);
225
226 /**
227 * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a
228 * <b>null-terminated</b> string.
229 *
230 * @param program
231 * @param name
232 */
233 int glGetUniformLocation(@GLuint int program, @NullTerminated @Check("1") @Const @GLchar ByteBuffer name);
234
235 @Alternate("glGetUniformLocation")
236 int glGetUniformLocation(@GLuint int program, @NullTerminated CharSequence name);
237
238 void glGetActiveUniform(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength,
239 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
240 @OutParameter @GLsizei @Check("1") IntBuffer size,
241 @OutParameter @GLenum @Check("1") IntBuffer type,
242 @OutParameter @GLchar ByteBuffer name);
243
244 /** Overloads glGetActiveUniform. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
245 @Alternate("glGetActiveUniform")
246 @GLreturn(value = "name", maxLength = "maxLength")
247 void glGetActiveUniform2(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
248 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
249 @OutParameter @Check("2") IntBuffer sizeType,
250 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
251 @OutParameter @GLchar ByteBuffer name);
252
253 /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
254 @Alternate(value = "glGetActiveUniform", javaAlt = true)
255 @GLreturn(value = "name", maxLength = "maxLength")
256 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,
258 @OutParameter @GLchar ByteBuffer name);
259
260 /** Overloads glGetActiveUniform. This version returns only the uniform size. */
261 @Alternate(value = "glGetActiveUniform", javaAlt = true)
262 @GLreturn(value = "size")
263 void glGetActiveUniformSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
264 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
265 @OutParameter IntBuffer size,
266 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
267 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
268
269 /** Overloads glGetActiveUniform. This version returns only the uniform type. */
270 @Alternate(value = "glGetActiveUniform", javaAlt = true)
271 @GLreturn(value = "type")
272 void glGetActiveUniformType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
273 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
274 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
275 @OutParameter @GLenum IntBuffer type,
276 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
277
278 @StripPostfix("params")
279 void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params);
280
281 @StripPostfix("params")
282 void glGetUniformiv(@GLuint int program, int location, @OutParameter @Check IntBuffer params);
283
284 void glGetShaderSource(@GLuint int shader, @AutoSize("source") @GLsizei int maxLength,
285 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
286 @OutParameter @GLchar ByteBuffer source);
287
288 @Alternate("glGetShaderSource")
289 @GLreturn(value = "source", maxLength = "maxLength")
290 void glGetShaderSource2(@GLuint int shader, @GLsizei int maxLength,
291 @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length,
292 @OutParameter @GLchar ByteBuffer source);
293
294 // ------------------------------------------------------------------
295 // ----------------------[ ARB_vertex_program ]----------------------
296 // ------------------------------------------------------------------
297
298 @NoErrorCheck
299 void glVertexAttrib1s(@GLuint int index, short x);
300
301 @NoErrorCheck
302 void glVertexAttrib1f(@GLuint int index, float x);
303
304 @NoErrorCheck
305 void glVertexAttrib1d(@GLuint int index, double x);
306
307 @NoErrorCheck
308 void glVertexAttrib2s(@GLuint int index, short x, short y);
309
310 @NoErrorCheck
311 void glVertexAttrib2f(@GLuint int index, float x, float y);
312
313 @NoErrorCheck
314 void glVertexAttrib2d(@GLuint int index, double x, double y);
315
316 @NoErrorCheck
317 void glVertexAttrib3s(@GLuint int index, short x, short y, short z);
318
319 @NoErrorCheck
320 void glVertexAttrib3f(@GLuint int index, float x, float y, float z);
321
322 @NoErrorCheck
323 void glVertexAttrib3d(@GLuint int index, double x, double y, double z);
324
325 @NoErrorCheck
326 void glVertexAttrib4s(@GLuint int index, short x, short y, short z, short w);
327
328 @NoErrorCheck
329 void glVertexAttrib4f(@GLuint int index, float x, float y, float z, float w);
330
331 @NoErrorCheck
332 void glVertexAttrib4d(@GLuint int index, double x, double y, double z, double w);
333
334 @NoErrorCheck
335 void glVertexAttrib4Nub(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
336
337 void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
338 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
339 @BufferObject(BufferKind.ArrayVBO)
340 @Check
341 @Const
342 @GLubyte
343 @GLbyte
344 @GLshort
345 @GLushort
346 @GLint
347 @GLuint
348 @GLfloat
349 @GLdouble Buffer buffer);
350
351 void glEnableVertexAttribArray(@GLuint int index);
352
353 void glDisableVertexAttribArray(@GLuint int index);
354
355 @StripPostfix("params")
356 void glGetVertexAttribfv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
357
358 @StripPostfix("params")
359 void glGetVertexAttribdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
360
361 @StripPostfix("params")
362 void glGetVertexAttribiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
363
364 @StripPostfix("pointer")
365 void glGetVertexAttribPointerv(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
366
367 // -----------------------------------------------------------------
368 // ----------------------[ ARB_vertex_shader ]----------------------
369 // -----------------------------------------------------------------
370
371 /**
372 * Accepted by the &lt;shaderType&gt; argument of CreateShader and
373 * returned by the &lt;params&gt; parameter of GetShader{if}v:
374 */
375 int GL_VERTEX_SHADER = 0x8B31;
376
377 /**
378 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
379 * GetFloatv, and GetDoublev:
380 */
381 int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A;
382 int GL_MAX_VARYING_FLOATS = 0x8B4B;
383 int GL_MAX_VERTEX_ATTRIBS = 0x8869;
384 int GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872;
385 int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
386 int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
387 int GL_MAX_TEXTURE_COORDS = 0x8871;
388
389 /**
390 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and
391 * by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
392 * GetDoublev:
393 */
394 int GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
395 int GL_VERTEX_PROGRAM_TWO_SIDE = 0x8643;
396
397 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib{dfi}vARB: */
398 int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
399 int GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
400 int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
401 int GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
402 int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
403 int GL_CURRENT_VERTEX_ATTRIB = 0x8626;
404
405 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttribPointervARB: */
406 int GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
407
408 void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name);
409
410 @Alternate("glBindAttribLocation")
411 void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated CharSequence name);
412
413 void glGetActiveAttrib(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength,
414 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
415 @OutParameter @Check("1") IntBuffer size,
416 @OutParameter @GLenum @Check("1") IntBuffer type,
417 @OutParameter @GLchar ByteBuffer name);
418
419 /** Overloads glGetActiveAttrib. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
420 @Alternate("glGetActiveAttrib")
421 @GLreturn(value = "name", maxLength = "maxLength")
422 void glGetActiveAttrib2(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
423 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
424 @OutParameter @Check("2") IntBuffer sizeType,
425 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
426 @OutParameter @GLchar ByteBuffer name);
427
428 /** Overloads glGetActiveAttrib. This version returns only the attrib name. */
429 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
430 @GLreturn(value = "name", maxLength = "maxLength")
431 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,
433 @OutParameter @GLchar ByteBuffer name);
434
435 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
436 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
437 @GLreturn(value = "size")
438 void glGetActiveAttribSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
439 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
440 @OutParameter IntBuffer size,
441 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
442 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
443
444 /** Overloads glGetActiveAttrib. This version returns only the attrib type. */
445 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
446 @GLreturn(value = "type")
447 void glGetActiveAttribType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
448 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
449 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
450 @OutParameter @GLenum IntBuffer type,
451 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
452
453 int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
454
455 @Alternate("glGetAttribLocation")
456 int glGetAttribLocation(@GLuint int program, @NullTerminated CharSequence name);
457
458 // -------------------------------------------------------------------
459 // ----------------------[ ARB_fragment_shader ]----------------------
460 // -------------------------------------------------------------------
461
462 /**
463 * Accepted by the &lt;shaderType&gt; argument of CreateShader and
464 * returned by the &lt;params&gt; parameter of GetShader{fi}vARB:
465 */
466 int GL_FRAGMENT_SHADER = 0x8B30;
467
468 /**
469 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
470 * GetFloatv, and GetDoublev:
471 */
472 int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49;
473
474 /**
475 * Accepted by the &lt;target&gt; parameter of Hint and the &lt;pname&gt; parameter of
476 * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
477 */
478 int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B;
479
480 // ----------------------------------------------------------------
481 // ----------------------[ ARB_draw_buffers ]----------------------
482 // ----------------------------------------------------------------
483
484 /**
485 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
486 * and GetDoublev:
487 */
488 int GL_MAX_DRAW_BUFFERS = 0x8824;
489 int GL_DRAW_BUFFER0 = 0x8825;
490 int GL_DRAW_BUFFER1 = 0x8826;
491 int GL_DRAW_BUFFER2 = 0x8827;
492 int GL_DRAW_BUFFER3 = 0x8828;
493 int GL_DRAW_BUFFER4 = 0x8829;
494 int GL_DRAW_BUFFER5 = 0x882A;
495 int GL_DRAW_BUFFER6 = 0x882B;
496 int GL_DRAW_BUFFER7 = 0x882C;
497 int GL_DRAW_BUFFER8 = 0x882D;
498 int GL_DRAW_BUFFER9 = 0x882E;
499 int GL_DRAW_BUFFER10 = 0x882F;
500 int GL_DRAW_BUFFER11 = 0x8830;
501 int GL_DRAW_BUFFER12 = 0x8831;
502 int GL_DRAW_BUFFER13 = 0x8832;
503 int GL_DRAW_BUFFER14 = 0x8833;
504 int GL_DRAW_BUFFER15 = 0x8834;
505
506 void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
507
508 @Alternate("glDrawBuffers")
509 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
510
511 // ----------------------------------------------------------------
512 // ----------------------[ ARB_point_sprite ]----------------------
513 // ----------------------------------------------------------------
514
515 /**
516 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, by
517 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
518 * GetDoublev, and by the &lt;target&gt; parameter of TexEnvi, TexEnviv,
519 * TexEnvf, TexEnvfv, GetTexEnviv, and GetTexEnvfv:
520 */
521 int GL_POINT_SPRITE = 0x8861;
522
523 /**
524 * When the &lt;target&gt; parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv,
525 * GetTexEnvfv, or GetTexEnviv is POINT_SPRITE, then the value of
526 * &lt;pname&gt; may be:
527 */
528 int GL_COORD_REPLACE = 0x8862;
529
530 /**
531 * Accepted by the &lt;pname&gt; parameter of PointParameter{if}vARB, and the
532 * &lt;pname&gt; of Get:
533 */
534 int GL_POINT_SPRITE_COORD_ORIGIN = 0x8CA0;
535
536 /** Accepted by the &lt;param&gt; parameter of PointParameter{if}vARB: */
537 int GL_LOWER_LEFT = 0x8CA1;
538 int GL_UPPER_LEFT = 0x8CA2;
539
540 // -----------------------------------------------------------------
541 // ----------------------[ Two-Sided Stencil ]----------------------
542 // -----------------------------------------------------------------
543
544 int GL_STENCIL_BACK_FUNC = 0x8800;
545 int GL_STENCIL_BACK_FAIL = 0x8801;
546 int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
547 int GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
548 int GL_STENCIL_BACK_REF = 0x8CA3;
549 int GL_STENCIL_BACK_VALUE_MASK = 0x8CA4;
550 int GL_STENCIL_BACK_WRITEMASK = 0x8CA5;
551
552 void glStencilOpSeparate(@GLenum int face, @GLenum int sfail, @GLenum int dpfail, @GLenum int dppass);
553
554 void glStencilFuncSeparate(@GLenum int face, @GLenum int func, int ref, @GLuint int mask);
555
556 void glStencilMaskSeparate(@GLenum int face, @GLuint int mask);
557
558 // -------------------------------------------------------------
559 // ----------------------[ EXT_blend_equation_separate ]----------------------
560 // -------------------------------------------------------------
561
562 int GL_BLEND_EQUATION_RGB = 0x8009;
563 int GL_BLEND_EQUATION_ALPHA = 0x883D;
564
565 void glBlendEquationSeparate(@GLenum int modeRGB, @GLenum int modeAlpha);
566 }
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.AutoSize;
34 import org.lwjgl.util.generator.GLsizei;
35 import org.lwjgl.util.generator.StripPostfix;
36
37 import java.nio.FloatBuffer;
38
39 public interface GL21 {
40
41 // ------------------------------------------------------------------
42 // --------------------------[ GLSL 1.20 ]---------------------------
43 // ------------------------------------------------------------------
44
45 /** Returned by the &lt;type&gt; parameter of GetActiveAttribARB. */
46 int GL_FLOAT_MAT2x3 = 0x8B65;
47 int GL_FLOAT_MAT2x4 = 0x8B66;
48 int GL_FLOAT_MAT3x2 = 0x8B67;
49 int GL_FLOAT_MAT3x4 = 0x8B68;
50 int GL_FLOAT_MAT4x2 = 0x8B69;
51 int GL_FLOAT_MAT4x3 = 0x8B6A;
52
53 @StripPostfix("matrices")
54 void glUniformMatrix2x3fv(int location, @AutoSize(value = "matrices", expression = " / (2 * 3)") @GLsizei int count,
55 boolean transpose, FloatBuffer matrices);
56
57 @StripPostfix("matrices")
58 void glUniformMatrix3x2fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 2)") @GLsizei int count,
59 boolean transpose, FloatBuffer matrices);
60
61 @StripPostfix("matrices")
62 void glUniformMatrix2x4fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count,
63 boolean transpose, FloatBuffer matrices);
64
65 @StripPostfix("matrices")
66 void glUniformMatrix4x2fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count,
67 boolean transpose, FloatBuffer matrices);
68
69 @StripPostfix("matrices")
70 void glUniformMatrix3x4fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 4)") @GLsizei int count,
71 boolean transpose, FloatBuffer matrices);
72
73 @StripPostfix("matrices")
74 void glUniformMatrix4x3fv(int location, @AutoSize(value = "matrices", expression = " / (4 * 3)") @GLsizei int count,
75 boolean transpose, FloatBuffer matrices);
76
77 // ------------------------------------------------------------------
78 // -------------------[ ARB_pixel_buffer_object ]--------------------
79 // ------------------------------------------------------------------
80
81 /**
82 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
83 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
84 * GetBufferParameteriv, and GetBufferPointerv.
85 */
86 int GL_PIXEL_PACK_BUFFER = 0x88EB;
87 int GL_PIXEL_UNPACK_BUFFER = 0x88EC;
88
89 /**
90 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
91 * GetFloatv, and GetDoublev.
92 */
93 int GL_PIXEL_PACK_BUFFER_BINDING = 0x88ED;
94 int GL_PIXEL_UNPACK_BUFFER_BINDING = 0x88EF;
95
96 // ------------------------------------------------------------------
97 // ----------------------[ EXT_texture_sRGB ]------------------------
98 // ------------------------------------------------------------------
99
100 /**
101 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D, TexImage2D,
102 * TexImage3D, CopyTexImage1D, CopyTexImage2D.
103 */
104 int GL_SRGB = 0x8C40;
105 int GL_SRGB8 = 0x8C41;
106 int GL_SRGB_ALPHA = 0x8C42;
107 int GL_SRGB8_ALPHA8 = 0x8C43;
108 int GL_SLUMINANCE_ALPHA = 0x8C44;
109 int GL_SLUMINANCE8_ALPHA8 = 0x8C45;
110 int GL_SLUMINANCE = 0x8C46;
111 int GL_SLUMINANCE8 = 0x8C47;
112 int GL_COMPRESSED_SRGB = 0x8C48;
113 int GL_COMPRESSED_SRGB_ALPHA = 0x8C49;
114 int GL_COMPRESSED_SLUMINANCE = 0x8C4A;
115 int GL_COMPRESSED_SLUMINANCE_ALPHA = 0x8C4B;
116
117 // ------------------------------------------------------------------
118 // -----------------------[ Misc additions ]-------------------------
119 // ------------------------------------------------------------------
120
121 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv and GetFloatv. */
122 int GL_CURRENT_RASTER_SECONDARY_COLOR = 0x845F;
123
124 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface GL30 {
38
39 // ----------------------------------------------------------
40 // ----------------------[ OpenGL 3.0 ]----------------------
41 // ----------------------------------------------------------
42
43 int GL_MAJOR_VERSION = 0x821B;
44 int GL_MINOR_VERSION = 0x821C;
45 int GL_NUM_EXTENSIONS = 0x821D;
46
47 int GL_CONTEXT_FLAGS = 0x821E;
48 int GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x0001;
49
50 int GL_DEPTH_BUFFER = 0x8223;
51 int GL_STENCIL_BUFFER = 0x8224;
52
53 int GL_COMPRESSED_RED = 0x8225;
54 int GL_COMPRESSED_RG = 0x8226;
55
56 int GL_COMPARE_REF_TO_TEXTURE = ARB_shadow.GL_COMPARE_R_TO_TEXTURE_ARB;
57
58 int GL_CLIP_DISTANCE0 = GL11.GL_CLIP_PLANE0;
59 int GL_CLIP_DISTANCE1 = GL11.GL_CLIP_PLANE1;
60 int GL_CLIP_DISTANCE2 = GL11.GL_CLIP_PLANE2;
61 int GL_CLIP_DISTANCE3 = GL11.GL_CLIP_PLANE3;
62 int GL_CLIP_DISTANCE4 = GL11.GL_CLIP_PLANE4;
63 int GL_CLIP_DISTANCE5 = GL11.GL_CLIP_PLANE5;
64 int GL_CLIP_DISTANCE6 = 0x3006;
65 int GL_CLIP_DISTANCE7 = 0x3007;
66
67 int GL_MAX_CLIP_DISTANCES = GL11.GL_MAX_CLIP_PLANES;
68
69 int GL_MAX_VARYING_COMPONENTS = GL20.GL_MAX_VARYING_FLOATS;
70
71 int GL_BUFFER_ACCESS_FLAGS = 0x911F;
72 int GL_BUFFER_MAP_LENGTH = 0x9120;
73 int GL_BUFFER_MAP_OFFSET = 0x9121;
74
75 String glGetStringi(@GLenum int name, @GLuint int index);
76
77 @StripPostfix("value")
78 void glClearBufferfv(@GLenum int buffer, int drawbuffer, @Const @Check("4") FloatBuffer value);
79
80 @StripPostfix("value")
81 void glClearBufferiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value);
82
83 @StripPostfix("value")
84 void glClearBufferuiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value);
85
86 void glClearBufferfi(@GLenum int buffer, int drawbuffer, float depth, int stencil);
87
88 // ---------------------------------------------------------------
89 // ----------------------[ EXT_gpu_shader4 ]----------------------
90 // ---------------------------------------------------------------
91
92 /**
93 * Accepted by the &lt;pname&gt; parameters of GetVertexAttribdv,
94 * GetVertexAttribfv, GetVertexAttribiv, GetVertexAttribIiv, and
95 * GetVertexAttribIuiv:
96 */
97 int GL_VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD;
98
99 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
100
101 int GL_SAMPLER_BUFFER = 0x8DC2;
102 int GL_SAMPLER_CUBE_SHADOW = 0x8DC5;
103 int GL_UNSIGNED_INT_VEC2 = 0x8DC6;
104 int GL_UNSIGNED_INT_VEC3 = 0x8DC7;
105 int GL_UNSIGNED_INT_VEC4 = 0x8DC8;
106 int GL_INT_SAMPLER_1D = 0x8DC9;
107 int GL_INT_SAMPLER_2D = 0x8DCA;
108 int GL_INT_SAMPLER_3D = 0x8DCB;
109 int GL_INT_SAMPLER_CUBE = 0x8DCC;
110 int GL_INT_SAMPLER_2D_RECT = 0x8DCD;
111 int GL_INT_SAMPLER_1D_ARRAY = 0x8DCE;
112 int GL_INT_SAMPLER_2D_ARRAY = 0x8DCF;
113 int GL_INT_SAMPLER_BUFFER = 0x8DD0;
114
115 int GL_UNSIGNED_INT_SAMPLER_1D = 0x8DD1;
116 int GL_UNSIGNED_INT_SAMPLER_2D = 0x8DD2;
117 int GL_UNSIGNED_INT_SAMPLER_3D = 0x8DD3;
118 int GL_UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4;
119 int GL_UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5;
120 int GL_UNSIGNED_INT_SAMPLER_1D_ARRAY = 0x8DD6;
121 int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7;
122 int GL_UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8;
123
124 /**
125 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
126 * and GetDoublev:
127 */
128 int GL_MIN_PROGRAM_TEXEL_OFFSET = 0x8904;
129 int GL_MAX_PROGRAM_TEXEL_OFFSET = 0x8905;
130
131 @NoErrorCheck
132 void glVertexAttribI1i(@GLuint int index, int x);
133
134 @NoErrorCheck
135 void glVertexAttribI2i(@GLuint int index, int x, int y);
136
137 @NoErrorCheck
138 void glVertexAttribI3i(@GLuint int index, int x, int y, int z);
139
140 @NoErrorCheck
141 void glVertexAttribI4i(@GLuint int index, int x, int y, int z, int w);
142
143 @NoErrorCheck
144 void glVertexAttribI1ui(@GLuint int index, @GLuint int x);
145
146 @NoErrorCheck
147 void glVertexAttribI2ui(@GLuint int index, @GLuint int x, @GLuint int y);
148
149 @NoErrorCheck
150 void glVertexAttribI3ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z);
151
152 @NoErrorCheck
153 void glVertexAttribI4ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
154
155 @NoErrorCheck
156 @StripPostfix("v")
157 void glVertexAttribI1iv(@GLuint int index, @Check("1") @Const IntBuffer v);
158
159 @NoErrorCheck
160 @StripPostfix("v")
161 void glVertexAttribI2iv(@GLuint int index, @Check("2") @Const IntBuffer v);
162
163 @NoErrorCheck
164 @StripPostfix("v")
165 void glVertexAttribI3iv(@GLuint int index, @Check("3") @Const IntBuffer v);
166
167 @NoErrorCheck
168 @StripPostfix("v")
169 void glVertexAttribI4iv(@GLuint int index, @Check("4") @Const IntBuffer v);
170
171 @NoErrorCheck
172 @StripPostfix("v")
173 void glVertexAttribI1uiv(@GLuint int index, @Check("1") @Const @GLuint IntBuffer v);
174
175 @NoErrorCheck
176 @StripPostfix("v")
177 void glVertexAttribI2uiv(@GLuint int index, @Check("2") @Const @GLuint IntBuffer v);
178
179 @NoErrorCheck
180 @StripPostfix("v")
181 void glVertexAttribI3uiv(@GLuint int index, @Check("3") @Const @GLuint IntBuffer v);
182
183 @NoErrorCheck
184 @StripPostfix("v")
185 void glVertexAttribI4uiv(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v);
186
187 @NoErrorCheck
188 @StripPostfix("v")
189 void glVertexAttribI4bv(@GLuint int index, @Check("4") @Const ByteBuffer v);
190
191 @NoErrorCheck
192 @StripPostfix("v")
193 void glVertexAttribI4sv(@GLuint int index, @Check("4") @Const ShortBuffer v);
194
195 @NoErrorCheck
196 @StripPostfix("v")
197 void glVertexAttribI4ubv(@GLuint int index, @Check("4") @Const @GLubyte ByteBuffer v);
198
199 @NoErrorCheck
200 @StripPostfix("v")
201 void glVertexAttribI4usv(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
202
203 void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
204 @CachedReference
205 @BufferObject(BufferKind.ArrayVBO)
206 @Check
207 @Const
208 @GLbyte
209 @GLubyte
210 @GLshort
211 @GLushort
212 @GLint
213 @GLuint Buffer buffer);
214
215 @StripPostfix("params")
216 void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
217
218 @StripPostfix("params")
219 void glGetVertexAttribIuiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params);
220
221 void glUniform1ui(int location, @GLuint int v0);
222
223 void glUniform2ui(int location, @GLuint int v0, @GLuint int v1);
224
225 void glUniform3ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2);
226
227 void glUniform4ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3);
228
229 @StripPostfix("value")
230 void glUniform1uiv(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value);
231
232 @StripPostfix("value")
233 void glUniform2uiv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value);
234
235 @StripPostfix("value")
236 void glUniform3uiv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value);
237
238 @StripPostfix("value")
239 void glUniform4uiv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value);
240
241 @StripPostfix("params")
242 void glGetUniformuiv(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params);
243
244 void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name);
245
246 @Alternate("glBindFragDataLocation")
247 void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name);
248
249 int glGetFragDataLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
250
251 @Alternate("glGetFragDataLocation")
252 int glGetFragDataLocation(@GLuint int program, @NullTerminated CharSequence name);
253
254 // ---------------------------------------------------------------------
255 // ----------------------[ NV_conditional_render ]----------------------
256 // ---------------------------------------------------------------------
257
258 /** Accepted by the &lt;mode&gt; parameter of BeginConditionalRender: */
259 int GL_QUERY_WAIT = 0x8E13;
260 int GL_QUERY_NO_WAIT = 0x8E14;
261 int GL_QUERY_BY_REGION_WAIT = 0x8E15;
262 int GL_QUERY_BY_REGION_NO_WAIT = 0x8E16;
263
264 void glBeginConditionalRender(@GLuint int id, @GLenum int mode);
265
266 void glEndConditionalRender();
267
268 // --------------------------------------------------------------------
269 // ----------------------[ ARB_map_buffer_range ]----------------------
270 // --------------------------------------------------------------------
271
272 /** Accepted by the &lt;access&gt; parameter of MapBufferRange: */
273 int GL_MAP_READ_BIT = 0x0001;
274 int GL_MAP_WRITE_BIT = 0x0002;
275 int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004;
276 int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008;
277 int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010;
278 int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020;
279
280 /**
281 * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null,
282 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
283 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
284 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this:
285 * <p/>
286 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer);
287 * <p/>
288 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
289 *
290 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created.
291 *
292 * @return A ByteBuffer representing the mapped buffer memory.
293 */
294 @CachedResult(isRange = true)
295 @GLvoid
296 @AutoResultSize("length")
297 ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
298
299 void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
300
301 // ----------------------------------------------------------------------
302 // ----------------------[ ARB_color_buffer_float ]----------------------
303 // ----------------------------------------------------------------------
304
305 /**
306 * Accepted by the &lt;target&gt; parameter of ClampColor and the &lt;pname&gt;
307 * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.
308 */
309 int GL_CLAMP_VERTEX_COLOR = 0x891A;
310 int GL_CLAMP_FRAGMENT_COLOR = 0x891B;
311 int GL_CLAMP_READ_COLOR = 0x891C;
312
313 /** Accepted by the &lt;clamp&gt; parameter of ClampColor. */
314 int GL_FIXED_ONLY = 0x891D;
315
316 void glClampColor(@GLenum int target, @GLenum int clamp);
317
318 // ----------------------------------------------------------------------
319 // ----------------------[ NV_depth_buffer_float ]----------------------
320 // ----------------------------------------------------------------------
321
322 /**
323 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D, TexImage2D,
324 * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT,
325 * and returned in the &lt;data&gt; parameter of GetTexLevelParameter and
326 * GetRenderbufferParameterivEXT:
327 */
328 int GL_DEPTH_COMPONENT32F = 0x8DAB;
329 int GL_DEPTH32F_STENCIL8 = 0x8DAC;
330
331 /**
332 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
333 * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and
334 * GetTexImage:
335 */
336 int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD;
337
338 // -----------------------------------------------------------------
339 // ----------------------[ ARB_texture_float ]----------------------
340 // -----------------------------------------------------------------
341
342 /** Accepted by the &lt;value&gt; parameter of GetTexLevelParameter: */
343 int GL_TEXTURE_RED_TYPE = 0x8C10;
344 int GL_TEXTURE_GREEN_TYPE = 0x8C11;
345 int GL_TEXTURE_BLUE_TYPE = 0x8C12;
346 int GL_TEXTURE_ALPHA_TYPE = 0x8C13;
347 int GL_TEXTURE_LUMINANCE_TYPE = 0x8C14;
348 int GL_TEXTURE_INTENSITY_TYPE = 0x8C15;
349 int GL_TEXTURE_DEPTH_TYPE = 0x8C16;
350
351 /** Returned by the &lt;params&gt; parameter of GetTexLevelParameter: */
352 int GL_UNSIGNED_NORMALIZED = 0x8C17;
353
354 /**
355 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
356 * TexImage2D, and TexImage3D:
357 */
358 int GL_RGBA32F = 0x8814;
359 int GL_RGB32F = 0x8815;
360 int GL_ALPHA32F = 0x8816;
361 int GL_RGBA16F = 0x881A;
362 int GL_RGB16F = 0x881B;
363 int GL_ALPHA16F = 0x881C;
364
365 // ----------------------------------------------------------------
366 // ----------------------[ EXT_packed_float ]----------------------
367 // ----------------------------------------------------------------
368
369 /**
370 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
371 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
372 * RenderbufferStorage:
373 */
374 int GL_R11F_G11F_B10F = 0x8C3A;
375
376 /**
377 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
378 * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D,
379 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
380 * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D,
381 * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter,
382 * ColorTable, ColorSubTable, and GetColorTable:
383 */
384 int GL_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B;
385
386 // ---------------------------------------------------------------------------
387 // ----------------------[ EXT_texture_shared_exponent ]----------------------
388 // ---------------------------------------------------------------------------
389
390 /**
391 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
392 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
393 * RenderbufferStorage:
394 */
395 int GL_RGB9_E5 = 0x8C3D;
396
397 /**
398 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
399 * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D,
400 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
401 * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D,
402 * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter,
403 * ColorTable, ColorSubTable, and GetColorTable:
404 */
405 int GL_UNSIGNED_INT_5_9_9_9_REV = 0x8C3E;
406
407 /**
408 * Accepted by the &lt;pname&gt; parameter of GetTexLevelParameterfv and
409 * GetTexLevelParameteriv:
410 */
411 int GL_TEXTURE_SHARED_SIZE = 0x8C3F;
412
413 // ----------------------------------------------------------------------
414 // ----------------------[ EXT_framebuffer_object ]----------------------
415 // ----------------------------------------------------------------------
416
417 /**
418 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
419 * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, and
420 * FramebufferRenderbuffer:
421 */
422 int GL_FRAMEBUFFER = 0x8D40;
423
424 /**
425 * Accepted by the &lt;target&gt; parameter of BindRenderbuffer,
426 * RenderbufferStorage, and GetRenderbufferParameteriv, and
427 * returned by GetFramebufferAttachmentParameteriv:
428 */
429 int GL_RENDERBUFFER = 0x8D41;
430
431 /**
432 * Accepted by the &lt;internalformat&gt; parameter of
433 * RenderbufferStorage:
434 */
435 int GL_STENCIL_INDEX1 = 0x8D46;
436 int GL_STENCIL_INDEX4 = 0x8D47;
437 int GL_STENCIL_INDEX8 = 0x8D48;
438 int GL_STENCIL_INDEX16 = 0x8D49;
439
440 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
441 int GL_RENDERBUFFER_WIDTH = 0x8D42;
442 int GL_RENDERBUFFER_HEIGHT = 0x8D43;
443 int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
444 int GL_RENDERBUFFER_RED_SIZE = 0x8D50;
445 int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51;
446 int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52;
447 int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53;
448 int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54;
449 int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55;
450
451 /**
452 * Accepted by the &lt;pname&gt; parameter of
453 * GetFramebufferAttachmentParameteriv:
454 */
455 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
456 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
457 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
458 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
459 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4;
460
461 /**
462 * Accepted by the &lt;attachment&gt; parameter of
463 * FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and
464 * GetFramebufferAttachmentParameteriv
465 */
466 int GL_COLOR_ATTACHMENT0 = 0x8CE0;
467 int GL_COLOR_ATTACHMENT1 = 0x8CE1;
468 int GL_COLOR_ATTACHMENT2 = 0x8CE2;
469 int GL_COLOR_ATTACHMENT3 = 0x8CE3;
470 int GL_COLOR_ATTACHMENT4 = 0x8CE4;
471 int GL_COLOR_ATTACHMENT5 = 0x8CE5;
472 int GL_COLOR_ATTACHMENT6 = 0x8CE6;
473 int GL_COLOR_ATTACHMENT7 = 0x8CE7;
474 int GL_COLOR_ATTACHMENT8 = 0x8CE8;
475 int GL_COLOR_ATTACHMENT9 = 0x8CE9;
476 int GL_COLOR_ATTACHMENT10 = 0x8CEA;
477 int GL_COLOR_ATTACHMENT11 = 0x8CEB;
478 int GL_COLOR_ATTACHMENT12 = 0x8CEC;
479 int GL_COLOR_ATTACHMENT13 = 0x8CED;
480 int GL_COLOR_ATTACHMENT14 = 0x8CEE;
481 int GL_COLOR_ATTACHMENT15 = 0x8CEF;
482 int GL_DEPTH_ATTACHMENT = 0x8D00;
483 int GL_STENCIL_ATTACHMENT = 0x8D20;
484
485 /** Returned by CheckFramebufferStatus(): */
486 int GL_FRAMEBUFFER_COMPLETE = 0x8CD5;
487 int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
488 int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
489 int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
490 int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA;
491 int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB;
492 int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC;
493 int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
494
495 /** Accepted by GetIntegerv(): */
496 int GL_FRAMEBUFFER_BINDING = 0x8CA6;
497 int GL_RENDERBUFFER_BINDING = 0x8CA7;
498 int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF;
499 int GL_MAX_RENDERBUFFER_SIZE = 0x84E8;
500
501 /** Returned by GetError(): */
502 int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506;
503
504 boolean glIsRenderbuffer(@GLuint int renderbuffer);
505
506 void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer);
507
508 void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
509
510 @Alternate("glDeleteRenderbuffers")
511 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
512
513 void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
514
515 @Alternate("glGenRenderbuffers")
516 @GLreturn("renderbuffers")
517 void glGenRenderbuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers);
518
519 void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
520
521 @StripPostfix("params")
522 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
523
524 @Alternate("glGetRenderbufferParameteriv")
525 @GLreturn("params")
526 @StripPostfix("params")
527 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
528
529 boolean glIsFramebuffer(@GLuint int framebuffer);
530
531 void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer);
532
533 void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
534
535 @Alternate("glDeleteFramebuffers")
536 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
537
538 void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
539
540 @Alternate("glGenFramebuffers")
541 @GLreturn("framebuffers")
542 void glGenFramebuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers);
543
544 @GLenum
545 int glCheckFramebufferStatus(@GLenum int target);
546
547 void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
548
549 void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
550
551 void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset);
552
553 void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
554
555 @StripPostfix("params")
556 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
557
558 @Alternate("glGetFramebufferAttachmentParameteriv")
559 @GLreturn("params")
560 @StripPostfix("params")
561 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
562
563 void glGenerateMipmap(@GLenum int target);
564
565 // --------------------------------------------------------------------------------------------
566 // ----------------------[ ARB_half_float_vertex & ARB_half_float_pixel ]----------------------
567 // --------------------------------------------------------------------------------------------
568
569 /**
570 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
571 * TexImage1D, TexImage2D, TexImage3D, GetTexImage, TexSubImage1D,
572 * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax,
573 * ConvolutionFilter1D, ConvolutionFilter2D, GetConvolutionFilter,
574 * SeparableFilter2D, GetSeparableFilter, ColorTable, ColorSubTable,
575 * and GetColorTable:
576 * <p/>
577 * Accepted by the &lt;type&gt; argument of VertexPointer, NormalPointer,
578 * ColorPointer, SecondaryColorPointer, FogCoordPointer, TexCoordPointer,
579 * and VertexAttribPointer:
580 */
581 int GL_HALF_FLOAT = 0x140B;
582
583 // ---------------------------------------------------------------------------
584 // ----------------------[ EXT_framebuffer_multisample ]----------------------
585 // ---------------------------------------------------------------------------
586
587 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv. */
588 int GL_RENDERBUFFER_SAMPLES = 0x8CAB;
589
590 /** Returned by CheckFramebufferStatus. */
591 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56;
592
593 /**
594 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
595 * GetFloatv, and GetDoublev.
596 */
597 int GL_MAX_SAMPLES = 0x8D57;
598
599 /**
600 * Establishes the data storage, format, dimensions, and number of
601 * samples of a renderbuffer object's image.
602 */
603 void glRenderbufferStorageMultisample(
604 @GLenum int target, @GLsizei int samples,
605 @GLenum int internalformat,
606 @GLsizei int width, @GLsizei int height);
607
608 // --------------------------------------------------------------------
609 // ----------------------[ EXT_framebuffer_blit ]----------------------
610 // --------------------------------------------------------------------
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;
620
621 /** Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv, and GetDoublev. */
622 int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6; // alias FRAMEBUFFER_BINDING
623 int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA;
624
625 /**
626 * Transfers a rectangle of pixel values from one
627 * region of the read framebuffer to another in the draw framebuffer.
628 * &lt;mask&gt; is the bitwise OR of a number of values indicating which
629 * buffers are to be copied. The values are COLOR_BUFFER_BIT,
630 * DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT.
631 * The pixels corresponding to these buffers are
632 * copied from the source rectangle, bound by the locations (srcX0,
633 * srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle,
634 * bound by the locations (dstX0, dstY0) and (dstX1, dstY1)
635 * inclusive.
636 * If the source and destination rectangle dimensions do not match,
637 * the source image is stretched to fit the destination
638 * rectangle. &lt;filter&gt; must be LINEAR or NEAREST and specifies the
639 * method of interpolation to be applied if the image is
640 * stretched.
641 */
642 void glBlitFramebuffer(
643 @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1,
644 @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1,
645 @GLbitfield int mask, @GLenum int filter);
646
647 // -------------------------------------------------------------------
648 // ----------------------[ EXT_texture_integer ]----------------------
649 // -------------------------------------------------------------------
650
651 /**
652 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
653 * GetFloatv, and GetDoublev:
654 */
655 int GL_RGBA_INTEGER_MODE = 0x8D9E;
656
657 /**
658 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D,
659 * TexImage2D, and TexImage3D:
660 */
661 int GL_RGBA32UI = 0x8D70;
662 int GL_RGB32UI = 0x8D71;
663 int GL_ALPHA32UI = 0x8D72;
664
665 int GL_RGBA16UI = 0x8D76;
666 int GL_RGB16UI = 0x8D77;
667 int GL_ALPHA16UI = 0x8D78;
668
669 int GL_RGBA8UI = 0x8D7C;
670 int GL_RGB8UI = 0x8D7D;
671 int GL_ALPHA8UI = 0x8D7E;
672
673 int GL_RGBA32I = 0x8D82;
674 int GL_RGB32I = 0x8D83;
675 int GL_ALPHA32I = 0x8D84;
676
677 int GL_RGBA16I = 0x8D88;
678 int GL_RGB16I = 0x8D89;
679 int GL_ALPHA16I = 0x8D8A;
680
681 int GL_RGBA8I = 0x8D8E;
682 int GL_RGB8I = 0x8D8F;
683 int GL_ALPHA8I = 0x8D90;
684
685 /**
686 * Accepted by the &lt;format&gt; parameter of TexImage1D, TexImage2D,
687 * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D,
688 * DrawPixels and ReadPixels:
689 */
690 int GL_RED_INTEGER = 0x8D94;
691 int GL_GREEN_INTEGER = 0x8D95;
692 int GL_BLUE_INTEGER = 0x8D96;
693 int GL_ALPHA_INTEGER = 0x8D97;
694 int GL_RGB_INTEGER = 0x8D98;
695 int GL_RGBA_INTEGER = 0x8D99;
696 int GL_BGR_INTEGER = 0x8D9A;
697 int GL_BGRA_INTEGER = 0x8D9B;
698
699 @StripPostfix("params")
700 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params);
701
702 @Alternate("glTexParameterIiv")
703 @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);
705
706 @StripPostfix("params")
707 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
708
709 @Alternate("glTexParameterIuiv")
710 @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);
712
713 @StripPostfix("params")
714 void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
715
716 @Alternate("glGetTexParameterIiv")
717 @GLreturn("params")
718 @StripPostfix(value = "params", postfix = "v")
719 void glGetTexParameterIiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
720
721 @StripPostfix("params")
722 void glGetTexParameterIuiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params);
723
724 @Alternate("glGetTexParameterIuiv")
725 @GLreturn("params")
726 @StripPostfix(value = "params", postfix = "v")
727 void glGetTexParameterIuiv2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
728
729 // -----------------------------------------------------------------
730 // ----------------------[ EXT_texture_array ]----------------------
731 // -----------------------------------------------------------------
732
733 /**
734 * Accepted by the &lt;target&gt; parameter of TexParameteri, TexParameteriv,
735 * TexParameterf, TexParameterfv, and BindTexture:
736 */
737 int GL_TEXTURE_1D_ARRAY = 0x8C18;
738 int GL_TEXTURE_2D_ARRAY = 0x8C1A;
739
740 /**
741 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
742 * CopyTexSubImage3D, CompressedTexImage3D, and CompressedTexSubImage3D:
743 */
744 int GL_PROXY_TEXTURE_2D_ARRAY = 0x8C1B;
745
746 /**
747 * Accepted by the &lt;target&gt; parameter of TexImage2D, TexSubImage2D,
748 * CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D, and
749 * CompressedTexSubImage2D:
750 */
751 int GL_PROXY_TEXTURE_1D_ARRAY = 0x8C19;
752
753 /**
754 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv
755 * and GetFloatv:
756 */
757 int GL_TEXTURE_BINDING_1D_ARRAY = 0x8C1C;
758 int GL_TEXTURE_BINDING_2D_ARRAY = 0x8C1D;
759 int GL_MAX_ARRAY_TEXTURE_LAYERS = 0x88FF;
760
761 /**
762 * Accepted by the &lt;param&gt; parameter of TexParameterf, TexParameteri,
763 * TexParameterfv, and TexParameteriv when the &lt;pname&gt; parameter is
764 * TEXTURE_COMPARE_MODE_ARB:
765 */
766 int GL_COMPARE_REF_DEPTH_TO_TEXTURE = 0x884E;
767
768 /**
769 * Accepted by the &lt;pname&gt; parameter of
770 * GetFramebufferAttachmentParameteriv:
771 */
772 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4;
773
774 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
775 int GL_SAMPLER_1D_ARRAY = 0x8DC0;
776 int GL_SAMPLER_2D_ARRAY = 0x8DC1;
777 int GL_SAMPLER_1D_ARRAY_SHADOW = 0x8DC3;
778 int GL_SAMPLER_2D_ARRAY_SHADOW = 0x8DC4;
779
780 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
781
782 // ------------------------------------------------------------------------
783 // ----------------------[ EXT_packed_depth_stencil ]----------------------
784 // ------------------------------------------------------------------------
785
786 /**
787 * Accepted by the &lt;format&gt; parameter of DrawPixels, ReadPixels,
788 * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
789 * TexSubImage3D, and GetTexImage, by the &lt;type&gt; parameter of
790 * CopyPixels, by the &lt;internalformat&gt; parameter of TexImage1D,
791 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
792 * RenderbufferStorage, and returned in the &lt;data&gt; parameter of
793 * GetTexLevelParameter and GetRenderbufferParameteriv.
794 */
795 int GL_DEPTH_STENCIL = 0x84F9;
796
797 /**
798 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels,
799 * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D,
800 * TexSubImage3D, and GetTexImage.
801 */
802 int GL_UNSIGNED_INT_24_8 = 0x84FA;
803
804 /**
805 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D,
806 * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and
807 * RenderbufferStorage, and returned in the &lt;data&gt; parameter of
808 * GetTexLevelParameter and GetRenderbufferParameteriv.
809 */
810 int GL_DEPTH24_STENCIL8 = 0x88F0;
811
812 /** Accepted by the &lt;value&gt; parameter of GetTexLevelParameter. */
813 int GL_TEXTURE_STENCIL_SIZE = 0x88F1;
814
815 // -----------------------------------------------------------------
816 // ----------------------[ EXT_draw_buffers2 ]----------------------
817 // -----------------------------------------------------------------
818
819 void glColorMaski(@GLuint int buf, boolean r, boolean g, boolean b, boolean a);
820
821 @StripPostfix(value = "data", hasPostfix = false)
822 void glGetBooleani_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data);
823
824 @Alternate("glGetBooleani_v")
825 @GLreturn("data")
826 @StripPostfix(value = "data", hasPostfix = false)
827 void glGetBooleani_v2(@GLenum int value, @GLuint int index, @OutParameter @GLboolean ByteBuffer data);
828
829 @StripPostfix("data")
830 void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
831
832 @Alternate("glGetIntegeri_v")
833 @GLreturn("data")
834 @StripPostfix("data")
835 void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
836
837 void glEnablei(@GLenum int target, @GLuint int index);
838
839 void glDisablei(@GLenum int target, @GLuint int index);
840
841 boolean glIsEnabledi(@GLenum int target, @GLuint int index);
842
843 // ----------------------------------------------------------------------------
844 // ----------------------[ ARB_texture_compression_rgtc ]----------------------
845 // ----------------------------------------------------------------------------
846
847 /**
848 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D,
849 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
850 * of CompressedTexSubImage2D:
851 */
852 int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
853 int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC;
854 int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD;
855 int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE;
856
857 // --------------------------------------------------------------
858 // ----------------------[ ARB_texture_rg ]----------------------
859 // --------------------------------------------------------------
860
861 /**
862 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D, TexImage2D,
863 * TexImage3D, CopyTexImage1D, and CopyTexImage2D:
864 */
865 int GL_R8 = 0x8229;
866 int GL_R16 = 0x822A;
867
868 int GL_RG8 = 0x822B;
869 int GL_RG16 = 0x822C;
870
871 int GL_R16F = 0x822D;
872 int GL_R32F = 0x822E;
873
874 int GL_RG16F = 0x822F;
875 int GL_RG32F = 0x8230;
876
877 int GL_R8I = 0x8231;
878 int GL_R8UI = 0x8232;
879 int GL_R16I = 0x8233;
880 int GL_R16UI = 0x8234;
881 int GL_R32I = 0x8235;
882 int GL_R32UI = 0x8236;
883
884 int GL_RG8I = 0x8237;
885 int GL_RG8UI = 0x8238;
886 int GL_RG16I = 0x8239;
887 int GL_RG16UI = 0x823A;
888 int GL_RG32I = 0x823B;
889 int GL_RG32UI = 0x823C;
890
891 /**
892 * Accepted by the &lt;format&gt; parameter of TexImage3D, TexImage2D,
893 * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D,
894 * DrawPixels and ReadPixels:
895 */
896 int GL_RG = 0x8227;
897 int GL_RG_INTEGER = 0x8228;
898
899 /**
900 * Accepted by the &lt;param&gt; parameter of the TexParameter{if}*
901 * functions when &lt;pname&gt; is DEPTH_TEXTURE_MODE:
902 */
903 int GL_RED = 0x1903;
904
905 // ----------------------------------------------------------------------
906 // ----------------------[ EXT_transform_feedback ]----------------------
907 // ----------------------------------------------------------------------
908
909 /**
910 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
911 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
912 * GetBufferPointerv, BindBufferRange, BindBufferOffset and
913 * BindBufferBase:
914 */
915 int GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E;
916
917 /**
918 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedv and
919 * GetBooleanIndexedv:
920 */
921 int GL_TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84;
922 int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85;
923
924 /**
925 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedv and
926 * GetBooleanIndexedv, and by the &lt;pname&gt; parameter of GetBooleanv,
927 * GetDoublev, GetIntegerv, and GetFloatv:
928 */
929 int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F;
930
931 /** Accepted by the &lt;bufferMode&gt; parameter of TransformFeedbackVaryings: */
932 int GL_INTERLEAVED_ATTRIBS = 0x8C8C;
933 int GL_SEPARATE_ATTRIBS = 0x8C8D;
934
935 /**
936 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
937 * GetQueryiv:
938 */
939 int GL_PRIMITIVES_GENERATED = 0x8C87;
940 int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88;
941
942 /**
943 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
944 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
945 * GetDoublev:
946 */
947 int GL_RASTERIZER_DISCARD = 0x8C89;
948
949 /**
950 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
951 * and GetFloatv:
952 */
953 int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A;
954 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B;
955 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80;
956
957 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
958 int GL_TRANSFORM_FEEDBACK_VARYINGS = 0x8C83;
959 int GL_TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F;
960 int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH = 0x8C76;
961
962 void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
963
964 void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer);
965
966 void glBeginTransformFeedback(@GLenum int primitiveMode);
967
968 void glEndTransformFeedback();
969
970 void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count,
971 @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings,
972 @GLenum int bufferMode);
973
974 @Alternate("glTransformFeedbackVaryings")
975 void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count,
976 @Const @NullTerminated @StringList("count") CharSequence[] varyings,
977 @GLenum int bufferMode);
978
979 void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
980 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
981 @OutParameter @GLsizei @Check("1") IntBuffer size,
982 @OutParameter @GLenum @Check("1") IntBuffer type,
983 @OutParameter @GLchar ByteBuffer name);
984
985 @Alternate("glGetTransformFeedbackVarying")
986 @GLreturn(value = "name", maxLength = "bufSize")
987 void glGetTransformFeedbackVarying2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
988 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
989 @OutParameter @GLsizei @Check("1") IntBuffer size,
990 @OutParameter @GLenum @Check("1") IntBuffer type,
991 @OutParameter @GLchar ByteBuffer name);
992
993 // -----------------------------------------------------------------------
994 // ----------------------[ ARB_vertex_array_object ]----------------------
995 // -----------------------------------------------------------------------
996
997 /**
998 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
999 * GetFloatv, and GetDoublev:
1000 */
1001 int GL_VERTEX_ARRAY_BINDING = 0x85B5;
1002
1003 void glBindVertexArray(@GLuint int array);
1004
1005 void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
1006
1007 @Alternate("glDeleteVertexArrays")
1008 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
1009
1010 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
1011
1012 @Alternate("glGenVertexArrays")
1013 @GLreturn("arrays")
1014 void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
1015
1016 boolean glIsVertexArray(@GLuint int array);
1017
1018 // --------------------------------------------------------------------
1019 // ----------------------[ ARB_framebuffer_sRGB ]----------------------
1020 // --------------------------------------------------------------------
1021
1022 /**
1023 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
1024 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
1025 * and GetDoublev:
1026 */
1027 int GL_FRAMEBUFFER_SRGB = 0x8DB9;
1028
1029 /**
1030 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
1031 * GetFloatv, and GetDoublev:
1032 */
1033 int GL_FRAMEBUFFER_SRGB_CAPABLE = 0x8DBA;
1034
1035 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface GL31 {
40
41 // ----------------------------------------------------------
42 // ----------------------[ OpenGL 3.1 ]----------------------
43 // ----------------------------------------------------------
44
45 int GL_RED_SNORM = 0x8F90;
46 int GL_RG_SNORM = 0x8F91;
47 int GL_RGB_SNORM = 0x8F92;
48 int GL_RGBA_SNORM = 0x8F93;
49 int GL_R8_SNORM = 0x8F94;
50 int GL_RG8_SNORM = 0x8F95;
51 int GL_RGB8_SNORM = 0x8F96;
52 int GL_RGBA8_SNORM = 0x8F97;
53 int GL_R16_SNORM = 0x8F98;
54 int GL_RG16_SNORM = 0x8F99;
55 int GL_RGB16_SNORM = 0x8F9A;
56 int GL_RGBA16_SNORM = 0x8F9B;
57 int GL_SIGNED_NORMALIZED = 0x8F9C;
58
59 // ------------------------------------------------------------------
60 // ----------------------[ ARB_draw_instanced ]----------------------
61 // ------------------------------------------------------------------
62
63 void glDrawArraysInstanced(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount);
64
65 void glDrawElementsInstanced(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
66 @BufferObject(BufferKind.ElementVBO)
67 @Const
68 @GLubyte
69 @GLushort
70 @GLuint Buffer indices, @GLsizei int primcount);
71
72 // ---------------------------------------------------------------
73 // ----------------------[ EXT_copy_buffer ]----------------------
74 // ---------------------------------------------------------------
75
76 int GL_COPY_READ_BUFFER = 0x8F36;
77 int GL_COPY_WRITE_BUFFER = 0x8F37;
78
79 void glCopyBufferSubData(@GLenum int readtarget, @GLenum int writetarget, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
80
81 // --------------------------------------------------------------------
82 // ----------------------[ NV_primitive_restart ]----------------------
83 // --------------------------------------------------------------------
84
85 /**
86 * Accepted by the &lt;cap&gt; parameter of IsEnabled, and by
87 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
88 * GetDoublev:
89 */
90 int GL_PRIMITIVE_RESTART = 0x8F9D;
91
92 /**
93 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
94 * GetFloatv, and GetDoublev:
95 */
96 int GL_PRIMITIVE_RESTART_INDEX = 0x8F9E;
97
98 void glPrimitiveRestartIndex(@GLuint int index);
99
100 // -------------------------------------------------------------------------
101 // ----------------------[ ARB_texture_buffer_object ]----------------------
102 // -------------------------------------------------------------------------
103
104 /**
105 * Accepted by the &lt;target&gt; parameter of BindBuffer, BufferData,
106 * BufferSubData, MapBuffer, MapBufferRange, BindTexture, UnmapBuffer,
107 * GetBufferSubData, GetBufferParameteriv, GetBufferPointerv, and TexBuffer,
108 * and the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv, and
109 * GetIntegerv:
110 */
111 int GL_TEXTURE_BUFFER = 0x8C2A;
112
113 /**
114 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetDoublev,
115 * GetFloatv, and GetIntegerv:
116 */
117 int GL_MAX_TEXTURE_BUFFER_SIZE = 0x8C2B;
118 int GL_TEXTURE_BINDING_BUFFER = 0x8C2C;
119 int GL_TEXTURE_BUFFER_DATA_STORE_BINDING = 0x8C2D;
120 int GL_TEXTURE_BUFFER_FORMAT = 0x8C2E;
121
122 void glTexBuffer(@GLenum int target, @GLenum int internalformat, @GLuint int buffer);
123
124 // ---------------------------------------------------------------------
125 // ----------------------[ ARB_texture_rectangle ]----------------------
126 // ---------------------------------------------------------------------
127
128 /**
129 * Accepted by the &lt;cap&gt; parameter of Enable, Disable and IsEnabled;
130 * by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv
131 * and GetDoublev; and by the &lt;target&gt; parameter of BindTexture,
132 * GetTexParameterfv, GetTexParameteriv, TexParameterf, TexParameteri,
133 * TexParameterfv and TexParameteriv:
134 * Accepted by the &lt;target&gt; parameter of GetTexImage,
135 * GetTexLevelParameteriv, GetTexLevelParameterfv, TexImage2D,
136 * CopyTexImage2D, TexSubImage2D and CopySubTexImage2D:
137 */
138 int GL_TEXTURE_RECTANGLE = 0x84F5;
139
140 /**
141 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
142 * GetFloatv and GetDoublev:
143 */
144 int GL_TEXTURE_BINDING_RECTANGLE = 0x84F6;
145
146 /**
147 * Accepted by the &lt;target&gt; parameter of GetTexLevelParameteriv,
148 * GetTexLevelParameterfv, GetTexParameteriv and TexImage2D:
149 */
150 int GL_PROXY_TEXTURE_RECTANGLE = 0x84F7;
151
152 /**
153 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
154 * GetIntegerv and GetFloatv:
155 */
156 int GL_MAX_RECTANGLE_TEXTURE_SIZE = 0x84F8;
157
158 /**
159 * Returned by &lt;type&gt; parameter of GetActiveUniform when the location
160 * &lt;index&gt; for program object &lt;program&gt; is of type sampler2DRect:
161 */
162 int GL_SAMPLER_2D_RECT = 0x8B63;
163
164 /**
165 * Returned by &lt;type&gt; parameter of GetActiveUniform when the location
166 * &lt;index&gt; for program object &lt;program&gt; is of type sampler2DRectShadow:
167 */
168 int GL_SAMPLER_2D_RECT_SHADOW = 0x8B64;
169
170 // -------------------------------------------------------------------------
171 // ----------------------[ ARB_uniform_buffer_object ]----------------------
172 // -------------------------------------------------------------------------
173
174 /**
175 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
176 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
177 * GetBufferPointerv:
178 */
179 int GL_UNIFORM_BUFFER = 0x8A11;
180
181 /**
182 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleanv,
183 * GetIntegerv, GetFloatv, and GetDoublev:
184 */
185 int GL_UNIFORM_BUFFER_BINDING = 0x8A28;
186
187 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
188 int GL_UNIFORM_BUFFER_START = 0x8A29;
189 int GL_UNIFORM_BUFFER_SIZE = 0x8A2A;
190
191 /**
192 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
193 * GetFloatv, and GetDoublev:
194 */
195 int GL_MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B;
196 int GL_MAX_GEOMETRY_UNIFORM_BLOCKS = 0x8A2C;
197 int GL_MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D;
198 int GL_MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E;
199 int GL_MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F;
200 int GL_MAX_UNIFORM_BLOCK_SIZE = 0x8A30;
201 int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31;
202 int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = 0x8A32;
203 int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33;
204 int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34;
205
206 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
207 int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35;
208 int GL_ACTIVE_UNIFORM_BLOCKS = 0x8A36;
209
210 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformsiv: */
211 int GL_UNIFORM_TYPE = 0x8A37;
212 int GL_UNIFORM_SIZE = 0x8A38;
213 int GL_UNIFORM_NAME_LENGTH = 0x8A39;
214 int GL_UNIFORM_BLOCK_INDEX = 0x8A3A;
215 int GL_UNIFORM_OFFSET = 0x8A3B;
216 int GL_UNIFORM_ARRAY_STRIDE = 0x8A3C;
217 int GL_UNIFORM_MATRIX_STRIDE = 0x8A3D;
218 int GL_UNIFORM_IS_ROW_MAJOR = 0x8A3E;
219
220 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockiv: */
221 int GL_UNIFORM_BLOCK_BINDING = 0x8A3F;
222 int GL_UNIFORM_BLOCK_DATA_SIZE = 0x8A40;
223 int GL_UNIFORM_BLOCK_NAME_LENGTH = 0x8A41;
224 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42;
225 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43;
226 int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44;
227 int GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45;
228 int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46;
229
230 /** Returned by GetActiveUniformsiv and GetUniformBlockIndex */
231 int GL_INVALID_INDEX = 0xFFFFFFFF;
232
233 void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
234 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames,
235 @OutParameter @GLuint IntBuffer uniformIndices);
236
237 @Alternate("glGetUniformIndices")
238 void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount,
239 @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames,
240 @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices);
241
242 @StripPostfix("params")
243 void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
244 @Const @GLuint IntBuffer uniformIndices,
245 @GLenum int pname,
246 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
247
248 @Alternate("glGetActiveUniformsiv")
249 @GLreturn("params")
250 @StripPostfix("params")
251 void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
252 @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer
253 @GLenum int pname,
254 @OutParameter @GLint IntBuffer params);
255
256 void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize,
257 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
258 @OutParameter @GLchar ByteBuffer uniformName);
259
260 @Alternate("glGetActiveUniformName")
261 @GLreturn(value = "uniformName", maxLength = "bufSize")
262 void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize,
263 @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length,
264 @OutParameter @GLchar ByteBuffer uniformName);
265
266 @GLuint
267 int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName);
268
269 @Alternate("glGetUniformBlockIndex")
270 @GLuint
271 int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName);
272
273 @StripPostfix("params")
274 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
275 @OutParameter @Check(value = "16") @GLint IntBuffer params);
276
277 @Alternate("glGetActiveUniformBlockiv")
278 @GLreturn("params")
279 @StripPostfix("params")
280 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
281 @OutParameter @GLint IntBuffer params);
282
283 void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize,
284 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
285 @OutParameter @GLchar ByteBuffer uniformBlockName);
286
287 @Alternate("glGetActiveUniformBlockName")
288 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
289 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
290 @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length,
291 @OutParameter @GLchar ByteBuffer uniformBlockName);
292
293 void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding);
294
295 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.LongBuffer;
39
40 public interface GL32 {
41
42 // ----------------------------------------------------------
43 // ----------------------[ OpenGL 3.2 ]----------------------
44 // ----------------------------------------------------------
45
46 int GL_CONTEXT_PROFILE_MASK = 0x9126;
47 int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001;
48 int GL_CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002;
49
50 int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122;
51 int GL_MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123;
52 int GL_MAX_GEOMETRY_OUTPUT_COMPONENTS = 0x9124;
53 int GL_MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125;
54
55 // ---------------------------------------------------------------------
56 // ----------------------[ ARB_vertex_array_bgra ]----------------------
57 // ---------------------------------------------------------------------
58
59 int GL_BGRA = 0x80E1;
60
61 // -----------------------------------------------------------------------------
62 // ----------------------[ ARB_draw_elements_base_vertex ]----------------------
63 // -----------------------------------------------------------------------------
64
65 void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
66 @BufferObject(BufferKind.ElementVBO)
67 @Const
68 @GLubyte
69 @GLushort
70 @GLuint Buffer indices, int basevertex);
71
72 void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
73 @BufferObject(BufferKind.ElementVBO)
74 @Const
75 @GLubyte
76 @GLushort
77 @GLuint Buffer indices, int basevertex);
78
79 void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
80 @BufferObject(BufferKind.ElementVBO)
81 @Const
82 @GLubyte
83 @GLushort
84 @GLuint Buffer indices, @GLsizei int primcount, int basevertex);
85
86 //void glMultiDrawElementsBaseVertex(@GLenum int mode, @GLsizei*count, @GLenum int type, void**indices, @GLsizei int primcount, int*basevertex)
87
88 // --------------------------------------------------------------------
89 // ----------------------[ ARB_provoking_vertex ]----------------------
90 // --------------------------------------------------------------------
91
92 /** Accepted by the &lt;mode&gt; parameter of ProvokingVertex: */
93 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D;
94 int GL_LAST_VERTEX_CONVENTION = 0x8E4E;
95
96 /**
97 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
98 * GetFloatv, and GetDoublev:
99 */
100 int GL_PROVOKING_VERTEX = 0x8E4F;
101 int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C;
102
103 void glProvokingVertex(@GLenum int mode);
104
105 // ---------------------------------------------------------------------
106 // ----------------------[ ARB_seamless_cube_map ]----------------------
107 // ---------------------------------------------------------------------
108
109 /**
110 * Accepted by the &lt;cap&gt; parameter of Enable, Disable and IsEnabled,
111 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv
112 * and GetDoublev:
113 */
114 int GL_TEXTURE_CUBE_MAP_SEAMLESS = 0x884F;
115
116 // -----------------------------------------------------------------------
117 // ----------------------[ ARB_texture_multisample ]----------------------
118 // -----------------------------------------------------------------------
119
120 /** Accepted by the &lt;pname&gt; parameter of GetMultisamplefv: */
121 int GL_SAMPLE_POSITION = 0x8E50;
122
123 /**
124 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
125 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
126 * GetDoublev:
127 */
128 int GL_SAMPLE_MASK = 0x8E51;
129
130 /**
131 * Accepted by the &lt;target&gt; parameter of GetBooleani_v and
132 * GetIntegeri_v:
133 */
134 int GL_SAMPLE_MASK_VALUE = 0x8E52;
135
136 /**
137 * Accepted by the &lt;target&gt; parameter of BindTexture and
138 * TexImage2DMultisample:
139 */
140 int GL_TEXTURE_2D_MULTISAMPLE = 0x9100;
141
142 /** Accepted by the &lt;target&gt; parameter of TexImage2DMultisample: */
143 int GL_PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101;
144
145 /**
146 * Accepted by the &lt;target&gt; parameter of BindTexture and
147 * TexImage3DMultisample:
148 */
149 int GL_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102;
150
151 /** Accepted by the &lt;target&gt; parameter of TexImage3DMultisample: */
152 int GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103;
153
154 /**
155 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
156 * and GetFloatv:
157 */
158 int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59;
159 int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E;
160 int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F;
161 int GL_MAX_INTEGER_SAMPLES = 0x9110;
162 int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104;
163 int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105;
164
165 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter */
166 int GL_TEXTURE_SAMPLES = 0x9106;
167 int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107;
168
169 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
170 int GL_SAMPLER_2D_MULTISAMPLE = 0x9108;
171 int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109;
172 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A;
173 int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B;
174 int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C;
175 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D;
176
177 void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
178 @GLsizei int width, @GLsizei int height,
179 boolean fixedsamplelocations);
180
181 void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
182 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
183 boolean fixedsamplelocations);
184
185 @StripPostfix("val")
186 void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val);
187
188 void glSampleMaski(@GLuint int index, @GLbitfield int mask);
189
190 // ---------------------------------------------------------------
191 // ----------------------[ ARB_depth_clamp ]----------------------
192 // ---------------------------------------------------------------
193
194 /**
195 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
196 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
197 * GetFloatv, and GetDoublev:
198 */
199 int GL_DEPTH_CLAMP = 0x864F;
200
201 // --------------------------------------------------------------------
202 // ----------------------[ ARB_geometry_shader4 ]----------------------
203 // --------------------------------------------------------------------
204
205 /**
206 * Accepted by the &lt;type&gt; parameter of CreateShader and returned by the
207 * &lt;params&gt; parameter of GetShaderiv:
208 */
209 int GL_GEOMETRY_SHADER = 0x8DD9;
210
211 /**
212 * Accepted by the &lt;pname&gt; parameter of ProgramParameteriEXT and
213 * GetProgramiv:
214 */
215 int GL_GEOMETRY_VERTICES_OUT = 0x8DDA;
216 int GL_GEOMETRY_INPUT_TYPE = 0x8DDB;
217 int GL_GEOMETRY_OUTPUT_TYPE = 0x8DDC;
218
219 /**
220 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
221 * GetFloatv, and GetDoublev:
222 */
223 int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS = 0x8C29;
224 //int GL_MAX_GEOMETRY_VARYING_COMPONENTS = 0x8DDD; -- Missing from 3.2 spec
225 //int GL_MAX_VERTEX_VARYING_COMPONENTS = 0x8DDE; -- Missing from 3.2 spec
226 int GL_MAX_VARYING_COMPONENTS = 0x8B4B;
227 int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS = 0x8DDF;
228 int GL_MAX_GEOMETRY_OUTPUT_VERTICES = 0x8DE0;
229 int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 0x8DE1;
230
231 /**
232 * Accepted by the &lt;mode&gt; parameter of Begin, DrawArrays,
233 * MultiDrawArrays, DrawElements, MultiDrawElements, and
234 * DrawRangeElements:
235 */
236 int GL_LINES_ADJACENCY = 0xA;
237 int GL_LINE_STRIP_ADJACENCY = 0xB;
238 int GL_TRIANGLES_ADJACENCY = 0xC;
239 int GL_TRIANGLE_STRIP_ADJACENCY = 0xD;
240
241 /** Returned by CheckFramebufferStatusEXT: */
242 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0x8DA8;
243 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT = 0x8DA9;
244
245 /**
246 * Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachment-
247 * ParameterivEXT:
248 */
249 int GL_FRAMEBUFFER_ATTACHMENT_LAYERED = 0x8DA7;
250 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4;
251
252 /**
253 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
254 * and by the &lt;pname&gt; parameter of GetIntegerv, GetFloatv, GetDoublev,
255 * and GetBooleanv:
256 */
257 int GL_PROGRAM_POINT_SIZE = 0x8642;
258
259 void glFramebufferTexture(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
260
261 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
262
263 // --------------------------------------------------------
264 // ----------------------[ ARB_sync ]----------------------
265 // --------------------------------------------------------
266
267 /** Accepted as the &lt;pname&gt; parameter of GetInteger64v: */
268 int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111;
269
270 /** Accepted as the &lt;pname&gt; parameter of GetSynciv: */
271 int GL_OBJECT_TYPE = 0x9112;
272 int GL_SYNC_CONDITION = 0x9113;
273 int GL_SYNC_STATUS = 0x9114;
274 int GL_SYNC_FLAGS = 0x9115;
275
276 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; OBJECT_TYPE: */
277 int GL_SYNC_FENCE = 0x9116;
278
279 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_CONDITION: */
280 int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117;
281
282 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_STATUS: */
283 int GL_UNSIGNALED = 0x9118;
284 int GL_SIGNALED = 0x9119;
285
286 /** Accepted in the &lt;flags&gt; parameter of ClientWaitSync: */
287 int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
288
289 /** Accepted in the &lt;timeout&gt; parameter of WaitSync: */
290 long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl;
291
292 /** Returned by ClientWaitSync: */
293 int GL_ALREADY_SIGNALED = 0x911A;
294 int GL_TIMEOUT_EXPIRED = 0x911B;
295 int GL_CONDITION_SATISFIED = 0x911C;
296 int GL_WAIT_FAILED = 0x911D;
297
298 @GLpointer("GLsync")
299 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
300
301 boolean glIsSync(@GLpointer("GLsync") GLSync sync);
302
303 void glDeleteSync(@GLpointer("GLsync") GLSync sync);
304
305 @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")
311 void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer data);
312
313 @Alternate("glGetInteger64v")
314 @GLreturn("data")
315 @StripPostfix(value = "data", postfix = "64")
316 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer data);
317
318 @StripPostfix(value = "data", postfix = "64")
319 @Optional(reason = "NV's 3.2 implementation does not expose this (last driver checked: 19?.??)")
320 void glGetInteger64i_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLint64 LongBuffer data);
321
322 @Alternate("glGetInteger64i_v")
323 @GLreturn("data")
324 @StripPostfix(value = "data", postfix = "64")
325 void glGetInteger64i_v2(@GLenum int value, @GLuint int index, @OutParameter @GLint64 LongBuffer data);
326
327 @StripPostfix("values")
328 void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
329 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
330 @OutParameter IntBuffer values);
331
332 @Alternate("glGetSynciv")
333 @GLreturn("values")
334 @StripPostfix("values")
335 void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
336 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
337 @OutParameter IntBuffer values);
338 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.LongBuffer;
39
40 @DeprecatedGL
41 public interface GL33 {
42
43 // -----------------------------------------------------------------------
44 // ----------------------[ ARB_blend_func_extended ]----------------------
45 // -----------------------------------------------------------------------
46
47 /**
48 * Accepted by the &lt;src&gt; and &lt;dst&gt; parameters of BlendFunc and
49 * BlendFunci, and by the &lt;srcRGB&gt;, &lt;dstRGB&gt;, &lt;srcAlpha&gt; and &lt;dstAlpha&gt;
50 * parameters of BlendFuncSeparate and BlendFuncSeparatei:
51 */
52 int GL_SRC1_COLOR = 0x88F9;
53 int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA;
54 int GL_ONE_MINUS_SRC1_COLOR = 0x88FA;
55 int GL_ONE_MINUS_SRC1_ALPHA = 0x88FB;
56
57 /**
58 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv
59 * and GetDoublev:
60 */
61 int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC;
62
63 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name);
64
65 @Alternate("glBindFragDataLocationIndexed")
66 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name);
67
68 int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
69
70 @Alternate("glGetFragDataIndex")
71 int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name);
72
73 // --------------------------------------------------------------------
74 // ----------------------[ ARB_occlusion_query2 ]----------------------
75 // --------------------------------------------------------------------
76
77 /**
78 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
79 * and GetQueryiv:
80 */
81 int GL_ANY_SAMPLES_PASSED = 0x8C2F;
82
83 // -------------------------------------------------------------------
84 // ----------------------[ ARB_sampler_objects ]----------------------
85 // -------------------------------------------------------------------
86
87 /**
88 * Accepted by the &lt;value&gt; parameter of the GetBooleanv, GetIntegerv,
89 * GetInteger64v, GetFloatv and GetDoublev functions:
90 */
91 int GL_SAMPLER_BINDING = 0x8919;
92
93 void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
94
95 @Alternate("glGenSamplers")
96 @GLreturn("samplers")
97 void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
98
99 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
100
101 @Alternate("glDeleteSamplers")
102 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
103
104 boolean glIsSampler(@GLuint int sampler);
105
106 void glBindSampler(@GLenum int unit, @GLuint int sampler);
107
108 void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param);
109
110 void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param);
111
112 @StripPostfix("params")
113 void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
114
115 @StripPostfix("params")
116 void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params);
117
118 @StripPostfix("params")
119 void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
120
121 @StripPostfix("params")
122 void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params);
123
124 @StripPostfix("params")
125 void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
126
127 @Alternate("glGetSamplerParameteriv")
128 @GLreturn("params")
129 @StripPostfix(value = "params", postfix = "v")
130 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
131
132 @StripPostfix("params")
133 void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
134
135 @Alternate("glGetSamplerParameterfv")
136 @GLreturn("params")
137 @StripPostfix(value = "params", postfix = "v")
138 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
139
140 @StripPostfix("params")
141 void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
142
143 @Alternate("glGetSamplerParameterIiv")
144 @GLreturn("params")
145 @StripPostfix(value = "params", postfix = "v")
146 void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
147
148 @StripPostfix("params")
149 void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
150
151 @Alternate("glGetSamplerParameterIuiv")
152 @GLreturn("params")
153 @StripPostfix(value = "params", postfix = "v")
154 void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
155
156 // -------------------------------------------------------------------
157 // ----------------------[ ARB_texture_rgb10_a2ui ]----------------------
158 // -------------------------------------------------------------------
159
160 /**
161 * Accepted by the &lt;internalFormat&gt; parameter of TexImage1D, TexImage2D,
162 * TexImage3D, CopyTexImage1D, CopyTexImage2D, RenderbufferStorage and
163 * RenderbufferStorageMultisample:
164 */
165 int GL_RGB10_A2UI = 0x906F;
166
167 // -------------------------------------------------------------------
168 // ----------------------[ ARB_texture_swizzle ]----------------------
169 // -------------------------------------------------------------------
170
171 /**
172 * Accepted by the &lt;pname&gt; parameters of TexParameteri,
173 * TexParameterf, TexParameteriv, TexParameterfv,
174 * GetTexParameterfv, and GetTexParameteriv:
175 */
176 int GL_TEXTURE_SWIZZLE_R = 0x8E42;
177 int GL_TEXTURE_SWIZZLE_G = 0x8E43;
178 int GL_TEXTURE_SWIZZLE_B = 0x8E44;
179 int GL_TEXTURE_SWIZZLE_A = 0x8E45;
180
181 /**
182 * Accepted by the &lt;pname&gt; parameters of TexParameteriv,
183 * TexParameterfv, GetTexParameterfv, and GetTexParameteriv:
184 */
185 int GL_TEXTURE_SWIZZLE_RGBA = 0x8E46;
186
187 // ---------------------------------------------------------------
188 // ----------------------[ ARB_timer_query ]----------------------
189 // ---------------------------------------------------------------
190
191 /**
192 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
193 * GetQueryiv:
194 */
195 int GL_TIME_ELAPSED = 0x88BF;
196
197 /**
198 * Accepted by the &lt;target&gt; parameter of GetQueryiv and QueryCounter.
199 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
200 * GetInteger64v, GetFloatv, and GetDoublev:
201 */
202 int GL_TIMESTAMP = 0x8E28;
203
204 void glQueryCounter(@GLuint int id, @GLenum int target);
205
206 @StripPostfix("params")
207 void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
208
209 @Alternate("glGetQueryObjecti64v")
210 @GLreturn("params")
211 @StripPostfix("params")
212 void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
213
214 @StripPostfix("params")
215 void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params);
216
217 @Alternate("glGetQueryObjectui64v")
218 @GLreturn("params")
219 @StripPostfix("params")
220 void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params);
221
222 // --------------------------------------------------------------------
223 // ----------------------[ ARB_instanced_arrays ]----------------------
224 // --------------------------------------------------------------------
225
226 /**
227 * Accepted by the &lt;pname&gt; parameters of GetVertexAttribdv,
228 * GetVertexAttribfv, and GetVertexAttribiv:
229 */
230 int GL_VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE;
231
232 void glVertexAttribDivisor(@GLuint int index, @GLuint int divisor);
233
234 // ------------------------------------------------------------------------------
235 // ----------------------[ ARB_vertex_type_2_10_10_10_rev ]----------------------
236 // ------------------------------------------------------------------------------
237
238 /**
239 * Accepted by the &lt;type&gt; parameter of VertexAttribPointer, VertexPointer,
240 * NormalPointer, ColorPointer, SecondaryColorPointer, TexCoordPointer,
241 * VertexAttribP{1234}ui, VertexP*, TexCoordP*, MultiTexCoordP*, NormalP3ui,
242 * ColorP*, SecondaryColorP* and VertexAttribP*
243 */
244 int GL_INT_2_10_10_10_REV = 0x8D9F;
245
246 @NoErrorCheck
247 @DeprecatedGL
248 void glVertexP2ui(@GLenum int type, @GLuint int value);
249
250 @NoErrorCheck
251 @DeprecatedGL
252 void glVertexP3ui(@GLenum int type, @GLuint int value);
253
254 @NoErrorCheck
255 @DeprecatedGL
256 void glVertexP4ui(@GLenum int type, @GLuint int value);
257
258 @NoErrorCheck
259 @DeprecatedGL
260 @StripPostfix("value")
261 void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value);
262
263 @NoErrorCheck
264 @DeprecatedGL
265 @StripPostfix("value")
266 void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value);
267
268 @NoErrorCheck
269 @DeprecatedGL
270 @StripPostfix("value")
271 void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value);
272
273 @NoErrorCheck
274 @DeprecatedGL
275 void glTexCoordP1ui(@GLenum int type, @GLuint int coords);
276
277 @NoErrorCheck
278 @DeprecatedGL
279 void glTexCoordP2ui(@GLenum int type, @GLuint int coords);
280
281 @NoErrorCheck
282 @DeprecatedGL
283 void glTexCoordP3ui(@GLenum int type, @GLuint int coords);
284
285 @NoErrorCheck
286 @DeprecatedGL
287 void glTexCoordP4ui(@GLenum int type, @GLuint int coords);
288
289 @NoErrorCheck
290 @DeprecatedGL
291 @StripPostfix("coords")
292 void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
293
294 @NoErrorCheck
295 @DeprecatedGL
296 @StripPostfix("coords")
297 void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
298
299 @NoErrorCheck
300 @DeprecatedGL
301 @StripPostfix("coords")
302 void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
303
304 @NoErrorCheck
305 @DeprecatedGL
306 @StripPostfix("coords")
307 void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
308
309 @NoErrorCheck
310 @DeprecatedGL
311 void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
312
313 @NoErrorCheck
314 @DeprecatedGL
315 void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
316
317 @NoErrorCheck
318 @DeprecatedGL
319 void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
320
321 @NoErrorCheck
322 @DeprecatedGL
323 void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
324
325 @NoErrorCheck
326 @DeprecatedGL
327 @StripPostfix("coords")
328 void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
329
330 @NoErrorCheck
331 @DeprecatedGL
332 @StripPostfix("coords")
333 void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
334
335 @NoErrorCheck
336 @DeprecatedGL
337 @StripPostfix("coords")
338 void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
339
340 @NoErrorCheck
341 @DeprecatedGL
342 @StripPostfix("coords")
343 void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
344
345 @NoErrorCheck
346 @DeprecatedGL
347 void glNormalP3ui(@GLenum int type, @GLuint int coords);
348
349 @NoErrorCheck
350 @DeprecatedGL
351 @StripPostfix("coords")
352 void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
353
354 @NoErrorCheck
355 @DeprecatedGL
356 void glColorP3ui(@GLenum int type, @GLuint int color);
357
358 @NoErrorCheck
359 @DeprecatedGL
360 void glColorP4ui(@GLenum int type, @GLuint int color);
361
362 @NoErrorCheck
363 @DeprecatedGL
364 @StripPostfix("color")
365 void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
366
367 @NoErrorCheck
368 @DeprecatedGL
369 @StripPostfix("color")
370 void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color);
371
372 @NoErrorCheck
373 @DeprecatedGL
374 void glSecondaryColorP3ui(@GLenum int type, @GLuint int color);
375
376 @NoErrorCheck
377 @DeprecatedGL
378 @StripPostfix("color")
379 void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
380
381 @NoErrorCheck
382 @DeprecatedGL
383 void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
384
385 @NoErrorCheck
386 @DeprecatedGL
387 void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
388
389 @NoErrorCheck
390 @DeprecatedGL
391 void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
392
393 @NoErrorCheck
394 @DeprecatedGL
395 void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
396
397 @NoErrorCheck
398 @DeprecatedGL
399 @StripPostfix("value")
400 void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value);
401
402 @NoErrorCheck
403 @DeprecatedGL
404 @StripPostfix("value")
405 void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value);
406
407 @NoErrorCheck
408 @DeprecatedGL
409 @StripPostfix("value")
410 void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value);
411
412 @NoErrorCheck
413 @DeprecatedGL
414 @StripPostfix("value")
415 void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value);
416
417 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.DoubleBuffer;
37 import java.nio.FloatBuffer;
38 import java.nio.IntBuffer;
39
40 import com.sun.mirror.type.PrimitiveType;
41
42 public interface GL40 {
43
44 // ----------------------------------------------------------------------
45 // ----------------------[ ARB_draw_buffers_blend ]----------------------
46 // ----------------------------------------------------------------------
47
48 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
49 void glBlendEquationi(@GLuint int buf, @GLenum int mode);
50
51 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
52 void glBlendEquationSeparatei(@GLuint int buf, @GLenum int modeRGB, @GLenum int modeAlpha);
53
54 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
55 void glBlendFunci(@GLuint int buf, @GLenum int src, @GLenum int dst);
56
57 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
58 void glBlendFuncSeparatei(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha);
59
60 // -----------------------------------------------------------------
61 // ----------------------[ ARB_draw_indirect ]----------------------
62 // -----------------------------------------------------------------
63
64 /**
65 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
66 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
67 * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange,
68 * GetBufferParameteriv, BindBufferRange, BindBufferBase, and
69 * CopyBufferSubData:
70 */
71 int GL_DRAW_INDIRECT_BUFFER = 0x8F3F;
72
73 /**
74 * Accepted by the &lt;value&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
75 * and GetDoublev:
76 */
77 int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43;
78
79 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
80
81 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
82
83 // ---------------------------------------------------------------
84 // ----------------------[ ARB_gpu_shader5 ]----------------------
85 // ---------------------------------------------------------------
86
87 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
88 int GL_GEOMETRY_SHADER_INVOCATIONS = 0x887F;
89
90 /**
91 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
92 * GetDoublev, and GetInteger64v:
93 */
94 int GL_MAX_GEOMETRY_SHADER_INVOCATIONS = 0x8E5A;
95 int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5B;
96 int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5C;
97 int GL_FRAGMENT_INTERPOLATION_OFFSET_BITS = 0x8E5D;
98 int GL_MAX_VERTEX_STREAMS = 0x8E71;
99
100 // -------------------------------------------------------------------
101 // ----------------------[ ARB_gpu_shader_fp64 ]----------------------
102 // -------------------------------------------------------------------
103
104 /**
105 * Returned in the &lt;type&gt; parameter of GetActiveUniform, and
106 * GetTransformFeedbackVarying:
107 */
108 int GL_DOUBLE_VEC2 = 0x8FFC;
109 int GL_DOUBLE_VEC3 = 0x8FFD;
110 int GL_DOUBLE_VEC4 = 0x8FFE;
111 int GL_DOUBLE_MAT2 = 0x8F46;
112 int GL_DOUBLE_MAT3 = 0x8F47;
113 int GL_DOUBLE_MAT4 = 0x8F48;
114 int GL_DOUBLE_MAT2x3 = 0x8F49;
115 int GL_DOUBLE_MAT2x4 = 0x8F4A;
116 int GL_DOUBLE_MAT3x2 = 0x8F4B;
117 int GL_DOUBLE_MAT3x4 = 0x8F4C;
118 int GL_DOUBLE_MAT4x2 = 0x8F4D;
119 int GL_DOUBLE_MAT4x3 = 0x8F4E;
120
121 void glUniform1d(int location, double x);
122
123 void glUniform2d(int location, double x, double y);
124
125 void glUniform3d(int location, double x, double y, double z);
126
127 void glUniform4d(int location, double x, double y, double z, double w);
128
129 @StripPostfix("value")
130 void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value);
131
132 @StripPostfix("value")
133 void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
134
135 @StripPostfix("value")
136 void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
137
138 @StripPostfix("value")
139 void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
140
141 @StripPostfix("value")
142 void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
143
144 @StripPostfix("value")
145 void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
146
147 @StripPostfix("value")
148 void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
149
150 @StripPostfix("value")
151 void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
152
153 @StripPostfix("value")
154 void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
155
156 @StripPostfix("value")
157 void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
158
159 @StripPostfix("value")
160 void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
161
162 @StripPostfix("value")
163 void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
164
165 @StripPostfix("value")
166 void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
167
168 @StripPostfix("params")
169 void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params);
170
171 // ------------------------------------------------------------------
172 // ----------------------[ ARB_sample_shading ]----------------------
173 // ------------------------------------------------------------------
174
175 /**
176 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
177 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
178 * and GetDoublev:
179 */
180 int GL_SAMPLE_SHADING = 0x8C36;
181
182 /**
183 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
184 * GetIntegerv, and GetFloatv:
185 */
186 int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37;
187
188 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
189 void glMinSampleShading(@GLclampf float value);
190
191 // ---------------------------------------------------------------------
192 // ----------------------[ ARB_shader_subroutine ]----------------------
193 // ---------------------------------------------------------------------
194
195 /** Accepted by the &lt;pname&gt; parameter of GetProgramStageiv: */
196 int GL_ACTIVE_SUBROUTINES = 0x8DE5;
197 int GL_ACTIVE_SUBROUTINE_UNIFORMS = 0x8DE6;
198 int GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS = 0x8E47;
199 int GL_ACTIVE_SUBROUTINE_MAX_LENGTH = 0x8E48;
200 int GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH = 0x8E49;
201
202 /**
203 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
204 * GetFloatv, GetDoublev, and GetInteger64v:
205 */
206 int GL_MAX_SUBROUTINES = 0x8DE7;
207 int GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS = 0x8DE8;
208
209 /** Accepted by the &lt;pname&gt; parameter of GetActiveSubroutineUniformiv: */
210 int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A;
211 int GL_COMPATIBLE_SUBROUTINES = 0x8E4B;
212 int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE;
213 int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH;
214
215 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
216
217 @GLuint
218 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
219
220 @StripPostfix("values")
221 void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
222 @OutParameter @Check("1") IntBuffer values);
223
224 @Alternate("glGetActiveSubroutineUniformiv")
225 @GLreturn("values")
226 @StripPostfix("values")
227 void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
228 @OutParameter IntBuffer values);
229
230 void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
231 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
232 @OutParameter @GLchar ByteBuffer name);
233
234 @Alternate("glGetActiveSubroutineUniformName")
235 @GLreturn(value = "name", maxLength = "bufsize")
236 void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
237 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
238 @OutParameter @GLchar ByteBuffer name);
239
240 void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
241 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
242 @OutParameter @GLchar ByteBuffer name);
243
244 @Alternate("glGetActiveSubroutineName")
245 @GLreturn(value = "name", maxLength = "bufsize")
246 void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
247 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
248 @OutParameter @GLchar ByteBuffer name);
249
250 @StripPostfix("indices")
251 void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices);
252
253 @StripPostfix("params")
254 void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params);
255
256 @Alternate("glGetUniformSubroutineuiv")
257 @GLreturn("params")
258 @StripPostfix("params")
259 void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
260
261 @StripPostfix("values")
262 void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values);
263
264 @Alternate("glGetProgramStageiv")
265 @GLreturn("values")
266 @StripPostfix("values")
267 void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values);
268
269 // -----------------------------------------------------------------------
270 // ----------------------[ ARB_tessellation_shader ]----------------------
271 // -----------------------------------------------------------------------
272
273 /**
274 * Accepted by the &lt;mode&gt; parameter of Begin and all vertex array functions
275 * that implicitly call Begin:
276 */
277 int GL_PATCHES = 0xE;
278
279 /**
280 * Accepted by the &lt;pname&gt; parameter of PatchParameteri, GetBooleanv,
281 * GetDoublev, GetFloatv, GetIntegerv, and GetInteger64v:
282 */
283 int GL_PATCH_VERTICES = 0x8E72;
284
285 /**
286 * Accepted by the &lt;pname&gt; parameter of PatchParameterfv, GetBooleanv,
287 * GetDoublev, GetFloatv, and GetIntegerv, and GetInteger64v:
288 */
289 int GL_PATCH_DEFAULT_INNER_LEVEL = 0x8E73;
290 int GL_PATCH_DEFAULT_OUTER_LEVEL = 0x8E74;
291
292 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
293 int GL_TESS_CONTROL_OUTPUT_VERTICES = 0x8E75;
294 int GL_TESS_GEN_MODE = 0x8E76;
295 int GL_TESS_GEN_SPACING = 0x8E77;
296 int GL_TESS_GEN_VERTEX_ORDER = 0x8E78;
297 int GL_TESS_GEN_POINT_MODE = 0x8E79;
298
299 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_MODE: */
300 int GL_ISOLINES = 0x8E7A;
301
302 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_SPACING: */
303 int GL_FRACTIONAL_ODD = 0x8E7B;
304 int GL_FRACTIONAL_EVEN = 0x8E7C;
305
306 /**
307 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetFloatv,
308 * GetIntegerv, and GetInteger64v:
309 */
310 int GL_MAX_PATCH_VERTICES = 0x8E7D;
311 int GL_MAX_TESS_GEN_LEVEL = 0x8E7E;
312 int GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E7F;
313 int GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E80;
314 int GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS = 0x8E81;
315 int GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS = 0x8E82;
316 int GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83;
317 int GL_MAX_TESS_PATCH_COMPONENTS = 0x8E84;
318 int GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS = 0x8E85;
319 int GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS = 0x8E86;
320 int GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS = 0x8E89;
321 int GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS = 0x8E8A;
322 int GL_MAX_TESS_CONTROL_INPUT_COMPONENTS = 0x886C;
323 int GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS = 0x886D;
324 int GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E1E;
325 int GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E1F;
326
327 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockiv: */
328 int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0;
329 int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1;
330
331 /**
332 * Accepted by the &lt;type&gt; parameter of CreateShader and returned by the
333 * &lt;params&gt; parameter of GetShaderiv:
334 */
335 int GL_TESS_EVALUATION_SHADER = 0x8E87;
336 int GL_TESS_CONTROL_SHADER = 0x8E88;
337
338 void glPatchParameteri(@GLenum int pname, int value);
339
340 @StripPostfix("values")
341 void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values);
342
343 // --------------------------------------------------------------------------
344 // ----------------------[ ARB_texture_cube_map_array ]----------------------
345 // --------------------------------------------------------------------------
346
347 /**
348 * Accepted by the &lt;target&gt; parameter of TexParameteri, TexParameteriv,
349 * TexParameterf, TexParameterfv, BindTexture, and GenerateMipmap:
350 * <p/>
351 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
352 * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D:
353 * <p/>
354 * Accepted by the &lt;tex&gt; parameter of GetTexImage:
355 */
356 int GL_TEXTURE_CUBE_MAP_ARRAY = 0x9009;
357
358 /**
359 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev,
360 * GetIntegerv and GetFloatv:
361 */
362 int GL_TEXTURE_BINDING_CUBE_MAP_ARRAY = 0x900A;
363
364 /**
365 * Accepted by the &lt;target&gt; parameter of TexImage3D, TexSubImage3D,
366 * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D:
367 */
368 int GL_PROXY_TEXTURE_CUBE_MAP_ARRAY = 0x900B;
369
370 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
371 int GL_SAMPLER_CUBE_MAP_ARRAY = 0x900C;
372 int GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW = 0x900D;
373 int GL_INT_SAMPLER_CUBE_MAP_ARRAY = 0x900E;
374 int GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY = 0x900F;
375
376 // ------------------------------------------------------------------
377 // ----------------------[ ARB_texture_gather ]----------------------
378 // ------------------------------------------------------------------
379
380 /**
381 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
382 * GetFloatv, and GetDoublev:
383 */
384 int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5E;
385 int GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5F;
386 int GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB = 0x8F9F;
387
388 // -----------------------------------------------------------------------
389 // ----------------------[ ARB_transform_feedback2 ]----------------------
390 // -----------------------------------------------------------------------
391
392 /** Accepted by the &lt;target&gt; parameter of BindTransformFeedback: */
393 int GL_TRANSFORM_FEEDBACK = 0x8E22;
394
395 /**
396 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
397 * and GetFloatv:
398 */
399 int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23;
400 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24;
401 int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25;
402
403 void glBindTransformFeedback(@GLenum int target, @GLuint int id);
404
405 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
406
407 @Alternate("glDeleteTransformFeedbacks")
408 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
409
410 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
411
412 @Alternate("glGenTransformFeedbacks")
413 @GLreturn("ids")
414 void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
415
416 boolean glIsTransformFeedback(@GLuint int id);
417
418 void glPauseTransformFeedback();
419
420 void glResumeTransformFeedback();
421
422 void glDrawTransformFeedback(@GLenum int mode, @GLuint int id);
423
424 // -----------------------------------------------------------------------
425 // ----------------------[ ARB_transform_feedback3 ]----------------------
426 // -----------------------------------------------------------------------
427
428 /**
429 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
430 * and GetFloatv:
431 */
432 int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70;
433
434 void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream);
435
436 void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id);
437
438 void glEndQueryIndexed(@GLenum int target, @GLuint int index);
439
440 @StripPostfix("params")
441 void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
442
443 @Alternate("glGetQueryIndexediv")
444 @GLreturn("params")
445 @StripPostfix("params")
446 void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params);
447
448 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36
37 public interface GREMEDY_string_marker {
38
39 void glStringMarkerGREMEDY(@AutoSize("string") @GLsizei int len, @Const ByteBuffer string);
40
41 @Alternate("glStringMarkerGREMEDY")
42 void glStringMarkerGREMEDY(@Constant("string.length()") @GLsizei int len, CharSequence string);
43
44 }
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 HP_occlusion_test {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, by
37 * the &lt;pname&gt; of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev :
38 */
39 int GL_OCCLUSION_TEST_HP = 0x8165;
40
41 /**
42 * Accepted by the &lt;pname&gt; of GetBooleanv, GetIntegerv, GetFloatv, and
43 * GetDoublev :
44 */
45 int GL_OCCLUSION_TEST_RESULT_HP = 0x8166;
46
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.opengl;
32
33 public interface IBM_rasterpos_clip {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of Enable and Disable and the &lt;value&gt;
37 * parameter of IsEnabled, GetBooleanv, GetIntegerv, GetFloatv, GetDoublev:
38 */
39 int GL_RASTER_POSITION_UNCLIPPED_IBM = 103010;
40
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.opengl;
32
33 /** Experimental extension, may be removed/changed in the future. */
34 public interface NVX_gpu_memory_info {
35
36 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv: */
37 int GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = 0x9047;
38 int GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX = 0x9048;
39 int GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX = 0x9049;
40 int GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX = 0x904A;
41 int GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX = 0x904B;
42
43 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_blend_square {
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 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface NV_conditional_render {
37
38 /**
39 * Accepted by the &lt;mode&gt; parameter of BeginConditionalRenderNV:
40 */
41 int GL_QUERY_WAIT_NV = 0x8E13;
42 int GL_QUERY_NO_WAIT_NV = 0x8E14;
43 int GL_QUERY_BY_REGION_WAIT_NV = 0x8E15;
44 int GL_QUERY_BY_REGION_NO_WAIT_NV = 0x8E16;
45
46 void glBeginConditionalRenderNV(@GLuint int id, @GLenum int mode);
47 void glEndConditionalRenderNV();
48
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_copy_depth_to_color {
34 int GL_DEPTH_STENCIL_TO_RGBA_NV = 0x886E;
35 int GL_DEPTH_STENCIL_TO_BGRA_NV = 0x886F;
36 }
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.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
35 import org.lwjgl.util.generator.GLuint;
36
37 public interface NV_copy_image {
38
39 void glCopyImageSubDataNV(
40 @GLuint int srcName, @GLenum int srcTarget, int srcLevel,
41 int srcX, int srcY, int srcZ,
42 @GLuint int dstName, @GLenum int dstTarget, int dstLevel,
43 int dstX, int dstY, int dstZ,
44 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
45
46 // TODO: Implement WGL and GLX cross-context copying.
47
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.opengl;
32
33 public interface NV_depth_buffer_float {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D, TexImage2D,
37 * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT,
38 * and returned in the &lt;data&gt; parameter of GetTexLevelParameter and
39 * GetRenderbufferParameterivEXT:
40 */
41 int GL_DEPTH_COMPONENT32F_NV = 0x8DAB;
42 int GL_DEPTH32F_STENCIL8_NV = 0x8DAC;
43
44 /**
45 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
46 * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and
47 * GetTexImage:
48 */
49 int GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV = 0x8DAD;
50
51 /**
52 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
53 * GetFloatv, and GetDoublev:
54 */
55 int GL_DEPTH_BUFFER_FLOAT_MODE_NV = 0x8DAF;
56
57 void glDepthRangedNV(double n, double f);
58
59 void glClearDepthdNV(double d);
60
61 void glDepthBoundsdNV(double zmin, double zmax);
62
63 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_depth_clamp {
34 int GL_DEPTH_CLAMP_NV = 0x864F;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_evaluators {
38 int GL_EVAL_2D_NV = 0x86C0;
39 int GL_EVAL_TRIANGULAR_2D_NV = 0x86C1;
40 int GL_MAP_TESSELLATION_NV = 0x86C2;
41 int GL_MAP_ATTRIB_U_ORDER_NV = 0x86C3;
42 int GL_MAP_ATTRIB_V_ORDER_NV = 0x86C4;
43 int GL_EVAL_FRACTIONAL_TESSELLATION_NV = 0x86C5;
44 int GL_EVAL_VERTEX_ATTRIB0_NV = 0x86C6;
45 int GL_EVAL_VERTEX_ATTRIB1_NV = 0x86C7;
46 int GL_EVAL_VERTEX_ATTRIB2_NV = 0x86C8;
47 int GL_EVAL_VERTEX_ATTRIB3_NV = 0x86C9;
48 int GL_EVAL_VERTEX_ATTRIB4_NV = 0x86CA;
49 int GL_EVAL_VERTEX_ATTRIB5_NV = 0x86CB;
50 int GL_EVAL_VERTEX_ATTRIB6_NV = 0x86CC;
51 int GL_EVAL_VERTEX_ATTRIB7_NV = 0x86CD;
52 int GL_EVAL_VERTEX_ATTRIB8_NV = 0x86CE;
53 int GL_EVAL_VERTEX_ATTRIB9_NV = 0x86CF;
54 int GL_EVAL_VERTEX_ATTRIB10_NV = 0x86D0;
55 int GL_EVAL_VERTEX_ATTRIB11_NV = 0x86D1;
56 int GL_EVAL_VERTEX_ATTRIB12_NV = 0x86D2;
57 int GL_EVAL_VERTEX_ATTRIB13_NV = 0x86D3;
58 int GL_EVAL_VERTEX_ATTRIB14_NV = 0x86D4;
59 int GL_EVAL_VERTEX_ATTRIB15_NV = 0x86D5;
60 int GL_MAX_MAP_TESSELLATION_NV = 0x86D6;
61 int GL_MAX_RATIONAL_EVAL_ORDER_NV = 0x86D7;
62
63 void glGetMapControlPointsNV(@GLenum int target, @GLuint int index, @GLenum int type, @GLsizei int ustride, @GLsizei int vstride, boolean packed,
64 @OutParameter
65 @Check
66 @Const
67 @GLfloat Buffer pPoints);
68
69 void glMapControlPointsNV(@GLenum int target, @GLuint int index, @GLenum int type, @GLsizei int ustride, @GLsizei int vstride, int uorder, int vorder, boolean packed, @Check @Const @GLfloat Buffer pPoints);
70
71 @StripPostfix("params")
72 void glMapParameterfvNV(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params);
73
74 @StripPostfix("params")
75 void glMapParameterivNV(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params);
76
77 @StripPostfix("params")
78 void glGetMapParameterfvNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @Const FloatBuffer params);
79
80 @StripPostfix("params")
81 void glGetMapParameterivNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @Const IntBuffer params);
82
83 @StripPostfix("params")
84 void glGetMapAttribParameterfvNV(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
85
86 @StripPostfix("params")
87 void glGetMapAttribParameterivNV(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
88
89 void glEvalMapsNV(@GLenum int target, @GLenum int mode);
90 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38
39 public interface NV_explicit_multisample {
40
41 /** Accepted by the &lt;pname&gt; parameter of GetMultisamplefvNV: */
42 int GL_SAMPLE_POSITION_NV = 0x8E50;
43
44 /**
45 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
46 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
47 * GetDoublev:
48 */
49
50 int GL_SAMPLE_MASK_NV = 0x8E51;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetBooleanIndexedvEXT and
54 * GetIntegerIndexedvEXT:
55 */
56
57 int GL_SAMPLE_MASK_VALUE_NV = 0x8E52;
58
59 /**
60 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
61 * and GetFloatv:
62 */
63
64 int GL_TEXTURE_BINDING_RENDERBUFFER_NV = 0x8E53;
65 int GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV = 0x8E54;
66 int GL_MAX_SAMPLE_MASK_WORDS_NV = 0x8E59;
67
68 /** Accepted by the &lt;target&gt; parameter of BindTexture, and TexRenderbufferNV: */
69
70 int GL_TEXTURE_RENDERBUFFER_NV = 0x8E55;
71
72 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
73 int GL_SAMPLER_RENDERBUFFER_NV = 0x8E56;
74 int GL_INT_SAMPLER_RENDERBUFFER_NV = 0x8E57;
75 int GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV = 0x8E58;
76
77 @StripPostfix(value = "data", extension = "EXT")
78 void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer data);
79
80 @Alternate("glGetBooleanIndexedvEXT")
81 @GLreturn("data")
82 @StripPostfix(value = "data", extension = "EXT")
83 void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer data);
84
85 @StripPostfix(value = "data", extension = "EXT")
86 void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer data);
87
88 @Alternate("glGetIntegerIndexedvEXT")
89 @GLreturn("data")
90 @StripPostfix(value = "data", extension = "EXT")
91 void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer data);
92
93 @StripPostfix("val")
94 void glGetMultisamplefvNV(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val);
95
96 void glSampleMaskIndexedNV(@GLuint int index, @GLbitfield int mask);
97
98 void glTexRenderbufferNV(@GLenum int target, @GLuint int renderbuffer);
99
100 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_fence {
38 int GL_ALL_COMPLETED_NV = 0x84F2;
39 int GL_FENCE_STATUS_NV = 0x84F3;
40 int GL_FENCE_CONDITION_NV = 0x84F4;
41
42 void glGenFencesNV(@AutoSize("piFences") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences);
43
44 void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences);
45
46 void glSetFenceNV(@GLuint int fence, @GLenum int condition);
47
48 boolean glTestFenceNV(@GLuint int fence);
49
50 void glFinishFenceNV(@GLuint int fence);
51
52 boolean glIsFenceNV(@GLuint int fence);
53
54 void glGetFenceivNV(@GLuint int fence, @GLenum int pname, @OutParameter @Check("4") IntBuffer piParams);
55 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_float_buffer {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D and
37 * CopyTexImage2D:
38 */
39 int GL_FLOAT_R_NV = 0x8880;
40 int GL_FLOAT_RG_NV = 0x8881;
41 int GL_FLOAT_RGB_NV = 0x8882;
42 int GL_FLOAT_RGBA_NV = 0x8883;
43 int GL_FLOAT_R16_NV = 0x8884;
44 int GL_FLOAT_R32_NV = 0x8885;
45 int GL_FLOAT_RG16_NV = 0x8886;
46 int GL_FLOAT_RG32_NV = 0x8887;
47 int GL_FLOAT_RGB16_NV = 0x8888;
48 int GL_FLOAT_RGB32_NV = 0x8889;
49 int GL_FLOAT_RGBA16_NV = 0x888A;
50 int GL_FLOAT_RGBA32_NV = 0x888B;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetTexLevelParameterfv and
54 * GetTexLevelParameteriv:
55 */
56 int GL_TEXTURE_FLOAT_COMPONENTS_NV = 0x888C;
57
58 /**
59 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
60 * and GetDoublev:
61 */
62 int GL_FLOAT_CLEAR_COLOR_VALUE_NV = 0x888D;
63 int GL_FLOAT_RGBA_MODE_NV = 0x888E;
64
65 /**
66 * Accepted in the &lt;piAttributes&gt; array of wglGetPixelFormatAttribivARB and
67 * wglGetPixelFormatAttribfvARB and in the &lt;piAttribIList&gt; and
68 * &lt;pfAttribFList&gt; arrays of wglChoosePixelFormatARB:
69 */
70 /*
71 int WGL_FLOAT_COMPONENTS_NV = 0x20B0;
72 int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = 0x20B1;
73 int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = 0x20B2;
74 int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = 0x20B3;
75 int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = 0x20B4;
76 */
77
78 /**
79 * Accepted in the &lt;piAttribIList&gt; array of wglCreatePbufferARB and returned
80 * in the &lt;value&gt; parameter of wglQueryPbufferARB when &lt;iAttribute&gt; is
81 * WGL_TEXTURE_FORMAT_ARB:
82 */
83 /*
84 int WGL_TEXTURE_FLOAT_R_NV = 0x20B5;
85 int WGL_TEXTURE_FLOAT_RG_NV = 0x20B6;
86 int WGL_TEXTURE_FLOAT_RGB_NV = 0x20B7;
87 int WGL_TEXTURE_FLOAT_RGBA_NV = 0x20B8;
88 */
89
90 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_fog_distance {
34 int GL_FOG_DISTANCE_MODE_NV = 0x855A;
35 int GL_EYE_RADIAL_NV = 0x855B;
36 int GL_EYE_PLANE_ABSOLUTE_NV = 0x855C;
37 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_fragment_program extends NV_program {
38
39 /**
40 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, by the
41 * &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev,
42 * and by the &lt;target&gt; parameter of BindProgramNV, LoadProgramNV,
43 * ProgramLocalParameter4dARB, ProgramLocalParameter4dvARB,
44 * ProgramLocalParameter4fARB, ProgramLocalParameter4fvARB,
45 * GetProgramLocalParameterdvARB, and GetProgramLocalParameterfvARB:
46 */
47 int GL_FRAGMENT_PROGRAM_NV = 0x8870;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
51 * and GetDoublev:
52 */
53 int GL_MAX_TEXTURE_COORDS_NV = 0x8871;
54 int GL_MAX_TEXTURE_IMAGE_UNITS_NV = 0x8872;
55 int GL_FRAGMENT_PROGRAM_BINDING_NV = 0x8873;
56 int GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV = 0x8868;
57
58 void glProgramNamedParameter4fNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, float x, float y, float z, float w);
59
60 void glProgramNamedParameter4dNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, double x, double y, double z, double w);
61
62 @StripPostfix("params")
63 void glGetProgramNamedParameterfvNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, @OutParameter @Check("4") FloatBuffer params);
64
65 @StripPostfix("params")
66 void glGetProgramNamedParameterdvNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, @OutParameter @Check("4") DoubleBuffer params);
67 }
68
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_fragment_program2 {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetProgramivARB:
37 */
38 int GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = 0x88F4;
39 int GL_MAX_PROGRAM_CALL_DEPTH_NV = 0x88F5;
40 int GL_MAX_PROGRAM_IF_DEPTH_NV = 0x88F6;
41 int GL_MAX_PROGRAM_LOOP_DEPTH_NV = 0x88F7;
42 int GL_MAX_PROGRAM_LOOP_COUNT_NV = 0x88F8;
43 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_fragment_program4 {
34
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_fragment_program_option {
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 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
35
36 public interface NV_framebuffer_multisample_coverage {
37
38 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameterivEXT. */
39 int GL_RENDERBUFFER_COVERAGE_SAMPLES_NV = 0x8CAB;
40 int GL_RENDERBUFFER_COLOR_SAMPLES_NV = 0x8E10;
41
42 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv. */
43 int GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV = 0x8E11;
44 int GL_MULITSAMPLE_COVERAGE_MODES_NV = 0x8E12;
45
46 void glRenderbufferStorageMultisampleCoverageNV(@GLenum int target, @GLsizei int coverageSamples, @GLsizei int colorSamples,
47 @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
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.opengl;
32
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
35
36 public interface NV_geometry_program4 {
37
38 /**
39 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and by
40 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
41 * GetDoublev:
42 */
43 int GL_GEOMETRY_PROGRAM_NV = 0x8C26;
44
45 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
46 int GL_MAX_PROGRAM_OUTPUT_VERTICES_NV = 0x8C27;
47 int GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV = 0x8C28;
48
49 void glProgramVertexLimitNV(@GLenum int target, int limit);
50
51 void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
52
53 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
54
55 void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
56
57 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_geometry_shader4 {
34
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface NV_gpu_program4 {
38
39 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
40 int GL_PROGRAM_ATTRIB_COMPONENTS_NV = 0x8906;
41 int GL_PROGRAM_RESULT_COMPONENTS_NV = 0x8907;
42 int GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV = 0x8908;
43 int GL_MAX_PROGRAM_RESULT_COMPONENTS_NV = 0x8909;
44 int GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV = 0x8DA5;
45 int GL_MAX_PROGRAM_GENERIC_RESULTS_NV = 0x8DA6;
46
47 // ---
48
49 void glProgramLocalParameterI4iNV(@GLenum int target, @GLuint int index, int x, int y, int z, int w);
50
51 @StripPostfix("params")
52 void glProgramLocalParameterI4ivNV(@GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params);
53
54 @StripPostfix("params")
55 void glProgramLocalParametersI4ivNV(@GLenum int target, @GLuint int index,
56 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params);
57
58 // ---
59
60 void glProgramLocalParameterI4uiNV(@GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
61
62 @StripPostfix("params")
63 void glProgramLocalParameterI4uivNV(@GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params);
64
65 @StripPostfix("params")
66 void glProgramLocalParametersI4uivNV(@GLenum int target, @GLuint int index,
67 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params);
68
69 // ---
70
71 void glProgramEnvParameterI4iNV(@GLenum int target, @GLuint int index, int x, int y, int z, int w);
72
73 @StripPostfix("params")
74 void glProgramEnvParameterI4ivNV(@GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params);
75
76 @StripPostfix("params")
77 void glProgramEnvParametersI4ivNV(@GLenum int target, @GLuint int index,
78 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params);
79
80 // ---
81
82 void glProgramEnvParameterI4uiNV(@GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
83
84 @StripPostfix("params")
85 void glProgramEnvParameterI4uivNV(@GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params);
86
87 @StripPostfix("params")
88 void glProgramEnvParametersI4uivNV(@GLenum int target, @GLuint int index,
89 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params);
90
91 // ---
92
93 @StripPostfix("params")
94 void glGetProgramLocalParameterIivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") IntBuffer params);
95
96 @StripPostfix("params")
97 void glGetProgramLocalParameterIuivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") @GLuint IntBuffer params);
98
99 // ---
100
101 @StripPostfix("params")
102 void glGetProgramEnvParameterIivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4")IntBuffer params);
103
104 @StripPostfix("params")
105 void glGetProgramEnvParameterIuivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") @GLuint IntBuffer params);
106
107 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_gpu_program5 {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
37 * GetFloatv, and GetDoublev:
38 */
39 int GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV = 0x8E5A;
40 int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV = 0x8E5B;
41 int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV = 0x8E5C;
42 int GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV = 0x8E5D;
43
44 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.LongBuffer;
36
37 @Dependent
38 public interface NV_gpu_shader5 {
39
40 /**
41 * Returned by the &lt;type&gt; parameter of GetActiveAttrib, GetActiveUniform, and
42 * GetTransformFeedbackVarying:
43 */
44 int GL_INT64_NV = 0x140E;
45 int GL_UNSIGNED_INT64_NV = 0x140F;
46
47 int GL_INT8_NV = 0x8FE0;
48 int GL_INT8_VEC2_NV = 0x8FE1;
49 int GL_INT8_VEC3_NV = 0x8FE2;
50 int GL_INT8_VEC4_NV = 0x8FE3;
51 int GL_INT16_NV = 0x8FE4;
52 int GL_INT16_VEC2_NV = 0x8FE5;
53 int GL_INT16_VEC3_NV = 0x8FE6;
54 int GL_INT16_VEC4_NV = 0x8FE7;
55 int GL_INT64_VEC2_NV = 0x8FE9;
56 int GL_INT64_VEC3_NV = 0x8FEA;
57 int GL_INT64_VEC4_NV = 0x8FEB;
58 int GL_UNSIGNED_INT8_NV = 0x8FEC;
59 int GL_UNSIGNED_INT8_VEC2_NV = 0x8FED;
60 int GL_UNSIGNED_INT8_VEC3_NV = 0x8FEE;
61 int GL_UNSIGNED_INT8_VEC4_NV = 0x8FEF;
62 int GL_UNSIGNED_INT16_NV = 0x8FF0;
63 int GL_UNSIGNED_INT16_VEC2_NV = 0x8FF1;
64 int GL_UNSIGNED_INT16_VEC3_NV = 0x8FF2;
65 int GL_UNSIGNED_INT16_VEC4_NV = 0x8FF3;
66 int GL_UNSIGNED_INT64_VEC2_NV = 0x8FF5;
67 int GL_UNSIGNED_INT64_VEC3_NV = 0x8FF6;
68 int GL_UNSIGNED_INT64_VEC4_NV = 0x8FF7;
69 int GL_FLOAT16_NV = 0x8FF8;
70 int GL_FLOAT16_VEC2_NV = 0x8FF9;
71 int GL_FLOAT16_VEC3_NV = 0x8FFA;
72 int GL_FLOAT16_VEC4_NV = 0x8FFB;
73
74 /** Accepted by the &lt;primitiveMode&gt; parameter of BeginTransformFeedback: */
75 int GL_PATCHES = ARB_tessellation_shader.GL_PATCHES;
76
77 void glUniform1i64NV(int location, @GLint64EXT long x);
78
79 void glUniform2i64NV(int location, @GLint64EXT long x, @GLint64EXT long y);
80
81 void glUniform3i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z);
82
83 void glUniform4i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w);
84
85 @StripPostfix("value")
86 void glUniform1i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value);
87
88 @StripPostfix("value")
89 void glUniform2i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value);
90
91 @StripPostfix("value")
92 void glUniform3i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value);
93
94 @StripPostfix("value")
95 void glUniform4i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value);
96
97 void glUniform1ui64NV(int location, @GLuint64EXT long x);
98
99 void glUniform2ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y);
100
101 void glUniform3ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z);
102
103 void glUniform4ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w);
104
105 @StripPostfix("value")
106 void glUniform1ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value);
107
108 @StripPostfix("value")
109 void glUniform2ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value);
110
111 @StripPostfix("value")
112 void glUniform3ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value);
113
114 @StripPostfix("value")
115 void glUniform4ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value);
116
117 @StripPostfix("params")
118 void glGetUniformi64vNV(@GLuint int program, int location, @GLint64EXT @Check LongBuffer params);
119
120 @StripPostfix("params")
121 void glGetUniformui64vNV(@GLuint int program, int location, @GLuint64EXT @Check LongBuffer params);
122
123 // -------------
124
125 @Dependent("EXT_direct_state_access")
126 void glProgramUniform1i64NV(@GLuint int program, int location, @GLint64EXT long x);
127
128 @Dependent("EXT_direct_state_access")
129 void glProgramUniform2i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y);
130
131 @Dependent("EXT_direct_state_access")
132 void glProgramUniform3i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z);
133
134 @Dependent("EXT_direct_state_access")
135 void glProgramUniform4i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w);
136
137 @Dependent("EXT_direct_state_access")
138 @StripPostfix("value")
139 void glProgramUniform1i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value);
140
141 @Dependent("EXT_direct_state_access")
142 @StripPostfix("value")
143 void glProgramUniform2i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value);
144
145 @Dependent("EXT_direct_state_access")
146 @StripPostfix("value")
147 void glProgramUniform3i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value);
148
149 @Dependent("EXT_direct_state_access")
150 @StripPostfix("value")
151 void glProgramUniform4i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value);
152
153 @Dependent("EXT_direct_state_access")
154 void glProgramUniform1ui64NV(@GLuint int program, int location, @GLuint64EXT long x);
155
156 @Dependent("EXT_direct_state_access")
157 void glProgramUniform2ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y);
158
159 @Dependent("EXT_direct_state_access")
160 void glProgramUniform3ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z);
161
162 @Dependent("EXT_direct_state_access")
163 void glProgramUniform4ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w);
164
165 @Dependent("EXT_direct_state_access")
166 @StripPostfix("value")
167 void glProgramUniform1ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value);
168
169 @Dependent("EXT_direct_state_access")
170 @StripPostfix("value")
171 void glProgramUniform2ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value);
172
173 @Dependent("EXT_direct_state_access")
174 @StripPostfix("value")
175 void glProgramUniform3ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value);
176
177 @Dependent("EXT_direct_state_access")
178 @StripPostfix("value")
179 void glProgramUniform4ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value);
180
181 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_half_float {
38
39 /**
40 * Accepted by the &lt;type&gt; argument of VertexPointer, NormalPointer,
41 * ColorPointer, TexCoordPointer, FogCoordPointerEXT,
42 * SecondaryColorPointerEXT, VertexWeightPointerEXT, VertexAttribPointerNV,
43 * DrawPixels, ReadPixels, TexImage1D, TexImage2D, TexImage3D, TexSubImage1D,
44 * TexSubImage2D, TexSubImage3D, and GetTexImage:
45 */
46 int GL_HALF_FLOAT_NV = 0x140B;
47
48 @NoErrorCheck
49 void glVertex2hNV(@GLhalf short x, @GLhalf short y);
50
51 @NoErrorCheck
52 void glVertex3hNV(@GLhalf short x, @GLhalf short y, @GLhalf short z);
53
54 @NoErrorCheck
55 void glVertex4hNV(@GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w);
56
57 @NoErrorCheck
58 void glNormal3hNV(@GLhalf short nx, @GLhalf short ny, @GLhalf short nz);
59
60 @NoErrorCheck
61 void glColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue);
62
63 @NoErrorCheck
64 void glColor4hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue, @GLhalf short alpha);
65
66 @NoErrorCheck
67 void glTexCoord1hNV(@GLhalf short s);
68
69 @NoErrorCheck
70 void glTexCoord2hNV(@GLhalf short s, @GLhalf short t);
71
72 @NoErrorCheck
73 void glTexCoord3hNV(@GLhalf short s, @GLhalf short t, @GLhalf short r);
74
75 @NoErrorCheck
76 void glTexCoord4hNV(@GLhalf short s, @GLhalf short t, @GLhalf short r, @GLhalf short q);
77
78 @NoErrorCheck
79 void glMultiTexCoord1hNV(@GLenum int target, @GLhalf short s);
80
81 @NoErrorCheck
82 void glMultiTexCoord2hNV(@GLenum int target, @GLhalf short s, @GLhalf short t);
83
84 @NoErrorCheck
85 void glMultiTexCoord3hNV(@GLenum int target, @GLhalf short s, @GLhalf short t, @GLhalf short r);
86
87 @NoErrorCheck
88 void glMultiTexCoord4hNV(@GLenum int target, @GLhalf short s, @GLhalf short t, @GLhalf short r, @GLhalf short q);
89
90 @NoErrorCheck
91 void glFogCoordhNV(@GLhalf short fog);
92
93 @NoErrorCheck
94 void glSecondaryColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue);
95
96 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
97 @NoErrorCheck
98 void glVertexWeighthNV(@GLhalf short weight);
99
100 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
101 @NoErrorCheck
102 void glVertexAttrib1hNV(@GLuint int index, @GLhalf short x);
103
104 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
105 @NoErrorCheck
106 void glVertexAttrib2hNV(@GLuint int index, @GLhalf short x, @GLhalf short y);
107
108 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
109 @NoErrorCheck
110 void glVertexAttrib3hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z);
111
112 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
113 @NoErrorCheck
114 void glVertexAttrib4hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w);
115
116 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
117 @NoErrorCheck
118 @StripPostfix("attribs")
119 void glVertexAttribs1hvNV(@GLuint int index, @AutoSize("attribs") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
120
121 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
122 @NoErrorCheck
123 @StripPostfix("attribs")
124 void glVertexAttribs2hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 1") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
125
126 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
127 @NoErrorCheck
128 @StripPostfix("attribs")
129 void glVertexAttribs3hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " / 3") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
130
131 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
132 @NoErrorCheck
133 @StripPostfix("attribs")
134 void glVertexAttribs4hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 2") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
135 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_light_max_exponent {
34 int GL_MAX_SHININESS_NV = 0x8504;
35 int GL_MAX_SPOT_EXPONENT_NV = 0x8505;
36 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_multisample_filter_hint {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of Hint and by the &lt;pname&gt;
37 * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
38 */
39 int GL_MULTISAMPLE_FILTER_HINT_NV = 0x8534;
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 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface NV_occlusion_query {
38
39 int GL_OCCLUSION_TEST_HP = 0x8165;
40 int GL_OCCLUSION_TEST_RESULT_HP = 0x8166;
41 /* HP_occlusion_test */
42 int GL_PIXEL_COUNTER_BITS_NV = 0x8864;
43 int GL_CURRENT_OCCLUSION_QUERY_ID_NV = 0x8865;
44 int GL_PIXEL_COUNT_NV = 0x8866;
45 int GL_PIXEL_COUNT_AVAILABLE_NV = 0x8867;
46
47 void glGenOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @OutParameter @GLuint IntBuffer piIDs);
48
49 @Alternate("glGenOcclusionQueriesNV")
50 @GLreturn("piIDs")
51 void glGenOcclusionQueriesNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer piIDs);
52
53 void glDeleteOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @Const @GLuint IntBuffer piIDs);
54
55 @Alternate("glDeleteOcclusionQueriesNV")
56 void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, piID), 0", keepParam = true) int piID);
57
58 boolean glIsOcclusionQueryNV(@GLuint int id);
59
60 void glBeginOcclusionQueryNV(@GLuint int id);
61
62 void glEndOcclusionQueryNV();
63
64 @StripPostfix("params")
65 void glGetOcclusionQueryuivNV(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
66
67 @Alternate("glGetOcclusionQueryuivNV")
68 @GLreturn("params")
69 @StripPostfix(value = "params", postfix = "v")
70 void glGetOcclusionQueryuivNV2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
71
72 @StripPostfix("params")
73 void glGetOcclusionQueryivNV(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
74
75 @Alternate("glGetOcclusionQueryivNV")
76 @GLreturn("params")
77 @StripPostfix(value = "params", postfix = "v")
78 void glGetOcclusionQueryivNV2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
79 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_packed_depth_stencil {
34 int GL_DEPTH_STENCIL_NV = 0x84F9;
35 int GL_UNSIGNED_INT_24_8_NV = 0x84FA;
36 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.FloatBuffer;
36 import java.nio.IntBuffer;
37
38 public interface NV_parameter_buffer_object {
39
40 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
41 int GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV = 0x8DA0;
42 int GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV = 0x8DA1;
43
44 /**
45 * Accepted by the &lt;target&gt; parameter of ProgramBufferParametersfvNV,
46 * ProgramBufferParametersIivNV, and ProgramBufferParametersIuivNV,
47 * BindBufferRangeNV, BindBufferOffsetNV, BindBufferBaseNV, and BindBuffer
48 * and the &lt;value&gt; parameter of GetIntegerIndexedvEXT:
49 */
50 int GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA2;
51 int GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA3;
52 int GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA4;
53
54 @StripPostfix("params")
55 void glProgramBufferParametersfvNV(@GLenum int target, @GLuint int buffer, @GLuint int index,
56 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const FloatBuffer params);
57
58 @StripPostfix("params")
59 void glProgramBufferParametersIivNV(@GLenum int target, @GLuint int buffer, @GLuint int index,
60 @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params);
61
62 @StripPostfix("params")
63 void glProgramBufferParametersIuivNV(@GLenum int target, @GLuint int buffer, @GLuint int index,
64 @AutoSize(value = "params", expression = " >> 2") @GLuint int count, @Const @GLuint IntBuffer params);
65
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 package org.lwjgl.opengl;
32
33 public interface NV_parameter_buffer_object2 {
34
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_pixel_data_range {
38
39 /**
40 * Accepted by the &lt;target&gt; parameter of PixelDataRangeNV and
41 * FlushPixelDataRangeNV, and by the &lt;cap&gt; parameter of
42 * EnableClientState, DisableClientState, and IsEnabled:
43 */
44 int GL_WRITE_PIXEL_DATA_RANGE_NV = 0x8878;
45 int GL_READ_PIXEL_DATA_RANGE_NV = 0x8879;
46
47 /**
48 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
49 * GetFloatv, and GetDoublev:
50 */
51 int GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV = 0x887A;
52 int GL_READ_PIXEL_DATA_RANGE_LENGTH_NV = 0x887B;
53
54 /**
55 * Accepted by the &lt;pname&gt; parameter of GetPointerv:
56 */
57 int GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV = 0x887C;
58 int GL_READ_PIXEL_DATA_RANGE_POINTER_NV = 0x887D;
59
60 void glPixelDataRangeNV(@GLenum int target, @AutoSize("data") @GLsizei int length,
61 @GLbyte
62 @GLshort
63 @GLint
64 @GLfloat
65 @GLdouble Buffer data);
66
67 void glFlushPixelDataRangeNV(@GLenum int target);
68 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_point_sprite {
38 int GL_POINT_SPRITE_NV = 0x8861;
39 int GL_COORD_REPLACE_NV = 0x8862;
40 int GL_POINT_SPRITE_R_MODE_NV = 0x8863;
41
42 void glPointParameteriNV(@GLenum int pname, int param);
43
44 @StripPostfix("params")
45 void glPointParameterivNV(@GLenum int pname, @Check("4") @Const IntBuffer params);
46 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @ForceInit
36 public interface NV_primitive_restart {
37
38 /**
39 * Accepted by the &lt;array&gt; parameter of EnableClientState and
40 * DisableClientState, by the &lt;cap&gt; parameter of IsEnabled, and by
41 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
42 * GetDoublev:
43 */
44 int GL_PRIMITIVE_RESTART_NV = 0x8558;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
48 * GetFloatv, and GetDoublev:
49 */
50 int GL_PRIMITIVE_RESTART_INDEX_NV = 0x8559;
51
52 void glPrimitiveRestartNV();
53
54 void glPrimitiveRestartIndexNV(@GLuint int index);
55 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.Buffer;
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 @Extension(postfix = "NV", isFinal = false)
40 public interface NV_program {
41
42 /** Accepted by the &lt;pname&gt; parameter of GetProgramivNV: */
43 int GL_PROGRAM_TARGET_NV = 0x8646;
44 int GL_PROGRAM_LENGTH_NV = 0x8627;
45 int GL_PROGRAM_RESIDENT_NV = 0x8647;
46
47 /** Accepted by the &lt;pname&gt; parameter of GetProgramStringNV: */
48 int GL_PROGRAM_STRING_NV = 0x8628;
49
50 /**
51 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
52 * GetFloatv, and GetDoublev:
53 */
54 int GL_PROGRAM_ERROR_POSITION_NV = 0x864B;
55
56 /** Accepted by the &lt;name&gt; parameter of GetString: */
57 int GL_PROGRAM_ERROR_STRING_NV = 0x8874;
58
59 void glLoadProgramNV(@GLenum int target, @GLuint int programID, @AutoSize("string") @GLsizei int length, @Const @GLubyte Buffer string);
60
61 @Alternate("glLoadProgramNV")
62 void glLoadProgramNV(@GLenum int target, @GLuint int programID, @Constant("string.length()") @GLsizei int length, CharSequence string);
63
64 void glBindProgramNV(@GLenum int target, @GLuint int programID);
65
66 void glDeleteProgramsNV(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
67
68 @Alternate("glDeleteProgramsNV")
69 void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program);
70
71 void glGenProgramsNV(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
72
73 @Alternate("glGenProgramsNV")
74 @GLreturn("programs")
75 void glGenProgramsNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
76
77 @StripPostfix("params")
78 void glGetProgramivNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLint IntBuffer params);
79
80 @Alternate("glGetProgramivNV")
81 @GLreturn("params")
82 @StripPostfix("params")
83 void glGetProgramivNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLint IntBuffer params);
84
85 void glGetProgramStringNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLubyte Buffer paramString);
86
87 @Alternate("glGetProgramStringNV")
88 @Code("\t\tint programLength = glGetProgramNV(programID, GL_PROGRAM_LENGTH_NV);")
89 @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true)
90 void glGetProgramStringNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString);
91
92 boolean glIsProgramNV(@GLuint int programID);
93
94 boolean glAreProgramsResidentNV(@AutoSize("programIDs") @GLsizei int n,
95 @Const @GLuint IntBuffer programIDs,
96 @OutParameter @GLboolean @Check("programIDs.remaining()") ByteBuffer programResidences);
97
98 void glRequestResidentProgramsNV(@AutoSize("programIDs") @GLsizei int n, @GLuint IntBuffer programIDs);
99
100 @Alternate("glRequestResidentProgramsNV")
101 void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, programID), 0", keepParam = true) int programID);
102 }
103
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_register_combiners {
38 int GL_REGISTER_COMBINERS_NV = 0x8522;
39 int GL_COMBINER0_NV = 0x8550;
40 int GL_COMBINER1_NV = 0x8551;
41 int GL_COMBINER2_NV = 0x8552;
42 int GL_COMBINER3_NV = 0x8553;
43 int GL_COMBINER4_NV = 0x8554;
44 int GL_COMBINER5_NV = 0x8555;
45 int GL_COMBINER6_NV = 0x8556;
46 int GL_COMBINER7_NV = 0x8557;
47 int GL_VARIABLE_A_NV = 0x8523;
48 int GL_VARIABLE_B_NV = 0x8524;
49 int GL_VARIABLE_C_NV = 0x8525;
50 int GL_VARIABLE_D_NV = 0x8526;
51 int GL_VARIABLE_E_NV = 0x8527;
52 int GL_VARIABLE_F_NV = 0x8528;
53 int GL_VARIABLE_G_NV = 0x8529;
54 int GL_CONSTANT_COLOR0_NV = 0x852A;
55 int GL_CONSTANT_COLOR1_NV = 0x852B;
56 int GL_PRIMARY_COLOR_NV = 0x852C;
57 int GL_SECONDARY_COLOR_NV = 0x852D;
58 int GL_SPARE0_NV = 0x852E;
59 int GL_SPARE1_NV = 0x852F;
60 int GL_UNSIGNED_IDENTITY_NV = 0x8536;
61 int GL_UNSIGNED_INVERT_NV = 0x8537;
62 int GL_EXPAND_NORMAL_NV = 0x8538;
63 int GL_EXPAND_NEGATE_NV = 0x8539;
64 int GL_HALF_BIAS_NORMAL_NV = 0x853A;
65 int GL_HALF_BIAS_NEGATE_NV = 0x853B;
66 int GL_SIGNED_IDENTITY_NV = 0x853C;
67 int GL_SIGNED_NEGATE_NV = 0x853D;
68 int GL_E_TIMES_F_NV = 0x8531;
69 int GL_SPARE0_PLUS_SECONDARY_COLOR_NV = 0x8532;
70 int GL_SCALE_BY_TWO_NV = 0x853E;
71 int GL_SCALE_BY_FOUR_NV = 0x853F;
72 int GL_SCALE_BY_ONE_HALF_NV = 0x8540;
73 int GL_BIAS_BY_NEGATIVE_ONE_HALF_NV = 0x8541;
74 int GL_DISCARD_NV = 0x8530;
75 int GL_COMBINER_INPUT_NV = 0x8542;
76 int GL_COMBINER_MAPPING_NV = 0x8543;
77 int GL_COMBINER_COMPONENT_USAGE_NV = 0x8544;
78 int GL_COMBINER_AB_DOT_PRODUCT_NV = 0x8545;
79 int GL_COMBINER_CD_DOT_PRODUCT_NV = 0x8546;
80 int GL_COMBINER_MUX_SUM_NV = 0x8547;
81 int GL_COMBINER_SCALE_NV = 0x8548;
82 int GL_COMBINER_BIAS_NV = 0x8549;
83 int GL_COMBINER_AB_OUTPUT_NV = 0x854A;
84 int GL_COMBINER_CD_OUTPUT_NV = 0x854B;
85 int GL_COMBINER_SUM_OUTPUT_NV = 0x854C;
86 int GL_NUM_GENERAL_COMBINERS_NV = 0x854E;
87 int GL_COLOR_SUM_CLAMP_NV = 0x854F;
88 int GL_MAX_GENERAL_COMBINERS_NV = 0x854D;
89
90 void glCombinerParameterfNV(@GLenum int pname, float param);
91
92 @StripPostfix("params")
93 void glCombinerParameterfvNV(@GLenum int pname, @Check("4") @Const FloatBuffer params);
94
95 void glCombinerParameteriNV(@GLenum int pname, int param);
96
97 @StripPostfix("params")
98 void glCombinerParameterivNV(@GLenum int pname, @Check("4") @Const IntBuffer params);
99
100 void glCombinerInputNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int input, @GLenum int mapping, @GLenum int componentUsage);
101
102 void glCombinerOutputNV(@GLenum int stage, @GLenum int portion, @GLenum int abOutput, @GLenum int cdOutput, @GLenum int sumOutput, @GLenum int scale, @GLenum int bias, boolean abDotProduct, boolean cdDotProduct, boolean muxSum);
103
104 void glFinalCombinerInputNV(@GLenum int variable, @GLenum int input, @GLenum int mapping, @GLenum int componentUsage);
105
106 @StripPostfix("params")
107 void glGetCombinerInputParameterfvNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
108
109 @Alternate("glGetCombinerInputParameterfvNV")
110 @GLreturn("params")
111 @StripPostfix(value = "params", postfix = "v")
112 void glGetCombinerInputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params);
113
114 @StripPostfix("params")
115 void glGetCombinerInputParameterivNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
116
117 @Alternate("glGetCombinerInputParameterivNV")
118 @GLreturn("params")
119 @StripPostfix(value = "params", postfix = "v")
120 void glGetCombinerInputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params);
121
122 @StripPostfix("params")
123 void glGetCombinerOutputParameterfvNV(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
124
125 @Alternate("glGetCombinerOutputParameterfvNV")
126 @GLreturn("params")
127 @StripPostfix(value = "params", postfix = "v")
128 void glGetCombinerOutputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter FloatBuffer params);
129
130 @StripPostfix("params")
131 void glGetCombinerOutputParameterivNV(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
132
133 @Alternate("glGetCombinerOutputParameterivNV")
134 @GLreturn("params")
135 @StripPostfix(value = "params", postfix = "v")
136 void glGetCombinerOutputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter IntBuffer params);
137
138 @StripPostfix("params")
139 void glGetFinalCombinerInputParameterfvNV(@GLenum int variable, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
140
141 @Alternate("glGetFinalCombinerInputParameterfvNV")
142 @GLreturn("params")
143 @StripPostfix(value = "params", postfix = "v")
144 void glGetFinalCombinerInputParameterfvNV2(@GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params);
145
146 @StripPostfix("params")
147 void glGetFinalCombinerInputParameterivNV(@GLenum int variable, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
148
149 @Alternate("glGetFinalCombinerInputParameterivNV")
150 @GLreturn("params")
151 @StripPostfix(value = "params", postfix = "v")
152 void glGetFinalCombinerInputParameterivNV2(@GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params);
153 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_register_combiners2 {
38 int GL_PER_STAGE_CONSTANTS_NV = 0x8535;
39
40 @StripPostfix("params")
41 void glCombinerStageParameterfvNV(@GLenum int stage, @GLenum int pname, @Const @Check("4") FloatBuffer params);
42
43 @StripPostfix("params")
44 void glGetCombinerStageParameterfvNV(@GLenum int stage, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
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.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.LongBuffer;
36
37 public interface NV_shader_buffer_load {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameter of GetBufferParameterui64vNV,
41 * GetNamedBufferParameterui64vNV:
42 */
43 int GL_BUFFER_GPU_ADDRESS_NV = 0x8F1D;
44
45 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
46 int GL_GPU_ADDRESS_NV = 0x8F34;
47
48 /** Accepted by the &lt;value&gt; parameter of GetIntegerui64vNV: */
49 int GL_MAX_SHADER_BUFFER_ADDRESS_NV = 0x8F35;
50
51 void glMakeBufferResidentNV(@GLenum int target, @GLenum int access);
52
53 void glMakeBufferNonResidentNV(@GLenum int target);
54
55 boolean glIsBufferResidentNV(@GLenum int target);
56
57 void glMakeNamedBufferResidentNV(@GLuint int buffer, @GLenum int access);
58
59 void glMakeNamedBufferNonResidentNV(@GLuint int buffer);
60
61 boolean glIsNamedBufferResidentNV(@GLuint int buffer);
62
63 @StripPostfix("params")
64 void glGetBufferParameterui64vNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
65
66 @Alternate("glGetBufferParameterui64vNV")
67 @GLreturn("params")
68 @StripPostfix("params")
69 void glGetBufferParameterui64vNV2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
70
71 @StripPostfix("params")
72 void glGetNamedBufferParameterui64vNV(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
73
74 @Alternate("glGetNamedBufferParameterui64vNV")
75 @GLreturn("params")
76 @StripPostfix("params")
77 void glGetNamedBufferParameterui64vNV2(@GLuint int buffer, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
78
79 @StripPostfix("result")
80 void glGetIntegerui64vNV(@GLenum int value, @OutParameter @Check("1") @GLuint64EXT LongBuffer result);
81
82 @Alternate("glGetIntegerui64vNV")
83 @GLreturn("result")
84 @StripPostfix("result")
85 void glGetIntegerui64vNV2(@GLenum int value, @OutParameter @GLuint64EXT LongBuffer result);
86
87 void glUniformui64NV(int location, @GLuint64EXT long value);
88
89 @StripPostfix("value")
90 void glUniformui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
91
92 @StripPostfix("params")
93 void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
94
95 void glProgramUniformui64NV(@GLuint int program, int location, @GLuint64EXT long value);
96
97 @StripPostfix("value")
98 void glProgramUniformui64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
99
100 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_shader_buffer_store {
34
35 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrierNV: */
36 int GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV = 0x00000010;
37
38 /** Accepted by the &lt;access&gt; parameter of MakeBufferResidentNV: */
39 int GL_READ_WRITE = GL15.GL_READ_WRITE;
40 int GL_WRITE_ONLY = GL15.GL_WRITE_ONLY;
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 package org.lwjgl.opengl;
32
33 public interface NV_tessellation_program5 {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled,
37 * by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
38 * and GetDoublev, and by the &lt;target&gt; parameter of ProgramStringARB,
39 * BindProgramARB, ProgramEnvParameter4[df][v]ARB,
40 * ProgramLocalParameter4[df][v]ARB, GetProgramEnvParameter[df]vARB,
41 * GetProgramLocalParameter[df]vARB, GetProgramivARB and
42 * GetProgramStringARB:
43 */
44 int GL_TESS_CONTROL_PROGRAM_NV = 0x891E;
45 int GL_TESS_EVALUATION_PROGRAM_NV = 0x891F;
46
47 /**
48 * Accepted by the &lt;target&gt; parameter of ProgramBufferParametersfvNV,
49 * ProgramBufferParametersIivNV, and ProgramBufferParametersIuivNV,
50 * BindBufferRangeNV, BindBufferOffsetNV, BindBufferBaseNV, and BindBuffer
51 * and the &lt;value&gt; parameter of GetIntegerIndexedvEXT:
52 */
53 int GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV = 0x8C74;
54 int GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV = 0x8C75;
55
56 /** Accepted by the &lt;pname&gt; parameter of GetProgramivARB: */
57 int GL_MAX_PROGRAM_PATCH_ATTRIBS_NV = 0x86D8;
58
59 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texgen_reflection {
34 int GL_NORMAL_MAP_NV = 0x8511;
35 int GL_REFLECTION_MAP_NV = 0x8512;
36 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texture_barrier {
34
35 void glTextureBarrierNV();
36
37 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @Extension(postfix = "NV", className = "NVTextureCompressionVTC")
36 public interface NV_texture_compression_vtc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage3D and
40 * CompressedTexImage3DARB and the &lt;format&gt; parameter of
41 * CompressedTexSubImage2DARB:
42 */
43 int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
44 int GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
45 int GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
46 int GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
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.opengl;
32
33 public interface NV_texture_env_combine4 {
34 int GL_COMBINE4_NV = 0x8503;
35 int GL_SOURCE3_RGB_NV = 0x8583;
36 int GL_SOURCE3_ALPHA_NV = 0x858B;
37 int GL_OPERAND3_RGB_NV = 0x8593;
38 int GL_OPERAND3_ALPHA_NV = 0x859B;
39 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texture_expand_normal {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameters of TexParameteri,
37 * TexParameteriv, TexParameterf, TexParameterfv, GetTexParameteri,
38 * and GetTexParameteriv:
39 */
40 int GL_TEXTURE_UNSIGNED_REMAP_MODE_NV = 0x888F;
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.opengl;
32
33 public interface NV_texture_rectangle {
34 int GL_TEXTURE_RECTANGLE_NV = 0x84F5;
35 int GL_TEXTURE_BINDING_RECTANGLE_NV = 0x84F6;
36 int GL_PROXY_TEXTURE_RECTANGLE_NV = 0x84F7;
37 int GL_MAX_RECTANGLE_TEXTURE_SIZE_NV = 0x84F8;
38 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texture_shader {
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, GetFloatv,
38 * and GetDoublev, and by the &lt;target&gt; parameter of TexEnvf, TexEnvfv,
39 * TexEnvi, TexEnviv, GetTexEnvfv, and GetTexEnviv.
40 */
41 int GL_TEXTURE_SHADER_NV = 0x86DE;
42
43 /**
44 * When the &lt;target&gt; parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv,
45 * GetTexEnvfv, and GetTexEnviv is TEXTURE_SHADER_NV, then the value
46 * of &lt;pname&gt; may be:
47 */
48 int GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV = 0x86D9;
49 int GL_SHADER_OPERATION_NV = 0x86DF;
50 int GL_OFFSET_TEXTURE_SCALE_NV = 0x86E2;
51 int GL_OFFSET_TEXTURE_BIAS_NV = 0x86E3;
52 int GL_OFFSET_TEXTURE_2D_SCALE_NV = GL_OFFSET_TEXTURE_SCALE_NV;
53 int GL_OFFSET_TEXTURE_2D_BIAS_NV = GL_OFFSET_TEXTURE_BIAS_NV;
54 int GL_PREVIOUS_TEXTURE_INPUT_NV = 0x86E4;
55
56 /**
57 * When the &lt;target&gt; parameter of TexEnvfv, TexEnviv, GetTexEnvfv, and
58 * GetTexEnviv is TEXTURE_SHADER_NV, then the value of &lt;pname&gt; may be:
59 */
60 int GL_CULL_MODES_NV = 0x86E0;
61 int GL_OFFSET_TEXTURE_MATRIX_NV = 0x86E1;
62 int GL_OFFSET_TEXTURE_2D_MATRIX_NV = GL_OFFSET_TEXTURE_MATRIX_NV;
63 int GL_CONST_EYE_NV = 0x86E5;
64
65 /**
66 * When the &lt;target&gt; parameter GetTexEnvfv and GetTexEnviv is
67 * TEXTURE_SHADER_NV, then the value of &lt;pname&gt; may be:
68 */
69 int GL_SHADER_CONSISTENT_NV = 0x86DD;
70
71 /**
72 * When the &lt;target&gt; and &lt;pname&gt; parameters of TexEnvf, TexEnvfv,
73 * TexEnvi, and TexEnviv are TEXTURE_SHADER_NV and SHADER_OPERATION_NV
74 * respectively, then the value of &lt;param&gt; or the value pointed to by
75 * &lt;params&gt; may be:
76 */
77 int GL_PASS_THROUGH_NV = 0x86E6;
78 int GL_CULL_FRAGMENT_NV = 0x86E7;
79
80 int GL_OFFSET_TEXTURE_2D_NV = 0x86E8;
81 int GL_OFFSET_TEXTURE_RECTANGLE_NV = 0x864C;
82 int GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV = 0x864D;
83 int GL_DEPENDENT_AR_TEXTURE_2D_NV = 0x86E9;
84 int GL_DEPENDENT_GB_TEXTURE_2D_NV = 0x86EA;
85
86 int GL_DOT_PRODUCT_NV = 0x86EC;
87 int GL_DOT_PRODUCT_DEPTH_REPLACE_NV = 0x86ED;
88 int GL_DOT_PRODUCT_TEXTURE_2D_NV = 0x86EE;
89 int GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV = 0x864E;
90 int GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV = 0x86F0;
91 int GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV = 0x86F1;
92 int GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV = 0x86F2;
93 int GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV = 0x86F3;
94
95 /**
96 * Accepted by the &lt;format&gt; parameter of GetTexImage, TexImage1D,
97 * TexImage2D, TexSubImage1D, and TexSubImage2D.
98 */
99 int GL_HILO_NV = 0x86F4;
100 int GL_DSDT_NV = 0x86F5;
101 int GL_DSDT_MAG_NV = 0x86F6;
102 int GL_DSDT_MAG_VIB_NV = 0x86F7;
103
104 /**
105 * Accepted by the &lt;type&gt; parameter of GetTexImage, TexImage1D,
106 * TexImage2D, TexSubImage1D, and TexSubImage2D.
107 */
108 int GL_UNSIGNED_INT_S8_S8_8_8_NV = 0x86DA;
109 int GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = 0x86DB;
110
111 /**
112 * Accepted by the &lt;internalformat&gt; parameter of CopyTexImage1D,
113 * CopyTexImage2D, TexImage1D, and TexImage2D.
114 */
115 int GL_SIGNED_RGBA_NV = 0x86FB;
116 int GL_SIGNED_RGBA8_NV = 0x86FC;
117 int GL_SIGNED_RGB_NV = 0x86FE;
118 int GL_SIGNED_RGB8_NV = 0x86FF;
119 int GL_SIGNED_LUMINANCE_NV = 0x8701;
120 int GL_SIGNED_LUMINANCE8_NV = 0x8702;
121 int GL_SIGNED_LUMINANCE_ALPHA_NV = 0x8703;
122 int GL_SIGNED_LUMINANCE8_ALPHA8_NV = 0x8704;
123 int GL_SIGNED_ALPHA_NV = 0x8705;
124 int GL_SIGNED_ALPHA8_NV = 0x8706;
125 int GL_SIGNED_INTENSITY_NV = 0x8707;
126 int GL_SIGNED_INTENSITY8_NV = 0x8708;
127 int GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = 0x870C;
128 int GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = 0x870D;
129
130 /**
131 * Accepted by the &lt;internalformat&gt; parameter of TexImage1D and
132 * TexImage2D.
133 */
134 int GL_HILO16_NV = 0x86F8;
135 int GL_SIGNED_HILO_NV = 0x86F9;
136 int GL_SIGNED_HILO16_NV = 0x86FA;
137 int GL_DSDT8_NV = 0x8709;
138 int GL_DSDT8_MAG8_NV = 0x870A;
139 int GL_DSDT_MAG_INTENSITY_NV = 0x86DC;
140 int GL_DSDT8_MAG8_INTENSITY8_NV = 0x870B;
141
142 /**
143 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
144 * GetFloatv, GetDoublev, PixelTransferf, and PixelTransferi.
145 */
146 int GL_HI_SCALE_NV = 0x870E;
147 int GL_LO_SCALE_NV = 0x870F;
148 int GL_DS_SCALE_NV = 0x8710;
149 int GL_DT_SCALE_NV = 0x8711;
150 int GL_MAGNITUDE_SCALE_NV = 0x8712;
151 int GL_VIBRANCE_SCALE_NV = 0x8713;
152 int GL_HI_BIAS_NV = 0x8714;
153 int GL_LO_BIAS_NV = 0x8715;
154 int GL_DS_BIAS_NV = 0x8716;
155 int GL_DT_BIAS_NV = 0x8717;
156 int GL_MAGNITUDE_BIAS_NV = 0x8718;
157 int GL_VIBRANCE_BIAS_NV = 0x8719;
158
159 /**
160 * Accepted by the &lt;pname&gt; parameter of TexParameteriv, TexParameterfv,
161 * GetTexParameterfv and GetTexParameteriv.
162 */
163 int GL_TEXTURE_BORDER_VALUES_NV = 0x871A;
164
165 /**
166 * Accepted by the &lt;pname&gt; parameter of GetTexLevelParameterfv and
167 * GetTexLevelParameteriv.
168 */
169 int GL_TEXTURE_HI_SIZE_NV = 0x871B;
170 int GL_TEXTURE_LO_SIZE_NV = 0x871C;
171 int GL_TEXTURE_DS_SIZE_NV = 0x871D;
172 int GL_TEXTURE_DT_SIZE_NV = 0x871E;
173 int GL_TEXTURE_MAG_SIZE_NV = 0x871F;
174 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texture_shader2 {
34 int GL_DOT_PRODUCT_TEXTURE_3D_NV = 0x86EF;
35 int GL_HILO_NV = 0x86F4;
36 int GL_DSDT_NV = 0x86F5;
37 int GL_DSDT_MAG_NV = 0x86F6;
38 int GL_DSDT_MAG_VIB_NV = 0x86F7;
39 int GL_UNSIGNED_INT_S8_S8_8_8_NV = 0x86DA;
40 int GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = 0x86DB;
41 int GL_SIGNED_RGBA_NV = 0x86FB;
42 int GL_SIGNED_RGBA8_NV = 0x86FC;
43 int GL_SIGNED_RGB_NV = 0x86FE;
44 int GL_SIGNED_RGB8_NV = 0x86FF;
45 int GL_SIGNED_LUMINANCE_NV = 0x8701;
46 int GL_SIGNED_LUMINANCE8_NV = 0x8702;
47 int GL_SIGNED_LUMINANCE_ALPHA_NV = 0x8703;
48 int GL_SIGNED_LUMINANCE8_ALPHA8_NV = 0x8704;
49 int GL_SIGNED_ALPHA_NV = 0x8705;
50 int GL_SIGNED_ALPHA8_NV = 0x8706;
51 int GL_SIGNED_INTENSITY_NV = 0x8707;
52 int GL_SIGNED_INTENSITY8_NV = 0x8708;
53 int GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = 0x870C;
54 int GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = 0x870D;
55 int GL_HILO16_NV = 0x86F8;
56 int GL_SIGNED_HILO_NV = 0x86F9;
57 int GL_SIGNED_HILO16_NV = 0x86FA;
58 int GL_DSDT8_NV = 0x8709;
59 int GL_DSDT8_MAG8_NV = 0x870A;
60 int GL_DSDT_MAG_INTENSITY_NV = 0x86DC;
61 int GL_DSDT8_MAG8_INTENSITY8_NV = 0x870B;
62 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_texture_shader3 {
34 int GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV = 0x8850;
35 int GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV = 0x8851;
36 int GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV = 0x8852;
37 int GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV = 0x8853;
38 int GL_OFFSET_HILO_TEXTURE_2D_NV = 0x8854;
39 int GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV = 0x8855;
40 int GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV = 0x8856;
41 int GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV = 0x8857;
42 int GL_DEPENDENT_HILO_TEXTURE_2D_NV = 0x8858;
43 int GL_DEPENDENT_RGB_TEXTURE_3D_NV = 0x8859;
44 int GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV = 0x885A;
45 int GL_DOT_PRODUCT_PASS_THROUGH_NV = 0x885B;
46 int GL_DOT_PRODUCT_TEXTURE_1D_NV = 0x885C;
47 int GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV = 0x885D;
48 int GL_HILO8_NV = 0x885E;
49 int GL_SIGNED_HILO8_NV = 0x885F;
50 int GL_FORCE_BLUE_TO_ONE_NV = 0x8860;
51 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.ByteBuffer;
36 import java.nio.IntBuffer;
37
38 public interface NV_transform_feedback {
39
40 /**
41 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
42 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
43 * GetBufferPointerv, BindBufferRangeNV, BindBufferOffsetNV and
44 * BindBufferBaseNV:
45 */
46 int GL_TRANSFORM_FEEDBACK_BUFFER_NV = 0x8C8E;
47
48 /**
49 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedvEXT and
50 * GetBooleanIndexedvEXT:
51 */
52 int GL_TRANSFORM_FEEDBACK_BUFFER_START_NV = 0x8C84;
53 int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV = 0x8C85;
54 int GL_TRANSFORM_FEEDBACK_RECORD_NV = 0x8C86;
55
56 /**
57 * Accepted by the &lt;param&gt; parameter of GetIntegerIndexedvEXT and
58 * GetBooleanIndexedvEXT, and by the &lt;pname&gt; parameter of GetBooleanv,
59 * GetDoublev, GetIntegerv, and GetFloatv:
60 */
61 int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV = 0x8C8F;
62
63 /**
64 * Accepted by the &lt;bufferMode&gt; parameter of TransformFeedbackAttribsNV and
65 * TransformFeedbackVaryingsNV:
66 */
67 int GL_INTERLEAVED_ATTRIBS_NV = 0x8C8C;
68 int GL_SEPARATE_ATTRIBS_NV = 0x8C8D;
69
70 /**
71 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, and
72 * GetQueryiv:
73 */
74 int GL_PRIMITIVES_GENERATED_NV = 0x8C87;
75 int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV = 0x8C88;
76
77 /**
78 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled, and by
79 * the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
80 * GetDoublev:
81 */
82 int GL_RASTERIZER_DISCARD_NV = 0x8C89;
83
84 /**
85 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
86 * and GetFloatv:
87 */
88 int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV = 0x8C8A;
89 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV = 0x8C8B;
90 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV = 0x8C80;
91 int GL_TRANSFORM_FEEDBACK_ATTRIBS_NV = 0x8C7E;
92
93 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
94 int GL_ACTIVE_VARYINGS_NV = 0x8C81;
95 int GL_ACTIVE_VARYING_MAX_LENGTH_NV = 0x8C82;
96 int GL_TRANSFORM_FEEDBACK_VARYINGS_NV = 0x8C83;
97
98 /**
99 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
100 * GetFloatv, and GetProgramiv:
101 */
102 int GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV = 0x8C7F;
103
104 /** Accepted by the &lt;attribs&gt; parameter of TransformFeedbackAttribsNV: */
105 int GL_BACK_PRIMARY_COLOR_NV = 0x8C77;
106 int GL_BACK_SECONDARY_COLOR_NV = 0x8C78;
107 int GL_TEXTURE_COORD_NV = 0x8C79;
108 int GL_CLIP_DISTANCE_NV = 0x8C7A;
109 int GL_VERTEX_ID_NV = 0x8C7B;
110 int GL_PRIMITIVE_ID_NV = 0x8C7C;
111 int GL_GENERIC_ATTRIB_NV = 0x8C7D;
112 int GL_LAYER_NV = 0x8DAA;
113
114 void glBindBufferRangeNV(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
115
116 void glBindBufferOffsetNV(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset);
117
118 void glBindBufferBaseNV(@GLenum int target, @GLuint int index, @GLuint int buffer);
119
120 void glTransformFeedbackAttribsNV(@AutoSize("attribs") @GLsizei int count, @Const IntBuffer attribs, @GLenum int bufferMode);
121
122 void glTransformFeedbackVaryingsNV(@GLuint int program, @AutoSize("locations") @GLsizei int count, @Const IntBuffer locations, @GLenum int bufferMode);
123
124 void glBeginTransformFeedbackNV(@GLenum int primitiveMode);
125
126 void glEndTransformFeedbackNV();
127
128 int glGetVaryingLocationNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
129
130 @Alternate("glGetVaryingLocationNV")
131 int glGetVaryingLocationNV(@GLuint int program, @NullTerminated CharSequence name);
132
133 void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
134 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
135 @OutParameter @GLsizei @Check("1") IntBuffer size,
136 @OutParameter @GLenum @Check("1") IntBuffer type,
137 @OutParameter @GLchar ByteBuffer name);
138
139 /** Overloads glGetActiveVaryingNV. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
140 @Alternate("glGetActiveVaryingNV")
141 @GLreturn(value = "name", maxLength = "bufSize")
142 void glGetActiveVaryingNV2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
143 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
144 @OutParameter @Check("2") IntBuffer sizeType,
145 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
146 @OutParameter @GLchar ByteBuffer name);
147
148 /** Overloads glGetActiveVaryingNV. This version returns only the varying name. */
149 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
150 @GLreturn(value = "name", maxLength = "bufSize")
151 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,
153 @OutParameter @GLchar ByteBuffer name);
154
155 /** Overloads glGetActiveVaryingNV. This version returns only the varying size. */
156 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
157 @GLreturn(value = "size")
158 void glGetActiveVaryingSizeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize,
159 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
160 @OutParameter IntBuffer size,
161 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
162 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
163
164 /** Overloads glGetActiveVaryingNV. This version returns only the varying type. */
165 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
166 @GLreturn(value = "type")
167 void glGetActiveVaryingTypeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize,
168 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
169 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
170 @OutParameter @GLenum IntBuffer type,
171 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
172
173 void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
174
175 @Alternate("glActiveVaryingNV")
176 void glActiveVaryingNV(@GLuint int program, @NullTerminated CharSequence name);
177
178 void glGetTransformFeedbackVaryingNV(@GLuint int program, @GLuint int index, @OutParameter @Check("1") IntBuffer location);
179
180 @Alternate("glGetTransformFeedbackVaryingNV")
181 @GLreturn("location")
182 void glGetTransformFeedbackVaryingNV2(@GLuint int program, @GLuint int index, @OutParameter IntBuffer location);
183
184 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.IntBuffer;
36
37 public interface NV_transform_feedback2 {
38
39 /** Accepted by the &lt;target&gt; parameter of BindTransformFeedbackNV: */
40
41 int GL_TRANSFORM_FEEDBACK_NV = 0x8E22;
42
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
45 * and GetFloatv:
46 */
47 int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV = 0x8E23;
48 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV = 0x8E24;
49 int GL_TRANSFORM_FEEDBACK_BINDING_NV = 0x8E25;
50
51 void glBindTransformFeedbackNV(@GLenum int target, @GLuint int id);
52
53 void glDeleteTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
54
55 @Alternate("glDeleteTransformFeedbacksNV")
56 void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
57
58 void glGenTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
59
60 @Alternate("glGenTransformFeedbacksNV")
61 @GLreturn("ids")
62 void glGenTransformFeedbacksNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
63
64 boolean glIsTransformFeedbackNV(@GLuint int id);
65
66 void glPauseTransformFeedbackNV();
67
68 void glResumeTransformFeedbackNV();
69
70 void glDrawTransformFeedbackNV(@GLenum int mode, @GLuint int id);
71
72 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_vertex_array_range {
38 int GL_VERTEX_ARRAY_RANGE_NV = 0x851D;
39 int GL_VERTEX_ARRAY_RANGE_LENGTH_NV = 0x851E;
40 int GL_VERTEX_ARRAY_RANGE_VALID_NV = 0x851F;
41 int GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV = 0x8520;
42 int GL_VERTEX_ARRAY_RANGE_POINTER_NV = 0x8521;
43
44 void glVertexArrayRangeNV(@AutoSize("pPointer") @GLsizei int size,
45 @Const
46 @GLbyte
47 @GLshort
48 @GLint
49 @GLfloat
50 @GLdouble Buffer pPointer);
51
52 void glFlushVertexArrayRangeNV();
53
54 @PlatformDependent({Platform.WGL, Platform.GLX})
55 @GLvoid
56 @AutoResultSize("size")
57 ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority);
58
59 @PlatformDependent({Platform.WGL, Platform.GLX})
60 void glFreeMemoryNV(@Check @GLbyte Buffer pointer);
61 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_vertex_array_range2 {
34 int GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV = 0x8533;
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.LongBuffer;
36
37 @Dependent
38 public interface NV_vertex_attrib_integer_64bit {
39
40 /**
41 * Accepted by the &lt;type&gt; parameter of VertexAttribLPointerEXT,
42 * VertexArrayVertexAttribLOffsetEXT, and VertexAttribLFormatNV:
43 */
44 int GL_INT64_NV = 0x140E;
45 int GL_UNSIGNED_INT64_NV = 0x140F;
46
47 void glVertexAttribL1i64NV(@GLuint int index, @GLint64EXT long x);
48
49 void glVertexAttribL2i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y);
50
51 void glVertexAttribL3i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z);
52
53 void glVertexAttribL4i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w);
54
55 @StripPostfix("v")
56 void glVertexAttribL1i64vNV(@GLuint int index, @Const @GLint64EXT @Check("1") LongBuffer v);
57
58 @StripPostfix("v")
59 void glVertexAttribL2i64vNV(@GLuint int index, @Const @GLint64EXT @Check("2") LongBuffer v);
60
61 @StripPostfix("v")
62 void glVertexAttribL3i64vNV(@GLuint int index, @Const @GLint64EXT @Check("3") LongBuffer v);
63
64 @StripPostfix("v")
65 void glVertexAttribL4i64vNV(@GLuint int index, @Const @GLint64EXT @Check("4") LongBuffer v);
66
67 void glVertexAttribL1ui64NV(@GLuint int index, @GLuint64EXT long x);
68
69 void glVertexAttribL2ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y);
70
71 void glVertexAttribL3ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z);
72
73 void glVertexAttribL4ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w);
74
75 @StripPostfix("v")
76 void glVertexAttribL1ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("1") LongBuffer v);
77
78 @StripPostfix("v")
79 void glVertexAttribL2ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("2") LongBuffer v);
80
81 @StripPostfix("v")
82 void glVertexAttribL3ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("3") LongBuffer v);
83
84 @StripPostfix("v")
85 void glVertexAttribL4ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("4") LongBuffer v);
86
87 @StripPostfix("params")
88 void glGetVertexAttribLi64vNV(@GLuint int index, @GLenum int pname, @OutParameter @GLint64EXT @Check("4") LongBuffer params);
89
90 @StripPostfix("params")
91 void glGetVertexAttribLui64vNV(@GLuint int index, @GLenum int pname, @OutParameter @GLuint64EXT @Check("4") LongBuffer params);
92
93 @Dependent("NV_vertex_buffer_unified_memory")
94 void glVertexAttribLFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride);
95
96 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.LongBuffer;
36
37 public interface NV_vertex_buffer_unified_memory {
38
39 /**
40 * Accepted by the &lt;cap&gt; parameter of DisableClientState,
41 * EnableClientState, IsEnabled:
42 */
43 int GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV = 0x8F1E;
44 int GL_ELEMENT_ARRAY_UNIFIED_NV = 0x8F1F;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of BufferAddressRangeNV
48 * and the &lt;value&gt; parameter of GetIntegerui64i_vNV:
49 */
50 int GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV = 0x8F20;
51 int GL_TEXTURE_COORD_ARRAY_ADDRESS_NV = 0x8F25;
52
53 /**
54 * Accepted by the &lt;pname&gt; parameter of BufferAddressRangeNV
55 * and the &lt;value&gt; parameter of GetIntegerui64vNV:
56 */
57 int GL_VERTEX_ARRAY_ADDRESS_NV = 0x8F21;
58 int GL_NORMAL_ARRAY_ADDRESS_NV = 0x8F22;
59 int GL_COLOR_ARRAY_ADDRESS_NV = 0x8F23;
60 int GL_INDEX_ARRAY_ADDRESS_NV = 0x8F24;
61 int GL_EDGE_FLAG_ARRAY_ADDRESS_NV = 0x8F26;
62 int GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV = 0x8F27;
63 int GL_FOG_COORD_ARRAY_ADDRESS_NV = 0x8F28;
64 int GL_ELEMENT_ARRAY_ADDRESS_NV = 0x8F29;
65
66 /** Accepted by the &lt;target&gt; parameter of GetIntegeri_vNV: */
67 int GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV = 0x8F2A;
68 int GL_TEXTURE_COORD_ARRAY_LENGTH_NV = 0x8F2F;
69
70 /** Accepted by the &lt;value&gt; parameter of GetIntegerv: */
71 int GL_VERTEX_ARRAY_LENGTH_NV = 0x8F2B;
72 int GL_NORMAL_ARRAY_LENGTH_NV = 0x8F2C;
73 int GL_COLOR_ARRAY_LENGTH_NV = 0x8F2D;
74 int GL_INDEX_ARRAY_LENGTH_NV = 0x8F2E;
75 int GL_EDGE_FLAG_ARRAY_LENGTH_NV = 0x8F30;
76 int GL_SECONDARY_COLOR_ARRAY_LENGTH_NV = 0x8F31;
77 int GL_FOG_COORD_ARRAY_LENGTH_NV = 0x8F32;
78 int GL_ELEMENT_ARRAY_LENGTH_NV = 0x8F33;
79
80 void glBufferAddressRangeNV(@GLenum int pname, @GLuint int index, @GLuint64EXT long address, @GLsizeiptr long length);
81
82 void glVertexFormatNV(int size, @GLenum int type, @GLsizei int stride);
83
84 void glNormalFormatNV(@GLenum int type, @GLsizei int stride);
85
86 void glColorFormatNV(int size, @GLenum int type, @GLsizei int stride);
87
88 void glIndexFormatNV(@GLenum int type, @GLsizei int stride);
89
90 void glTexCoordFormatNV(int size, @GLenum int type, @GLsizei int stride);
91
92 void glEdgeFlagFormatNV(@GLsizei int stride);
93
94 void glSecondaryColorFormatNV(int size, @GLenum int type, @GLsizei int stride);
95
96 void glFogCoordFormatNV(@GLenum int type, @GLsizei int stride);
97
98 void glVertexAttribFormatNV(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride);
99
100 void glVertexAttribIFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride);
101
102 @StripPostfix("result")
103 void glGetIntegerui64i_vNV(@GLenum int value, @GLuint int index, @OutParameter @Check("1") @GLuint64EXT LongBuffer result);
104
105 @Alternate("glGetIntegerui64i_vNV")
106 @GLreturn("result")
107 @StripPostfix("result")
108 void glGetIntegerui64i_vNV2(@GLenum int value, @GLuint int index, @OutParameter @GLuint64EXT LongBuffer result);
109
110 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 import java.nio.*;
36
37 public interface NV_vertex_program extends NV_program {
38
39 /**
40 Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled,
41 and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
42 and GetDoublev, and by the &lt;target&gt; parameter of BindProgramNV,
43 ExecuteProgramNV, GetProgramParameter[df]vNV, GetTrackMatrixivNV,
44 LoadProgramNV, ProgramParameter[s]4[df][v]NV, and TrackMatrixNV:
45 */
46 int GL_VERTEX_PROGRAM_NV = 0x8620;
47
48 /**
49 Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled,
50 and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
51 and GetDoublev:
52 */
53 int GL_VERTEX_PROGRAM_POINT_SIZE_NV = 0x8642;
54 int GL_VERTEX_PROGRAM_TWO_SIDE_NV = 0x8643;
55
56 /**
57 Accepted by the &lt;target&gt; parameter of ExecuteProgramNV and
58 LoadProgramNV:
59 */
60 int GL_VERTEX_STATE_PROGRAM_NV = 0x8621;
61
62 /**
63 Accepted by the &lt;pname&gt; parameter of GetVertexAttrib[dfi]vNV:
64 */
65 int GL_ATTRIB_ARRAY_SIZE_NV = 0x8623;
66 int GL_ATTRIB_ARRAY_STRIDE_NV = 0x8624;
67 int GL_ATTRIB_ARRAY_TYPE_NV = 0x8625;
68 int GL_CURRENT_ATTRIB_NV = 0x8626;
69
70 /**
71 Accepted by the &lt;pname&gt; parameter of GetProgramParameterfvNV
72 and GetProgramParameterdvNV:
73 */
74 int GL_PROGRAM_PARAMETER_NV = 0x8644;
75
76 /**
77 Accepted by the &lt;pname&gt; parameter of GetVertexAttribPointervNV:
78 */
79 int GL_ATTRIB_ARRAY_POINTER_NV = 0x8645;
80
81 /**
82 Accepted by the &lt;pname&gt; parameter of GetTrackMatrixivNV:
83 */
84 int GL_TRACK_MATRIX_NV = 0x8648;
85 int GL_TRACK_MATRIX_TRANSFORM_NV = 0x8649;
86
87 /**
88 Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
89 GetFloatv, and GetDoublev:
90 */
91 int GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = 0x862E;
92 int GL_MAX_TRACK_MATRICES_NV = 0x862F;
93 int GL_CURRENT_MATRIX_STACK_DEPTH_NV = 0x8640;
94 int GL_CURRENT_MATRIX_NV = 0x8641;
95 int GL_VERTEX_PROGRAM_BINDING_NV = 0x864A;
96
97 /**
98 Accepted by the &lt;matrix&gt; parameter of TrackMatrixNV:
99 */
100 int GL_MODELVIEW_PROJECTION_NV = 0x8629;
101
102 /**
103 Accepted by the &lt;matrix&gt; parameter of TrackMatrixNV and by the
104 &lt;mode&gt; parameter of MatrixMode:
105 */
106 int GL_MATRIX0_NV = 0x8630;
107 int GL_MATRIX1_NV = 0x8631;
108 int GL_MATRIX2_NV = 0x8632;
109 int GL_MATRIX3_NV = 0x8633;
110 int GL_MATRIX4_NV = 0x8634;
111 int GL_MATRIX5_NV = 0x8635;
112 int GL_MATRIX6_NV = 0x8636;
113 int GL_MATRIX7_NV = 0x8637;
114
115 /**
116 Accepted by the &lt;transform&gt; parameter of TrackMatrixNV:
117 */
118 int GL_IDENTITY_NV = 0x862A;
119 int GL_INVERSE_NV = 0x862B;
120 int GL_TRANSPOSE_NV = 0x862C;
121 int GL_INVERSE_TRANSPOSE_NV = 0x862D;
122
123 /**
124 Accepted by the &lt;array&gt; parameter of EnableClientState and
125 DisableClientState, by the &lt;cap&gt; parameter of IsEnabled, and by
126 the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv, and
127 GetDoublev:
128 */
129 int GL_VERTEX_ATTRIB_ARRAY0_NV = 0x8650;
130 int GL_VERTEX_ATTRIB_ARRAY1_NV = 0x8651;
131 int GL_VERTEX_ATTRIB_ARRAY2_NV = 0x8652;
132 int GL_VERTEX_ATTRIB_ARRAY3_NV = 0x8653;
133 int GL_VERTEX_ATTRIB_ARRAY4_NV = 0x8654;
134 int GL_VERTEX_ATTRIB_ARRAY5_NV = 0x8655;
135 int GL_VERTEX_ATTRIB_ARRAY6_NV = 0x8656;
136 int GL_VERTEX_ATTRIB_ARRAY7_NV = 0x8657;
137 int GL_VERTEX_ATTRIB_ARRAY8_NV = 0x8658;
138 int GL_VERTEX_ATTRIB_ARRAY9_NV = 0x8659;
139 int GL_VERTEX_ATTRIB_ARRAY10_NV = 0x865A;
140 int GL_VERTEX_ATTRIB_ARRAY11_NV = 0x865B;
141 int GL_VERTEX_ATTRIB_ARRAY12_NV = 0x865C;
142 int GL_VERTEX_ATTRIB_ARRAY13_NV = 0x865D;
143 int GL_VERTEX_ATTRIB_ARRAY14_NV = 0x865E;
144 int GL_VERTEX_ATTRIB_ARRAY15_NV = 0x865F;
145
146 /**
147 Accepted by the &lt;target&gt; parameter of GetMapdv, GetMapfv, GetMapiv,
148 Map1d and Map1f and by the &lt;cap&gt; parameter of Enable, Disable, and
149 IsEnabled, and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
150 GetFloatv, and GetDoublev:
151 */
152 int GL_MAP1_VERTEX_ATTRIB0_4_NV = 0x8660;
153 int GL_MAP1_VERTEX_ATTRIB1_4_NV = 0x8661;
154 int GL_MAP1_VERTEX_ATTRIB2_4_NV = 0x8662;
155 int GL_MAP1_VERTEX_ATTRIB3_4_NV = 0x8663;
156 int GL_MAP1_VERTEX_ATTRIB4_4_NV = 0x8664;
157 int GL_MAP1_VERTEX_ATTRIB5_4_NV = 0x8665;
158 int GL_MAP1_VERTEX_ATTRIB6_4_NV = 0x8666;
159 int GL_MAP1_VERTEX_ATTRIB7_4_NV = 0x8667;
160 int GL_MAP1_VERTEX_ATTRIB8_4_NV = 0x8668;
161 int GL_MAP1_VERTEX_ATTRIB9_4_NV = 0x8669;
162 int GL_MAP1_VERTEX_ATTRIB10_4_NV = 0x866A;
163 int GL_MAP1_VERTEX_ATTRIB11_4_NV = 0x866B;
164 int GL_MAP1_VERTEX_ATTRIB12_4_NV = 0x866C;
165 int GL_MAP1_VERTEX_ATTRIB13_4_NV = 0x866D;
166 int GL_MAP1_VERTEX_ATTRIB14_4_NV = 0x866E;
167 int GL_MAP1_VERTEX_ATTRIB15_4_NV = 0x866F;
168
169 /**
170 Accepted by the &lt;target&gt; parameter of GetMapdv, GetMapfv, GetMapiv,
171 Map2d and Map2f and by the &lt;cap&gt; parameter of Enable, Disable, and
172 IsEnabled, and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
173 GetFloatv, and GetDoublev:
174 */
175 int GL_MAP2_VERTEX_ATTRIB0_4_NV = 0x8670;
176 int GL_MAP2_VERTEX_ATTRIB1_4_NV = 0x8671;
177 int GL_MAP2_VERTEX_ATTRIB2_4_NV = 0x8672;
178 int GL_MAP2_VERTEX_ATTRIB3_4_NV = 0x8673;
179 int GL_MAP2_VERTEX_ATTRIB4_4_NV = 0x8674;
180 int GL_MAP2_VERTEX_ATTRIB5_4_NV = 0x8675;
181 int GL_MAP2_VERTEX_ATTRIB6_4_NV = 0x8676;
182 int GL_MAP2_VERTEX_ATTRIB7_4_NV = 0x8677;
183 int GL_MAP2_VERTEX_ATTRIB8_4_NV = 0x8678;
184 int GL_MAP2_VERTEX_ATTRIB9_4_NV = 0x8679;
185 int GL_MAP2_VERTEX_ATTRIB10_4_NV = 0x867A;
186 int GL_MAP2_VERTEX_ATTRIB11_4_NV = 0x867B;
187 int GL_MAP2_VERTEX_ATTRIB12_4_NV = 0x867C;
188 int GL_MAP2_VERTEX_ATTRIB13_4_NV = 0x867D;
189 int GL_MAP2_VERTEX_ATTRIB14_4_NV = 0x867E;
190 int GL_MAP2_VERTEX_ATTRIB15_4_NV = 0x867F;
191
192 void glExecuteProgramNV(@GLenum int target, @GLuint int id, @Check("4") @Const FloatBuffer params);
193
194 @StripPostfix("params")
195 void glGetProgramParameterfvNV(@GLenum int target, @GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") FloatBuffer params);
196
197 @StripPostfix("params")
198 void glGetProgramParameterdvNV(@GLenum int target, @GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") DoubleBuffer params);
199
200 @StripPostfix("params")
201 void glGetTrackMatrixivNV(@GLenum int target, @GLuint int address, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params);
202
203 @StripPostfix("params")
204 void glGetVertexAttribfvNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") FloatBuffer params);
205
206 @StripPostfix("params")
207 void glGetVertexAttribdvNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") DoubleBuffer params);
208
209 @StripPostfix("params")
210 void glGetVertexAttribivNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params);
211
212 @StripPostfix("pointer")
213 void glGetVertexAttribPointervNV(@GLuint int index, @GLenum int parameterName, @Result @GLvoid ByteBuffer pointer);
214
215 void glProgramParameter4fNV(@GLenum int target, @GLuint int index, float x, float y, float z, float w);
216
217 void glProgramParameter4dNV(@GLenum int target, @GLuint int index, double x, double y, double z, double w);
218
219 @StripPostfix("params")
220 void glProgramParameters4fvNV(@GLenum int target, @GLuint int index, @AutoSize(value = "params", expression = " >> 2") @GLuint int count,
221 @Const FloatBuffer params);
222
223 @StripPostfix("params")
224 void glProgramParameters4dvNV(@GLenum int target, @GLuint int index, @AutoSize(value = "params", expression = " >> 2") @GLuint int count,
225 @Const DoubleBuffer params);
226
227 void glTrackMatrixNV(@GLenum int target, @GLuint int address, @GLenum int matrix, @GLenum int transform);
228
229 void glVertexAttribPointerNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
230 @CachedReference(index="index",name="glVertexAttribPointer_buffer")
231 @BufferObject(BufferKind.ArrayVBO)
232 @Check
233 @Const
234 @GLbyte
235 @GLubyte
236 @GLshort
237 @GLushort
238 @GLint
239 @GLuint
240 @GLfloat
241 @GLdouble Buffer buffer);
242
243 @NoErrorCheck
244 void glVertexAttrib1sNV(@GLuint int index, short x);
245
246 @NoErrorCheck
247 void glVertexAttrib1fNV(@GLuint int index, float x);
248
249 @NoErrorCheck
250 void glVertexAttrib1dNV(@GLuint int index, double x);
251
252 @NoErrorCheck
253 void glVertexAttrib2sNV(@GLuint int index, short x, short y);
254
255 @NoErrorCheck
256 void glVertexAttrib2fNV(@GLuint int index, float x, float y);
257
258 @NoErrorCheck
259 void glVertexAttrib2dNV(@GLuint int index, double x, double y);
260
261 @NoErrorCheck
262 void glVertexAttrib3sNV(@GLuint int index, short x, short y, short z);
263
264 @NoErrorCheck
265 void glVertexAttrib3fNV(@GLuint int index, float x, float y, float z);
266
267 @NoErrorCheck
268 void glVertexAttrib3dNV(@GLuint int index, double x, double y, double z);
269
270 @NoErrorCheck
271 void glVertexAttrib4sNV(@GLuint int index, short x, short y, short z, short w);
272
273 @NoErrorCheck
274 void glVertexAttrib4fNV(@GLuint int index, float x, float y, float z, float w);
275
276 @NoErrorCheck
277 void glVertexAttrib4dNV(@GLuint int index, double x, double y, double z, double w);
278
279 @NoErrorCheck
280 void glVertexAttrib4ubNV(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
281
282 @NoErrorCheck
283 @StripPostfix("v")
284 void glVertexAttribs1svNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const ShortBuffer v);
285
286 @NoErrorCheck
287 @StripPostfix("v")
288 void glVertexAttribs1fvNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const FloatBuffer v);
289
290 @NoErrorCheck
291 @StripPostfix("v")
292 void glVertexAttribs1dvNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const DoubleBuffer v);
293
294 @NoErrorCheck
295 @StripPostfix("v")
296 void glVertexAttribs2svNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const ShortBuffer v);
297
298 @NoErrorCheck
299 @StripPostfix("v")
300 void glVertexAttribs2fvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const FloatBuffer v);
301
302 @NoErrorCheck
303 @StripPostfix("v")
304 void glVertexAttribs2dvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const DoubleBuffer v);
305
306 @NoErrorCheck
307 @StripPostfix("v")
308 void glVertexAttribs3svNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const ShortBuffer v);
309
310 @NoErrorCheck
311 @StripPostfix("v")
312 void glVertexAttribs3fvNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const FloatBuffer v);
313
314 @NoErrorCheck
315 @StripPostfix("v")
316 void glVertexAttribs3dvNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const DoubleBuffer v);
317
318 @NoErrorCheck
319 @StripPostfix("v")
320 void glVertexAttribs4svNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const ShortBuffer v);
321
322 @NoErrorCheck
323 @StripPostfix("v")
324 void glVertexAttribs4fvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const FloatBuffer v);
325
326 @NoErrorCheck
327 @StripPostfix("v")
328 void glVertexAttribs4dvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const DoubleBuffer v);
329 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface NV_vertex_program1_1 {
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 NV_vertex_program2 {
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 NV_vertex_program2_option {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetProgramivARB:
37 */
38 int GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = 0x88F4;
39 int GL_MAX_PROGRAM_CALL_DEPTH_NV = 0x88F5;
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 package org.lwjgl.opengl;
32
33 public interface NV_vertex_program3 {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
37 * GetFloatv, and GetDoublev:
38 */
39 int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C;
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 package org.lwjgl.opengl;
32
33 public interface NV_vertex_program4 {
34
35 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 public interface SGIS_generate_mipmap {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameter of TexParameteri, TexParameterf,
39 * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv.
40 */
41 int GL_GENERATE_MIPMAP_SGIS = 0x8191;
42
43 /**
44 * Accepted by the &lt;target&gt; parameter of Hint, and by the <pname>
45 * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.
46 */
47 int GL_GENERATE_MIPMAP_HINT_SGIS = 0x8192;
48
49 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34
35 @Extension(postfix = "SGIS", className = "SGISTextureLOD")
36 public interface SGIS_texture_lod {
37
38 /**
39 * Accepted by the &lt;pname&gt; parameter of TexParameteri, TexParameterf,
40 * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv.
41 */
42 int GL_TEXTURE_MIN_LOD_SGIS = 0x813A;
43 int GL_TEXTURE_MAX_LOD_SGIS = 0x813B;
44 int GL_TEXTURE_BASE_LEVEL_SGIS = 0x813C;
45 int GL_TEXTURE_MAX_LEVEL_SGIS = 0x813D;
46 }
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 SUN_slice_accum {
34
35 /**
36 * Accepted by the &lt;op&gt; parameter of Accum,
37 */
38 int GL_SLICE_ACCUM_SUN = 0x85CC;
39
40 }