Codebase list lwjgl / bb94ccf
Imported Upstream version 2.9.3+dfsg Markus Koschany 8 years ago
839 changed file(s) with 66274 addition(s) and 12368 deletion(s). Raw diff Collapse all Expand all
66 <import file="platform_build/build-applet.xml"/>
77 <import file="platform_build/build-webstart.xml"/>
88 <import file="platform_build/build-maven.xml"/>
9 <import file="eclipse-update/org.lwjgl.build/build-updatesite.xml"/>
910
1011 <!-- ================================================================== -->
11 <!-- Everything below this line is targets. -->
12 <!-- Do not modify, unless you know what you're doing -->
12 <!-- Everything below this line is targets. -->
13 <!-- Do not modify, unless you know what you're doing -->
1314 <!-- ================================================================== -->
1415
1516 <!-- ================================================================== -->
16 <!-- Initialize build -->
17 <!-- Initialize build -->
1718 <!-- ================================================================== -->
1819 <target name="-initialize">
1920 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
2021 <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing native bin folder" />
22 <mkdir dir="${lwjgl.bin}/lwjgles" taskname="initialiazing native OpenGL ES bin folder"/>
2123 <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" />
2224 <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" />
2325 <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" />
2931 <mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
3032 <mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
3133 <mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
34 <mkdir dir="${lwjgl.temp}/native/freebsd" taskname="initialiazing temp/freebsd folder" />
35 <mkdir dir="${lwjgl.temp}/native/openbsd" taskname="initialiazing temp/openbsd folder" />
3236 <mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
3337 <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
3438 </target>
4751 <!-- Useful when we need to force native recompilation -->
4852 <target name="clean-native" description="Cleans native files generated by this ant script" depends="clean-generated-native">
4953 <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" />
54 <delete dir="${lwjgl.bin}/lwjgles" quiet="true" failonerror="false" taskname="cleaning native OpenGL ES bin folder"/>
5055 </target>
5156
5257 <!-- Creates a distribution of LWJGL -->
5358 <target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
5459 <!-- Warn user -->
55 <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"/>
60 <echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux, ${lwjgl.lib}/freebsd and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
5661 <input
5762 message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
5863 validargs="yes,no"
110115 <antcall target="-jars_NoDEP" />
111116 </target>
112117
118 <!-- Create ONLY the jar archives for the ES build -->
119 <target name="jars_es" description="Creates the Java archives ONLY for the ES build and places them in libs/"
120 depends="-initialize, generate-all, compile, -createjars_es">
121 <antcall target="-jars_NoDEP"/>
122 </target>
123
113124 <target name="-jars_NoDEP">
114125 <move todir="libs/">
115126 <fileset dir="${lwjgl.temp}/jar">
123134 <!-- Create lwjgl.jar -->
124135 <jar destfile="${lwjgl.temp}/jar/lwjgl-debug.jar" taskname="lwjgl-debug.jar">
125136 <fileset refid="lwjgl.fileset" />
137 <fileset refid="lwjgl.fileset.dependencies"/>
126138 <manifest>
127139 <attribute name="Sealed" value="true"/>
128140 </manifest>
134146 <!-- Create lwjgl.jar -->
135147 <jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar">
136148 <fileset refid="lwjgl.fileset" />
149 <fileset refid="lwjgl.fileset.dependencies"/>
137150 <manifest>
138151 <attribute name="Sealed" value="true"/>
139152 </manifest>
145158 <fileset refid="lwjgl_util_applet.fileset" />
146159 <manifest>
147160 <attribute name="Sealed" value="true"/>
161 <attribute name="Trusted-Library" value="true"/>
162 <attribute name="Permissions" value="all-permissions"/>
163 <attribute name="Codebase" value="*"/>
164 <attribute name="Caller-Allowable-Codebase" value="*"/>
165 <attribute name="Application-Library-Allowable-Codebase" value="*"/>
148166 </manifest>
149167 </jar>
150168
160178 </jar>
161179 </target>
162180
181 <!-- Packages the java files for the ES build -->
182 <target name="-createjars_es">
183 <!-- ================================================================== -->
184 <!-- Generate a list of the OpenGL extension classes -->
185 <!-- ================================================================== -->
186 <fileset id="opengl-template-fileset" dir="${lwjgl.src}/generated/org/lwjgl/opengl" includes="${opengl-template-pattern}"/>
187 <property name="opengl-template-files" refid="opengl-template-fileset"/>
188
189 <tempfile property="temp.file"/>
190 <echo file="${temp.file}" message="${opengl-template-files}" taskname=""/>
191
192 <loadfile srcfile="${temp.file}" property="opengl-template-classes">
193 <filterchain>
194 <tokenfilter delimoutput=",">
195 <stringtokenizer delims=";"/>
196 <replaceregex pattern="(.+)[.]java"
197 replace="org/lwjgl/opengl/\1.class"/>
198 </tokenfilter>
199 </filterchain>
200 </loadfile>
201
202 <delete file="${temp.file}" />
203
204 <!-- Create lwjgl.jar -->
205 <jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar">
206 <!-- Files to include in the lwjgl.jar file, for the ES build -->
207 <fileset dir="${lwjgl.bin}" excludes="${opengl-template-classes}">
208 <patternset id="lwjgl_es.package.pattern">
209 <include name="org/**/*"/>
210 <exclude name="org/lwjgl/d3d/**"/>
211 <exclude name="org/lwjgl/test/**"/>
212 <exclude name="org/lwjgl/util/**"/>
213 <exclude name="org/lwjgl/examples/**"/>
214 </patternset>
215 </fileset>
216
217 <manifest>
218 <attribute name="Sealed" value="true"/>
219 </manifest>
220 </jar>
221
222 <!-- Create lwjgl_test.jar -->
223 <jar destfile="${lwjgl.temp}/jar/lwjgl_test.jar" taskname="lwjgl_test.jar">
224 <fileset refid="lwjgl_test_es.fileset"/>
225 </jar>
226 </target>
227
163228 <!-- Distributes files -->
164229 <target name="-distribute">
165230 <delete>
177242 <copy todir="${lwjgl.temp}/native/linux">
178243 <fileset dir="${lwjgl.lib}/linux">
179244 <patternset refid="lwjgl-linux.fileset" />
245 </fileset>
246 </copy>
247 <copy todir="${lwjgl.temp}/native/freebsd" failonerror="false">
248 <fileset dir="${lwjgl.lib}/freebsd">
249 <patternset refid="lwjgl-freebsd.fileset" />
250 </fileset>
251 </copy>
252 <copy todir="${lwjgl.temp}/native/openbsd" failonerror="false">
253 <fileset dir="${lwjgl.lib}/openbsd">
254 <patternset refid="lwjgl-openbsd.fileset" />
180255 </fileset>
181256 </copy>
182257 <copy todir="${lwjgl.temp}/native/macosx">
219294
220295 <!-- Generates the native headers from source files -->
221296 <target name="headers" description="invokes javah on java classes" depends="compile">
222 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
297 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux">
223298 <class name="org.lwjgl.LinuxSysImplementation" />
224299 <class name="org.lwjgl.opengl.LinuxEvent" />
225300 <class name="org.lwjgl.opengl.LinuxMouse" />
226301 <class name="org.lwjgl.opengl.LinuxKeyboard" />
227302 <class name="org.lwjgl.opengl.LinuxDisplay" />
228303 <class name="org.lwjgl.opengl.LinuxPeerInfo" />
229 <class name="org.lwjgl.opengl.LinuxPbufferPeerInfo" />
230 <class name="org.lwjgl.opengl.LinuxDisplayPeerInfo" />
231 <class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo" />
232 <class name="org.lwjgl.opengl.LinuxContextImplementation" />
233 <class name="org.lwjgl.opengl.LinuxCanvasImplementation" />
234 </javah>
235
236 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
304 </javah>
305
306 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl">
307 <class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/>
308 <class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/>
309 <class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/>
310 <class name="org.lwjgl.opengl.LinuxContextImplementation"/>
311 <class name="org.lwjgl.opengl.LinuxCanvasImplementation"/>
312 </javah>
313
314 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows">
315 <class name="org.lwjgl.WindowsSysImplementation"/>
237316 <class name="org.lwjgl.opengl.WindowsKeyboard" />
238 <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" />
239 <class name="org.lwjgl.opengl.WindowsDisplay" />
240317 <class name="org.lwjgl.opengl.WindowsRegistry" />
241 <class name="org.lwjgl.WindowsSysImplementation" />
242 <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo" />
243 <class name="org.lwjgl.opengl.WindowsPeerInfo" />
244 <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" />
245 <class name="org.lwjgl.opengl.WindowsContextImplementation" />
246 </javah>
247
248 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
318 <class name="org.lwjgl.opengl.WindowsDisplay"/>
319 <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo"/>
320 <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/>
321 </javah>
322
323 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl">
324 <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
325 <class name="org.lwjgl.opengl.WindowsPeerInfo"/>
326 <class name="org.lwjgl.opengl.WindowsContextImplementation"/>
327 </javah>
328
329 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles">
330 <class name="org.lwjgl.opengl.WindowsPeerInfo"/>
331 </javah>
332
333 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx">
249334 <class name="org.lwjgl.MacOSXSysImplementation" />
250 <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
251335 <class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
252336 <class name="org.lwjgl.opengl.MacOSXPeerInfo" />
253337 <class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" />
254338 <class name="org.lwjgl.opengl.MacOSXDisplay" />
255339 <class name="org.lwjgl.opengl.MacOSXContextImplementation" />
256 </javah>
257
258 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
340 <class name="org.lwjgl.opengl.MacOSXNativeKeyboard" />
341 <class name="org.lwjgl.opengl.MacOSXNativeMouse" />
342 <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
343 </javah>
344
345 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}">
259346 <class name="org.lwjgl.opengl.AWTSurfaceLock" />
260347 <class name="org.lwjgl.DefaultSysImplementation" />
261348 <class name="org.lwjgl.input.Cursor" />
262349 <class name="org.lwjgl.input.Keyboard" />
263350 <class name="org.lwjgl.input.Mouse" />
264351 <class name="org.lwjgl.openal.AL" />
265 <class name="org.lwjgl.opengl.GLContext" />
266 <class name="org.lwjgl.opengl.Pbuffer" />
267 <class name="org.lwjgl.opengl.CallbackUtil" />
268 <class name="org.lwjgl.opencl.CL" />
352 <class name="org.lwjgl.opencl.CL" />
269353 <class name="org.lwjgl.opencl.CallbackUtil" />
270 <class name="org.lwjgl.BufferUtils" />
354 <class name="org.lwjgl.BufferUtils" />
355 </javah>
356
357 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengl">
358 <class name="org.lwjgl.opengl.GLContext"/>
359 <class name="org.lwjgl.opengl.Pbuffer"/>
360 <class name="org.lwjgl.opengl.CallbackUtil"/>
361 <class name="org.lwjgl.opengl.NVPresentVideoUtil"/>
362 <class name="org.lwjgl.opengl.NVVideoCaptureUtil"/>
363 </javah>
364
365 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles">
366 <class name="org.lwjgl.opengles.EGL"/>
367 <class name="org.lwjgl.opengles.EGLKHRFenceSync"/>
368 <class name="org.lwjgl.opengles.EGLKHRReusableSync"/>
369 <class name="org.lwjgl.opengles.EGLNVSync"/>
370 <class name="org.lwjgl.opengles.GLContext"/>
371 <class name="org.lwjgl.opengles.CallbackUtil"/>
271372 </javah>
272373 </target>
273374
325426 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
326427 lwjgl.java.linux.version = ${lwjgl.java.linux.version}
327428 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
429 lwjgl.java.freebsd.version = ${lwjgl.java.linux.version}
430 lwjgl.native.freebsd.version = ${lwjgl.native.linux.version}
431 lwjgl.java.openbsd.version = ${lwjgl.java.linux.version}
432 lwjgl.native.openbsd.version = ${lwjgl.native.linux.version}
328433 lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
329434 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
330435 </echo>
356461
357462 <!-- Compiles the Java source code -->
358463 <target name="compile" description="Compiles the java source code" depends="-initialize">
359 <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
464 <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
360465 <!--<compilerarg value="-Xlint:unchecked"/>-->
361466 <src path="${lwjgl.src}/java/"/>
362467 <src path="${lwjgl.src}/generated/"/>
363468 <include name="org/lwjgl/*.java"/>
364469 <include name="org/lwjgl/input/**"/>
365470 <include name="org/lwjgl/opengl/**"/>
471 <include name="org/lwjgl/opengles/**"/>
366472 <include name="org/lwjgl/openal/**"/>
367473 <include name="org/lwjgl/opencl/**"/>
368474 <include name="org/lwjgl/util/**"/>
383489 </condition>
384490 <antcall target="-compile_native_linux" />
385491
492 <condition property="lwjgl.platform.freebsd">
493 <os name="FreeBSD" />
494 </condition>
495 <antcall target="-compile_native_freebsd" />
496
497 <condition property="lwjgl.platform.openbsd">
498 <os name="OpenBSD" />
499 </condition>
500 <antcall target="-compile_native_openbsd" />
501
386502 <condition property="lwjgl.platform.solaris">
387503 <os name="SunOS" />
388504 </condition>
411527 </copy>
412528 <!-- headless issues <version-check platform="linux"/> -->
413529 </target>
530
531 <!-- Compiles LWJGL on FreeBSD platforms -->
532 <target name="-compile_native_freebsd" if="lwjgl.platform.freebsd">
533 <ant antfile="platform_build/bsd_ant/build.xml" inheritAll="false"/>
534 <copy todir="${lwjgl.lib}/freebsd">
535 <fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
536 </copy>
537 </target>
538
539 <!-- Compiles LWJGL on OpenBSD platforms -->
540 <target name="-compile_native_openbsd" if="lwjgl.platform.openbsd">
541 <ant antfile="platform_build/bsd_ant/build.xml" inheritAll="false"/>
542 <copy todir="${lwjgl.lib}/openbsd">
543 <fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
544 </copy>
545 </target>
546
414547
415548 <!-- Compiles LWJGL on solaris platforms -->
416549 <target name="-compile_native_solaris" if="lwjgl.platform.solaris">
425558 <!-- Compiles LWJGL on Mac platforms -->
426559 <target name="-compile_native_macosx" if="lwjgl.platform.macosx">
427560 <ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/>
428 <copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
561 <copy file="${lwjgl.bin}/lwjgl/liblwjgl.dylib" todir="${lwjgl.lib}/macosx"/>
429562 <version-check platform="macosx"/>
563 </target>
564
565 <target name="compile_native_es" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
566 <condition property="lwjgl.platform.windows">
567 <os family="windows"/>
568 </condition>
569 <antcall target="-compile_native_win32_es"/>
570
571 <condition property="lwjgl.platform.linux">
572 <os name="Linux"/>
573 </condition>
574 <antcall target="-compile_native_linux_es"/>
575 </target>
576
577 <!-- Compiles LWJGL ES on Win32 platforms -->
578 <target name="-compile_native_win32_es" if="lwjgl.platform.windows">
579 <ant antfile="platform_build/windows_ant/build_es.xml" inheritAll="false"/>
580 <copy todir="${lwjgl.lib}/windows">
581 <fileset dir="${lwjgl.bin}/lwjgles" includes="lwjgl*.dll"/>
582 </copy>
583 </target>
584
585 <!-- Compiles LWJGL ES on Linux platforms -->
586 <target name="-compile_native_linux_es" if="lwjgl.platform.linux">
587 <ant antfile="platform_build/linux_ant/build_es.xml" inheritAll="false"/>
588 <copy todir="${lwjgl.lib}/linux">
589 <fileset dir="${lwjgl.bin}/lwjgles" includes="liblwjgl*.so"/>
590 </copy>
430591 </target>
431592
432593 <target name="repack200" description="Pack200-repack a jar file">
515676 <bottom><![CDATA[<i>Copyright &#169; 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
516677 </javadoc>
517678 </target>
679
680 <!-- get and copy nightly binaries into libs folder -->
681 <target name="copy-nightly-binaries" depends="-initialize" description="Copies latest successful nightly binaries into appropriate libs folder">
682 <delete file="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" failonerror="false"/>
683 <get src="http://ci.newdawnsoftware.com/job/LWJGL-git-dist/lastBuild/artifact/dist/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}" verbose="true"/>
684 <unzip src="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.lib}" overwrite="true">
685 <patternset>
686 <include name="**/native/**/*lwjgl*"/>
687 </patternset>
688 <globmapper from="lwjgl-${lwjgl.version}/native/*" to="*"/>
689 </unzip>
690 </target>
518691 </project>
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, bsd" 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/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib/i386 -ljawt" />
7 <property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib/amd64 -ljawt" />
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 <and>
46 <os name="FreeBSD"/>
47 <equals arg1="${hwplatform}" arg2="i386"/>
48 </and>
49 </condition>
50
51 <condition property="build.32bit.only">
52 <and>
53 <os name="OpenBSD"/>
54 <equals arg1="${hwplatform}" arg2="i386"/>
55 </and>
56 </condition>
57
58 <!-- On freebsd, the 64 bit jre doesn't have the 32 bit libs -->
59 <condition property="build.64bit.only">
60 <and>
61 <os name="FreeBSD"/>
62 <equals arg1="${hwplatform}" arg2="amd64"/>
63 </and>
64 </condition>
65
66 <condition property="build.64bit.only">
67 <and>
68 <os name="OpenBSD"/>
69 <equals arg1="${hwplatform}" arg2="amd64"/>
70 </and>
71 </condition>
72
73 <antcall target="compile32"/>
74 <antcall target="compile64"/>
75 </target>
76
77 <target name="compile32" unless="build.64bit.only">
78 <mkdir dir="x32"/>
79 <apply dir="x32" executable="cc" skipemptyfilesets="true" failonerror="true">
80 <arg line="${cflags32} ${cflags_pthread}"/>
81 <arg value="-I${java.home}/include"/>
82 <arg value="-I${java.home}/include/freebsd"/>
83 <arg value="-I${java.home}/include/openbsd"/>
84 <arg value="-I${java.home}/../include"/>
85 <arg value="-I${java.home}/../include/freebsd"/>
86 <arg value="-I${java.home}/../include/openbsd"/>
87 <arg value="-I/usr/local/include"/>
88 <arg value="-I/usr/X11R6/include"/>
89 <arg value="-I${native}/common"/>
90 <arg value="-I${native}/common/opengl"/>
91 <arg value="-I${native}/linux"/>
92 <arg value="-I${native}/linux/opengl"/>
93 <mapper type="glob" from="*.c" to="*.o"/>
94 <fileset dir="${native}/common" includes="*.c"/>
95 <fileset dir="${native}/common/opengl" includes="*.c"/>
96 <fileset dir="${native}/generated/openal" includes="*.c"/>
97 <fileset dir="${native}/generated/opencl" includes="*.c"/>
98 <fileset dir="${native}/generated/opengl" includes="*.c"/>
99 <fileset dir="${native}/linux" includes="*.c"/>
100 <fileset dir="${native}/linux/opengl" includes="*.c"/>
101 </apply>
102 <apply dir="." parallel="true" executable="cc" failonerror="true">
103 <srcfile/>
104 <arg line="${linker_flags32}"/>
105 <fileset dir="x32" includes="*.o"/>
106 </apply>
107 <apply dir="." parallel="true" executable="strip" failonerror="true">
108 <fileset file="${libname32}"/>
109 </apply>
110 </target>
111
112 <target name="compile64" unless="build.32bit.only">
113 <mkdir dir="x64"/>
114 <apply dir="x64" executable="cc" skipemptyfilesets="true" failonerror="true">
115 <arg line="${cflags64} ${cflags_pthread}"/>
116 <arg value="-I${java.home}/include"/>
117 <arg value="-I${java.home}/include/freebsd"/>
118 <arg value="-I${java.home}/include/openbsd"/>
119 <arg value="-I${java.home}/../include"/>
120 <arg value="-I${java.home}/../include/freebsd"/>
121 <arg value="-I${java.home}/../include/openbsd"/>
122 <arg value="-I/usr/local/include"/>
123 <arg value="-I/usr/X11R6/include"/>
124 <arg value="-I${native}/common"/>
125 <arg value="-I${native}/common/opengl"/>
126 <arg value="-I${native}/linux"/>
127 <arg value="-I${native}/linux/opengl"/>
128 <mapper type="glob" from="*.c" to="*.o"/>
129 <fileset dir="${native}/common" includes="*.c"/>
130 <fileset dir="${native}/common/opengl" includes="*.c"/>
131 <fileset dir="${native}/generated/openal" includes="*.c"/>
132 <fileset dir="${native}/generated/opencl" includes="*.c"/>
133 <fileset dir="${native}/generated/opengl" includes="*.c"/>
134 <fileset dir="${native}/linux" includes="*.c"/>
135 <fileset dir="${native}/linux/opengl" includes="*.c"/>
136 </apply>
137 <apply dir="." parallel="true" executable="cc" failonerror="true">
138 <srcfile/>
139 <arg line="${linker_flags64}"/>
140 <fileset dir="x64" includes="*.o"/>
141 </apply>
142 <apply dir="." parallel="true" executable="strip" failonerror="true">
143 <fileset file="${libname64}"/>
144 </apply>
145 </target>
146 </project>
1111 <property name="lwjgl.docs" location="doc" />
1212 <property name="lwjgl.temp" location="temp" />
1313 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.7.1" />
14 <property name="lwjgl.version" value="2.9.3" />
1515 <property name="lwjgl.web" location="www" />
1616
17 <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/>
18 <property name="opencl-template-pattern-extensions" value="org/lwjgl/opencl/KHR*.java,org/lwjgl/opencl/EXT*.java,org/lwjgl/opencl/APPLE*.java,org/lwjgl/opencl/AMD*.java,org/lwjgl/opencl/NV*.java"/>
19 <property name="opencl-template-pattern" value="org/lwjgl/opencl/CL*.java,${opencl-template-pattern-extensions}"/>
17 <property name="lwjgl.src.templates.al" location="${lwjgl.src.templates}/org/lwjgl/openal"/>
18 <property name="lwjgl.src.templates.gl" location="${lwjgl.src.templates}/org/lwjgl/opengl"/>
19 <property name="lwjgl.src.templates.gles" location="${lwjgl.src.templates}/org/lwjgl/opengles"/>
20 <property name="lwjgl.src.templates.cl" location="${lwjgl.src.templates}/org/lwjgl/opencl"/>
21
22 <property name="openal-template-pattern" value="AL*.java,EFX*.java"/>
23 <property name="opengl-template-pattern" value="GL*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,APPLE*.java,ATI*.java,NV*.java,NVX*.java,HP*.java,IBM*.java,SUN*.java,SGIS*.java,GREMEDY*.java,INTEL*.java"/>
24 <property name="opengles-template-pattern" value="GLES*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,ANGLE*.java,APPLE*.java,ARM*.java,DMP*.java,IMG*.java,NV*.java,OES*.java,QCOM*.java,VIV*.java"/>
25 <property name="opencl-template-pattern-extensions" value="KHR*.java,EXT*.java,APPLE*.java,AMD*.java,INTEL*.java,NV*.java"/>
26 <property name="opencl-template-pattern" value="CL*.java,${opencl-template-pattern-extensions}"/>
2027
2128 <!-- ================================================================== -->
2229 <!-- Filesets used for targets -->
2633 <fileset id="lwjgl.fileset" dir="${lwjgl.bin}">
2734 <patternset id="lwjgl.package.pattern">
2835 <include name="org/**/*" />
36 <exclude name="org/lwjgl/opengles/**"/>
2937 <exclude name="org/lwjgl/d3d/**" />
3038 <exclude name="org/lwjgl/test/**" />
3139 <exclude name="org/lwjgl/util/**" />
3240 <exclude name="org/lwjgl/examples/**" />
3341 </patternset>
3442 </fileset>
35
43 <fileset id="lwjgl.fileset.dependencies" dir="${lwjgl.bin}">
44 <patternset id="lwjgl.package.dependencies.pattern">
45 <include name="org/lwjgl/opengles/ContextAttribs*.*"/>
46 </patternset>
47 </fileset>
48
3649 <!-- Files to include in the lwjgl_util_applet.jar file -->
3750 <fileset id="lwjgl_util_applet.fileset" dir="${lwjgl.bin}">
3851 <patternset id="lwjgl_util_applet.package.pattern">
4558 <fileset id="lwjgl_test.fileset" dir="${lwjgl.bin}">
4659 <exclude name="**.*" />
4760 <include name="org/lwjgl/test/**" />
61 <exclude name="org/lwjgl/test/opengles/**"/>
4862 <include name="org/lwjgl/examples/**" />
4963 </fileset>
5064
5872 <include name="org/lwjgl/test/opencl/gl/*.cl" />
5973 </fileset>
6074
75 <!-- Files to include in the lwjgl_test.jar file for the ES build -->
76 <fileset id="lwjgl_test_es.fileset" dir="${lwjgl.bin}">
77 <exclude name="**.*"/>
78 <include name="org/lwjgl/test/**"/>
79 <exclude name="org/lwjgl/test/opengl/**"/>
80 <exclude name="org/lwjgl/test/*.*"/>
81 </fileset>
82
6183 <!-- Files to include in the lwjgl_util.jar file -->
6284 <fileset id="lwjgl_util.fileset" dir="${lwjgl.bin}">
6385 <patternset id="lwjgl_util.package.pattern">
6789 <include name="org/lwjgl/util/**" />
6890 </patternset>
6991 </fileset>
70
92
7193
7294 <!-- Files to include in the lwjgl_applet.jar file -->
7395 <fileset id="lwjgl_applet.fileset" dir="${lwjgl.bin}">
115137 <include name="liblwjgl*.so" />
116138 <include name="libopenal*.so" />
117139 </patternset>
118 <patternset id="lwjgl-linux-jinput.fileset">
140 <patternset id="lwjgl-linux-jinput.fileset">
119141 <include name="libjinput-linux.so" />
120142 <include name="libjinput-linux64.so" />
121143 </patternset>
124146 <!-- Files to include in mac os x package -->
125147 <patternset id="lwjgl-macosx.fileset">
126148 <patternset id="lwjgl-macosx-lwjgl.fileset">
127 <include name="liblwjgl.jnilib" />
149 <include name="liblwjgl.dylib" />
128150 <include name="openal.dylib" />
129151 </patternset>
130152 <patternset id="lwjgl-macosx-jinput.fileset">
131 <include name="libjinput-osx.jnilib" />
132 <include name="libjinput-osx-legacy.jnilib" />
153 <include name="libjinput-osx.dylib" />
154 <include name="libjinput-osx-legacy.dylib" />
133155 </patternset>
134156 </patternset>
135157
00 <project name="generator">
1
2 <import file="build-definitions.xml"/>
13
24 <!-- clean the generated files -->
35 <target name="clean-generated" description="Deletes the generated java source">
1315 </target>
1416
1517 <!-- Compiles the Java generator source code -->
16 <target name="generators" description="Compiles the native method generators">
17 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
18 <target name="generators" description="Compiles the native method generators">
19 <mkdir dir="${lwjgl.src}/generated/"/>
20 <mkdir dir="${lwjgl.src.native}/generated/openal"/>
21 <mkdir dir="${lwjgl.src.native}/generated/opengl"/>
22 <mkdir dir="${lwjgl.src.native}/generated/opengles"/>
23 <mkdir dir="${lwjgl.src.native}/generated/opencl"/>
24
25 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.6" target="1.6" includes="org/lwjgl/util/generator/**.java" taskname="generator">
1826 <include name="org/lwjgl/util/generator/openal/**.java"/>
1927 <include name="org/lwjgl/util/generator/opengl/**.java"/>
28 <include name="org/lwjgl/util/generator/opengles/**.java"/>
2029 <include name="org/lwjgl/util/generator/opencl/**.java"/>
21 <compilerarg value="-Xlint:all"/>
30 <compilerarg value="-Xlint:none"/>
2231 </javac>
23 <!-- Compile helper classes used by the templates -->
24 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
32
33 <!-- Compile helper classes used by the templates -->
34 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
2535 <include name="org/lwjgl/PointerWrapper.java"/>
2636 <include name="org/lwjgl/PointerBuffer.java"/>
2737 <!-- OpenGL -->
2838 <include name="org/lwjgl/opengl/GLSync.java"/>
2939 <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
3040 <include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
41 <include name="org/lwjgl/opengl/KHRDebugCallback.java"/>
42 <!-- OpenGL ES -->
43 <include name="org/lwjgl/opengles/EGLImageOES.java"/>
44 <include name="org/lwjgl/opengles/KHRDebugCallback.java"/>
3145 <!-- OpenCL -->
3246 <include name="org/lwjgl/opencl/CLPlatform.java"/>
3347 <include name="org/lwjgl/opencl/CLDevice.java"/>
3448 <include name="org/lwjgl/opencl/CLContext.java"/>
35 <include name="org/lwjgl/opencl/CLContextCallback.java"/>
3649 <include name="org/lwjgl/opencl/CLCommandQueue.java"/>
3750 <include name="org/lwjgl/opencl/CLMem.java"/>
38 <include name="org/lwjgl/opencl/CLMemObjectDestructorCallback.java"/>
39 <include name="org/lwjgl/opencl/CLBuildProgramCallback.java"/>
51 <include name="org/lwjgl/opencl/CL*Callback.java"/>
4052 <include name="org/lwjgl/opencl/CLNativeKernel.java"/>
41 <include name="org/lwjgl/opencl/CLEventCallback.java"/>
4253 <include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
4354 </javac>
4455 </target>
4556
4657 <!-- Proxy target to generate it all -->
47 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references, generate-opencl, generate-opencl-capabilities" description="Generates java and native source"/>
48
49 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references, generate-opencl-debug, generate-opencl-capabilities-debug" description="Generates java and native source with debug functionality"/>
58 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references, generate-opengles, generate-opengles-capabilities, generate-opencl, generate-opencl-capabilities" description="Generates java and native source"/>
59
60 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references, generate-opengles-debug, generate-opengles-capabilities-debug, generate-opencl-debug, generate-opencl-capabilities-debug" description="Generates java and native source with debug functionality"/>
61
62 <!-- ********************************************************************************
63 *********************************************************************************
64 OPENAL
65 *********************************************************************************
66 **************************************************************************** -->
5067
5168 <!-- Generate OpenAL -->
52 <target name="generate-openal" depends="generators" description="Generates java and native source for AL">
53 <apply executable="apt" parallel="true">
54 <arg value="-nocompile"/>
55 <arg value="-factory"/>
56 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
57 <arg value="-cp"/>
58 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
59 <arg value="-s"/>
60 <arg path="${lwjgl.src}/generated"/>
61 <arg value="-d"/>
62 <arg path="${lwjgl.src.native}/generated"/>
63 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
64 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
65 </apply>
69 <target name="generate-openal" depends="generators" description="Generates java and native source for AL">
70 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
71 <compilerarg value="-proc:only"/>
72 <compilerarg value="-processor"/>
73 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
74 <compilerarg value="-cp"/>
75 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
76 <compilerarg value="-s"/>
77 <compilerarg path="${lwjgl.src}/generated"/>
78 <compilerarg value="-d"/>
79 <compilerarg path="${lwjgl.src.native}/generated/openal"/>
80 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
81 <compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
82 <src>
83 <fileset dir="${lwjgl.src.templates.al}">
84 <include name="${openal-template-pattern}"/>
85 </fileset>
86 </src>
87 </javac>
6688 </target>
6789
6890 <!-- Generate OpenAL [DEBUG] -->
6991 <target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
70 <apply executable="apt" parallel="true">
71 <arg value="-nocompile"/>
72 <arg value="-factory"/>
73 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
74 <arg value="-cp"/>
75 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
76 <arg value="-s"/>
77 <arg path="${lwjgl.src}/generated"/>
78 <arg value="-d"/>
79 <arg path="${lwjgl.src.native}/generated"/>
80 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
81 <arg value="-Ageneratechecks"/>
82 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
83 </apply>
84 </target>
92 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
93 <compilerarg value="-proc:only"/>
94 <compilerarg value="-processor"/>
95 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
96 <compilerarg value="-cp"/>
97 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
98 <compilerarg value="-s"/>
99 <compilerarg path="${lwjgl.src}/generated"/>
100 <compilerarg value="-d"/>
101 <compilerarg path="${lwjgl.src.native}/generated/openal"/>
102 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
103 <compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
104 <compilerarg value="-Ageneratechecks"/>
105 <src>
106 <fileset dir="${lwjgl.src.templates.al}">
107 <include name="${openal-template-pattern}"/>
108 </fileset>
109 </src>
110 </javac>
111 </target>
112
113 <!-- ********************************************************************************
114 *********************************************************************************
115 OPENGL
116 *********************************************************************************
117 **************************************************************************** -->
85118
86119 <!-- Generate OpenGL -->
87120 <target name="generate-opengl" depends="generators" description="Generates java and native source for GL">
88 <apply executable="apt" parallel="true">
89 <arg value="-nocompile"/>
90 <arg value="-factory"/>
91 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
92 <arg value="-cp"/>
93 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
94 <arg value="-s"/>
95 <arg path="${lwjgl.src}/generated"/>
96 <arg value="-d"/>
97 <arg path="${lwjgl.src.native}/generated"/>
98 <arg value="-Acontextspecific"/>
99 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
100 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
101 </apply>
121 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processorGL">
122 <compilerarg value="-proc:only"/>
123 <compilerarg value="-processor"/>
124 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
125 <compilerarg value="-cp"/>
126 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
127 <compilerarg value="-s"/>
128 <compilerarg path="${lwjgl.src}/generated"/>
129 <compilerarg value="-d"/>
130 <compilerarg path="${lwjgl.src.native}/generated/opengl"/>
131 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
132 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
133 <compilerarg value="-Acontextspecific"/>
134 <src>
135 <fileset dir="${lwjgl.src.templates.gl}">
136 <include name="${opengl-template-pattern}"/>
137 </fileset>
138 </src>
139 </javac>
102140 </target>
103141
104142 <!-- Generate OpenGL [DEBUG] -->
105 <target name="generate-opengl-debug" depends="generators" description="Generates java and native source for GL">
106 <apply executable="apt" parallel="true">
107 <arg value="-nocompile"/>
108 <arg value="-factory"/>
109 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
110 <arg value="-cp"/>
111 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
112 <arg value="-s"/>
113 <arg path="${lwjgl.src}/generated"/>
114 <arg value="-d"/>
115 <arg path="${lwjgl.src.native}/generated"/>
116 <arg value="-Ageneratechecks"/>
117 <arg value="-Acontextspecific"/>
118 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
119 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
120 </apply>
143 <target name="generate-opengl-debug" depends="generators" description="Generates debug java and native source for GL">
144 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
145 <compilerarg value="-proc:only"/>
146 <compilerarg value="-processor"/>
147 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
148 <compilerarg value="-cp"/>
149 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
150 <compilerarg value="-s"/>
151 <compilerarg path="${lwjgl.src}/generated"/>
152 <compilerarg value="-d"/>
153 <compilerarg path="${lwjgl.src.native}/generated/opengl"/>
154 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
155 <compilerarg value="-Ageneratechecks"/>
156 <compilerarg value="-Acontextspecific"/>
157 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
158 <src>
159 <fileset dir="${lwjgl.src.templates.gl}">
160 <include name="${opengl-template-pattern}"/>
161 </fileset>
162 </src>
163 </javac>
121164 </target>
122165
123166 <!-- Generate OpenGL references -->
124167 <target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
125 <apply executable="apt" parallel="true">
126 <arg value="-nocompile"/>
127 <arg value="-factory"/>
128 <arg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessorFactory"/>
129 <arg value="-cp"/>
130 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
131 <arg value="-s"/>
132 <arg path="${lwjgl.src}/generated"/>
133 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
134 </apply>
168 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
169 <compilerarg value="-proc:only"/>
170 <compilerarg value="-processor"/>
171 <compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
172 <compilerarg value="-cp"/>
173 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
174 <compilerarg value="-s"/>
175 <compilerarg path="${lwjgl.src}/generated"/>
176 <src>
177 <fileset dir="${lwjgl.src.templates.gl}">
178 <include name="${opengl-template-pattern}"/>
179 </fileset>
180 </src>
181 </javac>
135182 </target>
136183
137184 <!-- Generate OpenGL context capabilities -->
138185 <target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
139 <apply executable="apt" parallel="true">
140 <arg value="-nocompile"/>
141 <arg value="-factory"/>
142 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
143 <arg value="-cp"/>
144 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
145 <arg value="-s"/>
146 <arg path="${lwjgl.src}/generated"/>
147 <arg value="-Acontextspecific"/>
148 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
149 </apply>
186 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
187 <compilerarg value="-proc:only"/>
188 <compilerarg value="-processor"/>
189 <compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
190 <compilerarg value="-cp"/>
191 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
192 <compilerarg value="-s"/>
193 <compilerarg path="${lwjgl.src}/generated"/>
194 <compilerarg value="-Acontextspecific"/>
195 <src>
196 <fileset dir="${lwjgl.src.templates.gl}">
197 <include name="${opengl-template-pattern}"/>
198 </fileset>
199 </src>
200 </javac>
150201 </target>
151202
152203 <!-- Generate OpenGL context capabilities [DEBUG] -->
153 <target name="generate-opengl-capabilities-debug" depends="generators" description="Generates java and native source for GL">
154 <apply executable="apt" parallel="true">
155 <arg value="-nocompile"/>
156 <arg value="-factory"/>
157 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
158 <arg value="-cp"/>
159 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
160 <arg value="-s"/>
161 <arg path="${lwjgl.src}/generated"/>
162 <arg value="-Ageneratechecks"/>
163 <arg value="-Acontextspecific"/>
164 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
165 </apply>
166 </target>
167
168 <!-- Generate OpenCL -->
204 <target name="generate-opengl-capabilities-debug" depends="generators" description="Generates debug java and native source for GL">
205 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
206 <compilerarg value="-proc:only"/>
207 <compilerarg value="-processor"/>
208 <compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
209 <compilerarg value="-cp"/>
210 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
211 <compilerarg value="-s"/>
212 <compilerarg path="${lwjgl.src}/generated"/>
213 <compilerarg value="-Ageneratechecks"/>
214 <compilerarg value="-Acontextspecific"/>
215 <src>
216 <fileset dir="${lwjgl.src.templates.gl}">
217 <include name="${opengl-template-pattern}"/>
218 </fileset>
219 </src>
220 </javac>
221 </target>
222
223 <!-- ********************************************************************************
224 *********************************************************************************
225 OPENGL ES
226 *********************************************************************************
227 **************************************************************************** -->
228
229 <!-- Generate OpenGL ES -->
230 <target name="generate-opengles" depends="generators" description="Generates java and native source for GL ES">
231 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
232 <compilerarg value="-proc:only"/>
233 <compilerarg value="-processor"/>
234 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
235 <compilerarg value="-cp"/>
236 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
237 <compilerarg value="-s"/>
238 <compilerarg path="${lwjgl.src}/generated"/>
239 <compilerarg value="-d"/>
240 <compilerarg path="${lwjgl.src.native}/generated/opengles"/>
241 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
242 <!--<compilerarg value="-Acontextspecific"/>-->
243 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
244 <src>
245 <fileset dir="${lwjgl.src.templates.gles}">
246 <include name="${opengles-template-pattern}"/>
247 </fileset>
248 </src>
249 </javac>
250 </target>
251
252 <!-- Generate OpenGL ES [DEBUG] -->
253 <target name="generate-opengles-debug" depends="generators" description="Generates debug java and native source for GL ES">
254 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
255 <compilerarg value="-proc:only"/>
256 <compilerarg value="-processor"/>
257 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
258 <compilerarg value="-cp"/>
259 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
260 <compilerarg value="-s"/>
261 <compilerarg path="${lwjgl.src}/generated"/>
262 <compilerarg value="-d"/>
263 <compilerarg path="${lwjgl.src.native}/generated/opengles"/>
264 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
265 <compilerarg value="-Ageneratechecks"/>
266 <!--<compilerarg value="-Acontextspecific"/>-->
267 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
268 <src>
269 <fileset dir="${lwjgl.src.templates.gles}">
270 <include name="${opengles-template-pattern}"/>
271 </fileset>
272 </src>
273 </javac>
274 </target>
275
276 <!-- Generate OpenGL ES context capabilities -->
277 <target name="generate-opengles-capabilities" depends="generators" description="Generates java and native source for GL ES">
278 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
279 <compilerarg value="-proc:only"/>
280 <compilerarg value="-processor"/>
281 <compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
282 <compilerarg value="-cp"/>
283 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
284 <compilerarg value="-s"/>
285 <compilerarg path="${lwjgl.src}/generated"/>
286 <!--<compilerarg value="-Acontextspecific"/>-->
287 <src>
288 <fileset dir="${lwjgl.src.templates.gles}">
289 <include name="${opengles-template-pattern}"/>
290 </fileset>
291 </src>
292 </javac>
293 </target>
294
295 <!-- Generate OpenGL ES context capabilities [DEBUG] -->
296 <target name="generate-opengles-capabilities-debug" depends="generators" description="Generates debug java and native source for GL ES">
297 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
298 <compilerarg value="-proc:only"/>
299 <compilerarg value="-processor"/>
300 <compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
301 <compilerarg value="-cp"/>
302 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
303 <compilerarg value="-s"/>
304 <compilerarg path="${lwjgl.src}/generated"/>
305 <compilerarg value="-Ageneratechecks"/>
306 <!--<compilerarg value="-Acontextspecific"/>-->
307 <src>
308 <fileset dir="${lwjgl.src.templates.gles}">
309 <include name="${opengles-template-pattern}"/>
310 </fileset>
311 </src>
312 </javac>
313 </target>
314
315 <!-- ********************************************************************************
316 *********************************************************************************
317 OPENCL
318 *********************************************************************************
319 **************************************************************************** -->
320
321 <!-- Generate OpenCL -->
169322 <target name="generate-opencl" depends="generators" description="Generates java and native source for CL">
170 <apply executable="apt" parallel="true">
171 <arg value="-nocompile"/>
172 <arg value="-factory"/>
173 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
174 <arg value="-cp"/>
175 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
176 <arg value="-s"/>
177 <arg path="${lwjgl.src}/generated"/>
178 <arg value="-d"/>
179 <arg path="${lwjgl.src.native}/generated"/>
180 <arg value="-Acontextspecific"/>
181 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
182 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
183 </apply>
323 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
324 <compilerarg value="-proc:only"/>
325 <compilerarg value="-processor"/>
326 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
327 <compilerarg value="-cp"/>
328 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
329 <compilerarg value="-s"/>
330 <compilerarg path="${lwjgl.src}/generated"/>
331 <compilerarg value="-d"/>
332 <compilerarg path="${lwjgl.src.native}/generated/opencl"/>
333 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
334 <compilerarg value="-Acontextspecific"/>
335 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
336 <src>
337 <fileset dir="${lwjgl.src.templates.cl}">
338 <include name="${opencl-template-pattern}"/>
339 </fileset>
340 </src>
341 </javac>
184342 </target>
185343
186344 <!-- Generate OpenCL [DEBUG] -->
187 <target name="generate-opencl-debug" depends="generators" description="Generates java and native source for CL">
188 <apply executable="apt" parallel="true">
189 <arg value="-nocompile"/>
190 <arg value="-factory"/>
191 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
192 <arg value="-cp"/>
193 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
194 <arg value="-s"/>
195 <arg path="${lwjgl.src}/generated"/>
196 <arg value="-d"/>
197 <arg path="${lwjgl.src.native}/generated"/>
198 <arg value="-Ageneratechecks"/>
199 <arg value="-Acontextspecific"/>
200 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
201 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
202 </apply>
345 <target name="generate-opencl-debug" depends="generators" description="Generates debug java and native source for CL">
346 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
347 <compilerarg value="-proc:only"/>
348 <compilerarg value="-processor"/>
349 <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
350 <compilerarg value="-cp"/>
351 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
352 <compilerarg value="-s"/>
353 <compilerarg path="${lwjgl.src}/generated"/>
354 <compilerarg value="-d"/>
355 <compilerarg path="${lwjgl.src.native}/generated/opencl"/>
356 <compilerarg value="-Abinpath=${lwjgl.bin}"/>
357 <compilerarg value="-Ageneratechecks"/>
358 <compilerarg value="-Acontextspecific"/>
359 <compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
360 <src>
361 <fileset dir="${lwjgl.src.templates.cl}">
362 <include name="${opencl-template-pattern}"/>
363 </fileset>
364 </src>
365 </javac>
203366 </target>
204367
205368 <!-- Generate OpenCL capabilities -->
206369 <target name="generate-opencl-capabilities" depends="generators" description="Generates capabilities for CL">
207 <apply executable="apt" parallel="true">
208 <arg value="-nocompile"/>
209 <arg value="-factory"/>
210 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
211 <arg value="-cp"/>
212 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
213 <arg value="-s"/>
214 <arg path="${lwjgl.src}/generated"/>
215 <arg value="-Acontextspecific"/>
216 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
217 </apply>
370 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
371 <compilerarg value="-proc:only"/>
372 <compilerarg value="-processor"/>
373 <compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
374 <compilerarg value="-cp"/>
375 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
376 <compilerarg value="-s"/>
377 <compilerarg path="${lwjgl.src}/generated"/>
378 <compilerarg value="-Acontextspecific"/>
379 <src>
380 <fileset dir="${lwjgl.src.templates.cl}">
381 <include name="${opencl-template-pattern}"/>
382 </fileset>
383 </src>
384 </javac>
218385 </target>
219386
220387 <!-- Generate OpenCL capabilities [DEBUG] -->
221 <target name="generate-opencl-capabilities-debug" depends="generators" description="Generates capabilities for CL">
222 <apply executable="apt" parallel="true">
223 <arg value="-nocompile"/>
224 <arg value="-factory"/>
225 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
226 <arg value="-cp"/>
227 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
228 <arg value="-s"/>
229 <arg path="${lwjgl.src}/generated"/>
230 <arg value="-Ageneratechecks"/>
231 <arg value="-Acontextspecific"/>
232 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
233 </apply>
388 <target name="generate-opencl-capabilities-debug" depends="generators" description="Generates debug capabilities for CL">
389 <javac destdir="${lwjgl.bin}" source="1.6" target="1.6" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
390 <compilerarg value="-proc:only"/>
391 <compilerarg value="-processor"/>
392 <compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
393 <compilerarg value="-cp"/>
394 <compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
395 <compilerarg value="-s"/>
396 <compilerarg path="${lwjgl.src}/generated"/>
397 <compilerarg value="-Ageneratechecks"/>
398 <compilerarg value="-Acontextspecific"/>
399 <src>
400 <fileset dir="${lwjgl.src.templates.cl}">
401 <include name="${opencl-template-pattern}"/>
402 </fileset>
403 </src>
404 </javac>
234405 </target>
235406 </project>
22 <property name="lwjgl.src.generated" location="${lwjgl.src}/generated" />
33 <property name="lwjgl.maven" location="maven" />
44 <property name="lwjgl.dstMaven" location="${lwjgl.temp}/maven" />
5
65 <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
7
8 <property name="lwjgl-maven-version" value="2.7.0"/>
9
6 <property name="jinput.version" value="2.0.5" />
7
108 <fileset id="lwjgl-sources.manual.fileset" dir="${lwjgl.src.java}">
119 <patternset refid="lwjgl.package.pattern" />
10 <patternset refid="lwjgl.package.dependencies.pattern"/>
1211 </fileset>
1312
1413 <fileset id="lwjgl-sources.generated.fileset" dir="${lwjgl.src.generated}">
2221 <patternset refid="lwjgl_util.package.pattern" />
2322 </fileset>
2423
24 <target name="-fixmavenversion">
25 <script language="javascript">
26 <![CDATA[
27 importPackage(java.lang);
28 var originalVersion = project.getProperty("lwjgl.version");
29 System.out.println("LWJGL Version: " + originalVersion);
30 var mavenVersion = originalVersion;
31 if(originalVersion.match(/^[0-9]+\.[0-9]+$/)){
32 System.out.println("Fixing LWJGL Maven version (Maven version should be x.y.z)");
33 mavenVersion = originalVersion + ".0";
34 }
35 if(!mavenVersion.match(/^.*-SNAPSHOT$/)){
36 var forceSnapshot = project.getProperty("snapshot")
37 if(forceSnapshot!=null && forceSnapshot!="false"){
38 System.out.println("Forcing Maven Version to Snapshot");
39 mavenVersion = mavenVersion + "-SNAPSHOT";
40 }
41 }
42
43 project.setNewProperty("lwjgl-maven-version",mavenVersion);
44 System.out.println("LWJGL Maven Version: " + project.getProperty("lwjgl-maven-version"));
45 ]]>
46 </script>
47 </target>
48
49 <target name="-checkjinputversion">
50 <script language="javascript" classpath="${lwjgl.lib}/jinput.jar">
51 <![CDATA[
52 importPackage(java.lang);
53 var version = net.java.games.input.Version.getVersion()
54 project.setNewProperty("jinputversion",version);
55 var declaredJinputVersion = project.getProperty("jinput.version");
56 System.out.println("JINPUT Version: " + version + " - DeclaredVersion: " + declaredJinputVersion);
57
58 if(declaredJinputVersion.equals(version)){
59 System.out.println("JINPUT Version Matches");
60 project.setNewProperty("jinputversionmatches", true);
61 } else {
62 System.out.println("JINPUT Version don't match");
63 }
64 ]]>
65 </script>
66 <condition property="failjinputcheck">
67 <and>
68 <not><isset property="jinputversionmatches" /></not>
69 <not><isset property="overridejinput" /></not>
70 </and>
71 </condition>
72 <fail if="failjinputcheck" message="Jinput version in project (${jinputversion}) is different from the declared jinput version for maven (${jinput.version}) add -Doverridejinput=true as a command line option to avoid this check" />
73 </target>
2574
2675 <target name="maven-full">
2776 <antcall target="clean-java" />
3382 <antcall target="maven"/>
3483 </target>
3584
36 <target name="maven">
85 <target name="maven" depends="-fixmavenversion, -checkjinputversion"> <!-- Added as dependency because using antcall creates a new project scope -->
3786 <delete dir="${lwjgl.dstMaven}" quiet="true" failonerror="false" taskname="cleaning maven dist" />
3887 <mkdir dir="${lwjgl.dstMaven}" taskname="initialiazing temp maven folder" />
3988 <antcall target="-copylwjgljars" />
4493 <antcall target="-copymavendeploybuild"/>
4594 <antcall target="-copymaventdist"/>
4695 </target>
96
97
98
99
100
101
47102
48103
49104 <target name="-copylwjgljars">
112167 </target>
113168
114169 <target name="-createmavennativejars">
115 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-win.jar" taskname="lwjgl-platform-natives-win.jar">
170 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-windows.jar" taskname="lwjgl-platform-natives-windows.jar">
116171 <fileset dir="${lwjgl.lib}/windows">
117172 <patternset refid="lwjgl-windows-lwjgl.fileset"/>
118173 </fileset>
122177 <patternset refid="lwjgl-linux-lwjgl.fileset"/>
123178 </fileset>
124179 </jar>
125 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-mac.jar" taskname="lwjgl-platform-natives-mac.jar">
180 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-osx.jar" taskname="lwjgl-platform-natives-osx.jar">
126181 <fileset dir="${lwjgl.lib}/macosx">
127182 <patternset refid="lwjgl-macosx-lwjgl.fileset"/>
128183 </fileset>
136191 </fileset>
137192 <filterset>
138193 <filter token="VERSION" value="${lwjgl-maven-version}"/>
194 <filter token="JINPUTVERSION" value="${jinput.version}"/>
139195 </filterset>
140196 </copy>
141197 </target>
147203 </fileset>
148204 </copy>
149205 </target>
150
206
151207 <target name="-copymaventdist">
152208 <zip destfile="${lwjgl.dist}/lwjgl-maven-${lwjgl.version}.zip" basedir="${lwjgl.temp}" includes="maven/**" />
153209 </target>
33 <property name="native" location="../../src/native"/>
44 <property name="libname32" value="liblwjgl.so"/>
55 <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" />
6 <property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" />
77 <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" />
88 <property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
99
2020 <exec executable="uname" outputproperty="hwplatform">
2121 <arg value="-m"/>
2222 </exec>
23 <condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
24 <os name="SunOS" />
25 </condition>
2623 <condition property="cflags_pthread" value="-pthreads" else="-pthread">
2724 <os name="SunOS" />
2825 </condition>
3835 <os name="SunOS" />
3936 </condition>
4037
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}"/>
38 <property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
39 <property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
4340
4441 <condition property="build.32bit.only">
4542 <not>
6461
6562 <target name="compile32" unless="build.64bit.only">
6663 <mkdir dir="x32"/>
67 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
64 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
6865 <arg line="${cflags32} ${cflags_pthread}"/>
6966 <arg value="-I${java.home}/include"/>
7067 <arg value="-I${java.home}/include/linux"/>
7269 <arg value="-I${java.home}/../include/linux"/>
7370 <arg value="-I${java.home}/../include/solaris"/>
7471 <arg value="-I${native}/common"/>
72 <arg value="-I${native}/common/opengl"/>
7573 <arg value="-I${native}/linux"/>
74 <arg value="-I${native}/linux/opengl"/>
7675 <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>
76 <fileset dir="${native}/common" includes="*.c"/>
77 <fileset dir="${native}/common/opengl" includes="*.c"/>
78 <fileset dir="${native}/generated/openal" includes="*.c"/>
79 <fileset dir="${native}/generated/opencl" includes="*.c"/>
80 <fileset dir="${native}/generated/opengl" includes="*.c"/>
81 <fileset dir="${native}/linux" includes="*.c"/>
82 <fileset dir="${native}/linux/opengl" includes="*.c"/>
83 </apply>
8184 <apply dir="." parallel="true" executable="gcc" failonerror="true">
8285 <srcfile/>
8386 <arg line="${linker_flags32}"/>
9093
9194 <target name="compile64" unless="build.32bit.only">
9295 <mkdir dir="x64"/>
93 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
96 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
9497 <arg line="${cflags64} ${cflags_pthread}"/>
9598 <arg value="-I${java.home}/include"/>
9699 <arg value="-I${java.home}/include/linux"/>
98101 <arg value="-I${java.home}/../include/linux"/>
99102 <arg value="-I${java.home}/../include/solaris"/>
100103 <arg value="-I${native}/common"/>
104 <arg value="-I${native}/common/opengl"/>
101105 <arg value="-I${native}/linux"/>
106 <arg value="-I${native}/linux/opengl"/>
102107 <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>
108 <fileset dir="${native}/common" includes="*.c"/>
109 <fileset dir="${native}/common/opengl" includes="*.c"/>
110 <fileset dir="${native}/generated/openal" includes="*.c"/>
111 <fileset dir="${native}/generated/opencl" includes="*.c"/>
112 <fileset dir="${native}/generated/opengl" includes="*.c"/>
113 <fileset dir="${native}/linux" includes="*.c"/>
114 <fileset dir="${native}/linux/opengl" includes="*.c"/>
115 </apply>
107116 <apply dir="." parallel="true" executable="gcc" failonerror="true">
108117 <srcfile/>
109118 <arg line="${linker_flags64}"/>
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, linux" basedir="../../bin/lwjgles" 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="lib_folder" value="${lwjgl.lib}/linux"/>
7 <property name="libs32" value="-L${lib_folder} -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" />
8 <property name="libs64" value="-L${lib_folder}/x64 -lEGL -L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" />
9 <property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
10
11 <target name="clean">
12 <delete>
13 <fileset dir="x32"/>
14 <fileset dir="x64"/>
15 <fileset dir="." includes="*.o"/>
16 <fileset dir="." includes="*.so"/>
17 </delete>
18 </target>
19
20 <target name="compile">
21 <exec executable="uname" outputproperty="hwplatform">
22 <arg value="-m"/>
23 </exec>
24 <condition property="cflags_pthread" value="-pthreads" else="-pthread">
25 <os name="SunOS" />
26 </condition>
27 <condition property="version_script_flags32" value="" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
28 <os name="SunOS" />
29 </condition>
30 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
31 <and>
32 <os name="SunOS" />
33 </and>
34 </condition>
35 <condition property="cflags64" value="-O2 -m64 -Wall -c -fPIC -std=c99 -Wunused" else="-O2 -Wall -c -fPIC -std=c99 -Wunused">
36 <os name="SunOS" />
37 </condition>
38
39 <property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
40 <property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
41
42 <condition property="build.32bit.only">
43 <not>
44 <or>
45 <equals arg1="${hwplatform}" arg2="x86_64"/>
46 <equals arg1="${hwplatform}" arg2="i86pc"/>
47 </or>
48 </not>
49 </condition>
50
51 <!-- On linux, the 64 bit jre doesn't have the 32 bit libs -->
52 <condition property="build.64bit.only">
53 <and>
54 <os name="Linux"/>
55 <equals arg1="${hwplatform}" arg2="x86_64"/>
56 </and>
57 </condition>
58
59 <antcall target="compile32"/>
60 <antcall target="compile64"/>
61 </target>
62
63 <target name="compile32" unless="build.64bit.only">
64 <mkdir dir="x32"/>
65 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
66 <arg line="${cflags32} ${cflags_pthread}"/>
67 <arg value="-I${java.home}/include"/>
68 <arg value="-I${java.home}/include/linux"/>
69 <arg value="-I${java.home}/../include"/>
70 <arg value="-I${java.home}/../include/linux"/>
71 <arg value="-I${java.home}/../include/solaris"/>
72 <arg value="-I${native}/common"/>
73 <arg value="-I${native}/common/opengles"/>
74 <arg value="-I${native}/linux"/>
75 <arg value="-I${native}/linux/opengles"/>
76 <mapper type="glob" from="*.c" to="*.o"/>
77 <fileset dir="${native}/common" includes="*.c"/>
78 <fileset dir="${native}/common/opengles" includes="*.c"/>
79 <fileset dir="${native}/generated/openal" includes="*.c"/>
80 <fileset dir="${native}/generated/opencl" includes="*.c"/>
81 <fileset dir="${native}/generated/opengles" includes="*.c"/>
82 <fileset dir="${native}/linux" includes="*.c"/>
83 <fileset dir="${native}/linux/opengles" includes="*.c"/>
84 </apply>
85 <apply dir="." parallel="true" executable="gcc" failonerror="true">
86 <srcfile/>
87 <arg line="${linker_flags32}"/>
88 <fileset dir="x32" includes="*.o"/>
89 </apply>
90 <apply dir="." parallel="true" executable="strip" failonerror="true">
91 <fileset file="${libname32}"/>
92 </apply>
93 </target>
94
95 <target name="compile64" unless="build.32bit.only">
96 <mkdir dir="x64"/>
97 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
98 <arg line="${cflags64} ${cflags_pthread}"/>
99 <arg value="-I${java.home}/include"/>
100 <arg value="-I${java.home}/include/linux"/>
101 <arg value="-I${java.home}/../include"/>
102 <arg value="-I${java.home}/../include/linux"/>
103 <arg value="-I${java.home}/../include/solaris"/>
104 <arg value="-I${native}/common"/>
105 <arg value="-I${native}/common/opengles"/>
106 <arg value="-I${native}/linux"/>
107 <arg value="-I${native}/linux/opengles"/>
108 <mapper type="glob" from="*.c" to="*.o"/>
109 <fileset dir="${native}/common" includes="*.c"/>
110 <fileset dir="${native}/common/opengles" includes="*.c"/>
111 <fileset dir="${native}/generated/openal" includes="*.c"/>
112 <fileset dir="${native}/generated/opencl" includes="*.c"/>
113 <fileset dir="${native}/generated/opengles" includes="*.c"/>
114 <fileset dir="${native}/linux" includes="*.c"/>
115 <fileset dir="${native}/linux/opengles" includes="*.c"/>
116 </apply>
117 <apply dir="." parallel="true" executable="gcc" failonerror="true">
118 <srcfile/>
119 <arg line="${linker_flags64}"/>
120 <fileset dir="x64" includes="*.o"/>
121 </apply>
122 <apply dir="." parallel="true" executable="strip" failonerror="true">
123 <fileset file="${libname64}"/>
124 </apply>
125 </target>
126 </project>
00 #!/bin/sh
11
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-
2 nm -j -g "$1"/*.o | grep -E "J(ava|NI)_[^.]*$"
0
10 <project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
21 <property name="native" location="../../src/native"/>
32
43 <target name="init">
5 <mkdir dir="ppc"/>
6 <mkdir dir="i386"/>
74 <mkdir dir="x86_64"/>
8 </target>
9
5 <property environment="env" />
6 <!-- Ask Xcode for correct path to XCode tools -->
7 <!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
8 <exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-select.error" failonerror="false" failifexecutionfails="false">
9 <arg value="-print-path" />
10 </exec>
11 <!-- Default to /Developer if xcode-select fails -->
12 <condition property="developer_path" value="/Developer">
13 <isset property="xcode-select.error" />
14 </condition>
15
16 <property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
17 <property name="jvm_headers_path" value="System/Library/Frameworks/JavaVM.framework/Versions/A/Headers"/>
18
19 <!-- Choose a JavaVM.framework -->
20 <condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
21 <and>
22 <not><isset property="javavmroot"/></not>
23 <available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk/${jvm_headers_path}" type="dir"/>
24 </and>
25 </condition>
26 <condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
27 <and>
28 <not><isset property="javavmroot"/></not>
29 <available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk/${jvm_headers_path}" type="dir"/>
30 </and>
31 </condition>
32 <condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
33 <and>
34 <not><isset property="javavmroot"/></not>
35 <available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk/${jvm_headers_path}" type="dir"/>
36 </and>
37 </condition>
38 <condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
39 <and>
40 <not><isset property="javavmroot"/></not>
41 <available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk/${jvm_headers_path}" type="dir"/>
42 </and>
43 </condition>
44 <condition property="javavmroot" value=""> <!-- Old location -->
45 <and>
46 <not><isset property="javavmroot"/></not>
47 <available file="/${jvm_headers_path}" type="dir"/>
48 </and>
49 </condition>
50
51 <!-- Choose a MacOSX SDK -->
52 <property name="compiler" value="clang"/> <!-- Default to clang for 10.8 and up -->
53
54 <condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
55 <and>
56 <not><isset property="sdkroot"/></not>
57 <available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk" type="dir"/>
58 </and>
59 </condition>
60 <condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
61 <and>
62 <not><isset property="sdkroot"/></not>
63 <available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk" type="dir"/>
64 </and>
65 </condition>
66
67 <!-- If we're on 10.7 or lower, use gcc instead of clang -->
68 <condition property="compiler" value="gcc-4.2">
69 <and>
70 <not><isset property="sdkroot"/></not>
71 <available file="gcc-4.2" filepath="${env.PATH}"/>
72 </and>
73 </condition>
74 <condition property="compiler" value="gcc">
75 <and>
76 <not><isset property="sdkroot"/></not>
77 <not><available file="gcc-4.2" filepath="${env.PATH}"/></not>
78 <available file="gcc" filepath="${env.PATH}"/>
79 </and>
80 </condition>
81
82 <condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
83 <and>
84 <not><isset property="sdkroot"/></not>
85 <available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk" type="dir"/>
86 </and>
87 </condition>
88 <condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
89 <and>
90 <not><isset property="sdkroot"/></not>
91 <available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk" type="dir"/>
92 </and>
93 </condition>
94 <condition property="sdkroot" value="${developer_path}/SDKs/MacOSx10.6.sdk"> <!-- Old XCode location -->
95 <and>
96 <not><isset property="sdkroot"/></not>
97 <available file="${developer_path}/SDKs/MacOSx10.6.sdk" type="dir"/>
98 </and>
99 </condition>
100 </target>
101
10102 <target name="clean">
11103 <delete failonerror="false">
12104 <fileset dir="i386"/>
13105 <fileset dir="x86_64"/>
14 <fileset dir="ppc"/>
15 <fileset dir="." includes="liblwjgl.jnilib"/>
106 <fileset dir="." includes="liblwjgl.dylib"/>
16107 <fileset dir="." includes="lwjgl.symbols"/>
17108 </delete>
18109 </target>
19110
20 <target name="compile">
111 <target name="compile" depends="init">
21112 <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"/>
113 <arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path} -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
23114 <!-- Map from *.m and *.c to .o -->
24115 <mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
25116 <fileset dir="${native}/macosx" includes="*.m"/>
26117 <fileset dir="${native}/macosx" includes="*.c"/>
27118 <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"/>
119 <fileset dir="${native}/common/opengl" includes="*.c"/>
120 <fileset dir="${native}/generated/openal" includes="*.c"/>
121 <fileset dir="${native}/generated/opencl" includes="*.c"/>
122 <fileset dir="${native}/generated/opengl" includes="*.c"/>
123 </apply>
124 </target>
125
126 <target name="link" depends="init">
127 <condition property="jdk_lib" value="${java.home}/lib">
128 <available file="${java.home}/lib/libjawt.dylib" type="file"/>
129 </condition>
130 <condition property="jdk_lib" value="${java.home}/../Libraries">
131 <not><isset property="jdk_lib"/></not>
132 </condition>
133
134 <apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
135 <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt"/>
35136 <fileset dir="${objdir}" includes="*.o"/>
36137 </apply>
37138 <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
39140 <fileset dir="." file="${libname}"/>
40141 </apply>
41142 </target>
42
143
43144 <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"/>
145 <echo message=" Compiler: ${compiler}"/>
146 <echo message=" Mac OS SDK: ${sdkroot}"/>
147 <echo message="JavaVM.framework: ${javavmroot}"/>
148
149 <condition property="build_x86_64" value="1">
150 <equals arg1="${compiler}" arg2="clang"/>
151 </condition>
152
153 <antcall target="-build"/>
154 </target>
155
156 <target name="-build" depends="-build_universal,-build_x86_x64"/>
157
158 <target name="-build_universal" unless="build_x86_64">
159 <mkdir dir="i386"/>
160
161 <property name="universal_sdkroot" location="${sdkroot}"/>
162 <property name="x86_64_sdkroot" location="${sdkroot}"/>
47163 <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>
55164 <antcall target="compile">
56165 <param name="dstdir" location="i386"/>
57 <param name="compiler" value="gcc-4.0"/>
58166 <param name="sdkroot" location="${universal_sdkroot}"/>
59 <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
167 <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
60168 </antcall>
61169 <antcall target="compile">
62170 <param name="dstdir" location="x86_64"/>
63 <param name="compiler" value="gcc-4.0"/>
64171 <param name="sdkroot" location="${universal_sdkroot}"/>
65172 <param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
66173 </antcall>
69176 <arg path="i386"/>
70177 </exec>
71178 <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">
78179 <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"/>
180 <param name="libname" value="liblwjgl-i386.dylib"/>
181 <param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
82182 </antcall>
83183 <antcall target="link">
84184 <param name="objdir" location="x86_64"/>
85 <param name="libname" value="liblwjgl-i86_64.jnilib"/>
86 <param name="linker" value="gcc-4.0"/>
185 <param name="libname" value="liblwjgl-i86_64.dylib"/>
87186 <param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
88187 </antcall>
89 <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
188 <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
90189 <arg value="-create"/>
91190 <srcfile/>
92191 <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>
192 <arg path="liblwjgl.dylib"/>
193 <fileset file="i386/liblwjgl-i386.dylib"/>
194 <fileset file="x86_64/liblwjgl-i86_64.dylib"/>
195 </apply>
196 </target>
197
198 <target name="-build_x86_x64" if="build_x86_64">
199 <antcall target="compile">
200 <param name="dstdir" location="x86_64"/>
201 <param name="sdkroot" location="${sdkroot}"/>
202 <param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
203 </antcall>
204 <exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
205 <arg path="../../platform_build/macosx_ant/build-symbol-list"/>
206 <arg path="x86_64"/>
207 </exec>
208 <antcall target="link">
209 <param name="objdir" location="x86_64"/>
210 <param name="libname" value="liblwjgl-i86_64.dylib"/>
211 <param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
212 </antcall>
213 <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
214 <arg value="-create"/>
215 <srcfile/>
216 <arg value="-output"/>
217 <arg path="liblwjgl.dylib"/>
218 <fileset file="x86_64/liblwjgl-i86_64.dylib"/>
219 </apply>
220 </target>
221 </project>
2121 <srcfile/>
2222 <fileset dir="${native}/windows" includes="*.c"/>
2323 <fileset dir="${native}/common" includes="*.c"/>
24 <fileset dir="${native}/generated" includes="*.c"/>
24 <fileset dir="${native}/generated/openal" includes="*.c"/>
25 <fileset dir="${native}/generated/opencl" includes="*.c"/>
26 <fileset dir="${native}/generated/opengl" includes="*.c"/>
2527 <mapper type="glob" from="*.c" to="*.o"/>
2628 </apply>
2729 </target>
5254 <fileset dir="." includes="*.dll"/>
5355 </delete>
5456 </target>
55
57
5658 <target name="compile">
5759 <property name="libs" value="-lkernel32 -lole32 -lopengl32 -lversion -luser32 -lgdi32 -ladvapi32 -lwinmm"/>
5860 <antcall target="compile_dir"/>
55 <property name="sdkhome" location="${env.MSSDK}"/>
66
77 <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"/>
8 <apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
9 <arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
1010 <arg value="/I${sdkhome}\include"/>
1111 <arg value="/I${java.home}\..\include"/>
1212 <arg value="/I${java.home}\..\include\win32"/>
1313 <arg value="/I${native}\common"/>
14 <arg value="/I${native}\common\opengl"/>
1415 <arg value="/I${native}\windows"/>
16 <arg value="/I${native}\windows\opengl"/>
1517 <srcfile/>
18 <fileset dir="${native}/common" includes="*.c"/>
19 <fileset dir="${native}/common/opengl" includes="*.c"/>
20 <fileset dir="${native}/generated/openal" includes="*.c"/>
21 <fileset dir="${native}/generated/opencl" includes="*.c"/>
22 <fileset dir="${native}/generated/opengl" includes="*.c"/>
1623 <fileset dir="${native}/windows" includes="*.c"/>
17 <fileset dir="${native}/common" includes="*.c"/>
18 <fileset dir="${native}/generated" includes="*.c"/>
24 <fileset dir="${native}/windows/opengl" includes="*.c"/>
1925 <mapper type="glob" from="*.c" to="*.obj"/>
2026 </apply>
2127 </target>
4248 <fileset dir="." includes="*.lib"/>
4349 </delete>
4450 </target>
45
51
4652 <target name="compile">
4753 <condition property="sdkhomelib" value="${sdkhome}\lib" else="${sdkhome}\lib\x64">
4854 <equals arg1="${os.arch}" arg2="x86"/>
0 <?xml version="1.0"?>
1
2 <project name="lwjgl native code, native code" basedir="../../bin/lwjgles" 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" parallel="true">
9 <arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
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}\common\opengles"/>
15 <arg value="/I${native}\windows"/>
16 <arg value="/I${native}\windows\opengles"/>
17 <srcfile/>
18 <fileset dir="${native}/common" includes="*.c"/>
19 <fileset dir="${native}/common/opengles" includes="*.c"/>
20 <fileset dir="${native}/generated/openal" includes="*.c"/>
21 <fileset dir="${native}/generated/opencl" includes="*.c"/>
22 <fileset dir="${native}/generated/opengles" includes="*.c"/>
23 <fileset dir="${native}/windows" includes="*.c"/>
24 <fileset dir="${native}/windows/opengles" includes="*.c"/>
25 <mapper type="glob" from="*.c" to="*.obj"/>
26 </apply>
27 </target>
28
29 <target name="link">
30 <apply dir="." parallel="true" executable="cl" failonerror="true">
31 <arg line="/LD /nologo"/>
32 <srcfile/>
33 <arg line="/Fe${dllname} /link"/>
34 <arg value="/LIBPATH:${java.home}\..\lib"/>
35 <arg value="/LIBPATH:${sdkhomelib}"/>
36 <arg value="/LIBPATH:..\..\libs\windows"/>
37 <arg value="/OPT:REF"/>
38 <arg value="/OPT:ICF"/>
39 <arg line="/DLL /DELAYLOAD:jawt.dll ${libs}"/>
40 <fileset dir="." includes="*.obj"/>
41 </apply>
42 </target>
43
44 <target name="clean">
45 <delete>
46 <fileset dir="." includes="*.obj"/>
47 <fileset dir="." includes="*.dll"/>
48 <fileset dir="." includes="*.exp"/>
49 <fileset dir="." includes="*.lib"/>
50 </delete>
51 </target>
52
53 <target name="compile">
54 <condition property="sdkhomelib" value="${sdkhome}\lib" else="${sdkhome}\lib\x64">
55 <equals arg1="${os.arch}" arg2="x86"/>
56 </condition>
57 <condition property="dllname" value="lwjgl.dll" else="lwjgl64.dll">
58 <equals arg1="${os.arch}" arg2="x86"/>
59 </condition>
60 <echo message="${sdkhomelib}"/>
61 <property name="libs" value="Kernel32.lib ole32.lib libEGL.lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib Comctl32.lib"/>
62 <antcall target="compile_dir"/>
63 <antcall target="link"/>
64 </target>
65 </project>
66
4141 * </p>
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
4343 * @author elias_naur <elias_naur@users.sourceforge.net>
44 * @version $Revision: 3419 $
45 * $Id: BufferChecks.java 3419 2010-09-30 17:21:50Z spasi $
44 * @version $Revision$
45 * $Id$
4646 */
4747 public class BufferChecks {
4848 /** Static methods only! */
158158 * This is a separate call to help inline checkBufferSize.
159159 */
160160 private static void throwBufferSizeException(Buffer buf, int size) {
161 throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size);
161 throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size + ". Because at most " + size + " elements can be returned, a buffer with at least " + size + " elements is required, regardless of actual returned element count");
162162 }
163163
164164 private static void throwBufferSizeException(PointerBuffer buf, int size) {
4343 /**
4444 * Some often-used Buffer code for creating native buffers of the appropriate size.
4545 *
46 * @author $Author: matzon $
47 * @version $Revision: 3456 $
48 * $Id: BufferUtils.java 3456 2010-11-24 21:48:23Z matzon $
46 * @author $Author$
47 * @version $Revision$
48 * $Id$
4949 */
5050
5151 public final class BufferUtils {
191191
192192 /** Fill buffer with zeros from position to remaining */
193193 private static native void zeroBuffer0(Buffer b, long off, long size);
194
195 /**
196 * Returns the memory address of the specified buffer.
197 *
198 * @param buffer the buffer
199 *
200 * @return the memory address
201 */
202 static native long getBufferAddress(Buffer buffer);
203
194204 }
3434 /**
3535 *
3636 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3426 $
38 * $Id: DefaultSysImplementation.java 3426 2010-10-01 22:20:14Z spasi $
37 * @version $Revision$
38 * $Id$
3939 */
4040 abstract class DefaultSysImplementation implements SysImplementation {
4141 public native int getJNIVersion();
3636 /**
3737 * A SysImplementation which delegates as much as it can to J2SE.
3838 * <p>
39 * @author $Author: matzon $
40 * @version $Revision: 2983 $
41 * $Id: J2SESysImplementation.java 2983 2008-04-07 18:36:09Z matzon $
39 * @author $Author$
40 * @version $Revision$
41 * $Id$
4242 */
4343 abstract class J2SESysImplementation extends DefaultSysImplementation {
4444
3737 * </p>
3838 *
3939 * @author Brian Matzon <brian@matzon.dk>
40 * @version $Revision: 2983 $
41 * $Id: LWJGLException.java 2983 2008-04-07 18:36:09Z matzon $
40 * @version $Revision$
41 * $Id$
4242 */
4343 public class LWJGLException extends Exception {
4444
4747 * </p>
4848 *
4949 * @author Brian Matzon <brian@matzon.dk>
50 * @version $Revision: 3475 $
51 * $Id: LWJGLUtil.java 3475 2011-01-23 07:48:50Z matzon $
50 * @version $Revision$
51 * $Id$
5252 */
5353 public class LWJGLUtil {
5454 public static final int PLATFORM_LINUX = 1;
5858 public static final String PLATFORM_MACOSX_NAME = "macosx";
5959 public static final String PLATFORM_WINDOWS_NAME = "windows";
6060
61 private static final String LWJGL_ICON_DATA_16x16 =
62 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
63 "\377\377\377\377\377\377\377\377\376\377\377\377\302\327\350\377" +
64 "\164\244\313\377\120\213\275\377\124\216\277\377\206\257\322\377" +
65 "\347\357\366\377\377\377\377\377\377\377\377\377\377\377\377\377" +
66 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
67 "\377\377\377\377\365\365\365\377\215\217\221\377\166\202\215\377" +
68 "\175\215\233\377\204\231\252\377\224\267\325\377\072\175\265\377" +
69 "\110\206\272\377\332\347\361\377\377\377\377\377\377\377\377\377" +
70 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
71 "\364\370\373\377\234\236\240\377\000\000\000\377\000\000\000\377" +
72 "\000\000\000\377\000\000\000\377\344\344\344\377\204\255\320\377" +
73 "\072\175\265\377\133\222\301\377\374\375\376\377\377\377\377\377" +
74 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
75 "\221\266\325\377\137\137\137\377\000\000\000\377\000\000\000\377" +
76 "\000\000\000\377\042\042\042\377\377\377\377\377\350\360\366\377" +
77 "\071\174\265\377\072\175\265\377\304\330\351\377\377\377\377\377" +
78 "\377\377\377\377\377\377\377\377\377\377\377\377\306\331\351\377" +
79 "\201\253\316\377\035\035\035\377\000\000\000\377\000\000\000\377" +
80 "\000\000\000\377\146\146\146\377\377\377\377\377\320\340\355\377" +
81 "\072\175\265\377\072\175\265\377\215\264\324\377\377\377\377\377" +
82 "\362\362\362\377\245\245\245\377\337\337\337\377\242\301\334\377" +
83 "\260\305\326\377\012\012\012\377\000\000\000\377\000\000\000\377" +
84 "\000\000\000\377\250\250\250\377\377\377\377\377\227\272\330\377" +
85 "\072\175\265\377\072\175\265\377\161\241\312\377\377\377\377\377" +
86 "\241\241\241\377\000\000\000\377\001\001\001\377\043\043\043\377" +
87 "\314\314\314\377\320\320\320\377\245\245\245\377\204\204\204\377" +
88 "\134\134\134\377\357\357\357\377\377\377\377\377\140\226\303\377" +
89 "\072\175\265\377\072\175\265\377\155\236\310\377\377\377\377\377" +
90 "\136\136\136\377\000\000\000\377\000\000\000\377\000\000\000\377" +
91 "\317\317\317\377\037\037\037\377\003\003\003\377\053\053\053\377" +
92 "\154\154\154\377\306\306\306\377\372\374\375\377\236\277\332\377" +
93 "\167\245\314\377\114\211\274\377\174\250\316\377\377\377\377\377" +
94 "\033\033\033\377\000\000\000\377\000\000\000\377\027\027\027\377" +
95 "\326\326\326\377\001\001\001\377\000\000\000\377\000\000\000\377" +
96 "\000\000\000\377\122\122\122\377\345\345\345\377\075\075\075\377" +
97 "\150\150\150\377\246\246\247\377\332\336\341\377\377\377\377\377" +
98 "\164\164\164\377\016\016\016\377\000\000\000\377\131\131\131\377" +
99 "\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377" +
100 "\000\000\000\377\221\221\221\377\233\233\233\377\000\000\000\377" +
101 "\000\000\000\377\000\000\000\377\002\002\002\377\103\103\103\377" +
102 "\377\377\377\377\356\356\356\377\214\214\214\377\277\277\277\377" +
103 "\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377" +
104 "\000\000\000\377\323\323\323\377\130\130\130\377\000\000\000\377" +
105 "\000\000\000\377\000\000\000\377\000\000\000\377\063\063\063\377" +
106 "\377\377\377\377\377\377\377\377\374\375\376\377\377\377\377\377" +
107 "\300\300\300\377\100\100\100\377\002\002\002\377\000\000\000\377" +
108 "\033\033\033\377\373\373\373\377\027\027\027\377\000\000\000\377" +
109 "\000\000\000\377\000\000\000\377\000\000\000\377\170\170\170\377" +
110 "\377\377\377\377\377\377\377\377\322\341\356\377\176\251\316\377" +
111 "\340\352\363\377\377\377\377\377\324\324\324\377\155\155\155\377" +
112 "\204\204\204\377\323\323\323\377\000\000\000\377\000\000\000\377" +
113 "\000\000\000\377\000\000\000\377\000\000\000\377\275\275\275\377" +
114 "\377\377\377\377\377\377\377\377\376\376\376\377\146\232\305\377" +
115 "\075\177\266\377\202\254\320\377\344\355\365\377\377\377\377\377" +
116 "\377\377\377\377\345\345\345\377\055\055\055\377\000\000\000\377" +
117 "\000\000\000\377\000\000\000\377\014\014\014\377\366\366\366\377" +
118 "\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" +
119 "\115\211\274\377\072\175\265\377\076\200\266\377\207\260\322\377" +
120 "\347\357\366\377\377\377\377\377\376\376\376\377\274\274\274\377" +
121 "\117\117\117\377\003\003\003\377\112\112\112\377\377\377\377\377" +
122 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
123 "\353\362\370\377\214\263\324\377\126\220\300\377\120\214\275\377" +
124 "\167\245\314\377\355\363\370\377\377\377\377\377\377\377\377\377" +
125 "\377\377\377\377\337\337\337\377\346\346\346\377\377\377\377\377";
126
127 private static final String LWJGL_ICON_DATA_32x32 =
128 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
129 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377" +
130 "\313\335\354\377\223\267\326\377\157\240\311\377\134\223\302\377\140\226\303\377\172\247\315\377\254\310\340\377\355\363\370\377" +
131 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
132 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
133 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377\265\316\343\377\132\222\301\377" +
134 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\105\205\271\377" +
135 "\241\301\334\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
136 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
137 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\374\374\377\342\352\361\377\270\317\343\377\256\311\340\377" +
138 "\243\302\334\377\230\272\330\377\214\263\323\377\201\254\317\377\156\237\310\377\075\177\266\377\072\175\265\377\072\175\265\377" +
139 "\072\175\265\377\162\242\312\377\365\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
140 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
141 "\377\377\377\377\377\377\377\377\377\377\377\377\330\330\330\377\061\061\061\377\044\044\044\377\061\061\061\377\100\100\100\377" +
142 "\122\122\122\377\145\145\145\377\164\164\164\377\217\217\217\377\367\370\370\377\254\310\337\377\073\175\265\377\072\175\265\377" +
143 "\072\175\265\377\072\175\265\377\171\247\315\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
144 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
145 "\377\377\377\377\377\377\377\377\376\376\376\377\150\150\150\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
146 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\266\266\266\377\376\376\376\377\206\256\321\377\072\175\265\377" +
147 "\072\175\265\377\072\175\265\377\072\175\265\377\256\312\341\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
148 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
149 "\377\377\377\377\323\342\356\377\341\352\362\377\050\050\050\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
150 "\000\000\000\377\000\000\000\377\000\000\000\377\002\002\002\377\336\336\336\377\377\377\377\377\365\370\373\377\133\222\301\377" +
151 "\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\364\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377" +
152 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
153 "\354\363\370\377\144\231\305\377\327\331\333\377\005\005\005\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
154 "\000\000\000\377\000\000\000\377\000\000\000\377\044\044\044\377\376\376\376\377\377\377\377\377\377\377\377\377\300\325\347\377" +
155 "\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\253\310\340\377\377\377\377\377\377\377\377\377\377\377\377\377" +
156 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377" +
157 "\170\246\314\377\173\247\315\377\236\236\236\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
158 "\000\000\000\377\000\000\000\377\000\000\000\377\145\145\145\377\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" +
159 "\067\173\264\377\072\175\265\377\072\175\265\377\072\175\265\377\146\232\305\377\377\377\377\377\377\377\377\377\377\377\377\377" +
160 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\327\350\377" +
161 "\071\175\265\377\262\314\341\377\130\130\130\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
162 "\000\000\000\377\000\000\000\377\000\000\000\377\251\251\251\377\377\377\377\377\377\377\377\377\377\377\377\377\274\322\345\377" +
163 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\100\201\267\377\356\364\371\377\377\377\377\377\377\377\377\377" +
164 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377\132\222\301\377" +
165 "\075\177\266\377\335\345\355\377\034\034\034\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
166 "\000\000\000\377\000\000\000\377\007\007\007\377\347\347\347\377\377\377\377\377\377\377\377\377\377\377\377\377\205\256\321\377" +
167 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\314\336\354\377\377\377\377\377\377\377\377\377" +
168 "\377\377\377\377\377\377\377\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\272\322\345\377\072\175\265\377" +
169 "\127\220\277\377\320\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
170 "\000\000\000\377\000\000\000\377\063\063\063\377\375\375\375\377\377\377\377\377\377\377\377\377\373\374\375\377\120\213\275\377" +
171 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\261\314\342\377\377\377\377\377\377\377\377\377" +
172 "\377\377\377\377\312\312\312\377\067\067\067\377\141\141\141\377\242\242\242\377\335\335\335\377\344\354\363\377\261\313\341\377" +
173 "\264\315\342\377\346\346\346\377\043\043\043\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
174 "\000\000\000\377\000\000\000\377\162\162\162\377\377\377\377\377\377\377\377\377\377\377\377\377\330\345\360\377\072\175\265\377" +
175 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\240\300\333\377\377\377\377\377\377\377\377\377" +
176 "\377\377\377\377\146\146\146\377\000\000\000\377\000\000\000\377\000\000\000\377\006\006\006\377\047\047\047\377\146\146\146\377" +
177 "\324\324\324\377\377\377\377\377\366\366\366\377\320\320\320\377\227\227\227\377\136\136\136\377\047\047\047\377\004\004\004\377" +
178 "\000\000\000\377\003\003\003\377\300\300\300\377\377\377\377\377\377\377\377\377\377\377\377\377\242\301\333\377\072\175\265\377" +
179 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\236\277\332\377\377\377\377\377\377\377\377\377" +
180 "\373\373\373\377\045\045\045\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
181 "\134\134\134\377\377\377\377\377\352\352\352\377\217\217\217\377\265\265\265\377\351\351\351\377\375\375\375\377\347\347\347\377" +
182 "\262\262\262\377\275\275\275\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\153\235\307\377\072\175\265\377" +
183 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\241\301\334\377\377\377\377\377\377\377\377\377" +
184 "\333\333\333\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
185 "\203\203\203\377\377\377\377\377\137\137\137\377\000\000\000\377\000\000\000\377\013\013\013\377\067\067\067\377\166\166\166\377" +
186 "\267\267\267\377\360\360\360\377\377\377\377\377\377\377\377\377\377\377\377\377\360\365\371\377\113\210\273\377\075\177\266\377" +
187 "\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\262\314\342\377\377\377\377\377\377\377\377\377" +
188 "\232\232\232\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
189 "\305\305\305\377\367\367\367\377\035\035\035\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
190 "\000\000\000\377\007\007\007\377\074\074\074\377\337\337\337\377\377\377\377\377\373\374\375\377\374\375\376\377\363\367\372\377" +
191 "\314\335\353\377\236\276\332\377\162\241\311\377\114\211\273\377\072\175\265\377\311\334\353\377\377\377\377\377\377\377\377\377" +
192 "\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\017\017\017\377" +
193 "\371\371\371\377\321\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
194 "\000\000\000\377\000\000\000\377\000\000\000\377\216\216\216\377\377\377\377\377\371\371\371\377\204\204\204\377\160\160\160\377" +
195 "\260\260\260\377\352\352\352\377\377\377\377\377\371\373\374\377\334\350\362\377\366\371\374\377\377\377\377\377\377\377\377\377" +
196 "\025\025\025\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\116\116\116\377" +
197 "\377\377\377\377\221\221\221\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
198 "\000\000\000\377\000\000\000\377\000\000\000\377\273\273\273\377\377\377\377\377\236\236\236\377\000\000\000\377\000\000\000\377" +
199 "\000\000\000\377\004\004\004\377\057\057\057\377\160\160\160\377\260\260\260\377\346\346\346\377\376\376\376\377\377\377\377\377" +
200 "\071\071\071\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\220\220\220\377" +
201 "\377\377\377\377\115\115\115\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
202 "\000\000\000\377\000\000\000\377\020\020\020\377\360\360\360\377\377\377\377\377\132\132\132\377\000\000\000\377\000\000\000\377" +
203 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\011\011\011\377\062\062\062\377\261\261\261\377" +
204 "\366\366\366\377\241\241\241\377\065\065\065\377\002\002\002\377\000\000\000\377\000\000\000\377\002\002\002\377\321\321\321\377" +
205 "\365\365\365\377\023\023\023\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
206 "\000\000\000\377\000\000\000\377\105\105\105\377\376\376\376\377\370\370\370\377\035\035\035\377\000\000\000\377\000\000\000\377" +
207 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\053\053\053\377" +
208 "\377\377\377\377\377\377\377\377\374\374\374\377\276\276\276\377\120\120\120\377\005\005\005\377\045\045\045\377\371\371\371\377" +
209 "\302\302\302\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
210 "\000\000\000\377\000\000\000\377\206\206\206\377\377\377\377\377\322\322\322\377\001\001\001\377\000\000\000\377\000\000\000\377" +
211 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\103\103\103\377" +
212 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377\334\334\334\377\340\340\340\377\377\377\377\377" +
213 "\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
214 "\000\000\000\377\001\001\001\377\310\310\310\377\377\377\377\377\216\216\216\377\000\000\000\377\000\000\000\377\000\000\000\377" +
215 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\210\210\210\377" +
216 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
217 "\337\337\337\377\051\051\051\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
218 "\000\000\000\377\030\030\030\377\365\365\365\377\377\377\377\377\112\112\112\377\000\000\000\377\000\000\000\377\000\000\000\377" +
219 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\317\317\317\377" +
220 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\361\366\372\377\377\377\377\377\377\377\377\377" +
221 "\377\377\377\377\371\371\371\377\265\265\265\377\113\113\113\377\006\006\006\377\000\000\000\377\000\000\000\377\000\000\000\377" +
222 "\000\000\000\377\122\122\122\377\377\377\377\377\370\370\370\377\020\020\020\377\000\000\000\377\000\000\000\377\000\000\000\377" +
223 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\034\034\034\377\370\370\370\377" +
224 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\206\257\321\377\220\265\325\377\352\361\367\377" +
225 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\333\333\333\377\170\170\170\377\033\033\033\377\000\000\000\377" +
226 "\000\000\000\377\226\226\226\377\377\377\377\377\306\306\306\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
227 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\132\132\132\377\377\377\377\377" +
228 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\330\351\377\072\175\265\377\103\203\270\377" +
229 "\224\270\326\377\355\363\370\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\364\364\364\377\247\247\247\377" +
230 "\205\205\205\377\364\364\364\377\377\377\377\377\206\206\206\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
231 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\235\235\235\377\377\377\377\377" +
232 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\373\375\377\135\224\302\377\072\175\265\377" +
233 "\072\175\265\377\106\205\271\377\230\273\330\377\357\364\371\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
234 "\377\377\377\377\377\377\377\377\377\377\377\377\233\233\233\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
235 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\005\005\005\377\335\335\335\377\377\377\377\377" +
236 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\305\331\351\377\073\176\266\377" +
237 "\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\236\276\332\377\362\366\372\377\377\377\377\377\377\377\377\377" +
238 "\377\377\377\377\377\377\377\377\377\377\377\377\373\373\373\377\216\216\216\377\045\045\045\377\001\001\001\377\000\000\000\377" +
239 "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\054\054\054\377\374\374\374\377\377\377\377\377" +
240 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\217\265\325\377" +
241 "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\112\207\273\377\243\302\334\377\363\367\372\377" +
242 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\372\372\377\260\260\260\377\105\105\105\377" +
243 "\004\004\004\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\156\156\156\377\377\377\377\377\377\377\377\377" +
244 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377" +
245 "\205\257\321\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\115\211\274\377" +
246 "\250\305\336\377\366\371\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377" +
247 "\322\322\322\377\150\150\150\377\016\016\016\377\000\000\000\377\001\001\001\377\270\270\270\377\377\377\377\377\377\377\377\377" +
248 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
249 "\376\376\377\377\261\313\342\377\114\211\274\377\071\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377" +
250 "\072\175\265\377\115\211\274\377\277\324\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
251 "\377\377\377\377\377\377\377\377\354\354\354\377\223\223\223\377\233\233\233\377\375\375\375\377\377\377\377\377\377\377\377\377" +
252 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
253 "\377\377\377\377\377\377\377\377\363\367\372\377\265\316\343\377\201\254\320\377\145\231\305\377\141\227\304\377\154\236\310\377" +
254 "\217\265\325\377\305\331\351\377\367\372\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
255 "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377";
256
61257 /** LWJGL Logo - 16 by 16 pixels */
62 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
63 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64 -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,
65 -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
66 -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,
67 -115, -113, -111, -1, 118, -126, -115, -1, 125, -115, -101, -1, -124, -103, -86, -1, -108, -73, -43, -1,
68 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,
69 -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,
70 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,
71 -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,
72 -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,
73 -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,
74 -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,
75 -1, 102, 102, 102, -1, -1, -1, -1, -1, -48, -32, -19, -1, 58, 125, -75, -1, 58, 125, -75, -1, -115, -76,
76 -44, -1, -1, -1, -1, -1, -14, -14, -14, -1, -91, -91, -91, -1, -33, -33, -33, -1, -94, -63, -36, -1, -80,
77 -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,
78 -105, -70, -40, -1, 58, 125, -75, -1, 58, 125, -75, -1, 113, -95, -54, -1, -1, -1, -1, -1, -95, -95, -95,
79 -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,
80 -124, -124, -124, -1, 92, 92, 92, -1, -17, -17, -17, -1, -1, -1, -1, -1, 96, -106, -61, -1, 58, 125, -75,
81 -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,
82 -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,
83 -6, -4, -3, -1, -98, -65, -38, -1, 119, -91, -52, -1, 76, -119, -68, -1, 124, -88, -50, -1, -1, -1, -1, -1,
84 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,
85 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,
86 -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,
87 -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,
88 -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,
89 -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,
90 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,
91 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,
92 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,
93 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,
94 -1, -32, -22, -13, -1, -1, -1, -1, -1, -44, -44, -44, -1, 109, 109, 109, -1, -124, -124, -124, -1, -45,
95 -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,
96 -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, 102, -102, -59, -1, 61, 127, -74, -1, -126, -84, -48, -1, -28, -19,
97 -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,
98 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,
99 -1, 77, -119, -68, -1, 58, 125, -75, -1, 62, -128, -74, -1, -121, -80, -46, -1, -25, -17, -10, -1, -1, -1,
100 -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,
101 -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,
102 -64, -1, 80, -116, -67, -1, 119, -91, -52, -1, -19, -13, -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
103 -1, -1, -33, -33, -33, -1, -26, -26, -26, -1, -1, -1, -1, -1
104 });
258 public static final ByteBuffer LWJGLIcon16x16 = loadIcon(LWJGL_ICON_DATA_16x16);
105259
106260 /** LWJGL Logo - 32 by 32 pixels */
107 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
108 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
109 -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,
110 -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,
111 -20, -1, -109, -73, -42, -1, 111, -96, -55, -1, 92, -109, -62, -1, 96, -106, -61, -1, 122, -89, -51, -1,
112 -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,
113 -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,
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, -4, -3, -2, -1, -75, -50, -29, -1, 90, -110, -63, -1,
116 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
117 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,
118 -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,
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, -4, -4, -4, -1, -30, -22, -15, -1, -72, -49, -29, -1, -82, -55, -32,
121 -1, -93, -62, -36, -1, -104, -70, -40, -1, -116, -77, -45, -1, -127, -84, -49, -1, 110, -97, -56, -1, 61,
122 127, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 114, -94, -54, -1, -11, -8, -5, -1, -1,
123 -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,
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, -40, -40, -40, -1, 49, 49, 49, -1, 36, 36, 36, -1, 49, 49, 49, -1, 64,
126 64, 64, -1, 82, 82, 82, -1, 101, 101, 101, -1, 116, 116, 116, -1, -113, -113, -113, -1, -9, -8, -8, -1,
127 -84, -56, -33, -1, 59, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 121, -89, -51,
128 -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,
129 -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,
130 -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,
131 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,
132 -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -82, -54, -31, -1, -1, -1,
133 -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,
134 -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,
135 -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,
136 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,
137 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70, -1, -12, -8, -5, -1, -1, -1, -1, -1,
138 -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,
139 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -20, -13, -8, -1, 100, -103, -59, -1, -41, -39, -37,
140 -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,
141 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,
142 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -85, -56, -32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
143 -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,
144 -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,
145 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,
146 -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,
147 -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,
148 -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,
149 -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,
150 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,
151 -1, -1, -1, -1, -1, -1, -68, -46, -27, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125,
152 -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,
153 -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,
154 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,
155 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,
156 -1, -1, -123, -82, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57,
157 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,
158 -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,
159 -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,
160 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,
161 -117, -67, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57, 125, -75, -1,
162 -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,
163 97, 97, -1, -94, -94, -94, -1, -35, -35, -35, -1, -28, -20, -13, -1, -79, -53, -31, -1, -76, -51, -30, -1,
164 -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,
165 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,
166 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
167 -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,
168 -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,
169 -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,
170 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,
171 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
172 -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,
173 -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,
174 -113, -113, -113, -1, -75, -75, -75, -1, -23, -23, -23, -1, -3, -3, -3, -1, -25, -25, -25, -1, -78, -78,
175 -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,
176 -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75,
177 -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,
178 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,
179 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,
180 -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,
181 127, -74, -1, 57, 124, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1,
182 -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,
183 -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,
184 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,
185 -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,
186 -66, -38, -1, 114, -95, -55, -1, 76, -119, -69, -1, 58, 125, -75, -1, -55, -36, -21, -1, -1, -1, -1, -1,
187 -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,
188 -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,
189 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,
190 -7, -7, -1, -124, -124, -124, -1, 112, 112, 112, -1, -80, -80, -80, -1, -22, -22, -22, -1, -1, -1, -1, -1,
191 -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,
192 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,
193 -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,
194 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,
195 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,
196 -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,
197 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,
198 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,
199 -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,
200 -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,
201 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,
202 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,
203 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,
204 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,
205 -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,
206 -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,
207 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,
208 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,
209 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,
210 -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,
211 -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,
212 -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,
213 -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,
214 -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,
215 -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,
216 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,
217 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,
218 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,
219 -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,
220 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,
221 -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,
222 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,
223 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -122, -81, -47, -1, -112, -75, -43, -1, -22, -15, -9,
224 -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,
225 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,
226 -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,
227 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,
228 -1, -1, -1, -1, -1, -61, -40, -23, -1, 58, 125, -75, -1, 67, -125, -72, -1, -108, -72, -42, -1, -19, -13,
229 -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,
230 -1, -123, -123, -123, -1, -12, -12, -12, -1, -1, -1, -1, -1, -122, -122, -122, -1, 0, 0, 0, -1, 0, 0, 0,
231 -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,
232 -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,
233 -1, -1, -6, -5, -3, -1, 93, -108, -62, -1, 58, 125, -75, -1, 58, 125, -75, -1, 70, -123, -71, -1, -104,
234 -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,
235 -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,
236 -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,
237 -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,
238 -59, -39, -23, -1, 59, 126, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70,
239 -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,
240 -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,
241 -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,
242 -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,
243 -113, -75, -43, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75,
244 -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,
245 -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,
246 -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,
247 -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,
248 -2, -1, -123, -81, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58,
249 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -88, -59, -34, -1, -10, -7, -4, -1, -1, -1, -1, -1, -1,
250 -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,
251 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,
252 -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,
253 -1, -1, -1, -1, -2, -2, -1, -1, -79, -53, -30, -1, 76, -119, -68, -1, 57, 125, -75, -1, 58, 125, -75, -1,
254 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -65, -44, -25,
255 -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,
256 -1, -1, -20, -20, -20, -1, -109, -109, -109, -1, -101, -101, -101, -1, -3, -3, -3, -1, -1, -1, -1, -1, -1,
257 -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,
258 -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,
259 -84, -48, -1, 101, -103, -59, -1, 97, -105, -60, -1, 108, -98, -56, -1, -113, -75, -43, -1, -59, -39, -23,
260 -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,
261 -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,
262 -1, -1, -1
263 });
261 public static final ByteBuffer LWJGLIcon32x32 = loadIcon(LWJGL_ICON_DATA_32x32);
264262
265263 /** Debug flag. */
266264 public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug");
270268 private static final int PLATFORM;
271269
272270 static {
273 LWJGLIcon16x16.flip();
274 LWJGLIcon32x32.flip();
275
276271 final String osName = getPrivilegedProperty("os.name");
277272 if ( osName.startsWith("Windows") )
278273 PLATFORM = PLATFORM_WINDOWS;
279 else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") )
274 else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("OpenBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
280275 PLATFORM = PLATFORM_LINUX;
281276 else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
282277 PLATFORM = PLATFORM_MACOSX;
283278 else
284279 throw new LinkageError("Unknown platform: " + osName);
280 }
281
282 private static ByteBuffer loadIcon(String data) {
283 int len = data.length();
284 ByteBuffer bb = BufferUtils.createByteBuffer(len);
285 for(int i=0 ; i<len ; i++) {
286 bb.put(i, (byte)data.charAt(i));
287 }
288 return bb.asReadOnlyBuffer();
285289 }
286290
287291 /**
312316 default:
313317 return "unknown";
314318 }
319 }
320
321 /**
322 * Wraps {@link System#mapLibraryName}. On OS X with JDK 6, the .jnilib file
323 * extension will be replaced with .dylib.
324 *
325 * @param name the name of the library.
326 *
327 * @return a platform-dependent native library name.
328 */
329 public static String mapLibraryName(String name) {
330 String libName = System.mapLibraryName(name);
331 return LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX && libName.endsWith(".jnilib")
332 ? libName.substring(0, libName.length() - ".jnilib".length()) + ".dylib"
333 : libName;
315334 }
316335
317336 /**
415434 * @return Absolute path to library if found, otherwise null
416435 */
417436 private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
437 Class<?> c = null;
438
418439 try {
419440 log("getPathFromClassLoader: searching for: " + libname);
420 Class<?> c = classloader.getClass();
441 c = classloader.getClass();
421442 while (c != null) {
422443 final Class<?> clazz = c;
423444 try {
435456 }
436457 }
437458 } catch (Exception e) {
438 log("Failure locating " + e + " using classloader:" + e);
459 log("Failure locating " + e + " using classloader:" + c);
439460 }
440461 return null;
441462 }
443464 /**
444465 * Gets a boolean property as a privileged action.
445466 */
446 private static boolean getPrivilegedBoolean(final String property_name) {
447 Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
467 public static boolean getPrivilegedBoolean(final String property_name) {
468 return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
448469 public Boolean run() {
449470 return Boolean.getBoolean(property_name);
450471 }
451472 });
452 return value;
473 }
474
475 /**
476 * Gets an integer property as a privileged action.
477 *
478 * @param property_name the integer property name
479 *
480 * @return the property value
481 */
482 public static Integer getPrivilegedInteger(final String property_name) {
483 return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
484 public Integer run() {
485 return Integer.getInteger(property_name);
486 }
487 });
488 }
489
490 /**
491 * Gets an integer property as a privileged action.
492 *
493 * @param property_name the integer property name
494 * @param default_val the default value to use if the property is not defined
495 *
496 * @return the property value
497 */
498 public static Integer getPrivilegedInteger(final String property_name, final int default_val) {
499 return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
500 public Integer run() {
501 return Integer.getInteger(property_name, default_val);
502 }
503 });
453504 }
454505
455506 /**
457508 *
458509 * @param msg Message to print
459510 */
460 public static void log(String msg) {
511 public static void log(CharSequence msg) {
461512 if (DEBUG) {
462 System.err.println(msg);
513 System.err.println("[LWJGL] " + msg);
463514 }
464515 }
465516
568619 * @param field the Field to test
569620 * @param value the integer value of the field
570621 *
571 * @result true if the Field is accepted
622 * @return true if the Field is accepted
572623 */
573624 boolean accept(Field field, int value);
574625
575626 }
576627
577 }
628 }
3030 */
3131 package org.lwjgl;
3232
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35 import java.security.PrivilegedExceptionAction;
36 import java.lang.UnsatisfiedLinkError;
3337
3438 /**
3539 *
3640 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3418 $
38 * $Id: LinuxSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
41 * @version $Revision$
42 * $Id$
3943 */
4044 final class LinuxSysImplementation extends J2SESysImplementation {
4145 private static final int JNI_VERSION = 19;
4246
4347 static {
44 java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
48 // Load libawt.so and libmawt.so, needed for libjawt.so
49 java.awt.Toolkit.getDefaultToolkit();
50
51 // manually load libjawt.so into vm, needed since Java 7
52 AccessController.doPrivileged(new PrivilegedAction<Object>() {
53 public Object run() {
54 try {
55 System.loadLibrary("jawt");
56 } catch (UnsatisfiedLinkError e) {
57 // catch and ignore an already loaded in another classloader
58 // exception, as vm already has it loaded
59 }
60 return null;
61 }
62 });
4563 }
4664
4765 public int getRequiredJNIVersion() {
5270 // Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
5371 // right anyway.
5472
55 String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
73 String[] browsers = {"sensible-browser", "xdg-open", "google-chrome", "chromium", "firefox", "iceweasel", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
5674
5775 for ( final String browser : browsers ) {
5876 try {
3030 */
3131 package org.lwjgl;
3232
33 import java.awt.Toolkit;
34
3533 import com.apple.eio.FileManager;
34 import java.security.AccessController;
35 import java.security.PrivilegedAction;
36 import java.security.PrivilegedExceptionAction;
37 import java.lang.UnsatisfiedLinkError;
3638
3739 /**
3840 *
3941 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3418 $
41 * $Id: MacOSXSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
42 * @version $Revision$
43 * $Id$
4244 */
4345 final class MacOSXSysImplementation extends J2SESysImplementation {
44 private static final int JNI_VERSION = 19;
46 private static final int JNI_VERSION = 25;
4547
4648 static {
47 // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
48 Toolkit.getDefaultToolkit();
49 // Manually start the AWT Application Loop
50 java.awt.Toolkit.getDefaultToolkit();
4951 }
50
52
5153 public int getRequiredJNIVersion() {
5254 return JNI_VERSION;
5355 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl;
32
33 import java.lang.reflect.Field;
34 import java.nio.*;
35 import java.nio.charset.*;
36
37 /**
38 * [INTERNAL USE ONLY]
39 * <p/>
40 * This class provides utility methods for passing buffers to JNI API calls.
41 *
42 * @author Spasi
43 */
44 public final class MemoryUtil {
45
46 private static final Charset ascii;
47 private static final Charset utf8;
48 private static final Charset utf16;
49
50 static {
51 ascii = Charset.forName("ISO-8859-1");
52 utf8 = Charset.forName("UTF-8");
53 utf16 = Charset.forName("UTF-16LE");
54 }
55
56 private static final Accessor memUtil;
57
58 static {
59 Accessor util;
60 try {
61 // Depends on java.nio.Buffer#address and sun.misc.Unsafe
62 util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
63 } catch (Exception e0) {
64 try {
65 // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
66 util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
67 } catch (Exception e1) {
68 try {
69 // Depends on java.nio.Buffer#address
70 util = new AccessorReflect();
71 } catch (Exception e2) {
72 LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers.");
73 util = new AccessorJNI();
74 }
75 }
76 }
77
78 LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName());
79 memUtil = util;
80
81 /*
82 BENCHMARK RESULTS - Oracle Server VM:
83
84 Unsafe: 4ns
85 ReflectFast: 8ns
86 Reflect: 10ns
87 JNI: 82ns
88
89 BENCHMARK RESULTS - Oracle Client VM:
90
91 Unsafe: 5ns
92 ReflectFast: 81ns
93 Reflect: 85ns
94 JNI: 87ns
95
96 On non-Oracle VMs, Unsafe should be the fastest implementation as well. In the absence
97 of Unsafe, performance will depend on how reflection and JNI are implemented. For now
98 we'll go with what we see on the Oracle VM (that is, we'll prefer reflection over JNI).
99 */
100 }
101
102 private MemoryUtil() {
103 }
104
105 /**
106 * Returns the memory address of the specified buffer. [INTERNAL USE ONLY]
107 *
108 * @param buffer the buffer
109 *
110 * @return the memory address
111 */
112 public static long getAddress0(Buffer buffer) { return memUtil.getAddress(buffer); }
113
114 public static long getAddress0Safe(Buffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer); }
115
116 public static long getAddress0(PointerBuffer buffer) { return memUtil.getAddress(buffer.getBuffer()); }
117
118 public static long getAddress0Safe(PointerBuffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer.getBuffer()); }
119
120 // --- [ API utilities ] ---
121
122 public static long getAddress(ByteBuffer buffer) { return getAddress(buffer, buffer.position()); }
123
124 public static long getAddress(ByteBuffer buffer, int position) { return getAddress0(buffer) + position; }
125
126 public static long getAddress(ShortBuffer buffer) { return getAddress(buffer, buffer.position()); }
127
128 public static long getAddress(ShortBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
129
130 public static long getAddress(CharBuffer buffer) { return getAddress(buffer, buffer.position()); }
131
132 public static long getAddress(CharBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
133
134 public static long getAddress(IntBuffer buffer) { return getAddress(buffer, buffer.position()); }
135
136 public static long getAddress(IntBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
137
138 public static long getAddress(FloatBuffer buffer) { return getAddress(buffer, buffer.position()); }
139
140 public static long getAddress(FloatBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
141
142 public static long getAddress(LongBuffer buffer) { return getAddress(buffer, buffer.position()); }
143
144 public static long getAddress(LongBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
145
146 public static long getAddress(DoubleBuffer buffer) { return getAddress(buffer, buffer.position()); }
147
148 public static long getAddress(DoubleBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
149
150 public static long getAddress(PointerBuffer buffer) { return getAddress(buffer, buffer.position()); }
151
152 public static long getAddress(PointerBuffer buffer, int position) { return getAddress0(buffer) + (position * PointerBuffer.getPointerSize()); }
153
154 // --- [ API utilities - Safe ] ---
155
156 public static long getAddressSafe(ByteBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
157
158 public static long getAddressSafe(ByteBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
159
160 public static long getAddressSafe(ShortBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
161
162 public static long getAddressSafe(ShortBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
163
164 public static long getAddressSafe(CharBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
165
166 public static long getAddressSafe(CharBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
167
168 public static long getAddressSafe(IntBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
169
170 public static long getAddressSafe(IntBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
171
172 public static long getAddressSafe(FloatBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
173
174 public static long getAddressSafe(FloatBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
175
176 public static long getAddressSafe(LongBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
177
178 public static long getAddressSafe(LongBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
179
180 public static long getAddressSafe(DoubleBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
181
182 public static long getAddressSafe(DoubleBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
183
184 public static long getAddressSafe(PointerBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
185
186 public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
187
188 // --- [ String utilities ] ---
189
190 /**
191 * Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated.
192 * If text is null, null is returned.
193 *
194 * @param text the text to encode
195 *
196 * @return the encoded text or null
197 *
198 * @see String#getBytes()
199 */
200 public static ByteBuffer encodeASCII(final CharSequence text) {
201 return encode(text, ascii);
202 }
203
204 /**
205 * Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated.
206 * If text is null, null is returned.
207 *
208 * @param text the text to encode
209 *
210 * @return the encoded text or null
211 *
212 * @see String#getBytes()
213 */
214 public static ByteBuffer encodeUTF8(final CharSequence text) {
215 return encode(text, utf8);
216 }
217
218 /**
219 * Returns a ByteBuffer containing the specified text UTF-16LE encoded and null-terminated.
220 * If text is null, null is returned.
221 *
222 * @param text the text to encode
223 *
224 * @return the encoded text
225 */
226 public static ByteBuffer encodeUTF16(final CharSequence text) {
227 return encode(text, utf16);
228 }
229
230 /**
231 * Wraps the specified text in a null-terminated CharBuffer and encodes it using the specified Charset.
232 *
233 * @param text the text to encode
234 * @param charset the charset to use for encoding
235 *
236 * @return the encoded text
237 */
238 private static ByteBuffer encode(final CharSequence text, final Charset charset) {
239 if ( text == null )
240 return null;
241
242 return encode(CharBuffer.wrap(new CharSequenceNT(text)), charset);
243 }
244
245 /**
246 * A {@link CharsetEncoder#encode(java.nio.CharBuffer)} implementation that uses {@link BufferUtils#createByteBuffer(int)}
247 * instead of {@link ByteBuffer#allocate(int)}.
248 *
249 * @see CharsetEncoder#encode(java.nio.CharBuffer)
250 */
251 private static ByteBuffer encode(final CharBuffer in, final Charset charset) {
252 final CharsetEncoder encoder = charset.newEncoder(); // encoders are not thread-safe, create a new one on every call
253
254 int n = (int)(in.remaining() * encoder.averageBytesPerChar());
255 ByteBuffer out = BufferUtils.createByteBuffer(n);
256
257 if ( n == 0 && in.remaining() == 0 )
258 return out;
259
260 encoder.reset();
261 while ( true ) {
262 CoderResult cr = in.hasRemaining() ? encoder.encode(in, out, true) : CoderResult.UNDERFLOW;
263 if ( cr.isUnderflow() )
264 cr = encoder.flush(out);
265
266 if ( cr.isUnderflow() )
267 break;
268
269 if ( cr.isOverflow() ) {
270 n = 2 * n + 1; // Ensure progress; n might be 0!
271 ByteBuffer o = BufferUtils.createByteBuffer(n);
272 out.flip();
273 o.put(out);
274 out = o;
275 continue;
276 }
277
278 try {
279 cr.throwException();
280 } catch (CharacterCodingException e) {
281 throw new RuntimeException(e);
282 }
283 }
284 out.flip();
285 return out;
286 }
287
288 public static String decodeASCII(final ByteBuffer buffer) {
289 return decode(buffer, ascii);
290 }
291
292 public static String decodeUTF8(final ByteBuffer buffer) {
293 return decode(buffer, utf8);
294 }
295
296 public static String decodeUTF16(final ByteBuffer buffer) {
297 return decode(buffer, utf16);
298 }
299
300 private static String decode(final ByteBuffer buffer, final Charset charset) {
301 if ( buffer == null )
302 return null;
303
304 return decodeImpl(buffer, charset);
305 }
306
307 private static String decodeImpl(final ByteBuffer in, final Charset charset) {
308 final CharsetDecoder decoder = charset.newDecoder(); // decoders are not thread-safe, create a new one on every call
309
310 int n = (int)(in.remaining() * decoder.averageCharsPerByte());
311 CharBuffer out = BufferUtils.createCharBuffer(n);
312
313 if ( (n == 0) && (in.remaining() == 0) )
314 return "";
315
316 decoder.reset();
317 for (; ; ) {
318 CoderResult cr = in.hasRemaining() ? decoder.decode(in, out, true) : CoderResult.UNDERFLOW;
319 if ( cr.isUnderflow() )
320 cr = decoder.flush(out);
321
322 if ( cr.isUnderflow() )
323 break;
324 if ( cr.isOverflow() ) {
325 n = 2 * n + 1; // Ensure progress; n might be 0!
326 CharBuffer o = BufferUtils.createCharBuffer(n);
327 out.flip();
328 o.put(out);
329 out = o;
330 continue;
331 }
332 try {
333 cr.throwException();
334 } catch (CharacterCodingException e) {
335 throw new RuntimeException(e);
336 }
337 }
338 out.flip();
339 return out.toString();
340 }
341
342 /** A null-terminated CharSequence. */
343 private static class CharSequenceNT implements CharSequence {
344
345 final CharSequence source;
346
347 CharSequenceNT(CharSequence source) {
348 this.source = source;
349 }
350
351 public int length() {
352 return source.length() + 1;
353
354 }
355
356 public char charAt(final int index) {
357 return index == source.length() ? '\0' : source.charAt(index);
358
359 }
360
361 public CharSequence subSequence(final int start, final int end) {
362 return new CharSequenceNT(source.subSequence(start, Math.min(end, source.length())));
363 }
364
365 }
366
367 interface Accessor {
368
369 long getAddress(Buffer buffer);
370
371 }
372
373 private static Accessor loadAccessor(final String className) throws Exception {
374 return (Accessor)Class.forName(className).newInstance();
375 }
376
377 /** Default implementation. */
378 private static class AccessorJNI implements Accessor {
379
380 public long getAddress(final Buffer buffer) {
381 return BufferUtils.getBufferAddress(buffer);
382 }
383
384 }
385
386 /** Implementation using reflection on ByteBuffer. */
387 private static class AccessorReflect implements Accessor {
388
389 private final Field address;
390
391 AccessorReflect() {
392 try {
393 address = getAddressField();
394 } catch (NoSuchFieldException e) {
395 throw new UnsupportedOperationException(e);
396 }
397 address.setAccessible(true);
398 }
399
400 public long getAddress(final Buffer buffer) {
401 try {
402 return address.getLong(buffer);
403 } catch (IllegalAccessException e) {
404 // cannot happen
405 return 0L;
406 }
407 }
408
409 }
410
411 static Field getAddressField() throws NoSuchFieldException {
412 return getDeclaredFieldRecursive(ByteBuffer.class, "address");
413 }
414
415 private static Field getDeclaredFieldRecursive(final Class<?> root, final String fieldName) throws NoSuchFieldException {
416 Class<?> type = root;
417
418 do {
419 try {
420 return type.getDeclaredField(fieldName);
421 } catch (NoSuchFieldException e) {
422 type = type.getSuperclass();
423 }
424 } while ( type != null );
425
426 throw new NoSuchFieldException(fieldName + " does not exist in " + root.getSimpleName() + " or any of its superclasses.");
427 }
428
429 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl;
32
33 import java.lang.reflect.Field;
34 import java.lang.reflect.Method;
35 import java.lang.reflect.Modifier;
36 import java.nio.Buffer;
37
38 import sun.misc.Unsafe;
39 import sun.reflect.FieldAccessor;
40
41 /**
42 * MemoryUtil.Accessor implementations that depend on sun.misc.
43 * We use reflection to grab these, so that we can compile on JDKs
44 * that do not support sun.misc.
45 *
46 * @author Spasi
47 */
48 final class MemoryUtilSun {
49
50 private MemoryUtilSun() {
51 }
52
53 /** Implementation using sun.misc.Unsafe. */
54 private static class AccessorUnsafe implements MemoryUtil.Accessor {
55
56 private final Unsafe unsafe;
57 private final long address;
58
59 AccessorUnsafe() {
60 try {
61 unsafe = getUnsafeInstance();
62 address = unsafe.objectFieldOffset(MemoryUtil.getAddressField());
63 } catch (Exception e) {
64 throw new UnsupportedOperationException(e);
65 }
66 }
67
68 public long getAddress(final Buffer buffer) {
69 return unsafe.getLong(buffer, address);
70 }
71
72 private static Unsafe getUnsafeInstance() {
73 final Field[] fields = Unsafe.class.getDeclaredFields();
74
75 /*
76 Different runtimes use different names for the Unsafe singleton,
77 so we cannot use .getDeclaredField and we scan instead. For example:
78
79 Oracle: theUnsafe
80 PERC : m_unsafe_instance
81 Android: THE_ONE
82 */
83 for ( Field field : fields ) {
84 if ( !field.getType().equals(Unsafe.class) )
85 continue;
86
87 final int modifiers = field.getModifiers();
88 if ( !(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) )
89 continue;
90
91 field.setAccessible(true);
92 try {
93 return (Unsafe)field.get(null);
94 } catch (IllegalAccessException e) {
95 // ignore
96 }
97 break;
98 }
99
100 throw new UnsupportedOperationException();
101 }
102
103 }
104
105 /** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */
106 private static class AccessorReflectFast implements MemoryUtil.Accessor {
107
108 private final FieldAccessor addressAccessor;
109
110 AccessorReflectFast() {
111 Field address;
112 try {
113 address = MemoryUtil.getAddressField();
114 } catch (NoSuchFieldException e) {
115 throw new UnsupportedOperationException(e);
116 }
117 address.setAccessible(true);
118
119 try {
120 Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
121 m.setAccessible(true);
122 addressAccessor = (FieldAccessor)m.invoke(address, true);
123 } catch (Exception e) {
124 throw new UnsupportedOperationException(e);
125 }
126 }
127
128 public long getAddress(final Buffer buffer) {
129 return addressAccessor.getLong(buffer);
130 }
131
132 }
133
134 }
+0
-409
src/java/org/lwjgl/NondirectBufferWrapper.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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 static final int INITIAL_BUFFER_SIZE = 1;
52
53 private static final ThreadLocal<CachedBuffers> thread_buffer = new ThreadLocal<CachedBuffers>() {
54 protected CachedBuffers initialValue() {
55 return new CachedBuffers(INITIAL_BUFFER_SIZE);
56 }
57 };
58
59 private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
60 CachedBuffers buffers = 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 static final 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 }
5858
5959 protected final ByteBuffer pointers;
6060
61 protected final Buffer view;
62 protected final IntBuffer view32;
61 protected final Buffer view;
62 protected final IntBuffer view32;
6363 protected final LongBuffer view64;
6464
6565 /**
7979 * @param source the source buffer
8080 */
8181 public PointerBuffer(final ByteBuffer source) {
82 if ( !source.isDirect() )
83 throw new IllegalArgumentException("ByteBuffer is not direct");
82 if ( LWJGLUtil.CHECKS )
83 checkSource(source);
8484
8585 pointers = source.slice().order(source.order());
8686
9393 }
9494 }
9595
96 private static void checkSource(final ByteBuffer source) {
97 if ( !source.isDirect() )
98 throw new IllegalArgumentException("The source buffer is not direct.");
99
100 final int alignment = is64Bit ? 8 : 4;
101 if ( (MemoryUtil.getAddress0(source) + source.position()) % alignment != 0 || source.remaining() % alignment != 0 )
102 throw new IllegalArgumentException("The source buffer is not aligned to " + alignment + " bytes.");
103 }
104
96105 /**
97106 * Returns the ByteBuffer that backs this PointerBuffer.
98107 *
540549 */
541550 public static void put(final ByteBuffer target, int index, long l) {
542551 if ( is64Bit )
543 target.putLong(index * 8, l);
552 target.putLong(index, l);
544553 else
545 target.putInt(index * 4, (int)l);
554 target.putInt(index, (int)l);
546555 }
547556
548557 // -- Bulk get operations --
4545 * System class (named Sys so as not to conflict with java.lang.System)
4646 * </p>
4747 * @author cix_foo <cix_foo@users.sourceforge.net>
48 * @version $Revision: 3488 $
49 * $Id: Sys.java 3488 2011-02-09 21:09:33Z matzon $
48 * @version $Revision$
49 * $Id$
5050 */
5151 public final class Sys {
5252 /** The native library name */
5353 private static final String JNI_LIBRARY_NAME = "lwjgl";
5454
5555 /** Current version of library */
56 private static final String VERSION = "2.7.1";
56 private static final String VERSION = "2.9.3";
5757
5858 private static final String POSTFIX64BIT = "64";
5959
6666 public Object run() {
6767 String library_path = System.getProperty("org.lwjgl.librarypath");
6868 if (library_path != null) {
69 System.load(library_path + File.separator +
70 System.mapLibraryName(lib_name));
69 System.load(library_path + File.separator + LWJGLUtil.mapLibraryName(lib_name));
7170 } else {
7271 System.loadLibrary(lib_name);
7372 }
7776 }
7877
7978 private static void loadLibrary(final String lib_name) {
79 // actively try to load 64bit libs on 64bit architectures first
80 String osArch = System.getProperty("os.arch");
81 boolean try64First = LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX && ("amd64".equals(osArch) || "x86_64".equals(osArch));
82
83 Error err = null;
84 if ( try64First ) {
85 try {
86 doLoadLibrary(lib_name + POSTFIX64BIT);
87 return;
88 } catch (UnsatisfiedLinkError e) {
89 err = e;
90 }
91 }
92
93 // fallback to loading the "old way"
8094 try {
8195 doLoadLibrary(lib_name);
8296 } catch (UnsatisfiedLinkError e) {
97 if ( try64First )
98 throw err;
99
83100 if (implementation.has64Bit()) {
84101 try {
85102 doLoadLibrary(lib_name + POSTFIX64BIT);
88105 LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
89106 }
90107 }
108
91109 // Throw original error
92110 throw e;
93111 }
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3426 $
40 * $Id: SysImplementation.java 3426 2010-10-01 22:20:14Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242 interface SysImplementation {
4343 /**
3030 */
3131 package org.lwjgl;
3232
33 import java.nio.ByteBuffer;
3334 import java.security.PrivilegedExceptionAction;
3435 import java.security.PrivilegedActionException;
3536 import java.security.AccessController;
3940
4041 /**
4142 * <p>
42 * @author $Author: spasi $
43 * @version $Revision: 3418 $
44 * $Id: WindowsSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
43 * @author $Author$
44 * @version $Revision$
45 * $Id$
4546 */
4647 final class WindowsSysImplementation extends DefaultSysImplementation {
47 private static final int JNI_VERSION = 23;
48 private static final int JNI_VERSION = 24;
4849
4950 static {
5051 Sys.initialize();
9495 if(!Display.isCreated()) {
9596 initCommonControls();
9697 }
97 nAlert(getHwnd(), title, message);
98
99 LWJGLUtil.log(String.format("*** Alert *** %s\n%s\n", title, message));
100
101 final ByteBuffer titleText = MemoryUtil.encodeUTF16(title);
102 final ByteBuffer messageText = MemoryUtil.encodeUTF16(message);
103 nAlert(getHwnd(), MemoryUtil.getAddress(titleText), MemoryUtil.getAddress(messageText));
98104 }
99 private static native void nAlert(long parent_hwnd, String title, String message);
105 private static native void nAlert(long parent_hwnd, long title, long message);
100106 private static native void initCommonControls();
101107
102108 public boolean openURL(final String url) {
4141 *
4242 * This is a <em>very basic</em> skeleton to init a game and run it.
4343 *
44 * @author $Author: spasi $
45 * @version $Revision: 3418 $
46 * $Id: Game.java 3418 2010-09-28 21:11:35Z spasi $
44 * @author $Author$
45 * @version $Revision$
46 * $Id$
4747 */
4848 public class Game {
4949
4646 * whether it's playing.
4747 * </p>
4848 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 3418 $
50 * $Id: SoundManager.java 3418 2010-09-28 21:11:35Z spasi $
49 * @version $Revision$
50 * $Id$
5151 */
5252 public class SoundManager {
5353
269269 * @param zone The dead zone to use for the RZ axis
270270 */
271271 void setRZAxisDeadZone(float zone);
272
273
274 /** Returns the number of rumblers this controller supports */
275 int getRumblerCount();
276
277 /** Returns the name of the specified rumbler
278 *
279 * @param index The rumbler index
280 */
281 String getRumblerName(int index);
282
283 /** Sets the vibration strength of the specified rumbler
284 *
285 * @param index The index of the rumbler
286 * @param strength The strength to vibrate at
287 */
288 void setRumblerStrength(int index, float strength);
272289 }
5151 private int index;
5252 /** Type of control that generated the event */
5353 private int type;
54 /** True when a button is pressed, if this event was caused by the button */
55 private boolean buttonState;
5456 /** True if this event was caused by the x axis */
5557 private boolean xaxis;
5658 /** True if this event was caused by the y axis */
5759 private boolean yaxis;
5860 /** The time stamp of this event */
5961 private long timeStamp;
62 /** The value on a specified axis, if this event was caused by the x-axis */
63 private float xaxisValue;
64 /** The value on a specified axis, if this event was caused by the y-axis */
65 private float yaxisValue;
6066
6167 /**
6268 * Create a new event
6975 * @param yaxis True if this event was caused by the y-axis
7076 */
7177 ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
78 this(source, timeStamp, type, index, false, xaxis, yaxis, 0, 0);
79 }
80
81 /**
82 * Create a new event
83 *
84 * @param source The source of the event
85 * @param timeStamp The time stamp given for this event
86 * @param type The type of control generating this event
87 * @param index The index of the input that generated the event
88 * @param buttonState True when a button is pressed, if this event was caused by the button
89 * @param xaxis True if this event was caused by the x-axis
90 * @param yaxis True if this event was caused by the y-axis
91 * @param xaxisValue The value on a specified axis, if this event was caused by the x-axis
92 * @param yaxisValue The value on a specified axis, if this event was caused by the y-axis
93 */
94 ControllerEvent(Controller source,long timeStamp, int type,int index,boolean buttonState,boolean xaxis,boolean yaxis,float xaxisValue,float yaxisValue) {
7295 this.source = source;
7396 this.timeStamp = timeStamp;
7497 this.type = type;
7598 this.index = index;
99 this.buttonState = buttonState;
76100 this.xaxis = xaxis;
77101 this.yaxis = yaxis;
102 this.xaxisValue = xaxisValue;
103 this.yaxisValue = yaxisValue;
78104 }
79105
80106 /**
115141 }
116142
117143 /**
144 * Check the button is pressed or not, when this event was caused
145 *
146 * @return True when a button is pressed, if this event was caused by the button
147 */
148 public boolean getButtonState() {
149 return buttonState;
150 }
151
152 /**
118153 * Check if this event was generated by a axis
119154 *
120155 * @return True if this event was generated by a axis
158193 public boolean isYAxis() {
159194 return yaxis;
160195 }
196
197 /**
198 * Get the value on an X axis when this event was caused
199 *
200 * @return The value on a specified axis, if this event was caused by the x-axis
201 */
202 public float getXAxisValue() {
203 return xaxisValue;
204 }
205
206 /**
207 * Get the value on an Y axis when this event was caused
208 *
209 * @return The value on a specified axis, if this event was caused by the y-axis
210 */
211 public float getYAxisValue() {
212 return yaxisValue;
213 }
161214
162215 /*
163216 * @see java.lang.Object#toString()
261261 /**
262262 * Get the timestamp assigned to the current event
263263 *
264 * @return The timestamp assigned ot the current event
264 * @return The timestamp assigned to the current event
265265 */
266266 public static long getEventNanoseconds() {
267267 return event.getTimeStamp();
268 }
269
270 /**
271 * Gets the state of the button that generated the current event
272 *
273 * @return True if button was down, or false if released
274 */
275 public static boolean getEventButtonState() {
276 return event.getButtonState();
277 }
278
279 /**
280 * Get the value on an X axis of the current event
281 *
282 * @return The value on a x axis of the current event
283 */
284 public static float getEventXAxisValue() {
285 return event.getXAxisValue();
286 }
287
288 /**
289 * Get the value on an Y axis of the current event
290 *
291 * @return The value on a y axis of the current event
292 */
293 public static float getEventYAxisValue() {
294 return event.getYAxisValue();
268295 }
269296
270297 /**
3232
3333 import java.nio.IntBuffer;
3434
35 import org.lwjgl.BufferChecks;
3536 import org.lwjgl.BufferUtils;
3637 import org.lwjgl.LWJGLException;
3738 import org.lwjgl.LWJGLUtil;
38 import org.lwjgl.NondirectBufferWrapper;
3939 import org.lwjgl.Sys;
4040
4141 /**
4444 * class can be used with Mouse.setCursor(), if available.
4545 *
4646 * @author elias_naur <elias_naur@users.sourceforge.net>
47 * @version $Revision: 3418 $
48 * $Id: Cursor.java 3418 2010-09-28 21:11:35Z spasi $
47 * @version $Revision$
48 * $Id$
4949 */
5050
5151 public class Cursor {
8585 synchronized (OpenGLPackageAccess.global_lock) {
8686 if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
8787 throw new LWJGLException("Native cursors not supported");
88 images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
88 BufferChecks.checkBufferSize(images, width*height*numImages);
8989 if (delays != null)
90 delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
90 BufferChecks.checkBufferSize(delays, numImages);
9191 if (!Mouse.isCreated())
9292 throw new IllegalStateException("Mouse must be created before creating cursor objects");
9393 if (width*height*numImages > images.remaining())
162162 IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
163163 flipImages(width, height, numImages, images, images_copy);
164164
165 // Win32 doesn't (afaik) allow for animation based cursors, except when they're
166 // in the .ani format, which we don't support.
165 // Mac and Windows doesn't (afaik) allow for animation based cursors, except in the .ani
166 // format on Windows, which we don't support.
167167 // The cursor animation was therefor developed using java side time tracking.
168168 // unfortunately X flickers when changing cursor. We therefore check for either
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
169 // Windows, Mac or X and do accordingly.
170 // we might want to split it into a X/Win/Mac cursor if it gets too cluttered
171171
172172 CursorElement[] cursors;
173173 switch (LWJGLUtil.getPlatform()) {
174174 case LWJGLUtil.PLATFORM_MACOSX:
175 /* Fall through */
175
176 // OS X requires the image format to be in ABGR format
177 convertARGBtoABGR(images_copy);
178
179 // create our cursor elements
180 cursors = new CursorElement[numImages];
181 for(int i=0; i<numImages; i++) {
182 Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
183 long delay = (delays != null) ? delays.get(i) : 0;
184 long timeout = System.currentTimeMillis();
185 cursors[i] = new CursorElement(handle, delay, timeout);
186
187 // offset to next image
188 images_copy.position(width*height*(i+1));
189 }
190 break;
176191 case LWJGLUtil.PLATFORM_WINDOWS:
177192 // create our cursor elements
178193 cursors = new CursorElement[numImages];
207222 throw new RuntimeException("Unknown OS");
208223 }
209224 return cursors;
225 }
226
227 /**
228 * Convert an IntBuffer image of ARGB format into ABGR
229 *
230 * @param imageBuffer image to convert
231 */
232 private static void convertARGBtoABGR(IntBuffer imageBuffer) {
233 for (int i = 0; i < imageBuffer.limit(); i++) {
234 int argbColor = imageBuffer.get(i);
235
236 byte alpha = (byte)(argbColor >>> 24);
237 byte blue = (byte)(argbColor >>> 16);
238 byte green = (byte)(argbColor >>> 8);
239 byte red = (byte)argbColor;
240
241 int abgrColor = ((alpha & 0xff) << 24 ) + ((red & 0xff) << 16 ) + ((green & 0xff) << 8 ) + ((blue & 0xff) );
242
243 imageBuffer.put(i, abgrColor);
244 }
210245 }
211246
212247 /**
3737 import net.java.games.input.Component.Identifier.Button;
3838 import net.java.games.input.Event;
3939 import net.java.games.input.EventQueue;
40 import net.java.games.input.Rumbler;
4041
4142 /**
4243 * A wrapper round a JInput controller that attempts to make the interface
5556 private ArrayList<Component> axes = new ArrayList<Component>();
5657 /** The POVs that have been detected on the JInput controller */
5758 private ArrayList<Component> pov = new ArrayList<Component>();
59 /** The rumblers exposed by the controller */
60 private Rumbler[] rumblers;
5861 /** The state of the buttons last check */
5962 private boolean[] buttonState;
6063 /** The values that were read from the pov last check */
8588 * @param index The index this controller has been assigned to
8689 * @param target The target JInput controller this class is wrapping
8790 */
88 JInputController(int index,net.java.games.input.Controller target) {
91 JInputController(int index, net.java.games.input.Controller target) {
8992 this.target = target;
9093 this.index = index;
9194
147150 axesMax[i] = 1.0f;
148151 deadZones[i] = 0.05f;
149152 }
153
154 rumblers = target.getRumblers();
150155 }
151156
152157 /*
202207 buttonState[buttonIndex] = event.getValue() != 0;
203208
204209 // fire button pressed event
205 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
210 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
211 buttonState[buttonIndex],false,false,0,0));
206212 }
207213
208214 // handle pov events
226232 Component axis = event.getComponent();
227233 int axisIndex = axes.indexOf(axis);
228234 float value = axis.getPollData();
235 float xaxisValue = 0;
236 float yaxisValue = 0;
229237
230238 // fixed dead zone since most axis don't report it :(
231239 if (Math.abs(value) < deadZones[axisIndex]) {
240248
241249 // normalize the value based on maximum value read in the past
242250 value /= axesMax[axisIndex];
251
252 if (axisIndex == xaxis) {
253 xaxisValue = value;
254 }
255 if (axisIndex == yaxis) {
256 yaxisValue = value;
257 }
258
243259 // fire event
244 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
245 axisIndex == xaxis,axisIndex == yaxis));
260 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
261 axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
246262 axesValue[axisIndex] = value;
247263 }
248264 }
505521 return 0;
506522 }
507523
524 public int getRumblerCount() {
525 return rumblers.length;
526 }
527
528 public String getRumblerName(int index) {
529 return rumblers[index].getAxisName();
530 }
531
532 public void setRumblerStrength(int index, float strength) {
533 rumblers[index].rumble(strength);
534 }
508535
509536 }
5050 * @author cix_foo <cix_foo@users.sourceforge.net>
5151 * @author elias_naur <elias_naur@users.sourceforge.net>
5252 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 3463 $
54 * $Id: Keyboard.java 3463 2010-12-15 18:48:56Z kappa1 $
53 * @version $Revision$
54 * $Id$
5555 */
5656 public class Keyboard {
5757 /** Internal use - event size in bytes */
157157 public static final int KEY_F13 = 0x64; /* (NEC PC98) */
158158 public static final int KEY_F14 = 0x65; /* (NEC PC98) */
159159 public static final int KEY_F15 = 0x66; /* (NEC PC98) */
160 public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */
161 public static final int KEY_F17 = 0x68;
162 public static final int KEY_F18 = 0x69;
160163 public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
164 public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */
161165 public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
162166 public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
163167 public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
172176 public static final int KEY_UNLABELED = 0x97; /* (J3100) */
173177 public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
174178 public static final int KEY_RCONTROL = 0x9D;
179 public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
175180 public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
176181 public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
177182 public static final int KEY_SYSRQ = 0xB7;
178183 public static final int KEY_RMENU = 0xB8; /* right Alt */
184 public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
179185 public static final int KEY_PAUSE = 0xC5; /* Pause */
180186 public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
181187 public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
187193 public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
188194 public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
189195 public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
190 public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
196 public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
197 public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
191198 /**
192199 * The left windows key, mapped to KEY_LMETA
193200 *
215222 private static final int BUFFER_SIZE = 50;
216223
217224 /** Key names */
218 private static final String[] keyName = new String[255];
225 private static final String[] keyName = new String[KEYBOARD_SIZE];
219226 private static final Map<String, Integer> keyMap = new HashMap<String, Integer>(253);
220227 private static int counter;
221228
228235 && Modifier.isPublic(field.getModifiers())
229236 && Modifier.isFinal(field.getModifiers())
230237 && field.getType().equals(int.class)
231 && field.getName().startsWith("KEY_") ) {
238 && field.getName().startsWith("KEY_")
239 && !field.getName().endsWith("WIN") ) { /* Don't use deprecated names */
232240
233241 int key = field.getInt(null);
234242 String name = field.getName().substring(4);
5858 * @author cix_foo <cix_foo@users.sourceforge.net>
5959 * @author elias_naur <elias_naur@users.sourceforge.net>
6060 * @author Brian Matzon <brian@matzon.dk>
61 * @version $Revision: 3418 $
62 * $Id: Mouse.java 3418 2010-09-28 21:11:35Z spasi $
61 * @version $Revision$
62 * $Id$
6363 */
6464 public class Mouse {
6565 /** Internal use - event size in bytes */
7676
7777 /** Mouse absolute Y position in pixels */
7878 private static int y;
79
80 /** Mouse absolute X position in pixels without any clipping */
81 private static int absolute_x;
82
83 /** Mouse absolute Y position in pixels without any clipping */
84 private static int absolute_y;
7985
8086 /** Buffer to hold the deltas dx, dy and dwheel */
8187 private static IntBuffer coord_buffer;
127133 /** The position of the mouse it was grabbed at */
128134 private static int grab_x;
129135 private static int grab_y;
136 /** The last absolute mouse event position (before clipping) for delta computation */
137 private static int last_event_raw_x;
138 private static int last_event_raw_y;
130139
131140 /** Buffer size in events */
132141 private static final int BUFFER_SIZE = 50;
139148 private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS ||
140149 LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX;
141150
142 private static final boolean allowNegativeMouseCoords = getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
151 private static boolean clipMouseCoordinatesToWindow = !getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
143152
144153 /**
145154 * Mouse cannot be constructed.
188197 }
189198 }
190199
200 public static boolean isClipMouseCoordinatesToWindow() {
201 return clipMouseCoordinatesToWindow;
202 }
203
204 public static void setClipMouseCoordinatesToWindow(boolean clip) {
205 clipMouseCoordinatesToWindow = clip;
206 }
207
191208 /**
192209 * Set the position of the cursor. If the cursor is not grabbed,
193210 * the native cursor is moved to the new position.
343360 dy += poll_coord2;
344361 x += poll_coord1;
345362 y += poll_coord2;
363 absolute_x += poll_coord1;
364 absolute_y += poll_coord2;
346365 } else {
347 dx = poll_coord1 - x;
348 dy = poll_coord2 - y;
349 x = poll_coord1;
350 y = poll_coord2;
366 dx = poll_coord1 - absolute_x;
367 dy = poll_coord2 - absolute_y;
368 absolute_x = x = poll_coord1;
369 absolute_y = y = poll_coord2;
351370 }
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;
371
372 if(clipMouseCoordinatesToWindow) {
373 x = Math.min(Display.getWidth() - 1, Math.max(0, x));
374 y = Math.min(Display.getHeight() - 1, Math.max(0, y));
375 }
376
377 dwheel += poll_dwheel;
357378 read();
358379 }
359380 }
411432 /**
412433 * Gets the next mouse event. You can query which button caused the event by using
413434 * <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>.
435 * <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>
436 * and <code>getEventDY()</code>.
416437 * @see org.lwjgl.input.Mouse#getEventButton()
417438 * @see org.lwjgl.input.Mouse#getEventButtonState()
418439 * @return true if a mouse event was read, false otherwise
428449 event_dy = readBuffer.getInt();
429450 event_x += event_dx;
430451 event_y += event_dy;
452 last_event_raw_x = event_x;
453 last_event_raw_y = event_y;
431454 } else {
432455 int new_event_x = readBuffer.getInt();
433456 int new_event_y = readBuffer.getInt();
434 event_dx = new_event_x - event_x;
435 event_dy = new_event_y - event_y;
457 event_dx = new_event_x - last_event_raw_x;
458 event_dy = new_event_y - last_event_raw_y;
436459 event_x = new_event_x;
437460 event_y = new_event_y;
461 last_event_raw_x = new_event_x;
462 last_event_raw_y = new_event_y;
438463 }
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));
464 if(clipMouseCoordinatesToWindow) {
465 event_x = Math.min(Display.getWidth() - 1, Math.max(0, event_x));
466 event_y = Math.min(Display.getHeight() - 1, Math.max(0, event_y));
467 }
441468 event_dwheel = readBuffer.getInt();
442469 event_nanos = readBuffer.getLong();
443470 return true;
637664 poll();
638665 event_x = x;
639666 event_y = y;
667 last_event_raw_x = x;
668 last_event_raw_y = y;
640669 resetMouse();
641670 }
642671 }
4141 * </p>
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 3418 $
45 * $Id: AL.java 3418 2010-09-28 21:11:35Z spasi $
44 * @version $Revision$
45 * $Id$
4646 */
4747 public final class AL {
4848 /** ALCdevice instance. */
114114 String[] library_names;
115115 switch (LWJGLUtil.getPlatform()) {
116116 case LWJGLUtil.PLATFORM_WINDOWS:
117 libname = "OpenAL32";
118 library_names = new String[]{"OpenAL64.dll", "OpenAL32.dll"};
117 if ( Sys.is64Bit() ) {
118 libname = "OpenAL64";
119 library_names = new String[]{"OpenAL64.dll"};
120 } else {
121 libname = "OpenAL32";
122 library_names = new String[]{"OpenAL32.dll"};
123 }
119124 break;
120125 case LWJGLUtil.PLATFORM_LINUX:
121126 libname = "openal";
3030 */
3131 package org.lwjgl.openal;
3232
33 import java.nio.Buffer;
33 import java.nio.ByteBuffer;
3434 import java.nio.IntBuffer;
3535 import java.util.HashMap;
3636
3737 import org.lwjgl.BufferChecks;
3838 import org.lwjgl.LWJGLException;
39 import org.lwjgl.MemoryUtil;
3940
4041 /**
4142 *
150151 * @return String property from device
151152 */
152153 public static String alcGetString(ALCdevice device, int pname) {
153 String result;
154 result = nalcGetString(getDevice(device), pname);
154 ByteBuffer buffer = nalcGetString(getDevice(device), pname);
155155 Util.checkALCError(device);
156 return result;
157 }
158 static native String nalcGetString(long device, int pname);
156 return MemoryUtil.decodeUTF8(buffer);
157 }
158 static native ByteBuffer nalcGetString(long device, int pname);
159159
160160 /**
161161 * The application can query ALC for information using an integer query function.
179179 */
180180 public static void alcGetInteger(ALCdevice device, int pname, IntBuffer integerdata) {
181181 BufferChecks.checkDirect(integerdata);
182 nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), integerdata, integerdata.position());
182 nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), MemoryUtil.getAddress(integerdata));
183183 Util.checkALCError(device);
184184 }
185 static native void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
185 static native void nalcGetIntegerv(long device, int pname, int size, long integerdata);
186186
187187 /**
188188 * The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
197197 * @return opened device, or null
198198 */
199199 public static ALCdevice alcOpenDevice(String devicename) {
200 long device_address = nalcOpenDevice(devicename);
200 ByteBuffer buffer = MemoryUtil.encodeUTF8(devicename);
201 long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer));
201202 if(device_address != 0) {
202203 ALCdevice device = new ALCdevice(device_address);
203204 synchronized (ALC10.devices) {
207208 }
208209 return null;
209210 }
210 static native long nalcOpenDevice(String devicename);
211 static native long nalcOpenDevice(long devicename);
211212
212213 /**
213214 * The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to
245246 * @return New context, or null if creation failed
246247 */
247248 public static ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrList) {
248 long context_address = nalcCreateContext(getDevice(device), attrList);
249 long context_address = nalcCreateContext(getDevice(device), MemoryUtil.getAddressSafe(attrList));
249250 Util.checkALCError(device);
250251
251252 if(context_address != 0) {
258259 }
259260 return null;
260261 }
261 static native long nalcCreateContext(long device, IntBuffer attrList);
262 static native long nalcCreateContext(long device, long attrList);
262263
263264 /**
264265 * To make a Context current with respect to AL Operation (state changes by issueing
393394 * @return true if extension is available, false if not
394395 */
395396 public static boolean alcIsExtensionPresent(ALCdevice device, String extName) {
396 boolean result = nalcIsExtensionPresent(getDevice(device), extName);
397 ByteBuffer buffer = MemoryUtil.encodeASCII(extName);
398 boolean result = nalcIsExtensionPresent(getDevice(device), MemoryUtil.getAddress(buffer));
397399 Util.checkALCError(device);
398400 return result;
399401 }
400 static native boolean nalcIsExtensionPresent(long device, String extName);
402 private static native boolean nalcIsExtensionPresent(long device, long extName);
401403
402404 /**
403405 * Enumeration/token values are device independend, but tokens defined for
410412 * @return value of enumeration
411413 */
412414 public static int alcGetEnumValue(ALCdevice device, String enumName) {
413 int result = nalcGetEnumValue(getDevice(device), enumName);
415 ByteBuffer buffer = MemoryUtil.encodeASCII(enumName);
416 int result = nalcGetEnumValue(getDevice(device), MemoryUtil.getAddress(buffer));
414417 Util.checkALCError(device);
415418 return result;
416419 }
417 static native int nalcGetEnumValue(long device, String enumName);
420 private static native int nalcGetEnumValue(long device, long enumName);
418421
419422 static long getDevice(ALCdevice device) {
420423 if(device != null) {
3636 import org.lwjgl.BufferUtils;
3737 import org.lwjgl.LWJGLException;
3838 import org.lwjgl.LWJGLUtil;
39
39 import org.lwjgl.MemoryUtil;
4040
4141 /**
4242 * <p>
9191 * @return ALCdevice if it was possible to open a device
9292 */
9393 public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) {
94 long device_address = nalcCaptureOpenDevice(devicename, frequency, format, buffersize);
94 ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
95 long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddressSafe(buffer), frequency, format, buffersize);
9596 if(device_address != 0) {
9697 ALCdevice device = new ALCdevice(device_address);
9798 synchronized (ALC10.devices) {
101102 }
102103 return null;
103104 }
104 static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize);
105 private static native long nalcCaptureOpenDevice(long devicename, int frequency, int format, int buffersize);
105106
106107 /**
107108 * The alcCaptureCloseDevice function allows the application to disconnect from a capture
161162 * @param samples Number of samples to request
162163 */
163164 public static void alcCaptureSamples(ALCdevice device, ByteBuffer buffer, int samples ) {
164 nalcCaptureSamples(ALC10.getDevice(device), buffer, buffer.position(), samples);
165 }
166 static native void nalcCaptureSamples(long device, ByteBuffer buffer, int position, int samples );
165 nalcCaptureSamples(ALC10.getDevice(device), MemoryUtil.getAddress(buffer), samples);
166 }
167 static native void nalcCaptureSamples(long device, long buffer, int samples );
167168
168169 static native void initNativeStubs() throws LWJGLException;
169170
4545 * AL and ALC are threadsafe.
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 3418 $
49 * $Id: ALCcontext.java 3418 2010-09-28 21:11:35Z spasi $
48 * @version $Revision$
49 * $Id$
5050 */
5151 public final class ALCcontext {
5252
8181 * @param contextFrequency Frequency to add
8282 * @param contextRefresh Refresh rate to add
8383 * @param contextSynchronized Whether to synchronize the context
84 * @return
84 * @return attribute list
8585 */
8686 static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
8787 IntBuffer attribList = BufferUtils.createIntBuffer(7);
4444 * which has to map the available backends to unique device specifiers.
4545 *
4646 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 3418 $
48 * $Id: ALCdevice.java 3418 2010-09-28 21:11:35Z spasi $
47 * @version $Revision$
48 * $Id$
4949 */
5050 public final class ALCdevice {
5151
3636 * causes an error.
3737 *
3838 * @author Brian Matzon <brian@matzon.dk>
39 * @version $Revision: 2983 $
40 * $Id: OpenALException.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242 public class OpenALException extends RuntimeException {
4343
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
3838 * @author Brian Matzon <brian@matzon.dk>
39 * @version $Revision: 2983 $
39 * @version $Revision$
4040 */
4141
4242 public final class Util {
3030 */
3131 package org.lwjgl.opencl;
3232
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
33 import org.lwjgl.*;
3634 import org.lwjgl.opencl.FastLongMap.Entry;
3735
3836 import java.nio.*;
5250 */
5351 final class APIUtil {
5452
55 private static final int INITIAL_BUFFER_SIZE = 256;
53 private static final int INITIAL_BUFFER_SIZE = 256;
5654 private static final int INITIAL_LENGTHS_SIZE = 4;
5755
5856 private static final int BUFFERS_SIZE = 32;
222220 *
223221 * @return the String as a ByteBuffer
224222 */
225 static ByteBuffer getBuffer(final CharSequence string) {
223 static long getBuffer(final CharSequence string) {
226224 final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
227225 buffer.flip();
228 return buffer;
226 return MemoryUtil.getAddress0(buffer);
229227 }
230228
231229 /**
235233 *
236234 * @return the String as a ByteBuffer
237235 */
238 static ByteBuffer getBuffer(final CharSequence string, final int offset) {
236 static long getBuffer(final CharSequence string, final int offset) {
239237 final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
240238 buffer.flip();
241 return buffer;
239 return MemoryUtil.getAddress(buffer);
242240 }
243241
244242 /**
248246 *
249247 * @return the String as a ByteBuffer
250248 */
251 static ByteBuffer getBufferNT(final CharSequence string) {
249 static long getBufferNT(final CharSequence string) {
252250 final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
253251 buffer.put((byte)0);
254252 buffer.flip();
255 return buffer;
253 return MemoryUtil.getAddress0(buffer);
256254 }
257255
258256 static int getTotalLength(final CharSequence[] strings) {
270268 *
271269 * @return the Strings as a ByteBuffer
272270 */
273 static ByteBuffer getBuffer(final CharSequence[] strings) {
271 static long getBuffer(final CharSequence[] strings) {
274272 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
275273
276274 for ( CharSequence string : strings )
277275 encode(buffer, string);
278276
279277 buffer.flip();
280 return buffer;
278 return MemoryUtil.getAddress0(buffer);
281279 }
282280
283281 /**
287285 *
288286 * @return the Strings as a ByteBuffer
289287 */
290 static ByteBuffer getBufferNT(final CharSequence[] strings) {
288 static long getBufferNT(final CharSequence[] strings) {
291289 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
292290
293291 for ( CharSequence string : strings ) {
296294 }
297295
298296 buffer.flip();
299 return buffer;
297 return MemoryUtil.getAddress0(buffer);
300298 }
301299
302300 /**
306304 *
307305 * @return the String lengths in a PointerBuffer
308306 */
309 static PointerBuffer getLengths(final CharSequence[] strings) {
307 static long getLengths(final CharSequence[] strings) {
310308 PointerBuffer buffer = getLengths(strings.length);
311309
312310 for ( CharSequence string : strings )
313311 buffer.put(string.length());
314312
315313 buffer.flip();
316 return buffer;
314 return MemoryUtil.getAddress0(buffer);
317315 }
318316
319317 /**
323321 *
324322 * @return the buffer lengths in a PointerBuffer
325323 */
326 static PointerBuffer getLengths(final ByteBuffer[] buffers) {
324 static long getLengths(final ByteBuffer[] buffers) {
327325 PointerBuffer lengths = getLengths(buffers.length);
328326
329327 for ( ByteBuffer buffer : buffers )
330328 lengths.put(buffer.remaining());
331329
332330 lengths.flip();
333 return lengths;
331 return MemoryUtil.getAddress0(lengths);
334332 }
335333
336334 static int getSize(final PointerBuffer lengths) {
341339 return (int)size;
342340 }
343341
342 static long getPointer(final PointerWrapper pointer) {
343 return MemoryUtil.getAddress0(getBufferPointer().put(0, pointer));
344 }
345
346 static long getPointerSafe(final PointerWrapper pointer) {
347 return MemoryUtil.getAddress0(getBufferPointer().put(0, pointer == null ? 0L : pointer.getPointer()));
348 }
349
344350 private static class Buffers {
345351
346352 final ShortBuffer shorts;
347 final IntBuffer ints;
348 final IntBuffer intsDebug;
349 final LongBuffer longs;
350
351 final FloatBuffer floats;
353 final IntBuffer ints;
354 final IntBuffer intsDebug;
355 final LongBuffer longs;
356
357 final FloatBuffer floats;
352358 final DoubleBuffer doubles;
353359
354360 final PointerBuffer pointers;
452458 */
453459 static void releaseObjects(final CLDevice device) {
454460 // Release objects only if we're about to hit 0.
455 if ( device.getReferenceCount() > 1 )
461 if ( !device.isValid() || device.getReferenceCount() > 1 )
456462 return;
457463
458464 releaseObjects(device.getSubCLDeviceRegistry(), DESTRUCTOR_CLSubDevice);
465471 */
466472 static void releaseObjects(final CLContext context) {
467473 // Release objects only if we're about to hit 0.
468 if ( context.getReferenceCount() > 1 )
474 if ( !context.isValid() || context.getReferenceCount() > 1 )
469475 return;
470476
471477 releaseObjects(context.getCLEventRegistry(), DESTRUCTOR_CLEvent);
482488 */
483489 static void releaseObjects(final CLProgram program) {
484490 // Release objects only if we're about to hit 0.
485 if ( program.getReferenceCount() > 1 )
491 if ( !program.isValid() || program.getReferenceCount() > 1 )
486492 return;
487493
488494 releaseObjects(program.getCLKernelRegistry(), DESTRUCTOR_CLKernel);
495501 */
496502 static void releaseObjects(final CLCommandQueue queue) {
497503 // Release objects only if we're about to hit 0.
498 if ( queue.getReferenceCount() > 1 )
504 if ( !queue.isValid() || queue.getReferenceCount() > 1 )
499505 return;
500506
501507 releaseObjects(queue.getCLEventRegistry(), DESTRUCTOR_CLEvent);
512518 }
513519 }
514520
515 private static final ObjectDestructor<CLDevice> DESTRUCTOR_CLSubDevice = new ObjectDestructor<CLDevice>() {
521 private static final ObjectDestructor<CLDevice> DESTRUCTOR_CLSubDevice = new ObjectDestructor<CLDevice>() {
516522 public void release(final CLDevice object) { clReleaseDeviceEXT(object); }
517523 };
518 private static final ObjectDestructor<CLMem> DESTRUCTOR_CLMem = new ObjectDestructor<CLMem>() {
524 private static final ObjectDestructor<CLMem> DESTRUCTOR_CLMem = new ObjectDestructor<CLMem>() {
519525 public void release(final CLMem object) { clReleaseMemObject(object); }
520526 };
521527 private static final ObjectDestructor<CLCommandQueue> DESTRUCTOR_CLCommandQueue = new ObjectDestructor<CLCommandQueue>() {
522528 public void release(final CLCommandQueue object) { clReleaseCommandQueue(object); }
523529 };
524 private static final ObjectDestructor<CLSampler> DESTRUCTOR_CLSampler = new ObjectDestructor<CLSampler>() {
530 private static final ObjectDestructor<CLSampler> DESTRUCTOR_CLSampler = new ObjectDestructor<CLSampler>() {
525531 public void release(final CLSampler object) { clReleaseSampler(object); }
526532 };
527 private static final ObjectDestructor<CLProgram> DESTRUCTOR_CLProgram = new ObjectDestructor<CLProgram>() {
533 private static final ObjectDestructor<CLProgram> DESTRUCTOR_CLProgram = new ObjectDestructor<CLProgram>() {
528534 public void release(final CLProgram object) { clReleaseProgram(object); }
529535 };
530 private static final ObjectDestructor<CLKernel> DESTRUCTOR_CLKernel = new ObjectDestructor<CLKernel>() {
536 private static final ObjectDestructor<CLKernel> DESTRUCTOR_CLKernel = new ObjectDestructor<CLKernel>() {
531537 public void release(final CLKernel object) { clReleaseKernel(object); }
532538 };
533 private static final ObjectDestructor<CLEvent> DESTRUCTOR_CLEvent = new ObjectDestructor<CLEvent>() {
539 private static final ObjectDestructor<CLEvent> DESTRUCTOR_CLEvent = new ObjectDestructor<CLEvent>() {
534540 public void release(final CLEvent object) { clReleaseEvent(object); }
535541 };
536542
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.MemoryUtil;
3536 import org.lwjgl.Sys;
3637
3738 import java.nio.ByteBuffer;
142143 return 0;
143144 }
144145
145 static native long getFunctionAddress(String name);
146 /** Helper method to get a pointer to a named function in the OpenCL library. */
147 static long getFunctionAddress(String name) {
148 ByteBuffer buffer = MemoryUtil.encodeASCII(name);
149 return ngetFunctionAddress(MemoryUtil.getAddress(buffer));
150 }
151 private static native long ngetFunctionAddress(long name);
146152
147153 static native ByteBuffer getHostBuffer(final long address, final int size);
148154
00 /*
1 * Copyright (c) 2002-2010 LWJGL Project
1 * Copyright (c) 2002-2011 LWJGL Project
22 * All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
3232
3333 /**
3434 * Instances of this class can be used to receive OpenCL program build notifications.
35 * A single CLBuildProgramCallback instance should only be used with programs created
36 * in the same CLContext.
3537 *
3638 * @author Spasi
3739 */
38 public abstract class CLBuildProgramCallback extends CLCallback {
39
40 protected CLBuildProgramCallback() {
41 super(CallbackUtil.getBuildProgramCallback());
42 }
43
44 /**
45 * Called from native code.
46 *
47 * @param program_address the CLProgram object pointer
48 */
49 private void handleMessage(long program_address) {
50 handleMessage(CLContext.getCLProgramGlobal(program_address));
51 }
52
53 /**
54 * The callback method.
55 *
56 * @param program the CLProgram object that was built
57 */
58 protected abstract void handleMessage(CLProgram program);
40 public abstract class CLBuildProgramCallback extends CLProgramCallback {
5941
6042 }
+0
-59
src/java/org/lwjgl/opencl/CLCallback.java less more
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Base class for OpenCL callback objects.
37 *
38 * @author Spasi
39 */
40 abstract class CLCallback extends PointerWrapperAbstract {
41
42 private final boolean custom;
43
44 protected CLCallback(final long pointer) {
45 this(pointer, false);
46 }
47
48 protected CLCallback(final long pointer, final boolean custom) {
49 super(pointer);
50
51 this.custom = custom;
52 }
53
54 final boolean isCustom() {
55 return custom;
56 }
57
58 }
5252 /**
5353 * Calculates the number of bytes in the specified cl_mem buffer rectangle region.
5454 *
55 * @param origin the host origin
55 * @param offset the host offset
5656 * @param region the rectangle region
5757 * @param row_pitch the host row pitch
5858 * @param slice_pitch the host slice pitch
5959 *
6060 * @return the region size in bytes
6161 */
62 static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) {
63 if ( !LWJGLUtil.CHECKS )
64 return 0;
65
66 final long x = origin.get(0);
67 final long y = origin.get(1);
68 final long z = origin.get(2);
62 static int calculateBufferRectSize(final PointerBuffer offset, final PointerBuffer region, long row_pitch, long slice_pitch) {
63 if ( !LWJGLUtil.CHECKS )
64 return 0;
65
66 final long x = offset.get(0);
67 final long y = offset.get(1);
68 final long z = offset.get(2);
6969
7070 if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) )
71 throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z);
71 throw new IllegalArgumentException("Invalid cl_mem host offset: " + x + ", " + y + ", " + z);
7272
7373 final long w = region.get(0);
7474 final long h = region.get(1);
4949 super(pointer, context);
5050 if ( isValid() ) {
5151 this.device = device;
52 this.clEvents = new CLObjectRegistryGlobal<CLEvent>(CLContext.clEventsGlobal);
52 this.clEvents = new CLObjectRegistry<CLEvent>();
5353 context.getCLCommandQueueRegistry().registerObject(this);
5454 } else {
5555 this.device = null;
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 /**
34 * Instances of this class can be used to receive OpenCL program compilation notifications.
35 * A single CLCompileProgramCallback instance should only be used with programs created
36 * in the same CLContext.
37 *
38 * @author Spasi
39 */
40 public abstract class CLCompileProgramCallback extends CLProgramCallback {
41
42 }
4848 private static final CLContextUtil util = (CLContextUtil)CLPlatform.getInfoUtilInstance(CLContext.class, "CL_CONTEXT_UTIL");
4949
5050 private final CLObjectRegistry<CLCommandQueue> clCommandQueues;
51 private final CLObjectRegistry<CLMem> clMems;
52 private final CLObjectRegistry<CLSampler> clSamplers;
53 private final CLObjectRegistry<CLProgram> clPrograms;
54 private final CLObjectRegistry<CLEvent> clEvents;
55
56 /** Global registry for build callbacks. */
57 static final FastLongMap<CLProgram> clProgramsGlobal = new FastLongMap<CLProgram>();
58
59 /** Global registry for event callbacks. */
60 static final FastLongMap<CLEvent> clEventsGlobal = new FastLongMap<CLEvent>();
51 private final CLObjectRegistry<CLMem> clMems;
52 private final CLObjectRegistry<CLSampler> clSamplers;
53 private final CLObjectRegistry<CLProgram> clPrograms;
54 private final CLObjectRegistry<CLEvent> clEvents;
55
56 private long
57 contextCallback,
58 printfCallback;
6159
6260 CLContext(final long pointer, final CLPlatform platform) {
6361 super(pointer, platform);
6967 clCommandQueues = new CLObjectRegistry<CLCommandQueue>();
7068 clMems = new CLObjectRegistry<CLMem>();
7169 clSamplers = new CLObjectRegistry<CLSampler>();
72 clPrograms = new CLObjectRegistryGlobal<CLProgram>(clProgramsGlobal);
73 clEvents = new CLObjectRegistryGlobal<CLEvent>(clEventsGlobal);
70 clPrograms = new CLObjectRegistry<CLProgram>();
71 clEvents = new CLObjectRegistry<CLEvent>();
7472 } else {
7573 clCommandQueues = null;
7674 clMems = null;
274272
275273 CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; }
276274
277 static CLProgram getCLProgramGlobal(final long id) { return clProgramsGlobal.get(id); }
278
279 static CLEvent getCLEventGlobal(final long id) { return clEventsGlobal.get(id); }
275 private boolean checkCallback(final long callback, final int result) {
276 if ( result == 0 && (callback == 0 || isValid()) )
277 return true;
278
279 if ( callback != 0 )
280 CallbackUtil.deleteGlobalRef(callback);
281 return false;
282 }
283
284 /**
285 * Associates this context with the specified context callback reference. If the context
286 * is invalid, the callback reference is deleted. NO-OP if user_data is 0.
287 *
288 * @param callback the context callback pointer
289 */
290 void setContextCallback(final long callback) {
291 if ( checkCallback(callback, 0) )
292 this.contextCallback = callback;
293 }
294
295 /**
296 * Associates this context with the specified printf callback reference. If the context
297 * is invalid, the callback reference is deleted. NO-OP if user_data is 0.
298 *
299 * @param callback the printf callback pointer
300 */
301 void setPrintfCallback(final long callback, final int result) {
302 if ( checkCallback(callback, result) )
303 this.printfCallback = callback;
304 }
305
306 /**
307 * Decrements the context's reference count. If the reference
308 * count hits zero, it also deletes
309 * any callback objects associated with it.
310 */
311 void releaseImpl() {
312 if ( release() > 0 )
313 return;
314
315 if ( contextCallback != 0 )
316 CallbackUtil.deleteGlobalRef(contextCallback);
317 if ( printfCallback != 0 )
318 CallbackUtil.deleteGlobalRef(printfCallback);
319 }
280320
281321 }
107107
108108 // -------[ IMPLEMENTATION STUFF BELOW ]-------
109109
110 CLObjectRegistry<CLEvent> getParentRegistry() {
111 if ( queue == null )
112 return getParent().getCLEventRegistry();
113 else
114 return queue.getCLEventRegistry();
115 }
116
110117 int release() {
111118 try {
112119 return super.release();
3030 */
3131 package org.lwjgl.opencl;
3232
33 import org.lwjgl.PointerWrapperAbstract;
34
3335 /**
34 * Instances of this class can be used to receive OpenCL memory object destruction notifications.
36 * Instances of this class can be used to handle OpenCL event callbacks. A single
37 * CLEventCallback instance should only be used on events generated from the same
38 * CLCommandQueue or on user events associated with the same CLContext.
3539 *
3640 * @author Spasi
3741 */
38 public abstract class CLEventCallback extends CLCallback {
42 public abstract class CLEventCallback extends PointerWrapperAbstract {
43
44 private CLObjectRegistry<CLEvent> eventRegistry;
3945
4046 protected CLEventCallback() {
4147 super(CallbackUtil.getEventCallback());
48 }
49
50 /**
51 * Sets the eventRegistry that contains the CLEvents to which we're registered.
52 *
53 * @param eventRegistry the CLEvent object registry
54 */
55 void setRegistry(final CLObjectRegistry<CLEvent> eventRegistry) {
56 this.eventRegistry = eventRegistry;
4257 }
4358
4459 /**
4762 * @param event_address the CLEvent object pointer
4863 */
4964 private void handleMessage(long event_address, int event_command_exec_status) {
50 handleMessage(CLContext.getCLEventGlobal(event_address), event_command_exec_status);
65 handleMessage(eventRegistry.getObject(event_address), event_command_exec_status);
5166 }
5267
5368 /**
5469 * The callback method.
5570 *
56 * @param event the CLEvent object
71 * @param event the CLEvent object
72 * @param event_command_exec_status the execution status
5773 */
5874 protected abstract void handleMessage(CLEvent event, int event_command_exec_status);
5975
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 /**
34 * Instances of this class can be used to receive OpenCL program linkage notifications.
35 * A single CLLinkProgramCallback instance should only be used with programs created
36 * in the same CLContext.
37 *
38 * @author Spasi
39 */
40 public abstract class CLLinkProgramCallback extends CLProgramCallback {
41
42 }
3030 */
3131 package org.lwjgl.opencl;
3232
33 import org.lwjgl.PointerWrapperAbstract;
34
3335 /**
3436 * Instances of this class can be used to receive OpenCL memory object destruction notifications.
3537 *
3638 * @author Spasi
3739 */
38 public abstract class CLMemObjectDestructorCallback extends CLCallback {
40 public abstract class CLMemObjectDestructorCallback extends PointerWrapperAbstract {
3941
4042 protected CLMemObjectDestructorCallback() {
4143 super(CallbackUtil.getMemObjectDestructorCallback());
3030 */
3131 package org.lwjgl.opencl;
3232
33 import org.lwjgl.PointerWrapperAbstract;
34
3335 import java.nio.ByteBuffer;
3436
3537 /**
4244 * @see CL10#clEnqueueNativeKernel
4345 * @see #execute(java.nio.ByteBuffer[])
4446 */
45 public abstract class CLNativeKernel extends CLCallback {
47 public abstract class CLNativeKernel extends PointerWrapperAbstract {
4648
4749 protected CLNativeKernel() {
4850 super(CallbackUtil.getNativeKernelCallback());
+0
-57
src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java less more
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 /**
34 * A CLObject registry that also registers/unregisters objects to/from a global registry.
35 *
36 * @author Spasi
37 */
38 final class CLObjectRegistryGlobal<T extends CLObjectChild> extends CLObjectRegistry<T> {
39
40 private final FastLongMap<T> globalRegistry;
41
42 CLObjectRegistryGlobal(final FastLongMap<T> globalRegistry) {
43 this.globalRegistry = globalRegistry;
44 }
45
46 void registerObject(final T object) {
47 super.registerObject(object);
48 globalRegistry.put(object.getPointer(), object);
49 }
50
51 void unregisterObject(final T object) {
52 super.unregisterObject(object);
53 globalRegistry.remove(object.getPointerUnsafe());
54 }
55
56 }
5252
5353 private final CLObjectRegistry<CLDevice> clDevices;
5454
55 /** Global registry for build callbacks. */
56 static final FastLongMap<CLDevice> clDevicesGlobal = new FastLongMap<CLDevice>();
57
5855 private Object caps;
5956
6057 CLPlatform(final long pointer) {
6259
6360 if ( isValid() ) {
6461 clPlatforms.put(pointer, this);
65 clDevices = new CLObjectRegistryGlobal<CLDevice>(clDevicesGlobal);
62 clDevices = new CLObjectRegistry<CLDevice>();
6663 } else
6764 clDevices = null;
6865 }
194191
195192 CLObjectRegistry<CLDevice> getCLDeviceRegistry() { return clDevices; }
196193
197 static CLDevice getCLDeviceGlobal(final long id) { return clDevicesGlobal.get(id); }
198
199194 /**
200195 * Called from <code>clGetDeviceIDs</code> to register new devices.
201196 *
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Instances of this class can be used to receive OpenCL printf messages.
37 * Different CLContexts should use different CLPrintfCallback instances.
38 *
39 * @author Spasi
40 */
41 public abstract class CLPrintfCallback extends PointerWrapperAbstract {
42
43 protected CLPrintfCallback() {
44 super(CallbackUtil.getPrintfCallback());
45 }
46
47 /** The callback method. */
48 protected abstract void handleMessage(String data);
49
50 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Base class for OpenCL program action notifications.
37 *
38 * @author Spasi
39 */
40 abstract class CLProgramCallback extends PointerWrapperAbstract {
41
42 private CLContext context;
43
44 protected CLProgramCallback() {
45 super(CallbackUtil.getProgramCallback());
46 }
47
48 /**
49 * Sets the context that contains the CLPrograms to which we're registered.
50 *
51 * @param context the CLContext object
52 */
53 final void setContext(final CLContext context) {
54 this.context = context;
55 }
56
57 /**
58 * Called from native code.
59 *
60 * @param program_address the CLProgram object pointer
61 */
62 private void handleMessage(long program_address) {
63 handleMessage(context.getCLProgram(program_address));
64 }
65
66 /**
67 * The callback method.
68 *
69 * @param program the CLProgram object affected
70 */
71 protected abstract void handleMessage(CLProgram program);
72
73 }
6969 *
7070 * @param ref the GlobalRef memory address.
7171 */
72 private static native void deleteGlobalRef(long ref);
72 static native void deleteGlobalRef(long ref);
7373
7474 /**
7575 * Deletes the global reference represented by user_data if an OpenCL error occured.
9898 */
9999 static native long getContextCallback();
100100
101 /**
102 * Associates the specified CLContext with the specified global reference. If the context
103 * is invalid, the global reference is deleted. NO-OP if user_data is 0.
104 *
105 * @param context the CLContext to register
106 * @param user_data the global reference pointer
107 */
108 static void registerCallback(final CLContext context, final long user_data) {
109 if ( context.getPointerUnsafe() == 0 ) {
110 if ( user_data != 0 )
111 deleteGlobalRef(user_data);
112 return;
113 }
114
115 if ( user_data != 0 )
116 contextUserData.put(context, user_data);
117 }
118
119 /**
120 * Decrements the specified context's reference count, clears its association
121 * with a CLContextCallback object if it exists and deletes the corresponding
122 * global reference.
123 *
124 * @param context the CLContext to unregister
125 */
126 static void unregisterCallback(final CLContext context) {
127 if ( context.release() > 0 )
128 return;
129
130 final Long user_data = contextUserData.remove(context);
131
132 if ( user_data != null )
133 deleteGlobalRef(user_data);
134 }
135
136101 /* [ Other callback functionality ]
137102 The other callbacks are simpler. We create the GlobalRef before passing the callback,
138103 we delete it when we receive the callback call.
150115 *
151116 * @return the callback function address
152117 */
153 static native long getBuildProgramCallback();
118 static native long getProgramCallback();
154119
155120 /**
156121 * Returns the memory address of the native function we pass to clEnqueueNativeKernel.
165130 * @return the callback function address
166131 */
167132 static native long getEventCallback();
133
134 /**
135 * Returns the memory address of the native function we pass to clSetPrintfCallback.
136 *
137 * @return the callback function address
138 */
139 static native long getPrintfCallback();
168140
169141 /**
170142 * Returns the memory address of the native function we pass to clCreateContext(FromType),
117117 final long user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);
118118 CLContext __result = null;
119119 try {
120 __result = new CLContext(nclCreateContext(properties.getBuffer(), 0, devices.size(), properties.getBuffer(), propertyCount * PointerBuffer.getPointerSize(), pfn_notify == null ? 0 : pfn_notify.getPointer(), user_data, errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), platform);
120 __result = new CLContext(nclCreateContext(MemoryUtil.getAddress0(properties.getBuffer()), devices.size(), MemoryUtil.getAddress(properties, propertyCount), pfn_notify == null ? 0 : pfn_notify.getPointer(), user_data, MemoryUtil.getAddressSafe(errcode_ret), function_pointer), platform);
121121 if ( LWJGLUtil.DEBUG )
122122 Util.checkCLError(errcode_ret.get(0));
123123 return __result;
124124 } finally {
125 CallbackUtil.registerCallback(__result, user_data);
125 if ( __result != null ) __result.setContextCallback(user_data);
126126 }
127127 }
128128
255255
256256 final int size;
257257 switch ( param_name ) {
258 case CL_KERNEL_WORK_GROUP_SIZE:
258 case CL_KERNEL_COMPILE_WORK_GROUP_SIZE:
259259 size = 3;
260260 break;
261261 default:
303303 else if ( LWJGLUtil.DEBUG )
304304 errcode_ret = APIUtil.getBufferInt();
305305
306 CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_row_pitch, host_ptr,
307 host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0,
308 errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
306 CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_row_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
307 (host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0),
308 MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
309309 if ( LWJGLUtil.DEBUG )
310310 Util.checkCLError(errcode_ret.get(0));
311311 return __result;
323323 else if ( LWJGLUtil.DEBUG )
324324 errcode_ret = APIUtil.getBufferInt();
325325
326 CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr,
327 host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0,
328 errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
326 CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
327 (host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
328 MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
329329 if ( LWJGLUtil.DEBUG )
330330 Util.checkCLError(errcode_ret.get(0));
331331 return __result;
546546
547547 target = new ByteBuffer[sizes.remaining()];
548548 for ( int i = 0; i < sizes.remaining(); i++ )
549 target[i] = BufferUtils.createByteBuffer((int)sizes.get(0));
549 target[i] = BufferUtils.createByteBuffer((int)sizes.get(i));
550550 } else if ( LWJGLUtil.DEBUG ) {
551551 final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
552552
109109 description = "OTHER";
110110 break;
111111 default:
112 description = "Unknown (" + Integer.toHexString(category) + ")";
112 description = printUnknownToken(category);
113113 }
114114 System.err.println("\tCategory: " + description);
115115
124124 description = "LOW";
125125 break;
126126 default:
127 description = "Unknown (" + Integer.toHexString(category) + ")";
127 description = printUnknownToken(severity);
128128 }
129129 System.err.println("\tSeverity: " + description);
130130
131131 System.err.println("\tMessage: " + message);
132 }
133
134 private String printUnknownToken(final int token) {
135 return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
132136 }
133137 });
134138 }
00 /*
1 * Copyright (c) 2002-2008 LWJGL Project
1 * Copyright (c) 2002-2011 LWJGL Project
22 * All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
3232
3333 import org.lwjgl.BufferUtils;
3434 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.MemoryUtil;
3536
3637 import java.nio.*;
3738
38 /** @author spasi */
39 /**
40 * Utility class for OpenGL API calls. Instances of APIUtil are created in ContextCapabilities,
41 * so we have an instance per OpenGL context.
42 *
43 * @author spasi
44 */
3945 final class APIUtil {
4046
41 private static final int INITIAL_BUFFER_SIZE = 256;
47 private static final int INITIAL_BUFFER_SIZE = 256;
4248 private static final int INITIAL_LENGTHS_SIZE = 4;
4349
4450 private static final int BUFFERS_SIZE = 32;
4551
46 private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() {
47 protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
48 };
49
50 private static final ThreadLocal<ByteBuffer> bufferTL = new ThreadLocal<ByteBuffer>() {
51 protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
52 };
53
54 private static final ThreadLocal<IntBuffer> lengthsTL = new ThreadLocal<IntBuffer>() {
55 protected IntBuffer initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); }
56 };
57
58 private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() {
59 protected Buffers initialValue() { return new Buffers(); }
60 };
61
62 private APIUtil() {
63 }
64
65 private static char[] getArray(final int size) {
66 char[] array = arrayTL.get();
52 private char[] array;
53 private ByteBuffer buffer;
54 private IntBuffer lengths;
55
56 private final IntBuffer ints;
57 private final LongBuffer longs;
58 private final FloatBuffer floats;
59 private final DoubleBuffer doubles;
60
61 APIUtil() {
62 array = new char[INITIAL_BUFFER_SIZE];
63 buffer = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
64 lengths = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
65
66 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
67 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
68
69 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
70 doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
71 }
72
73 private static char[] getArray(final ContextCapabilities caps, final int size) {
74 char[] array = caps.util.array;
6775
6876 if ( array.length < size ) {
6977 int sizeNew = array.length << 1;
7179 sizeNew <<= 1;
7280
7381 array = new char[size];
74 arrayTL.set(array);
82 caps.util.array = array;
7583 }
7684
7785 return array;
7886 }
7987
80 static ByteBuffer getBufferByte(final int size) {
81 ByteBuffer buffer = bufferTL.get();
88 static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) {
89 ByteBuffer buffer = caps.util.buffer;
8290
8391 if ( buffer.capacity() < size ) {
8492 int sizeNew = buffer.capacity() << 1;
8694 sizeNew <<= 1;
8795
8896 buffer = BufferUtils.createByteBuffer(size);
89 bufferTL.set(buffer);
97 caps.util.buffer = buffer;
9098 } else
9199 buffer.clear();
92100
93101 return buffer;
94102 }
95103
96 private static ByteBuffer getBufferByteOffset(final int size) {
97 ByteBuffer buffer = bufferTL.get();
104 private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) {
105 ByteBuffer buffer = caps.util.buffer;
98106
99107 if ( buffer.capacity() < size ) {
100108 int sizeNew = buffer.capacity() << 1;
103111
104112 final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
105113 bufferNew.put(buffer);
106 bufferTL.set(buffer = bufferNew);
114 caps.util.buffer = (buffer = bufferNew);
107115 } else {
108116 buffer.position(buffer.limit());
109117 buffer.limit(buffer.capacity());
112120 return buffer;
113121 }
114122
115 static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
116
117 static IntBuffer getBufferInt() { return buffersTL.get().ints; }
118
119 static LongBuffer getBufferLong() { return buffersTL.get().longs; }
120
121 static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
122
123 static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; }
124
125 static IntBuffer getLengths() {
126 return getLengths(1);
127 }
128
129 static IntBuffer getLengths(final int size) {
130 IntBuffer lengths = lengthsTL.get();
123 static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.ints; }
124
125 static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.longs; }
126
127 static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.floats; }
128
129 static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.doubles; }
130
131 static IntBuffer getLengths(final ContextCapabilities caps) {
132 return getLengths(caps, 1);
133 }
134
135 static IntBuffer getLengths(final ContextCapabilities caps, final int size) {
136 IntBuffer lengths = caps.util.lengths;
131137
132138 if ( lengths.capacity() < size ) {
133139 int sizeNew = lengths.capacity();
135141 sizeNew <<= 1;
136142
137143 lengths = BufferUtils.createIntBuffer(size);
138 lengthsTL.set(lengths);
144 caps.util.lengths = lengths;
139145 } else
140146 lengths.clear();
141147
167173 *
168174 * @return the buffer as a String.
169175 */
170 static String getString(final ByteBuffer buffer) {
176 static String getString(final ContextCapabilities caps, final ByteBuffer buffer) {
171177 final int length = buffer.remaining();
172 final char[] charArray = getArray(length);
178 final char[] charArray = getArray(caps, length);
173179
174180 for ( int i = buffer.position(); i < buffer.limit(); i++ )
175181 charArray[i - buffer.position()] = (char)buffer.get(i);
184190 *
185191 * @return the String as a ByteBuffer
186192 */
187 static ByteBuffer getBuffer(final CharSequence string) {
188 final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
189 buffer.flip();
190 return buffer;
193 static long getBuffer(final ContextCapabilities caps, final CharSequence string) {
194 final ByteBuffer buffer = encode(getBufferByte(caps, string.length()), string);
195 buffer.flip();
196 return MemoryUtil.getAddress0(buffer);
191197 }
192198
193199 /**
197203 *
198204 * @return the String as a ByteBuffer
199205 */
200 static ByteBuffer getBuffer(final CharSequence string, final int offset) {
201 final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
202 buffer.flip();
203 return buffer;
206 static long getBuffer(final ContextCapabilities caps, final CharSequence string, final int offset) {
207 final ByteBuffer buffer = encode(getBufferByteOffset(caps, offset + string.length()), string);
208 buffer.flip();
209 return MemoryUtil.getAddress(buffer);
204210 }
205211
206212 /**
210216 *
211217 * @return the String as a ByteBuffer
212218 */
213 static ByteBuffer getBufferNT(final CharSequence string) {
214 final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
219 static long getBufferNT(final ContextCapabilities caps, final CharSequence string) {
220 final ByteBuffer buffer = encode(getBufferByte(caps, string.length() + 1), string);
215221 buffer.put((byte)0);
216222 buffer.flip();
217 return buffer;
223 return MemoryUtil.getAddress0(buffer);
218224 }
219225
220226 static int getTotalLength(final CharSequence[] strings) {
232238 *
233239 * @return the Strings as a ByteBuffer
234240 */
235 static ByteBuffer getBuffer(final CharSequence[] strings) {
236 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
241 static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
242 final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));
237243
238244 for ( CharSequence string : strings )
239245 encode(buffer, string);
240246
241247 buffer.flip();
242 return buffer;
248 return MemoryUtil.getAddress0(buffer);
243249 }
244250
245251 /**
249255 *
250256 * @return the Strings as a ByteBuffer
251257 */
252 static ByteBuffer getBufferNT(final CharSequence[] strings) {
253 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
258 static long getBufferNT(final ContextCapabilities caps, final CharSequence[] strings) {
259 final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings) + strings.length);
254260
255261 for ( CharSequence string : strings ) {
256262 encode(buffer, string);
258264 }
259265
260266 buffer.flip();
261 return buffer;
267 return MemoryUtil.getAddress0(buffer);
262268 }
263269
264270 /**
268274 *
269275 * @return the String lengths in an IntBuffer
270276 */
271 static IntBuffer getLengths(final CharSequence[] strings) {
272 IntBuffer buffer = getLengths(strings.length);
277 static long getLengths(final ContextCapabilities caps, final CharSequence[] strings) {
278 IntBuffer buffer = getLengths(caps, strings.length);
273279
274280 for ( CharSequence string : strings )
275281 buffer.put(string.length());
276282
277283 buffer.flip();
278 return buffer;
279 }
280
281 private static class Buffers {
282
283 final ShortBuffer shorts;
284 final IntBuffer ints;
285 final LongBuffer longs;
286
287 final FloatBuffer floats;
288 final DoubleBuffer doubles;
289
290 Buffers() {
291 shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
292 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
293 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
294
295 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
296 doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
297 }
298
284 return MemoryUtil.getAddress0(buffer);
285 }
286
287 static long getInt(final ContextCapabilities caps, final int value) {
288 return MemoryUtil.getAddress0(getBufferInt(caps).put(0, value));
289 }
290
291 static long getBufferByte0(final ContextCapabilities caps) {
292 return MemoryUtil.getAddress0(getBufferByte(caps, 0));
299293 }
300294
301295 }
112112 description = "OTHER";
113113 break;
114114 default:
115 description = "Unknown (" + Integer.toHexString(source) + ")";
115 description = printUnknownToken(source);
116116 }
117117 System.err.println("\tSource: " + description);
118118
136136 description = "OTHER";
137137 break;
138138 default:
139 description = "Unknown (" + Integer.toHexString(source) + ")";
139 description = printUnknownToken(type);
140140 }
141141 System.err.println("\tType: " + description);
142142
151151 description = "LOW";
152152 break;
153153 default:
154 description = "Unknown (" + Integer.toHexString(source) + ")";
154 description = printUnknownToken(severity);
155155 }
156156 System.err.println("\tSeverity: " + description);
157157
158158 System.err.println("\tMessage: " + message);
159 }
160
161 private String printUnknownToken(final int token) {
162 return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
159163 }
160164 });
161165 }
183187 /**
184188 * This method will be called when an ARB_debug_output message is generated.
185189 *
186 * @param id the message ID
187190 * @param source the message source
188191 * @param type the message type
192 * @param id the message ID
189193 * @param severity the message severity
190194 * @param message the string representation of the message.
191195 */
3939 /**
4040 *
4141 * @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 $
42 * @version $Revision$
43 * $Id$
4444 */
4545 interface AWTCanvasImplementation {
4646 /**
4747 * Return an opaque handle to the canvas peer information required to create a context from it.
4848 */
49 PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException;
49 PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException;
5050
5151 /**
5252 * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
4141 import java.awt.event.HierarchyEvent;
4242 import java.awt.event.HierarchyListener;
4343
44 import static org.lwjgl.opengl.GL11.*;
45
4446 /**
4547 * <p/>
4648 * An AWT rendering context.
4749 * <p/>
4850 *
49 * @author $Author: spasi $
50 * $Id: AWTGLCanvas.java 3418 2010-09-28 21:11:35Z spasi $
51 * @version $Revision: 3418 $
51 * @author $Author$
52 * $Id$
53 * @version $Revision$
5254 */
5355 public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListener, HierarchyListener {
5456
5557 private static final long serialVersionUID = 1L;
5658
5759 private static final AWTCanvasImplementation implementation;
58 private boolean update_context;
60 private boolean update_context;
5961 private Object SYNC_LOCK = new Object();
6062
6163 /** The requested pixel format */
6870 private final ContextAttribs attribs;
6971
7072 /** Context handle */
71 private PeerInfo peer_info;
72 private Context context;
73 private PeerInfo peer_info;
74 private ContextGL context;
7375
7476 /**
7577 * re-entry counter for support for re-entrant
104106 }
105107 }
106108
109 public void setPixelFormat(final PixelFormatLWJGL pf) throws LWJGLException {
110 throw new UnsupportedOperationException();
111 }
112
113 public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException {
114 throw new UnsupportedOperationException();
115 }
116
117 public PixelFormatLWJGL getPixelFormat() {
118 return pixel_format;
119 }
120
107121 /** This method should only be called internally. */
108 public Context getContext() {
122 public ContextGL getContext() {
109123 return context;
110124 }
111125
112126 /** This method should only be called internally. */
113 public Context createSharedContext() throws LWJGLException {
127 public ContextGL createSharedContext() throws LWJGLException {
114128 synchronized ( SYNC_LOCK ) {
115129 if ( context == null ) throw new IllegalStateException("Canvas not yet displayable");
116130
117 return new Context(peer_info, context.getContextAttribs(), context);
118 }
131 return new ContextGL(peer_info, context.getContextAttribs(), context);
132 }
133 }
134
135 public void checkGLError() {
136 Util.checkGLError();
137 }
138
139 public void initContext(final float r, final float g, final float b) {
140 // set background clear color
141 glClearColor(r, g, b, 0.0f);
142 // Clear window to avoid the desktop "showing through"
143 glClear(GL_COLOR_BUFFER_BIT);
119144 }
120145
121146 /** Constructor using the default PixelFormat. */
194219 synchronized ( SYNC_LOCK ) {
195220 if ( context == null )
196221 throw new IllegalStateException("Canvas not yet displayable");
197 Context.setSwapInterval(swap_interval);
222 ContextGL.setSwapInterval(swap_interval);
198223 }
199224 }
200225
208233 synchronized ( SYNC_LOCK ) {
209234 if ( context == null )
210235 throw new IllegalStateException("Canvas not yet displayable");
211 Context.swapBuffers();
236 ContextGL.swapBuffers();
212237 }
213238 }
214239
237262 if ( context == null )
238263 throw new IllegalStateException("Canvas not yet displayable");
239264 if ( context.isCurrent() )
240 Context.releaseCurrentContext();
265 context.releaseCurrent();
241266 }
242267 }
243268
289314 return;
290315 try {
291316 if ( peer_info == null ) {
292 this.peer_info = implementation.createPeerInfo(this, pixel_format);
317 this.peer_info = implementation.createPeerInfo(this, pixel_format, attribs);
293318 }
294319 peer_info.lockAndGetHandle();
295320 try {
296321 if ( context == null ) {
297 this.context = new Context(peer_info, attribs, drawable != null ? ((DrawableLWJGL)drawable).getContext() : null);
322 this.context = new ContextGL(peer_info, attribs, drawable != null ? (ContextGL)((DrawableLWJGL)drawable).getContext() : null);
298323 first_run = true;
299324 }
300325
314339 } finally {
315340 reentry_count--;
316341 if ( reentry_count == 0 )
317 Context.releaseCurrentContext();
342 context.releaseCurrent();
318343 }
319344 } finally {
320345 peer_info.unlock();
3131 package org.lwjgl.opengl;
3232
3333 import java.awt.Canvas;
34 import java.awt.Component;
35 import java.applet.Applet;
3436 import java.nio.ByteBuffer;
3537 import java.security.AccessController;
3638 import java.security.PrivilegedActionException;
4244 /**
4345 *
4446 * @author elias_naur <elias_naur@users.sourceforge.net>
45 * @version $Revision: 3418 $
46 * $Id: AWTSurfaceLock.java 3418 2010-09-28 21:11:35Z spasi $
47 * @version $Revision$
48 * $Id$
4749 */
4850 final class AWTSurfaceLock {
4951
7779 // We need to elevate privileges because of an AWT bug. Please see
7880 // http://192.18.37.44/forums/index.php?topic=10572 for a discussion.
7981 // It is only needed on first call, so we avoid it on all subsequent calls
80 // due to performance.
82 // due to performance..
83
8184 if (firstLockSucceeded)
8285 return lockAndInitHandle(lock_buffer, component);
8386 else
+0
-89
src/java/org/lwjgl/opengl/AbstractDrawable.java less more
0 package org.lwjgl.opengl;
1
2 import org.lwjgl.LWJGLException;
3 import org.lwjgl.LWJGLUtil;
4 import org.lwjgl.PointerBuffer;
5
6 /**
7 * @author Spasi
8 */
9 abstract class AbstractDrawable implements DrawableLWJGL {
10
11 /** Handle to the native GL rendering context */
12 protected PeerInfo peer_info;
13
14 /** The OpenGL Context. */
15 protected Context context;
16
17 protected AbstractDrawable() {
18 }
19
20 public Context getContext() {
21 synchronized ( GlobalLock.lock ) {
22 return context;
23 }
24 }
25
26 public Context createSharedContext() throws LWJGLException {
27 synchronized ( GlobalLock.lock ) {
28 checkDestroyed();
29 return new Context(peer_info, context.getContextAttribs(), context);
30 }
31 }
32
33 public boolean isCurrent() throws LWJGLException {
34 synchronized ( GlobalLock.lock ) {
35 checkDestroyed();
36 return context.isCurrent();
37 }
38 }
39
40 public void makeCurrent() throws LWJGLException {
41 synchronized ( GlobalLock.lock ) {
42 checkDestroyed();
43 context.makeCurrent();
44 }
45 }
46
47 public void releaseContext() throws LWJGLException {
48 synchronized ( GlobalLock.lock ) {
49 checkDestroyed();
50 if ( context.isCurrent() )
51 Context.releaseCurrentContext();
52 }
53 }
54
55 public void destroy() {
56 synchronized ( GlobalLock.lock ) {
57 if ( context == null )
58 return;
59
60 try {
61 releaseContext();
62
63 context.forceDestroy();
64 context = null;
65
66 if ( peer_info != null ) {
67 peer_info.destroy();
68 peer_info = null;
69 }
70 } catch (LWJGLException e) {
71 LWJGLUtil.log("Exception occurred while destroying Drawable: " + e);
72 }
73 }
74 }
75
76 public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
77 synchronized ( GlobalLock.lock ) {
78 checkDestroyed();
79 context.setCLSharingProperties(properties);
80 }
81 }
82
83 protected final void checkDestroyed() {
84 if ( context == null )
85 throw new IllegalStateException("The Drawable has no context available.");
86 }
87
88 }
4141 final class CallbackUtil {
4242
4343 /** Context -> Long */
44 private static final Map<Context, Long> contextUserParamsARB = new HashMap<Context, Long>();
44 private static final Map<ContextCapabilities, Long> contextUserParamsARB = new HashMap<ContextCapabilities, Long>();
4545 /** Context -> Long */
46 private static final Map<Context, Long> contextUserParamsAMD = new HashMap<Context, Long>();
46 private static final Map<ContextCapabilities, Long> contextUserParamsAMD = new HashMap<ContextCapabilities, Long>();
47 /** Context -> Long */
48 private static final Map<ContextCapabilities, Long> contextUserParamsKHR = new HashMap<ContextCapabilities, Long>();
4749
4850 private CallbackUtil() {}
4951
8385 *
8486 * @param userParam the global reference pointer
8587 */
86 private static void registerContextCallback(final long userParam, final Map<Context, Long> contextUserData) {
87 Context context = Context.getCurrentContext();
88 if ( context == null ) {
88 private static void registerContextCallback(final long userParam, final Map<ContextCapabilities, Long> contextUserData) {
89 ContextCapabilities caps = GLContext.getCapabilities();
90 if ( caps == null ) {
8991 deleteGlobalRef(userParam);
9092 throw new IllegalStateException("No context is current.");
9193 }
9294
93 final Long userParam_old = contextUserData.remove(context);
95 final Long userParam_old = contextUserData.remove(caps);
9496 if ( userParam_old != null )
9597 deleteGlobalRef(userParam_old);
9698
9799 if ( userParam != 0 )
98 contextUserData.put(context, userParam);
100 contextUserData.put(caps, userParam);
99101 }
100102
101103 /**
103105 *
104106 * @param context the Context to unregister
105107 */
106 static void unregisterCallbacks(final Context context) {
107 Long userParam = contextUserParamsARB.remove(context);
108 static void unregisterCallbacks(final Object context) {
109 // TODO: This is never called for custom contexts. Need to fix for LWJGL 3.0
110 final ContextCapabilities caps = GLContext.getCapabilities(context);
111
112 Long userParam = contextUserParamsARB.remove(caps);
108113 if ( userParam != null )
109114 deleteGlobalRef(userParam);
110115
111 userParam = contextUserParamsAMD.remove(context);
116 userParam = contextUserParamsAMD.remove(caps);
117 if ( userParam != null )
118 deleteGlobalRef(userParam);
119
120 userParam = contextUserParamsKHR.remove(caps);
112121 if ( userParam != null )
113122 deleteGlobalRef(userParam);
114123 }
153162 registerContextCallback(userParam, contextUserParamsAMD);
154163 }
155164
165 // --------- [ KHR_debug ] ---------
166
167 /**
168 * Returns the memory address of the native function we pass to glDebugMessageCallback.
169 *
170 * @return the callback function address
171 */
172 static native long getDebugCallbackKHR();
173
174 /**
175 * Associates the current OpenGL context with the specified global reference. If there
176 * is no context current, the global reference is deleted and an exception is thrown.
177 * Any previous callback registrations will be cleared.
178 *
179 * @param userParam the global reference pointer
180 */
181 static void registerContextCallbackKHR(final long userParam) {
182 registerContextCallback(userParam, contextUserParamsKHR);
183 }
184
156185 }
00 /*
1 * Copyright (c) 2002-2008 LWJGL Project
1 * Copyright (c) 2002-2011 LWJGL Project
22 * All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
36 import org.lwjgl.Sys;
37 import org.lwjgl.opencl.KHRGLSharing;
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 import static org.lwjgl.opengl.GL11.*;
4334
4435 /**
45 * <p/>
46 * Context encapsulates an OpenGL context.
47 * <p/>
48 * <p/>
49 * This class is thread-safe.
50 *
51 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 3418 $
53 * $Id: Context.java 3418 2010-09-28 21:11:35Z spasi $
36 * @author Spasi
37 * @since 14/5/2011
5438 */
55 final class Context {
39 interface Context {
5640
57 /** The platform specific implementation of context methods */
58 private static final ContextImplementation implementation;
41 boolean isCurrent() throws LWJGLException;
5942
60 /** The current Context */
61 private static final ThreadLocal<Context> current_context_local = new ThreadLocal<Context>();
43 void makeCurrent() throws LWJGLException;
6244
63 /** Handle to the native GL rendering context */
64 private final ByteBuffer handle;
65 private final PeerInfo peer_info;
45 void releaseCurrent() throws LWJGLException;
6646
67 private final ContextAttribs contextAttribs;
68 private final boolean forwardCompatible;
69
70 /** Whether the context has been destroyed */
71 private boolean destroyed;
72
73 private boolean destroy_requested;
74
75 /** The thread that has this context current, or null. */
76 private Thread thread;
77
78 static {
79 Sys.initialize();
80 implementation = createImplementation();
81 }
82
83 private static ContextImplementation createImplementation() {
84 switch ( LWJGLUtil.getPlatform() ) {
85 case LWJGLUtil.PLATFORM_LINUX:
86 return new LinuxContextImplementation();
87 case LWJGLUtil.PLATFORM_WINDOWS:
88 return new WindowsContextImplementation();
89 case LWJGLUtil.PLATFORM_MACOSX:
90 return new MacOSXContextImplementation();
91 default:
92 throw new IllegalStateException("Unsupported platform");
93 }
94 }
95
96 PeerInfo getPeerInfo() {
97 return peer_info;
98 }
99
100 ContextAttribs getContextAttribs() {
101 return contextAttribs;
102 }
103
104 static Context getCurrentContext() {
105 return current_context_local.get();
106 }
107
108 /** Create a context with the specified peer info and shared context */
109 Context(PeerInfo peer_info, ContextAttribs attribs, Context shared_context) throws LWJGLException {
110 Context context_lock = shared_context != null ? shared_context : this;
111 // If shared_context is not null, synchronize on it to make sure it is not deleted
112 // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE
113 synchronized ( context_lock ) {
114 if ( shared_context != null && shared_context.destroyed )
115 throw new IllegalArgumentException("Shared context is destroyed");
116 GLContext.loadOpenGLLibrary();
117 try {
118 this.peer_info = peer_info;
119 this.contextAttribs = attribs;
120
121 IntBuffer attribList;
122 if ( attribs != null ) {
123 attribList = attribs.getAttribList();
124 forwardCompatible = attribs.isForwardCompatible();
125 } else {
126 attribList = null;
127 forwardCompatible = false;
128 }
129
130 this.handle = implementation.create(peer_info, attribList, shared_context != null ? shared_context.handle : null);
131 } catch (LWJGLException e) {
132 GLContext.unloadOpenGLLibrary();
133 throw e;
134 }
135 }
136 }
137
138 /** Release the current context (if any). After this call, no context is current. */
139 public static void releaseCurrentContext() throws LWJGLException {
140 Context current_context = getCurrentContext();
141 if ( current_context != null ) {
142 implementation.releaseCurrentContext();
143 GLContext.useContext(null);
144 current_context_local.set(null);
145 synchronized ( current_context ) {
146 current_context.thread = null;
147 current_context.checkDestroy();
148 }
149 }
150 }
151
152 /**
153 * Release the context from its drawable. This is necessary on some platforms,
154 * like Mac OS X, where binding the context to a drawable and binding the context
155 * for rendering are two distinct actions and where calling releaseDrawable
156 * on every releaseCurrentContext results in artifacts.
157 */
158 public synchronized void releaseDrawable() throws LWJGLException {
159 if ( destroyed )
160 throw new IllegalStateException("Context is destroyed");
161 implementation.releaseDrawable(getHandle());
162 }
163
164 /** Update the context. Should be called whenever it's drawable is moved or resized */
165 public synchronized void update() {
166 if ( destroyed )
167 throw new IllegalStateException("Context is destroyed");
168 implementation.update(getHandle());
169 }
170
171 /** Swap the buffers on the current context. Only valid for double-buffered contexts */
172 public static void swapBuffers() throws LWJGLException {
173 implementation.swapBuffers();
174 }
175
176 private boolean canAccess() {
177 return thread == null || Thread.currentThread() == thread;
178 }
179
180 private void checkAccess() {
181 if ( !canAccess() )
182 throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current");
183 }
184
185 /** Make the context current */
186 public synchronized void makeCurrent() throws LWJGLException {
187 checkAccess();
188 if ( destroyed )
189 throw new IllegalStateException("Context is destroyed");
190 thread = Thread.currentThread();
191 current_context_local.set(this);
192 implementation.makeCurrent(peer_info, handle);
193 GLContext.useContext(this, forwardCompatible);
194 }
195
196 ByteBuffer getHandle() {
197 return handle;
198 }
199
200 /** Query whether the context is current */
201 public synchronized boolean isCurrent() throws LWJGLException {
202 if ( destroyed )
203 throw new IllegalStateException("Context is destroyed");
204 return implementation.isCurrent(handle);
205 }
206
207 private void checkDestroy() {
208 if ( !destroyed && destroy_requested ) {
209 try {
210 releaseDrawable();
211 implementation.destroy(peer_info, handle);
212 CallbackUtil.unregisterCallbacks(this);
213 destroyed = true;
214 thread = null;
215 GLContext.unloadOpenGLLibrary();
216 } catch (LWJGLException e) {
217 LWJGLUtil.log("Exception occurred while destroying context: " + e);
218 }
219 }
220 }
221
222 /**
223 * Set the buffer swap interval. This call is a best-attempt at changing
224 * the monitor swap interval, which is the minimum periodicity of color buffer swaps,
225 * measured in video frame periods, and is not guaranteed to be successful.
226 * <p/>
227 * A video frame period is the time required to display a full frame of video data.
228 */
229 public static void setSwapInterval(int value) {
230 implementation.setSwapInterval(value);
231 }
232
233 /**
234 * Destroy the context. This method behaves the same as destroy() with the extra
235 * requirement that the context must be either current to the current thread or not
236 * current at all.
237 */
238 public synchronized void forceDestroy() throws LWJGLException {
239 checkAccess();
240 destroy();
241 }
242
243 /**
244 * Request destruction of the Context. If the context is current, no context will be current after this call.
245 * The context is destroyed when no thread has it current.
246 */
247 public synchronized void destroy() throws LWJGLException {
248 if ( destroyed )
249 return;
250 destroy_requested = true;
251 boolean was_current = isCurrent();
252 int error = GL_NO_ERROR;
253 if ( was_current ) {
254 if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 )
255 error = glGetError();
256 releaseCurrentContext();
257 }
258 checkDestroy();
259 if ( was_current && error != GL_NO_ERROR )
260 throw new OpenGLException(error);
261 }
262
263 public synchronized void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
264 final ByteBuffer peer_handle = peer_info.lockAndGetHandle();
265 try {
266 switch ( LWJGLUtil.getPlatform() ) {
267 case LWJGLUtil.PLATFORM_WINDOWS:
268 final WindowsContextImplementation implWindows = (WindowsContextImplementation)implementation;
269 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implWindows.getHGLRC(handle));
270 properties.put(KHRGLSharing.CL_WGL_HDC_KHR).put(implWindows.getHDC(peer_handle));
271 break;
272 case LWJGLUtil.PLATFORM_LINUX:
273 final LinuxContextImplementation implLinux = (LinuxContextImplementation)implementation;
274 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle));
275 properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle));
276 break;
277 default:
278 throw new UnsupportedOperationException("CL/GL context sharing is not supposed on this platform.");
279 }
280 } finally {
281 peer_info.unlock();
282 }
283 }
47 void releaseDrawable() throws LWJGLException;
28448
28549 }
00 /*
1 * Copyright (c) 2002-2008 LWJGL Project
1 * Copyright (c) 2002-2014 LWJGL Project
22 * All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
3434 import org.lwjgl.LWJGLUtil;
3535
3636 import java.nio.IntBuffer;
37 import java.util.LinkedHashMap;
38 import java.util.Map.Entry;
3739
3840 /**
39 * This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context and
40 * ARB_create_context_profile extensions.
41 * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
42 * OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
43 * (read the ARB_create_context spec for details)
41 * This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context extension.
42 * <p/>
43 * The attributes supported are described in the following extensions:<br>
44 * <ul>
45 * <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt">WGL_ARB_create_context(_profile)</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context.txt">GLX_ARB_create_context(_profile)</a></li>
46 * <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_robustness.txt">WGL_ARB_create_context_robustness</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_robustness.txt">GLX_ARB_create_context_robustness</a></li>
47 * <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_robustness_isolation.txt">WGL_ARB_robustness_isolation</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_robustness_isolation.txt">GLX_ARB_robustness_isolation</a></li>
48 * <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_es2_profile.txt">WGL_EXT_create_context_es2_profile</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_es2_profile.txt">GLX_EXT_create_context_es2_profile</a></li>
49 * <li><a href="http://www.opengl.org/registry/specs/ARB/context_flush_control.txt">KHR_context_flush_control</a></li>
50 * </ul>
4451 * <p/>
4552 * Use of this class is optional. If an OpenGL context is created without passing an instance of this class
4653 * (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward
4754 * compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same
4855 * as non-debug contexts or forward compatible contexts having support for deprecated functionality.
4956 * <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.
57 * If the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} flag is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0
58 * specification), even if the driver exposes the corresponding entry points.
59 * <p/>
60 * This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an instance of this class must be passed
61 * to LWJGL. The only valid configuration is <code>ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB)</code>, anything else will be ignored.
5362 *
5463 * @author spasi <spasi@users.sourceforge.net>
5564 */
5665 public final class ContextAttribs {
5766
58 // Same values for GLX & WGL
59 private static final int CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
60
61 private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004;
62 private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
63 private static final int
64 NO_RESET_NOTIFICATION_ARB = 0x8261,
65 LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
67 // ATTRIBUTES
68
69 public static final int CONTEXT_MAJOR_VERSION_ARB = 0x2091;
70 public static final int CONTEXT_MINOR_VERSION_ARB = 0x2092;
71
72 public static final int CONTEXT_PROFILE_MASK_ARB = 0x9126,
73 CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001,
74 CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002,
75 CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
76
77 public static final int CONTEXT_FLAGS_ARB = 0x2094,
78 CONTEXT_DEBUG_BIT_ARB = 0x0001,
79 CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002,
80 CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004,
81 CONTEXT_RESET_ISOLATION_BIT_ARB = 0x00000008;
82
83 public static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256,
84 NO_RESET_NOTIFICATION_ARB = 0x8261,
85 LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
86
87 public static final int CONTEXT_RELEASE_BEHABIOR_ARB = 0x2097,
88 CONTEXT_RELEASE_BEHAVIOR_NONE_ARB = 0x0000,
89 CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB = 0x2098;
90
91 public static final int CONTEXT_LAYER_PLANE_ARB = 0x2093; // WGL-only
92
93 // STATE
6694
6795 private int majorVersion;
6896 private int minorVersion;
6997
98 private int profileMask;
99 private int contextFlags;
100
101 private int contextResetNotificationStrategy = NO_RESET_NOTIFICATION_ARB;
102 private int contextReleaseBehavior = CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB;
103
70104 private int layerPlane;
71105
72 private boolean debug;
73 private boolean forwardCompatible;
74 private boolean robustAccess;
75
76 private boolean profileCore;
77 private boolean profileCompatibility;
78 private boolean profileES;
79
80 private boolean loseContextOnReset;
81
106 // CONSTRUCTORS
107
108 /** Creates the default ContextAttribs instance. No special attributes will be used when creating the OpenGL context. */
82109 public ContextAttribs() {
83110 this(1, 0);
84111 }
85112
86 public ContextAttribs(final int majorVersion, final int minorVersion) {
113 /** Creates a ContextAttribs instance for the given OpenGL version. */
114 public ContextAttribs(int majorVersion, int minorVersion) {
115 this(majorVersion, minorVersion, 0, 0);
116 }
117
118 /**
119 * Creates a new ContextAttribs instance with the given attributes.
120 *
121 * @param majorVersion the major OpenGL version
122 * @param minorVersion the minor OpenGL version
123 * @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
124 */
125 public ContextAttribs(int majorVersion, int minorVersion, int profileMask) {
126 this(majorVersion, minorVersion, 0, profileMask);
127 }
128
129 /**
130 * Creates a new ContextAttribs instance with the given attributes.
131 *
132 * @param majorVersion the major OpenGL version
133 * @param minorVersion the minor OpenGL version
134 * @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
135 * @param contextFlags the context flags, a bitfield value. One or more of:<br>{@link #CONTEXT_DEBUG_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB}, {@link #CONTEXT_RESET_ISOLATION_BIT_ARB}
136 */
137 public ContextAttribs(int majorVersion, int minorVersion, int profileMask, int contextFlags) {
87138 if ( majorVersion < 0 || 4 < majorVersion ||
88139 minorVersion < 0 ||
89 (majorVersion == 4 && 0 < minorVersion) ||
140 (majorVersion == 4 && 5 < minorVersion) ||
90141 (majorVersion == 3 && 3 < minorVersion) ||
91142 (majorVersion == 2 && 1 < minorVersion) ||
92143 (majorVersion == 1 && 5 < minorVersion) )
93144 throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
94145
146 if ( LWJGLUtil.CHECKS ) {
147 if ( 1 < Integer.bitCount(profileMask) || CONTEXT_ES2_PROFILE_BIT_EXT < profileMask )
148 throw new IllegalArgumentException("Invalid profile mask specified: " + Integer.toBinaryString(profileMask));
149
150 if ( 0xF < contextFlags )
151 throw new IllegalArgumentException("Invalid context flags specified: " + Integer.toBinaryString(profileMask));
152 }
153
95154 this.majorVersion = majorVersion;
96155 this.minorVersion = minorVersion;
97 }
98
99 private ContextAttribs(final ContextAttribs attribs) {
100 this.majorVersion = attribs.majorVersion;
101 this.minorVersion = attribs.minorVersion;
102
103 this.layerPlane = attribs.layerPlane;
104
105 this.debug = attribs.debug;
106 this.forwardCompatible = attribs.forwardCompatible;
107 this.robustAccess = attribs.robustAccess;
108
109 this.profileCore = attribs.profileCore;
110 this.profileCompatibility = attribs.profileCompatibility;
111 this.profileES = attribs.profileES;
112
113 this.loseContextOnReset = attribs.loseContextOnReset;
114 }
115
156
157 this.profileMask = profileMask;
158 this.contextFlags = contextFlags;
159 }
160
161 // Copy constructor
162 private ContextAttribs(ContextAttribs other) {
163 this.majorVersion = other.majorVersion;
164 this.minorVersion = other.minorVersion;
165
166 this.profileMask = other.profileMask;
167 this.contextFlags = other.contextFlags;
168
169 this.contextResetNotificationStrategy = other.contextResetNotificationStrategy;
170 this.contextReleaseBehavior = other.contextReleaseBehavior;
171
172 this.layerPlane = other.layerPlane;
173 }
174
175 // GETTERS
176
177 /** Returns the {@link #CONTEXT_MAJOR_VERSION_ARB} value. */
116178 public int getMajorVersion() {
117179 return majorVersion;
118180 }
119181
182 /** Returns the {@link #CONTEXT_MINOR_VERSION_ARB} value. */
120183 public int getMinorVersion() {
121184 return minorVersion;
122185 }
123186
187 /** Returns the {@link #CONTEXT_PROFILE_MASK_ARB} value. */
188 public int getProfileMask() {
189 return profileMask;
190 }
191
192 private boolean hasMask(int mask) {
193 return profileMask == mask;
194 }
195
196 /** Returns true if the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} has been set. */
197 public boolean isProfileCore() {
198 return hasMask(CONTEXT_CORE_PROFILE_BIT_ARB);
199 }
200
201 /** Returns true if the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} has been set. */
202 public boolean isProfileCompatibility() {
203 return hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
204 }
205
206 /** Returns true if the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} has been set. */
207 public boolean isProfileES() {
208 return hasMask(CONTEXT_ES2_PROFILE_BIT_EXT);
209 }
210
211 /** Returns the {@link #CONTEXT_FLAGS_ARB} value. */
212 public int getContextFlags() {
213 return contextFlags;
214 }
215
216 private boolean hasFlag(int flag) {
217 return (contextFlags & flag) != 0;
218 }
219
220 /** Returns true if the {@link #CONTEXT_DEBUG_BIT_ARB} has been set. */
221 public boolean isDebug() {
222 return hasFlag(CONTEXT_DEBUG_BIT_ARB);
223 }
224
225 /** Returns true if the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} has been set. */
226 public boolean isForwardCompatible() {
227 return hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
228 }
229
230 /** Returns true if the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} has been set. */
231 public boolean isRobustAccess() { return hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB); }
232
233 /** Returns true if the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} has been set. */
234 public boolean isContextResetIsolation() {
235 return hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB);
236 }
237
238 /** Returns the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} value. */
239 public int getContextResetNotificationStrategy() {
240 return contextResetNotificationStrategy;
241 }
242
243 /**
244 * Returns true if the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} has been set to {@link #LOSE_CONTEXT_ON_RESET_ARB}.
245 *
246 * @deprecated use {@link #getContextResetNotificationStrategy} instead
247 */
248 public boolean isLoseContextOnReset() { return contextResetNotificationStrategy == LOSE_CONTEXT_ON_RESET_ARB; }
249
250 /** Returns the {@link #CONTEXT_RELEASE_BEHABIOR_ARB} value. */
251 public int getContextReleaseBehavior() {
252 return contextReleaseBehavior;
253 }
254
255 /** Returns the {@link #CONTEXT_LAYER_PLANE_ARB} value. */
124256 public int getLayerPlane() {
125257 return layerPlane;
126258 }
127259
128 public boolean isDebug() {
129 return debug;
130 }
131
132 public boolean isForwardCompatible() {
133 return forwardCompatible;
134 }
135
136 public boolean isProfileCore() {
137 return profileCore;
138 }
139
140 public boolean isProfileCompatibility() {
141 return profileCompatibility;
142 }
143
144 public boolean isProfileES() {
145 return profileES;
146 }
147
148 public ContextAttribs withLayer(final int layerPlane) {
260 // CHAIN CONFIGURATION PATTERN
261
262 private ContextAttribs toggleMask(int mask, boolean value) {
263 if ( value == hasMask(mask) )
264 return this;
265
266 ContextAttribs attribs = new ContextAttribs(this);
267 attribs.profileMask = value ? mask : 0;
268 return attribs;
269 }
270
271 /**
272 * Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
273 * If {@code profileCore} is true, all other bits in the mask are cleared.
274 */
275 public ContextAttribs withProfileCore(boolean profileCore) {
276 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
277 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
278
279 return toggleMask(CONTEXT_CORE_PROFILE_BIT_ARB, profileCore);
280 }
281
282 /**
283 * Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
284 * If {@code profileCompatibility} is true, all other bits in the mask are cleared.
285 */
286 public ContextAttribs withProfileCompatibility(boolean profileCompatibility) {
287 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
288 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
289
290 return toggleMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, profileCompatibility);
291 }
292
293 /**
294 * Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
295 * If {@code profileES} is true, all other bits in the mask are cleared.
296 */
297 public ContextAttribs withProfileES(boolean profileES) {
298 if ( !(majorVersion == 2 && minorVersion == 0) )
299 throw new IllegalArgumentException("The OpenGL ES profile is only supported on OpenGL version 2.0.");
300
301 return toggleMask(CONTEXT_ES2_PROFILE_BIT_EXT, profileES);
302 }
303
304 private ContextAttribs toggleFlag(int flag, boolean value) {
305 if ( value == hasFlag(flag) )
306 return this;
307
308 ContextAttribs attribs = new ContextAttribs(this);
309 attribs.contextFlags ^= flag; // toggle bit
310 return attribs;
311 }
312
313 /** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_DEBUG_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
314 public ContextAttribs withDebug(boolean debug) { return toggleFlag(CONTEXT_DEBUG_BIT_ARB, debug); }
315
316 /** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
317 public ContextAttribs withForwardCompatible(boolean forwardCompatible) { return toggleFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, forwardCompatible); }
318
319 /** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
320 public ContextAttribs withRobustAccess(boolean robustAccess) { return toggleFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB, robustAccess); }
321
322 /** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
323 public ContextAttribs withContextResetIsolation(boolean contextResetIsolation) { return toggleFlag(CONTEXT_RESET_ISOLATION_BIT_ARB, contextResetIsolation); }
324
325 /**
326 * Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to the given strategy. The default context reset notification
327 * strategy is {@link #NO_RESET_NOTIFICATION_ARB}.
328 *
329 * @param strategy the context reset notification strategy. One of:<br>{@link #NO_RESET_NOTIFICATION_ARB}, {@link #LOSE_CONTEXT_ON_RESET_ARB}
330 *
331 * @return the new ContextAttribs
332 */
333 public ContextAttribs withResetNotificationStrategy(int strategy) {
334 if ( strategy == contextResetNotificationStrategy )
335 return this;
336
337 if ( LWJGLUtil.CHECKS && !(strategy == NO_RESET_NOTIFICATION_ARB || strategy == LOSE_CONTEXT_ON_RESET_ARB) )
338 throw new IllegalArgumentException("Invalid context reset notification strategy specified: 0x" + LWJGLUtil.toHexString(strategy));
339
340 ContextAttribs attribs = new ContextAttribs(this);
341 attribs.contextResetNotificationStrategy = strategy;
342 return attribs;
343 }
344
345 /**
346 * Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to {@link #LOSE_CONTEXT_ON_RESET_ARB} if the parameter is
347 * true or to {@link #NO_RESET_NOTIFICATION_ARB} if the parameter is false.
348 *
349 * @param loseContextOnReset the context reset notification strategy
350 *
351 * @return the new ContextAttribs
352 *
353 * @deprecated use {@link #withResetNotificationStrategy} instead
354 */
355 public ContextAttribs withLoseContextOnReset(boolean loseContextOnReset) {
356 return withResetNotificationStrategy(loseContextOnReset ? LOSE_CONTEXT_ON_RESET_ARB : NO_RESET_NOTIFICATION_ARB);
357 }
358
359 /**
360 * Returns a ContextAttribs instance with {@link #CONTEXT_RELEASE_BEHABIOR_ARB} set to the given behavior. The default context release behavior is
361 * {@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}.
362 *
363 * @param behavior the context release behavior. One of:<br>{@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}, {@link #CONTEXT_RELEASE_BEHAVIOR_NONE_ARB}
364 *
365 * @return the new ContextAttribs
366 */
367 public ContextAttribs withContextReleaseBehavior(int behavior) {
368 if ( behavior == contextReleaseBehavior )
369 return this;
370
371 if ( LWJGLUtil.CHECKS && !(behavior == CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB || behavior == CONTEXT_RELEASE_BEHAVIOR_NONE_ARB) )
372 throw new IllegalArgumentException("Invalid context release behavior specified: 0x" + LWJGLUtil.toHexString(behavior));
373
374 ContextAttribs attribs = new ContextAttribs(this);
375 attribs.contextReleaseBehavior = behavior;
376 return attribs;
377 }
378
379 /** Returns a new {@code ContextAttribs} instance with {@link #CONTEXT_LAYER_PLANE_ARB} set to the given value. */
380 public ContextAttribs withLayer(int layerPlane) {
381 if ( LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_WINDOWS )
382 throw new IllegalArgumentException("The CONTEXT_LAYER_PLANE_ARB attribute is supported only on the Windows platform.");
383
384 if ( layerPlane == this.layerPlane )
385 return this;
386
149387 if ( layerPlane < 0 )
150388 throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
151389
152 if ( layerPlane == this.layerPlane )
153 return this;
154
155 final ContextAttribs attribs = new ContextAttribs(this);
390 ContextAttribs attribs = new ContextAttribs(this);
156391 attribs.layerPlane = layerPlane;
157392 return attribs;
158393 }
159394
160 public ContextAttribs withDebug(final boolean debug) {
161 if ( debug == this.debug )
162 return this;
163
164 final ContextAttribs attribs = new ContextAttribs(this);
165 attribs.debug = debug;
166 return attribs;
167 }
168
169 public ContextAttribs withForwardCompatible(final boolean forwardCompatible) {
170 if ( forwardCompatible == this.forwardCompatible )
171 return this;
172
173 final ContextAttribs attribs = new ContextAttribs(this);
174 attribs.forwardCompatible = forwardCompatible;
175 return attribs;
176 }
177
178 public ContextAttribs withProfileCore(final boolean profileCore) {
179 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
180 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
181
182 if ( profileCore == this.profileCore )
183 return this;
184
185 final ContextAttribs attribs = new ContextAttribs(this);
186 attribs.profileCore = profileCore;
187 if ( profileCore )
188 attribs.profileCompatibility = false;
189
190 return attribs;
191 }
192
193 public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) {
194 if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
195 throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
196
197 if ( profileCompatibility == this.profileCompatibility )
198 return this;
199
200 final ContextAttribs attribs = new ContextAttribs(this);
201 attribs.profileCompatibility = profileCompatibility;
202 if ( profileCompatibility )
203 attribs.profileCore = false;
204
205 return attribs;
206 }
207
208 public ContextAttribs withProfileES(final boolean profileES) {
209 if ( !(majorVersion == 2 && minorVersion == 0) )
210 throw new IllegalArgumentException("The OpenGL ES profiles is only supported for OpenGL version 2.0.");
211
212 if ( profileES == this.profileES )
213 return this;
214
215 final ContextAttribs attribs = new ContextAttribs(this);
216 attribs.profileES = profileES;
217
218 return attribs;
219 }
220
221 /**
222 * Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set
223 * to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION
224 * if the parameter is false.
225 *
226 * @param loseContextOnReset
227 *
228 * @return the new ContextAttribs
229 */
230 public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) {
231 if ( loseContextOnReset == this.loseContextOnReset )
232 return this;
233
234 final ContextAttribs attribs = new ContextAttribs(this);
235 attribs.loseContextOnReset = loseContextOnReset;
236 return attribs;
237 }
238
239 private static ContextAttribsImplementation getImplementation() {
240 switch ( LWJGLUtil.getPlatform() ) {
241 case LWJGLUtil.PLATFORM_LINUX:
242 return new LinuxContextAttribs();
243 case LWJGLUtil.PLATFORM_WINDOWS:
244 return new WindowsContextAttribs();
245 case LWJGLUtil.PLATFORM_MACOSX:
246 return new MacOSXContextAttribs();
247 default:
248 throw new IllegalStateException("Unsupported platform");
395 IntBuffer getAttribList() {
396 if ( LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX )
397 return null;
398
399 LinkedHashMap<Integer, Integer> map = new LinkedHashMap<Integer, Integer>(8);
400
401 if ( !(majorVersion == 1 && minorVersion == 0) ) {
402 map.put(CONTEXT_MAJOR_VERSION_ARB, majorVersion);
403 map.put(CONTEXT_MINOR_VERSION_ARB, minorVersion);
249404 }
250 }
251
252 IntBuffer getAttribList() {
253 ContextAttribsImplementation implementation = getImplementation();
254
255 int attribCount = 0;
256
257 if ( !(majorVersion == 1 && minorVersion == 0) )
258 attribCount += 2;
259 if ( 0 < layerPlane )
260 attribCount++;
261
262 int flags = 0;
263 if ( debug )
264 flags |= implementation.getDebugBit();
265 if ( forwardCompatible )
266 flags |= implementation.getForwardCompatibleBit();
267 if ( robustAccess )
268 flags |= CONTEXT_ROBUST_ACCESS_BIT_ARB;
269 if ( 0 < flags )
270 attribCount++;
271
272 int profileMask = 0;
273 if ( profileCore )
274 profileMask |= implementation.getProfileCoreBit();
275 else if ( profileCompatibility )
276 profileMask |= implementation.getProfileCompatibilityBit();
277 else if ( profileES )
278 profileMask |= CONTEXT_ES2_PROFILE_BIT_EXT;
279 if ( 0 < profileMask )
280 attribCount++;
281
282 if ( attribCount == 0 )
405
406 if ( contextFlags != 0 )
407 map.put(CONTEXT_FLAGS_ARB, contextFlags);
408
409 if ( profileMask != 0 )
410 map.put(CONTEXT_PROFILE_MASK_ARB, profileMask);
411
412 if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
413 map.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, contextResetNotificationStrategy);
414
415 if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
416 map.put(CONTEXT_RELEASE_BEHABIOR_ARB, contextReleaseBehavior);
417
418 if ( layerPlane != 0 )
419 map.put(CONTEXT_LAYER_PLANE_ARB, layerPlane);
420
421 if ( map.isEmpty() )
283422 return null;
284423
285 final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);
286
287 if ( !(majorVersion == 1 && minorVersion == 0) ) {
288 attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion);
289 attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion);
424 IntBuffer attribs = BufferUtils.createIntBuffer((map.size() * 2) + 1);
425 for ( Entry<Integer, Integer> attrib : map.entrySet() ) {
426 attribs
427 .put(attrib.getKey())
428 .put(attrib.getValue());
290429 }
291 if ( 0 < layerPlane )
292 attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane);
293 if ( 0 < flags )
294 attribs.put(implementation.getFlagsAttrib()).put(flags);
295 if ( 0 < profileMask )
296 attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
297 if ( loseContextOnReset )
298 attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);
299
300430 attribs.put(0);
301431 attribs.rewind();
302432 return attribs;
307437
308438 sb.append("ContextAttribs:");
309439 sb.append(" Version=").append(majorVersion).append('.').append(minorVersion);
310 sb.append(" - Layer=").append(layerPlane);
311 sb.append(" - Debug=").append(debug);
312 sb.append(" - ForwardCompatible=").append(forwardCompatible);
313 sb.append(" - RobustAccess=").append(robustAccess);
314 if ( robustAccess )
315 sb.append(" (").append(loseContextOnReset ? "LOSE_CONTEXT_ON_RESET" : "NO_RESET_NOTIFICATION");
316 sb.append(" - Profile=");
317 if ( profileCore )
318 sb.append("Core");
319 else if ( profileCompatibility )
320 sb.append("Compatibility");
321 else
322 sb.append("None");
440
441 if ( profileMask != 0 ) {
442 sb.append(", Profile=");
443 if ( hasMask(CONTEXT_CORE_PROFILE_BIT_ARB) )
444 sb.append("CORE");
445 else if ( hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) )
446 sb.append("COMPATIBLITY");
447 else if ( hasMask(CONTEXT_ES2_PROFILE_BIT_EXT) )
448 sb.append("ES2");
449 else
450 sb.append("*unknown*");
451 }
452
453 if ( contextFlags != 0 ) {
454 if ( hasFlag(CONTEXT_DEBUG_BIT_ARB) )
455 sb.append(", DEBUG");
456 if ( hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) )
457 sb.append(", FORWARD_COMPATIBLE");
458 if ( hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB) )
459 sb.append(", ROBUST_ACCESS");
460 if ( hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB) )
461 sb.append(", RESET_ISOLATION");
462 }
463
464 if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
465 sb.append(", LOSE_CONTEXT_ON_RESET");
466 if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
467 sb.append(", RELEASE_BEHAVIOR_NONE");
468
469 if ( layerPlane != 0 )
470 sb.append(", Layer=").append(layerPlane);
323471
324472 return sb.toString();
325473 }
+0
-56
src/java/org/lwjgl/opengl/ContextAttribsImplementation.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
36 import org.lwjgl.Sys;
37 import org.lwjgl.opencl.KHRGLSharing;
38 import org.lwjgl.opencl.APPLEGLSharing;
39
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42
43 import static org.lwjgl.opengl.GL11.*;
44
45 /**
46 * <p/>
47 * Context encapsulates an OpenGL context.
48 * <p/>
49 * <p/>
50 * This class is thread-safe.
51 *
52 * @author elias_naur <elias_naur@users.sourceforge.net>
53 * @version $Revision$
54 * $Id$
55 */
56 final class ContextGL implements Context {
57
58 /** The platform specific implementation of context methods */
59 private static final ContextImplementation implementation;
60
61 /** The current Context */
62 private static final ThreadLocal<ContextGL> current_context_local = new ThreadLocal<ContextGL>();
63
64 /** Handle to the native GL rendering context */
65 private final ByteBuffer handle;
66 private final PeerInfo peer_info;
67
68 private final ContextAttribs contextAttribs;
69 private final boolean forwardCompatible;
70
71 /** Whether the context has been destroyed */
72 private boolean destroyed;
73
74 private boolean destroy_requested;
75
76 /** The thread that has this context current, or null. */
77 private Thread thread;
78
79 static {
80 Sys.initialize();
81 implementation = createImplementation();
82 }
83
84 private static ContextImplementation createImplementation() {
85 switch ( LWJGLUtil.getPlatform() ) {
86 case LWJGLUtil.PLATFORM_LINUX:
87 return new LinuxContextImplementation();
88 case LWJGLUtil.PLATFORM_WINDOWS:
89 return new WindowsContextImplementation();
90 case LWJGLUtil.PLATFORM_MACOSX:
91 return new MacOSXContextImplementation();
92 default:
93 throw new IllegalStateException("Unsupported platform");
94 }
95 }
96
97 PeerInfo getPeerInfo() {
98 return peer_info;
99 }
100
101 ContextAttribs getContextAttribs() {
102 return contextAttribs;
103 }
104
105 static ContextGL getCurrentContext() {
106 return current_context_local.get();
107 }
108
109 /** Create a context with the specified peer info and shared context */
110 ContextGL(PeerInfo peer_info, ContextAttribs attribs, ContextGL shared_context) throws LWJGLException {
111 ContextGL context_lock = shared_context != null ? shared_context : this;
112 // If shared_context is not null, synchronize on it to make sure it is not deleted
113 // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE
114 synchronized ( context_lock ) {
115 if ( shared_context != null && shared_context.destroyed )
116 throw new IllegalArgumentException("Shared context is destroyed");
117 GLContext.loadOpenGLLibrary();
118 try {
119 this.peer_info = peer_info;
120 this.contextAttribs = attribs;
121
122 IntBuffer attribList;
123 if ( attribs != null ) {
124 attribList = attribs.getAttribList();
125 forwardCompatible = attribs.isForwardCompatible();
126 } else {
127 attribList = null;
128 forwardCompatible = false;
129 }
130
131 this.handle = implementation.create(peer_info, attribList, shared_context != null ? shared_context.handle : null);
132 } catch (LWJGLException e) {
133 GLContext.unloadOpenGLLibrary();
134 throw e;
135 }
136 }
137 }
138
139 /** Release the current context (if any). After this call, no context is current. */
140 public void releaseCurrent() throws LWJGLException {
141 ContextGL current_context = getCurrentContext();
142 if ( current_context != null ) {
143 implementation.releaseCurrentContext();
144 GLContext.useContext(null);
145 current_context_local.set(null);
146 synchronized ( current_context ) {
147 current_context.thread = null;
148 current_context.checkDestroy();
149 }
150 }
151 }
152
153 /**
154 * Release the context from its drawable. This is necessary on some platforms,
155 * like Mac OS X, where binding the context to a drawable and binding the context
156 * for rendering are two distinct actions and where calling releaseDrawable
157 * on every releaseCurrentContext results in artifacts.
158 */
159 public synchronized void releaseDrawable() throws LWJGLException {
160 if ( destroyed )
161 throw new IllegalStateException("Context is destroyed");
162 implementation.releaseDrawable(getHandle());
163 }
164
165 /** Update the context. Should be called whenever it's drawable is moved or resized */
166 public synchronized void update() {
167 if ( destroyed )
168 throw new IllegalStateException("Context is destroyed");
169 implementation.update(getHandle());
170 }
171
172 /** Swap the buffers on the current context. Only valid for double-buffered contexts */
173 public static void swapBuffers() throws LWJGLException {
174 implementation.swapBuffers();
175 }
176
177 private boolean canAccess() {
178 return thread == null || Thread.currentThread() == thread;
179 }
180
181 private void checkAccess() {
182 if ( !canAccess() )
183 throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current");
184 }
185
186 /** Make the context current */
187 public synchronized void makeCurrent() throws LWJGLException {
188 checkAccess();
189 if ( destroyed )
190 throw new IllegalStateException("Context is destroyed");
191 thread = Thread.currentThread();
192 current_context_local.set(this);
193 implementation.makeCurrent(peer_info, handle);
194 GLContext.useContext(this, forwardCompatible);
195 }
196
197 ByteBuffer getHandle() {
198 return handle;
199 }
200
201 /** Query whether the context is current */
202 public synchronized boolean isCurrent() throws LWJGLException {
203 if ( destroyed )
204 throw new IllegalStateException("Context is destroyed");
205 return implementation.isCurrent(handle);
206 }
207
208 private void checkDestroy() {
209 if ( !destroyed && destroy_requested ) {
210 try {
211 releaseDrawable();
212 implementation.destroy(peer_info, handle);
213 CallbackUtil.unregisterCallbacks(this);
214 destroyed = true;
215 thread = null;
216 GLContext.unloadOpenGLLibrary();
217 } catch (LWJGLException e) {
218 LWJGLUtil.log("Exception occurred while destroying context: " + e);
219 }
220 }
221 }
222
223 /**
224 * Set the buffer swap interval. This call is a best-attempt at changing
225 * the monitor swap interval, which is the minimum periodicity of color buffer swaps,
226 * measured in video frame periods, and is not guaranteed to be successful.
227 * <p/>
228 * A video frame period is the time required to display a full frame of video data.
229 */
230 public static void setSwapInterval(int value) {
231 implementation.setSwapInterval(value);
232 }
233
234 /**
235 * Destroy the context. This method behaves the same as destroy() with the extra
236 * requirement that the context must be either current to the current thread or not
237 * current at all.
238 */
239 public synchronized void forceDestroy() throws LWJGLException {
240 checkAccess();
241 destroy();
242 }
243
244 /**
245 * Request destruction of the Context. If the context is current, no context will be current after this call.
246 * The context is destroyed when no thread has it current.
247 */
248 public synchronized void destroy() throws LWJGLException {
249 if ( destroyed )
250 return;
251 destroy_requested = true;
252 boolean was_current = isCurrent();
253 int error = GL_NO_ERROR;
254 if ( was_current ) {
255 try {
256 // May fail on GLContext.getCapabilities()
257 error = glGetError();
258 } catch (Exception e) {
259 // ignore
260 }
261 releaseCurrent();
262 }
263 checkDestroy();
264 if ( was_current && error != GL_NO_ERROR )
265 throw new OpenGLException(error);
266 }
267
268 public synchronized void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
269 final ByteBuffer peer_handle = peer_info.lockAndGetHandle();
270 try {
271 switch ( LWJGLUtil.getPlatform() ) {
272 case LWJGLUtil.PLATFORM_WINDOWS:
273 final WindowsContextImplementation implWindows = (WindowsContextImplementation)implementation;
274 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implWindows.getHGLRC(handle));
275 properties.put(KHRGLSharing.CL_WGL_HDC_KHR).put(implWindows.getHDC(peer_handle));
276 break;
277 case LWJGLUtil.PLATFORM_LINUX:
278 final LinuxContextImplementation implLinux = (LinuxContextImplementation)implementation;
279 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle));
280 properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle));
281 break;
282 case LWJGLUtil.PLATFORM_MACOSX:
283 if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 6)) { // only supported on OS X 10.6+
284 // http://oscarbg.blogspot.com/2009/10/about-opencl-opengl-interop.html
285 final MacOSXContextImplementation implMacOSX = (MacOSXContextImplementation)implementation;
286 final long CGLShareGroup = implMacOSX.getCGLShareGroup(handle);
287 properties.put(APPLEGLSharing.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(CGLShareGroup);
288 break;
289 }
290 default:
291 throw new UnsupportedOperationException("CL/GL context sharing is not supported on this platform.");
292 }
293 } finally {
294 peer_info.unlock();
295 }
296 }
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.opengl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36 import org.lwjgl.opengles.EGLContext;
37 import org.lwjgl.opengles.GLContext;
38 import org.lwjgl.opengles.GLES20;
39 import org.lwjgl.opengles.PowerManagementEventException;
40
41 import static org.lwjgl.opengles.EGL.*;
42
43 /**
44 * <p/>
45 * Context encapsulates an OpenGL ES context.
46 * <p/>
47 * <p/>
48 * This class is thread-safe.
49 *
50 * @author elias_naur <elias_naur@users.sourceforge.net>
51 * @version $Revision: 3332 $
52 * $Id: Context.java 3332 2010-04-20 18:21:05Z spasi $
53 */
54 final class ContextGLES implements org.lwjgl.opengl.Context {
55
56 /** The current Context */
57 private static final ThreadLocal<ContextGLES> current_context_local = new ThreadLocal<ContextGLES>();
58
59 /** Handle to the native GL rendering context */
60 private final DrawableGLES drawable;
61 private final EGLContext eglContext;
62
63 private final org.lwjgl.opengles.ContextAttribs contextAttribs;
64
65 /** Whether the context has been destroyed */
66 private boolean destroyed;
67
68 private boolean destroy_requested;
69
70 /** The thread that has this context current, or null. */
71 private Thread thread;
72
73 static {
74 Sys.initialize();
75 }
76
77 public EGLContext getEGLContext() {
78 return eglContext;
79 }
80
81 org.lwjgl.opengles.ContextAttribs getContextAttribs() {
82 return contextAttribs;
83 }
84
85 static ContextGLES getCurrentContext() {
86 return current_context_local.get();
87 }
88
89 /** Create a context with the specified peer info and shared context */
90 ContextGLES(DrawableGLES drawable, org.lwjgl.opengles.ContextAttribs attribs, ContextGLES shared_context) throws LWJGLException {
91 if ( drawable == null )
92 throw new IllegalArgumentException();
93
94 ContextGLES context_lock = shared_context != null ? shared_context : this;
95 // If shared_context is not null, synchronize on it to make sure it is not deleted
96 // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE
97 synchronized ( context_lock ) {
98 if ( shared_context != null && shared_context.destroyed )
99 throw new IllegalArgumentException("Shared context is destroyed");
100
101 this.drawable = drawable;
102 this.contextAttribs = attribs;
103 this.eglContext = drawable.getEGLDisplay().createContext(drawable.getEGLConfig(),
104 shared_context == null ? null : shared_context.eglContext,
105 attribs == null ? new org.lwjgl.opengles.ContextAttribs(2).getAttribList() : attribs.getAttribList());
106 }
107 }
108
109 /** Release the current context (if any). After this call, no context is current. */
110 public void releaseCurrent() throws LWJGLException, PowerManagementEventException {
111 eglReleaseCurrent(drawable.getEGLDisplay());
112 org.lwjgl.opengles.GLContext.useContext(null);
113 current_context_local.set(null);
114
115 synchronized ( this ) {
116 thread = null;
117 checkDestroy();
118 }
119 }
120
121 /** Swap the buffers on the current context. Only valid for double-buffered contexts */
122 public static void swapBuffers() throws LWJGLException, PowerManagementEventException {
123 ContextGLES current_context = getCurrentContext();
124 if ( current_context != null )
125 current_context.drawable.getEGLSurface().swapBuffers();
126 }
127
128 private boolean canAccess() {
129 return thread == null || Thread.currentThread() == thread;
130 }
131
132 private void checkAccess() {
133 if ( !canAccess() )
134 throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current");
135 }
136
137 /** Make the context current */
138 public synchronized void makeCurrent() throws LWJGLException, PowerManagementEventException {
139 checkAccess();
140 if ( destroyed )
141 throw new IllegalStateException("Context is destroyed");
142 thread = Thread.currentThread();
143 current_context_local.set(this);
144 eglContext.makeCurrent(drawable.getEGLSurface());
145 org.lwjgl.opengles.GLContext.useContext(this);
146 }
147
148 /** Query whether the context is current */
149 public synchronized boolean isCurrent() throws LWJGLException {
150 if ( destroyed )
151 throw new IllegalStateException("Context is destroyed");
152 return eglIsCurrentContext(eglContext);
153 }
154
155 private void checkDestroy() {
156 if ( !destroyed && destroy_requested ) {
157 try {
158 eglContext.destroy();
159 destroyed = true;
160 thread = null;
161 } catch (LWJGLException e) {
162 LWJGLUtil.log("Exception occurred while destroying context: " + e);
163 }
164 }
165 }
166
167 /**
168 * Set the buffer swap interval. This call is a best-attempt at changing
169 * the monitor swap interval, which is the minimum periodicity of color buffer swaps,
170 * measured in video frame periods, and is not guaranteed to be successful.
171 * <p/>
172 * A video frame period is the time required to display a full frame of video data.
173 */
174 public static void setSwapInterval(int value) {
175 ContextGLES current_context = getCurrentContext();
176 if ( current_context != null ) {
177 try {
178 current_context.drawable.getEGLDisplay().setSwapInterval(value);
179 } catch (LWJGLException e) {
180 LWJGLUtil.log("Failed to set swap interval. Reason: " + e.getMessage());
181 }
182 }
183 }
184
185 /**
186 * Destroy the context. This method behaves the same as destroy() with the extra
187 * requirement that the context must be either current to the current thread or not
188 * current at all.
189 */
190 public synchronized void forceDestroy() throws LWJGLException {
191 checkAccess();
192 destroy();
193 }
194
195 /**
196 * Request destruction of the Context. If the context is current, no context will be current after this call.
197 * The context is destroyed when no thread has it current.
198 */
199 public synchronized void destroy() throws LWJGLException {
200 if ( destroyed )
201 return;
202 destroy_requested = true;
203 boolean was_current = isCurrent();
204 int error = GLES20.GL_NO_ERROR;
205 if ( was_current ) {
206 if ( org.lwjgl.opengles.GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGLES20 )
207 error = GLES20.glGetError();
208
209 try {
210 releaseCurrent();
211 } catch (PowerManagementEventException e) {
212 // Ignore
213 }
214 }
215 checkDestroy();
216 if ( was_current && error != GLES20.GL_NO_ERROR )
217 throw new OpenGLException(error);
218 }
219
220 public void releaseDrawable() throws LWJGLException {
221 }
222
223 }
4141 * <p/>
4242 *
4343 * @author elias_naur <elias_naur@users.sourceforge.net>
44 * @version $Revision: 3116 $
45 * $Id: ContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
44 * @version $Revision$
45 * $Id$
4646 */
4747 interface ContextImplementation {
4848 /**
6161 import java.util.Arrays;
6262 import java.util.HashSet;
6363
64 import static org.lwjgl.opengl.GL11.*;
65
6664 public final class Display {
6765
6866 private static final Thread shutdown_hook = new Thread() {
8381 /** The current display mode, if created */
8482 private static DisplayMode current_mode;
8583
86 /** Timer for sync() */
87 private static long timeThen;
88
8984 /** X coordinate of the window */
9085 private static int x = -1;
9186
9893 */
9994 private static int y = -1;
10095
96 /** the width of the Display window */
97 private static int width = 0;
98
99 /** the height of the Display window */
100 private static int height = 0;
101
101102 /** Title of the window (never null) */
102103 private static String title = "Game";
103104
108109 private static int swap_interval;
109110
110111 /** The Drawable instance that tracks the current Display context */
111 private static final AbstractDrawable drawable;
112 private static DrawableLWJGL drawable;
112113
113114 private static boolean window_created;
114115
115116 private static boolean parent_resized;
117
118 private static boolean window_resized;
119
120 private static boolean window_resizable;
116121
117122 /** Initial Background Color of Display */
118123 private static float r, g, b;
133138 LWJGLUtil.log("Initial mode: " + initial_mode);
134139 } catch (LWJGLException e) {
135140 throw new RuntimeException(e);
136 }
137 drawable = new AbstractDrawable() {
138 public void destroy() {
139 synchronized ( GlobalLock.lock ) {
140 if ( !isCreated() )
141 return;
142
143 releaseDrawable();
144 super.destroy();
145 destroyWindow();
146 x = y = -1;
147 cached_icons = null;
148 reset();
149 removeShutdownHook();
150 }
151 }
152141 };
153142 }
154143
255244 try {
256245 if ( was_fullscreen && !isFullscreen() )
257246 display_impl.resetDisplayMode();
258 else if ( isFullscreen() )
247 else if ( isFullscreen() )
259248 switchDisplayMode();
260249 createWindow();
261250 makeCurrentAndSetSwapInterval();
313302 tmp_parent.addComponentListener(component_listener);
314303 }
315304 DisplayMode mode = getEffectiveMode();
316 display_impl.createWindow(mode, tmp_parent, getWindowX(), getWindowY());
305 display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
317306 window_created = true;
307
308 width = Display.getDisplayMode().getWidth();
309 height = Display.getDisplayMode().getHeight();
318310
319311 setTitle(title);
320312 initControls();
329321
330322 private static void releaseDrawable() {
331323 try {
332 Context context = drawable.context;
324 Context context = drawable.getContext();
333325 if ( context != null && context.isCurrent() ) {
334 Context.releaseCurrentContext();
326 context.releaseCurrent();
335327 context.releaseDrawable();
336328 }
337329 } catch (LWJGLException e) {
408400 }
409401 }
410402
411 private static long timeLate;
412
413 /**
414 * Best sync method that works reliably.
415 *
416 * @param fps The desired frame rate, in frames per second
403 /**
404 * An accurate sync method that will attempt to run at a constant frame rate.
405 * It should be called once every frame.
406 *
407 * @param fps - the desired frame rate, in frames per second
417408 */
418409 public static void sync(int fps) {
419 long timeNow;
420 long gapTo;
421 long savedTimeLate;
422 synchronized ( GlobalLock.lock ) {
423 gapTo = Sys.getTimerResolution() / fps + timeThen;
424 timeNow = Sys.getTime();
425 savedTimeLate = timeLate;
426 }
427
428 try {
429 while ( gapTo > timeNow + savedTimeLate ) {
430 Thread.sleep(1);
431 timeNow = Sys.getTime();
432 }
433 } catch (InterruptedException e) {
434 Thread.currentThread().interrupt();
435 }
436
437 synchronized ( GlobalLock.lock ) {
438 if ( gapTo < timeNow )
439 timeLate = timeNow - gapTo;
440 else
441 timeLate = 0;
442
443 timeThen = timeNow;
444 }
410 Sync.sync(fps);
445411 }
446412
447413 /** @return the title of the window */
647613 throw new IllegalStateException("Display not created");
648614
649615 if ( LWJGLUtil.DEBUG )
650 Util.checkGLError();
651 Context.swapBuffers();
616 drawable.checkGLError();
617 drawable.swapBuffers();
652618 }
653619 }
654620
682648 }
683649 }
684650
651 window_resized = !isFullscreen() && parent == null && display_impl.wasResized();
652
653 if ( window_resized ) {
654 width = display_impl.getWidth();
655 height = display_impl.getHeight();
656 }
657
685658 if ( parent_resized ) {
686659 reshape();
687660 parent_resized = false;
661 window_resized = true;
688662 }
689663
690664 if ( processMessages )
761735 * @throws LWJGLException
762736 */
763737 public static void create() throws LWJGLException {
764 synchronized ( GlobalLock.lock ) {
765 create(new PixelFormat());
766 }
738 create(new PixelFormat());
767739 }
768740
769741 /**
781753 */
782754 public static void create(PixelFormat pixel_format) throws LWJGLException {
783755 synchronized ( GlobalLock.lock ) {
784 create(pixel_format, null, null);
756 create(pixel_format, null, (ContextAttribs)null);
785757 }
786758 }
787759
801773 */
802774 public static void create(PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException {
803775 synchronized ( GlobalLock.lock ) {
804 create(pixel_format, shared_drawable, null);
776 create(pixel_format, shared_drawable, (ContextAttribs)null);
805777 }
806778 }
807779
850822 registerShutdownHook();
851823 if ( isFullscreen() )
852824 switchDisplayMode();
825
826 final DrawableGL drawable = new DrawableGL() {
827 public void destroy() {
828 synchronized ( GlobalLock.lock ) {
829 if ( !isCreated() )
830 return;
831
832 releaseDrawable();
833 super.destroy();
834 destroyWindow();
835 x = y = -1;
836 cached_icons = null;
837 reset();
838 removeShutdownHook();
839 }
840 }
841 };
842 Display.drawable = drawable;
843
853844 try {
854 drawable.peer_info = display_impl.createPeerInfo(pixel_format);
845 drawable.setPixelFormat(pixel_format, attribs);
855846 try {
856847 createWindow();
857848 try {
858 drawable.context = new Context(drawable.peer_info, attribs, shared_drawable != null ? ((AbstractDrawable)shared_drawable).getContext() : null);
849 drawable.context = new ContextGL(drawable.peer_info, attribs, shared_drawable != null ? ((DrawableGL)shared_drawable).getContext() : null);
859850 try {
860851 makeCurrentAndSetSwapInterval();
861852 initContext();
879870 }
880871
881872 /**
873 * Create the OpenGL ES context with the given minimum parameters. If isFullscreen() is true or if windowed
874 * context are not supported on the platform, the display mode will be switched to the mode returned by
875 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
876 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
877 * created with the given parameters, a LWJGLException will be thrown.
878 * <p/>
879 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
880 *
881 * @param pixel_format Describes the minimum specifications the context must fulfill. Must be an instance of org.lwjgl.opengles.PixelFormat.
882 *
883 * @throws LWJGLException
884 */
885
886 public static void create(PixelFormatLWJGL pixel_format) throws LWJGLException {
887 synchronized ( GlobalLock.lock ) {
888 create(pixel_format, null, null);
889 }
890 }
891
892 /**
893 * Create the OpenGL ES context with the given minimum parameters. If isFullscreen() is true or if windowed
894 * context are not supported on the platform, the display mode will be switched to the mode returned by
895 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
896 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
897 * created with the given parameters, a LWJGLException will be thrown.
898 * <p/>
899 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
900 *
901 * @param pixel_format Describes the minimum specifications the context must fulfill. Must be an instance of org.lwjgl.opengles.PixelFormat.
902 * @param shared_drawable The Drawable to share context with. (optional, may be null)
903 *
904 * @throws LWJGLException
905 */
906 public static void create(PixelFormatLWJGL pixel_format, Drawable shared_drawable) throws LWJGLException {
907 synchronized ( GlobalLock.lock ) {
908 create(pixel_format, shared_drawable, null);
909 }
910 }
911
912 /**
913 * Create the OpenGL ES context with the given minimum parameters. If isFullscreen() is true or if windowed
914 * context are not supported on the platform, the display mode will be switched to the mode returned by
915 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
916 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
917 * created with the given parameters, a LWJGLException will be thrown.
918 * <p/>
919 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
920 *
921 * @param pixel_format Describes the minimum specifications the context must fulfill. Must be an instance of org.lwjgl.opengles.PixelFormat.
922 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
923 *
924 * @throws LWJGLException
925 */
926 public static void create(PixelFormatLWJGL pixel_format, org.lwjgl.opengles.ContextAttribs attribs) throws LWJGLException {
927 synchronized ( GlobalLock.lock ) {
928 create(pixel_format, null, attribs);
929 }
930 }
931
932 /**
933 * Create the OpenGL ES context with the given minimum parameters. If isFullscreen() is true or if windowed
934 * context are not supported on the platform, the display mode will be switched to the mode returned by
935 * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
936 * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be
937 * created with the given parameters, a LWJGLException will be thrown.
938 * <p/>
939 * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates.
940 *
941 * @param pixel_format Describes the minimum specifications the context must fulfill. Must be an instance of org.lwjgl.opengles.PixelFormat.
942 * @param shared_drawable The Drawable to share context with. (optional, may be null)
943 * @param attribs The ContextAttribs to use when creating the context. (optional, may be null)
944 *
945 * @throws LWJGLException
946 */
947 public static void create(PixelFormatLWJGL pixel_format, Drawable shared_drawable, org.lwjgl.opengles.ContextAttribs attribs) throws LWJGLException {
948 synchronized ( GlobalLock.lock ) {
949 if ( isCreated() )
950 throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
951 if ( pixel_format == null )
952 throw new NullPointerException("pixel_format cannot be null");
953 removeShutdownHook();
954 registerShutdownHook();
955 if ( isFullscreen() )
956 switchDisplayMode();
957
958 final DrawableGLES drawable = new DrawableGLES() {
959
960 public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException {
961 throw new UnsupportedOperationException();
962 }
963
964 public void destroy() {
965 synchronized ( GlobalLock.lock ) {
966 if ( !isCreated() )
967 return;
968
969 releaseDrawable();
970 super.destroy();
971 destroyWindow();
972 x = y = -1;
973 cached_icons = null;
974 reset();
975 removeShutdownHook();
976 }
977 }
978 };
979 Display.drawable = drawable;
980
981 try {
982 drawable.setPixelFormat(pixel_format);
983 try {
984 createWindow();
985 try {
986 drawable.createContext(attribs, shared_drawable);
987 try {
988 makeCurrentAndSetSwapInterval();
989 initContext();
990 } catch (LWJGLException e) {
991 drawable.destroy();
992 throw e;
993 }
994 } catch (LWJGLException e) {
995 destroyWindow();
996 throw e;
997 }
998 } catch (LWJGLException e) {
999 drawable.destroy();
1000 throw e;
1001 }
1002 } catch (LWJGLException e) {
1003 display_impl.resetDisplayMode();
1004 throw e;
1005 }
1006 }
1007 }
1008
1009 /**
8821010 * Set the initial color of the Display. This method is called before the Display is created and will set the
8831011 * background color to the one specified in this method.
8841012 *
8951023 private static void makeCurrentAndSetSwapInterval() throws LWJGLException {
8961024 makeCurrent();
8971025 try {
898 Util.checkGLError();
1026 drawable.checkGLError();
8991027 } catch (OpenGLException e) {
9001028 LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage());
9011029 }
9031031 }
9041032
9051033 private static void initContext() {
906 // set background clear color
907 glClearColor(r, g, b, 0.0f);
908 // Clear window to avoid the desktop "showing through"
909 glClear(GL_COLOR_BUFFER_BIT);
1034 drawable.initContext(r, g, b);
9101035 update();
9111036 }
9121037
9191044 return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
9201045 public Boolean run() {
9211046 return Boolean.getBoolean(property_name);
1047 }
1048 });
1049 }
1050
1051 /** Gets a string property as a privileged action. */
1052 static String getPrivilegedString(final String property_name) {
1053 return AccessController.doPrivileged(new PrivilegedAction<String>() {
1054 public String run() {
1055 return System.getProperty(property_name);
9221056 }
9231057 });
9241058 }
9561090 * regardless of whether the Display was the current rendering context.
9571091 */
9581092 public static void destroy() {
959 drawable.destroy();
1093 if(isCreated()) {
1094 drawable.destroy();
1095 }
9601096 }
9611097
9621098 /*
9891125 synchronized ( GlobalLock.lock ) {
9901126 swap_interval = value;
9911127 if ( isCreated() )
992 Context.setSwapInterval(swap_interval);
1128 drawable.setSwapInterval(swap_interval);
1129
9931130 }
9941131 }
9951132
10641201 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
10651202 * <li>Mac OS X should be supplied one 128x128 icon</li>
10661203 * </ul>
1067 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
1204 * The implementation will use the supplied ByteBuffers with image data in RGBA (size must be a power of two) and perform any conversions nescesarry for the specific platform.
10681205 * <p/>
10691206 * <b>NOTE:</b> The display will make a deep copy of the supplied byte buffer array, for the purpose
10701207 * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to
10961233 }
10971234 }
10981235 }
1236
1237 /**
1238 * Enable or disable the Display window to be resized.
1239 *
1240 * @param resizable set to true to make the Display window resizable;
1241 * false to disable resizing on the Display window.
1242 */
1243 public static void setResizable(boolean resizable) {
1244 window_resizable = resizable;
1245 if ( isCreated() ) {
1246 display_impl.setResizable(resizable);
1247 }
1248 }
1249
1250 /**
1251 * @return true if the Display window is resizable.
1252 */
1253 public static boolean isResizable() {
1254 return window_resizable;
1255 }
1256
1257 /**
1258 * @return true if the Display window has been resized.
1259 * This value will be updated after a call to Display.update().
1260 *
1261 * This will return false if running in fullscreen or with Display.setParent(Canvas parent)
1262 */
1263 public static boolean wasResized() {
1264 return window_resized;
1265 }
1266
1267 /**
1268 * @return this method will return the x position (top-left) of the Display window.
1269 *
1270 * If running in fullscreen mode it will return 0.
1271 * If Display.setParent(Canvas parent) is being used, the x position of
1272 * the parent will be returned.
1273 */
1274 public static int getX() {
1275
1276 if (Display.isFullscreen()) {
1277 return 0;
1278 }
1279
1280 if (parent != null) {
1281 return parent.getX();
1282 }
1283
1284 return display_impl.getX();
1285 }
1286
1287 /**
1288 * @return this method will return the y position (top-left) of the Display window.
1289 *
1290 * If running in fullscreen mode it will return 0.
1291 * If Display.setParent(Canvas parent) is being used, the y position of
1292 * the parent will be returned.
1293 */
1294 public static int getY() {
1295
1296 if (Display.isFullscreen()) {
1297 return 0;
1298 }
1299
1300 if (parent != null) {
1301 return parent.getY();
1302 }
1303
1304 return display_impl.getY();
1305 }
1306
1307 /**
1308 * @return this method will return the width of the Display window.
1309 *
1310 * If running in fullscreen mode it will return the width of the current set DisplayMode.
1311 * If Display.setParent(Canvas parent) is being used, the width of the parent
1312 * will be returned.
1313 *
1314 * This value will be updated after a call to Display.update().
1315 */
1316 public static int getWidth() {
1317
1318 if (Display.isFullscreen()) {
1319 return Display.getDisplayMode().getWidth();
1320 }
1321
1322 if (parent != null) {
1323 return parent.getWidth();
1324 }
1325
1326 return width;
1327 }
1328
1329 /**
1330 * @return this method will return the height of the Display window.
1331 *
1332 * If running in fullscreen mode it will return the height of the current set DisplayMode.
1333 * If Display.setParent(Canvas parent) is being used, the height of the parent
1334 * will be returned.
1335 *
1336 * This value will be updated after a call to Display.update().
1337 */
1338 public static int getHeight() {
1339
1340 if (Display.isFullscreen()) {
1341 return Display.getDisplayMode().getHeight();
1342 }
1343
1344 if (parent != null) {
1345 return parent.getHeight();
1346 }
1347
1348 return height;
1349 }
1350
1351 /**
1352 * @return this method will return the pixel scale factor of the Display window.
1353 *
1354 * This method should be used when running in high DPI mode. In such modes Operating
1355 * Systems will scale the Display window to avoid the window shrinking due to high
1356 * resolutions. The OpenGL frame buffer will however use the higher resolution and
1357 * not be scaled to match the Display window size.
1358 *
1359 * OpenGL methods that require pixel dependent values e.g. glViewport, glTexImage2D,
1360 * glReadPixels, glScissor, glLineWidth, glRenderbufferStorage, etc can convert the
1361 * scaled Display and Mouse coordinates to the correct high resolution value by
1362 * multiplying them by the pixel scale factor.
1363 *
1364 * e.g. Display.getWidth() * Display.getPixelScaleFactor() will return the high DPI
1365 * width of the OpenGL frame buffer. Whereas Display.getWidth() will be the same as
1366 * the OpenGL frame buffer in non high DPI mode.
1367 *
1368 * Where high DPI mode is not available this method will just return 1.0f therefore
1369 * not have any effect on values that are multiplied by it.
1370 */
1371 public static float getPixelScaleFactor() {
1372 return display_impl.getPixelScaleFactor();
1373 }
10991374 }
4646
4747 interface DisplayImplementation extends InputImplementation {
4848
49 void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException;
49 void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException;
5050
5151 void destroyWindow();
5252
107107 * Create the native PeerInfo.
108108 * @throws LWJGLException
109109 */
110 PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException;
110 PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException;
111111
112112 // void destroyPeerInfo();
113113
135135 /**
136136 * Method to create a Pbuffer
137137 */
138 PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
138 PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs,
139139 IntBuffer pixelFormatCaps,
140140 IntBuffer pBufferAttribs) throws LWJGLException;
141141
158158 * @return number of icons used.
159159 */
160160 int setIcon(ByteBuffer[] icons);
161
162 /**
163 * Enable or disable the Display window to be resized.
164 *
165 * @param resizable set to true to make the Display window resizable;
166 * false to disable resizing on the Display window.
167 */
168 void setResizable(boolean resizable);
169
170 /**
171 * @return true if the Display window has been resized since this method was last called.
172 */
173 boolean wasResized();
174
175 /**
176 * @return this method will return the width of the Display window.
177 */
178 int getWidth();
179
180 /**
181 * @return this method will return the height of the Display window.
182 */
183 int getHeight();
184
185 /**
186 * @return this method will return the top-left x position of the Display window.
187 */
188 int getX();
189
190 /**
191 * @return this method will return the top-left y position of the Display window.
192 */
193 int getY();
194
195 /**
196 * @return this method will return the pixel scale factor of the Display window useful for high resolution modes.
197 */
198 float getPixelScaleFactor();
161199 }
3737 * getAvailableDisplayModes()</code> method.
3838 *
3939 * @author cix_foo <cix_foo@users.sourceforge.net>
40 * @version $Revision: 3418 $
41 * $Id: DisplayMode.java 3418 2010-09-28 21:11:35Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343
4444 public final class DisplayMode {
7474 this.fullscreen = fullscreen;
7575 }
7676
77 /** True iff this instance can be used for fullscreen modes */
77 /** True if this instance can be used for fullscreen modes */
7878 public boolean isFullscreenCapable() {
7979 return fullscreen;
8080 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
36
37 import static org.lwjgl.opengl.GL11.*;
38
39 /** @author Spasi */
40 abstract class DrawableGL implements DrawableLWJGL {
41
42 /** The PixelFormat used to create the drawable. */
43 protected PixelFormat pixel_format;
44
45 /** Handle to the native GL rendering context */
46 protected PeerInfo peer_info;
47
48 /** The OpenGL Context. */
49 protected ContextGL context;
50
51 protected DrawableGL() {
52 }
53
54 public void setPixelFormat(final PixelFormatLWJGL pf) throws LWJGLException {
55 throw new UnsupportedOperationException();
56 }
57
58 public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException {
59 this.pixel_format = (PixelFormat)pf;
60 this.peer_info = Display.getImplementation().createPeerInfo(pixel_format, attribs);
61 }
62
63 public PixelFormatLWJGL getPixelFormat() {
64 return pixel_format;
65 }
66
67 public ContextGL getContext() {
68 synchronized ( GlobalLock.lock ) {
69 return context;
70 }
71 }
72
73 public ContextGL createSharedContext() throws LWJGLException {
74 synchronized ( GlobalLock.lock ) {
75 checkDestroyed();
76 return new ContextGL(peer_info, context.getContextAttribs(), context);
77 }
78 }
79
80 public void checkGLError() {
81 Util.checkGLError();
82 }
83
84 public void setSwapInterval(final int swap_interval) {
85 ContextGL.setSwapInterval(swap_interval);
86 }
87
88 public void swapBuffers() throws LWJGLException {
89 ContextGL.swapBuffers();
90 }
91
92 public void initContext(final float r, final float g, final float b) {
93 // set background clear color
94 glClearColor(r, g, b, 0.0f);
95 // Clear window to avoid the desktop "showing through"
96 glClear(GL_COLOR_BUFFER_BIT);
97 }
98
99 public boolean isCurrent() throws LWJGLException {
100 synchronized ( GlobalLock.lock ) {
101 checkDestroyed();
102 return context.isCurrent();
103 }
104 }
105
106 public void makeCurrent() throws LWJGLException {
107 synchronized ( GlobalLock.lock ) {
108 checkDestroyed();
109 context.makeCurrent();
110 }
111 }
112
113 public void releaseContext() throws LWJGLException {
114 synchronized ( GlobalLock.lock ) {
115 checkDestroyed();
116 if ( context.isCurrent() )
117 context.releaseCurrent();
118 }
119 }
120
121 public void destroy() {
122 synchronized ( GlobalLock.lock ) {
123 if ( context == null )
124 return;
125
126 try {
127 releaseContext();
128
129 context.forceDestroy();
130 context = null;
131
132 if ( peer_info != null ) {
133 peer_info.destroy();
134 peer_info = null;
135 }
136 } catch (LWJGLException e) {
137 LWJGLUtil.log("Exception occurred while destroying Drawable: " + e);
138 }
139 }
140 }
141
142 public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
143 synchronized ( GlobalLock.lock ) {
144 checkDestroyed();
145 context.setCLSharingProperties(properties);
146 }
147 }
148
149 protected final void checkDestroyed() {
150 if ( context == null )
151 throw new IllegalStateException("The Drawable has no context available.");
152 }
153
154 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
37 import org.lwjgl.opengles.ContextAttribs;
38 import org.lwjgl.opengles.*;
39 import org.lwjgl.opengles.Util;
40
41 import static org.lwjgl.opengles.EGL.*;
42 import static org.lwjgl.opengles.GLES20.*;
43
44 /**
45 * @author Spasi
46 * @since 14/5/2011
47 */
48 abstract class DrawableGLES implements DrawableLWJGL {
49
50 /** The PixelFormat used to create the EGLDisplay. */
51 protected org.lwjgl.opengles.PixelFormat pixel_format;
52
53 protected EGLDisplay eglDisplay;
54 protected EGLConfig eglConfig;
55 protected EGLSurface eglSurface;
56
57 /** The OpenGL Context. */
58 protected ContextGLES context;
59
60 /** The Drawable that shares objects with this Drawable. */
61 protected Drawable shared_drawable;
62
63 protected DrawableGLES() {
64 }
65
66 public void setPixelFormat(final PixelFormatLWJGL pf) throws LWJGLException {
67 synchronized ( GlobalLock.lock ) {
68 this.pixel_format = (org.lwjgl.opengles.PixelFormat)pf;
69 }
70 }
71
72 public PixelFormatLWJGL getPixelFormat() {
73 synchronized ( GlobalLock.lock ) {
74 return pixel_format;
75 }
76 }
77
78 public void initialize(final long window, final long display_id, final int eglSurfaceType, final org.lwjgl.opengles.PixelFormat pf) throws LWJGLException {
79 synchronized ( GlobalLock.lock ) {
80 if ( eglSurface != null ) {
81 eglSurface.destroy();
82 eglSurface = null;
83 }
84
85 if ( eglDisplay != null ) {
86 eglDisplay.terminate();
87 eglDisplay = null;
88 }
89
90 final EGLDisplay eglDisplay = eglGetDisplay((int)display_id);
91
92 int[] attribs = {
93 EGL_LEVEL, 0,
94 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
95 EGL_NATIVE_RENDERABLE, EGL_FALSE,
96 };
97
98 final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, BufferUtils.createIntBuffer(1));
99 if ( configs.length == 0 )
100 throw new LWJGLException("No EGLConfigs found for the specified PixelFormat.");
101
102 final EGLConfig eglConfig = pf.getBestMatch(configs);
103 final EGLSurface eglSurface = eglDisplay.createWindowSurface(eglConfig, window, null);
104 pf.setSurfaceAttribs(eglSurface);
105
106 this.eglDisplay = eglDisplay;
107 this.eglConfig = eglConfig;
108 this.eglSurface = eglSurface;
109
110 // This can happen when switching in and out of full-screen mode.
111 if ( context != null )
112 context.getEGLContext().setDisplay(eglDisplay);
113 }
114 }
115
116 public void createContext(final ContextAttribs attribs, final Drawable shared_drawable) throws LWJGLException {
117 synchronized ( GlobalLock.lock ) {
118 this.context = new ContextGLES(this, attribs, shared_drawable != null ? ((DrawableGLES)shared_drawable).getContext() : null);
119 this.shared_drawable = shared_drawable;
120 }
121 }
122
123 Drawable getSharedDrawable() {
124 synchronized ( GlobalLock.lock ) {
125 return shared_drawable;
126 }
127 }
128
129 public EGLDisplay getEGLDisplay() {
130 synchronized ( GlobalLock.lock ) {
131 return eglDisplay;
132 }
133 }
134
135 public EGLConfig getEGLConfig() {
136 synchronized ( GlobalLock.lock ) {
137 return eglConfig;
138 }
139 }
140
141 public EGLSurface getEGLSurface() {
142 synchronized ( GlobalLock.lock ) {
143 return eglSurface;
144 }
145 }
146
147 public ContextGLES getContext() {
148 synchronized ( GlobalLock.lock ) {
149 return context;
150 }
151 }
152
153 public org.lwjgl.opengl.Context createSharedContext() throws LWJGLException {
154 synchronized ( GlobalLock.lock ) {
155 checkDestroyed();
156 return new ContextGLES(this, context.getContextAttribs(), context);
157 }
158 }
159
160 public void checkGLError() {
161 Util.checkGLError();
162 }
163
164 public void setSwapInterval(final int swap_interval) {
165 ContextGLES.setSwapInterval(swap_interval);
166 }
167
168 public void swapBuffers() throws LWJGLException {
169 ContextGLES.swapBuffers();
170 }
171
172 public void initContext(final float r, final float g, final float b) {
173 // set background clear color
174 glClearColor(r, g, b, 0.0f);
175 // Clear window to avoid the desktop "showing through"
176 glClear(GL_COLOR_BUFFER_BIT);
177 }
178
179 public boolean isCurrent() throws LWJGLException {
180 synchronized ( GlobalLock.lock ) {
181 checkDestroyed();
182 return context.isCurrent();
183 }
184 }
185
186 public void makeCurrent() throws LWJGLException, PowerManagementEventException {
187 synchronized ( GlobalLock.lock ) {
188 checkDestroyed();
189 context.makeCurrent();
190 }
191 }
192
193 public void releaseContext() throws LWJGLException, PowerManagementEventException {
194 synchronized ( GlobalLock.lock ) {
195 checkDestroyed();
196 if ( context.isCurrent() )
197 context.releaseCurrent();
198 }
199 }
200
201 public void destroy() {
202 synchronized ( GlobalLock.lock ) {
203 try {
204 if ( context != null ) {
205 try {
206 releaseContext();
207 } catch (PowerManagementEventException e) {
208 // Ignore
209 }
210
211 context.forceDestroy();
212 context = null;
213 }
214
215 if ( eglSurface != null ) {
216 eglSurface.destroy();
217 eglSurface = null;
218 }
219
220 if ( eglDisplay != null ) {
221 eglDisplay.terminate();
222 eglDisplay = null;
223 }
224
225 pixel_format = null;
226 shared_drawable = null;
227 } catch (LWJGLException e) {
228 LWJGLUtil.log("Exception occurred while destroying Drawable: " + e);
229 }
230 }
231 }
232
233 protected void checkDestroyed() {
234 if ( context == null )
235 throw new IllegalStateException("The Drawable has no context available.");
236 }
237
238 public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
239 throw new UnsupportedOperationException();
240 }
241
242 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
031 package org.lwjgl.opengl;
132
233 import org.lwjgl.LWJGLException;
334
435 /**
36 * [INTERNAL USE ONLY]
37 *
538 * @author Spasi
639 */
740 interface DrawableLWJGL extends Drawable {
41
42 void setPixelFormat(PixelFormatLWJGL pf) throws LWJGLException;
43
44 void setPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs) throws LWJGLException;
45
46 PixelFormatLWJGL getPixelFormat();
847
948 /**
1049 * [INTERNAL USE ONLY] Returns the Drawable's Context.
2059 */
2160 Context createSharedContext() throws LWJGLException;
2261
23 }
62 void checkGLError();
63
64 void setSwapInterval(int swap_interval);
65
66 void swapBuffers() throws LWJGLException;
67
68 void initContext(final float r, final float g, final float b);
69
70 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import java.nio.Buffer;
34
3533 import org.lwjgl.BufferUtils;
3634 import org.lwjgl.LWJGLUtil;
35
36 import java.nio.Buffer;
37 import java.nio.FloatBuffer;
3738
3839 import static org.lwjgl.opengl.ARBBufferObject.*;
3940 import static org.lwjgl.opengl.ATIVertexArrayObject.*;
4243 import static org.lwjgl.opengl.EXTDirectStateAccess.*;
4344 import static org.lwjgl.opengl.GL11.*;
4445 import static org.lwjgl.opengl.GL15.*;
46 import static org.lwjgl.opengl.NVPathRendering.*;
4547
4648 /**
4749 * A class to check buffer boundaries in GL methods. Many GL
5355 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
5456 *
5557 * @author cix_foo <cix_foo@users.sourceforge.net>
56 * @version $Revision: 3459 $
57 * $Id: GLChecks.java 3459 2010-11-29 17:21:05Z spasi $
58 * @version $Revision$
59 * $Id$
5860 */
5961 class GLChecks {
6062
6264 private GLChecks() {
6365 }
6466
65 static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
66 return glGetBufferParameter(buffer_enum, GL_BUFFER_SIZE);
67 }
68
69 static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) {
70 return glGetBufferParameterARB(buffer_enum, GL_BUFFER_SIZE_ARB);
71 }
72
73 static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) {
74 return glGetObjectBufferATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI);
75 }
76
77 static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) {
78 return glGetNamedBufferParameterEXT(buffer, GL_BUFFER_SIZE);
79 }
80
8167 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
8268 static void ensureArrayVBOdisabled(ContextCapabilities caps) {
83 if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
69 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
8470 throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
8571 }
8672
8773 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
8874 static void ensureArrayVBOenabled(ContextCapabilities caps) {
89 if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
75 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
9076 throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
9177 }
9278
9379 /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
9480 static void ensureElementVBOdisabled(ContextCapabilities caps) {
95 if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
81 if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
9682 throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
9783 }
9884
9985 /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
10086 static void ensureElementVBOenabled(ContextCapabilities caps) {
101 if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
87 if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
10288 throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
10389 }
10490
208194 case GL_FLOAT:
209195 bpe = 4;
210196 break;
211 default :
197 default:
212198 // TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8
213199 return 0;
214 // throw new IllegalArgumentException("Unknown type " + type);
200 // throw new IllegalArgumentException("Unknown type " + type);
215201 }
216202 int epp;
217203 switch ( format ) {
232218 case GL_BGRA_EXT:
233219 epp = 4;
234220 break;
235 default :
221 default:
236222 // TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT)
237223 return 0;
238224 /* // Assume 4 elements per pixel
241227
242228 return bpe * epp;
243229 }
244 }
230
231 // NV_path_rendering checks
232
233 static int calculateBytesPerCharCode(int type) {
234 switch ( type ) {
235 case GL_UNSIGNED_BYTE:
236 case GL_UTF8_NV:
237 return 1;
238 case GL_UNSIGNED_SHORT:
239 case GL_2_BYTES:
240 case GL_UTF16_NV:
241 return 2;
242 case GL_3_BYTES:
243 return 3;
244 case GL_4_BYTES:
245 return 4;
246 default:
247 throw new IllegalArgumentException("Unsupported charcode type: " + type);
248 }
249 }
250
251 static int calculateBytesPerPathName(int pathNameType) {
252 switch ( pathNameType ) {
253 case GL_BYTE:
254 case GL_UNSIGNED_BYTE:
255 case GL_UTF8_NV:
256 return 1;
257 case GL_SHORT:
258 case GL_UNSIGNED_SHORT:
259 case GL_2_BYTES:
260 case GL_UTF16_NV:
261 return 2;
262 case GL_3_BYTES:
263 return 3;
264 case GL_INT:
265 case GL_UNSIGNED_INT:
266 case GL_FLOAT:
267 case GL_4_BYTES:
268 return 4;
269 default:
270 throw new IllegalArgumentException("Unsupported path name type: " + pathNameType);
271 }
272 }
273
274 static int calculateTransformPathValues(int transformType) {
275 switch ( transformType ) {
276 case GL_NONE:
277 return 0;
278 case GL_TRANSLATE_X_NV:
279 case GL_TRANSLATE_Y_NV:
280 return 1;
281 case GL_TRANSLATE_2D_NV:
282 return 2;
283 case GL_TRANSLATE_3D_NV:
284 return 3;
285 case GL_AFFINE_2D_NV:
286 case GL_TRANSPOSE_AFFINE_2D_NV:
287 return 6;
288 case GL_AFFINE_3D_NV:
289 case GL_TRANSPOSE_AFFINE_3D_NV:
290 return 12;
291 default:
292 throw new IllegalArgumentException("Unsupported transform type: " + transformType);
293 }
294 }
295
296 static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) {
297 final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode);
298
299 switch ( colorFormat ) {
300 case GL_RGB:
301 return 3 * coeffsPerComponent;
302 case GL_RGBA:
303 return 4 * coeffsPerComponent;
304 default:
305 return coeffsPerComponent;
306 }
307 }
308
309 static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) {
310 if ( genMode == GL_NONE )
311 return 0;
312
313 return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode);
314 }
315
316 private static int calculatePathGenCoeffsPerComponent(int genMode) {
317 switch ( genMode ) {
318 case GL_NONE:
319 return 0;
320 case GL_OBJECT_LINEAR:
321 case GL_PATH_OBJECT_BOUNDING_BOX_NV:
322 return 3;
323 case GL_EYE_LINEAR:
324 return 4;
325 default:
326 throw new IllegalArgumentException("Unsupported gen mode: " + genMode);
327 }
328 }
329
330 static int calculateMetricsSize(int metricQueryMask, int stride) {
331 if ( LWJGLUtil.DEBUG && (stride < 0 || (stride % 4) != 0) )
332 throw new IllegalArgumentException("Invalid stride value: " + stride);
333
334 final int metrics = Integer.bitCount(metricQueryMask);
335
336 if ( LWJGLUtil.DEBUG && (stride >> 2) < metrics )
337 throw new IllegalArgumentException("The queried metrics do not fit in the specified stride: " + stride);
338
339 return stride == 0 ? metrics : (stride >> 2);
340 }
341
342 }
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.MemoryUtil;
3536 import org.lwjgl.Sys;
3637
3738 import java.lang.reflect.Method;
39 import java.nio.ByteBuffer;
3840 import java.security.AccessController;
3941 import java.security.PrivilegedAction;
4042 import java.security.PrivilegedExceptionAction;
5557 * That way, multiple threads can have multiple contexts current and render to them concurrently.
5658 *
5759 * @author elias_naur <elias_naur@users.sourceforge.net>
58 * @version $Revision: 3418 $
59 * $Id: GLContext.java 3418 2010-09-28 21:11:35Z spasi $
60 * @version $Revision$
61 * $Id$
6062 */
6163 public final class GLContext {
6264
116118 * @return The current capabilities instance.
117119 */
118120 public static ContextCapabilities getCapabilities() {
121 ContextCapabilities caps = getCapabilitiesImpl();
122 if ( caps == null )
123 throw new RuntimeException("No OpenGL context found in the current thread.");
124
125 return caps;
126 }
127
128 private static ContextCapabilities getCapabilitiesImpl() {
119129 CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
120130 // Check owner of cache entry
121131 if ( recent_cache_entry.owner == Thread.currentThread() ) {
125135 return recent_cache_entry.capabilities;
126136 } else // Some other thread has written to the cache since, and we fall back to the slower path
127137 return getThreadLocalCapabilities();
138 }
139
140 /**
141 * Returns the capabilities instance associated with the specified context object.
142 *
143 * @param context the context object
144 *
145 * @return the capabilities instance
146 */
147 static ContextCapabilities getCapabilities(Object context) {
148 return capability_cache.get(context);
128149 }
129150
130151 private static ContextCapabilities getThreadLocalCapabilities() {
186207 return 0;
187208 }
188209
189 /** Helper method to get a pointer to a named function in the OpenGL library */
190 static native long getFunctionAddress(String name);
210 /** Helper method to get a pointer to a named function in the OpenGL library. */
211 static long getFunctionAddress(String name) {
212 ByteBuffer buffer = MemoryUtil.encodeASCII(name);
213 return ngetFunctionAddress(MemoryUtil.getAddress(buffer));
214 }
215 private static native long ngetFunctionAddress(long name);
191216
192217 /**
193218 * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
217242 }
218243
219244 final int[][] GL_VERSIONS = {
220 { 1, 2, 3, 4, 5 }, // OpenGL 1
221 { 0, 1 }, // OpenGL 2
222 { 0, 1, 2, 3 }, // OpenGL 3
223 { 0, 1 }, // OpenGL 4
245 { 1, 2, 3, 4, 5 }, // OpenGL 1
246 { 0, 1 }, // OpenGL 2
247 { 0, 1, 2, 3 }, // OpenGL 3
248 { 0, 1, 2, 3, 4, 5 }, // OpenGL 4
224249 };
225250
226251 for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {
3737 * GLU constants.
3838 *
3939 * @author cix_foo <cix_foo@users.sourceforge.net>
40 * @version $Revision: 3418 $
41 * $Id: GLUConstants.java 3418 2010-09-28 21:11:35Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 public interface GLUConstants {
4444
6868 void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
6969
7070 /**
71 * Method to read the keyboard buffer
71 * Method to read the mouse buffer
7272 */
7373 void readMouse(ByteBuffer buffer);
7474
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Instances of this class are needed to use the callback functionality of the KHR_debug extension.
37 * Users of this class may provide implementations of the {@code Handler} interface to receive notifications.
38 * The same {@code Handler} instance may be used by different contexts but it is not recommended.
39 * Handler notifications are synchronized.
40 *
41 * @author Spasi
42 */
43 public final class KHRDebugCallback extends PointerWrapperAbstract {
44
45 /** Severity levels. */
46 private static final int
47 GL_DEBUG_SEVERITY_HIGH = 0x9146,
48 GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
49 GL_DEBUG_SEVERITY_LOW = 0x9148,
50 GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
51
52 /** Sources. */
53 private static final int
54 GL_DEBUG_SOURCE_API = 0x8246,
55 GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
56 GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
57 GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
58 GL_DEBUG_SOURCE_APPLICATION = 0x824A,
59 GL_DEBUG_SOURCE_OTHER = 0x824B;
60
61 /** Types. */
62 private static final int
63 GL_DEBUG_TYPE_ERROR = 0x824C,
64 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
65 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
66 GL_DEBUG_TYPE_PORTABILITY = 0x824F,
67 GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
68 GL_DEBUG_TYPE_OTHER = 0x8251,
69 GL_DEBUG_TYPE_MARKER = 0x8268;
70
71 private static final long CALLBACK_POINTER;
72
73 static {
74 long pointer = 0;
75 try {
76 // Call reflectively so that we can compile this class for the Generator.
77 pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugCallbackKHR").invoke(null);
78 } catch (Exception e) {
79 // ignore
80 }
81 CALLBACK_POINTER = pointer;
82 }
83
84 private final Handler handler;
85
86 /**
87 * Creates an KHRebugCallback with a default callback handler.
88 * The default handler will simply print the message on System.err.
89 */
90 public KHRDebugCallback() {
91 this(new Handler() {
92 public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
93 System.err.println("[LWJGL] KHR_debug message");
94 System.err.println("\tID: " + id);
95
96 String description;
97 switch ( source ) {
98 case GL_DEBUG_SOURCE_API:
99 description = "API";
100 break;
101 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
102 description = "WINDOW SYSTEM";
103 break;
104 case GL_DEBUG_SOURCE_SHADER_COMPILER:
105 description = "SHADER COMPILER";
106 break;
107 case GL_DEBUG_SOURCE_THIRD_PARTY:
108 description = "THIRD PARTY";
109 break;
110 case GL_DEBUG_SOURCE_APPLICATION:
111 description = "APPLICATION";
112 break;
113 case GL_DEBUG_SOURCE_OTHER:
114 description = "OTHER";
115 break;
116 default:
117 description = printUnknownToken(source);
118 }
119 System.err.println("\tSource: " + description);
120
121 switch ( type ) {
122 case GL_DEBUG_TYPE_ERROR:
123 description = "ERROR";
124 break;
125 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
126 description = "DEPRECATED BEHAVIOR";
127 break;
128 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
129 description = "UNDEFINED BEHAVIOR";
130 break;
131 case GL_DEBUG_TYPE_PORTABILITY:
132 description = "PORTABILITY";
133 break;
134 case GL_DEBUG_TYPE_PERFORMANCE:
135 description = "PERFORMANCE";
136 break;
137 case GL_DEBUG_TYPE_OTHER:
138 description = "OTHER";
139 break;
140 case GL_DEBUG_TYPE_MARKER:
141 description = "MARKER";
142 break;
143 default:
144 description = printUnknownToken(type);
145 }
146 System.err.println("\tType: " + description);
147
148 switch ( severity ) {
149 case GL_DEBUG_SEVERITY_HIGH:
150 description = "HIGH";
151 break;
152 case GL_DEBUG_SEVERITY_MEDIUM:
153 description = "MEDIUM";
154 break;
155 case GL_DEBUG_SEVERITY_LOW:
156 description = "LOW";
157 break;
158 case GL_DEBUG_SEVERITY_NOTIFICATION:
159 description = "NOTIFICATION";
160 break;
161 default:
162 description = printUnknownToken(severity);
163 }
164 System.err.println("\tSeverity: " + description);
165
166 System.err.println("\tMessage: " + message);
167 }
168
169 private String printUnknownToken(final int token) {
170 return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
171 }
172 });
173 }
174
175 /**
176 * Creates an ARBDebugOutputCallback with the specified callback handler.
177 * The handler's {@code handleMessage} method will be called whenever
178 * debug output is generated by the GL.
179 *
180 * @param handler the callback handler
181 */
182 public KHRDebugCallback(final Handler handler) {
183 super(CALLBACK_POINTER);
184
185 this.handler = handler;
186 }
187
188 Handler getHandler() {
189 return handler;
190 }
191
192 /** Implementations of this interface can be used to receive ARB_debug_output notifications. */
193 public interface Handler {
194
195 /**
196 * This method will be called when an ARB_debug_output message is generated.
197 *
198 * @param source the message source
199 * @param type the message type
200 * @param id the message ID
201 * @param severity the message severity
202 * @param message the string representation of the message.
203 */
204 void handleMessage(int source, int type, int id, int severity, String message);
205
206 }
207
208 }
3939 /**
4040 *
4141 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: LinuxAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 * @version $Revision$
43 * $Id$
4444 */
4545 final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
4646 private final Canvas component;
4343 /**
4444 *
4545 * @author elias_naur <elias_naur@users.sourceforge.net>
46 * @version $Revision: 3418 $
47 * $Id: LinuxCanvasImplementation.java 3418 2010-09-28 21:11:35Z spasi $
46 * @version $Revision$
47 * $Id$
4848 */
4949 final class LinuxCanvasImplementation implements AWTCanvasImplementation {
5050 static int getScreenFromDevice(final GraphicsDevice device) throws LWJGLException {
7575 }
7676 }
7777
78 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
78 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
7979 return new LinuxAWTGLCanvasPeerInfo(component);
8080 }
8181
+0
-94
src/java/org/lwjgl/opengl/LinuxContextAttribs.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 }
3737
3838 /**
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3412 $
41 * $Id: LinuxContextImplementation.java 3412 2010-09-26 23:43:24Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class LinuxContextImplementation implements ContextImplementation {
4444
6666 }
6767
6868 public void swapBuffers() throws LWJGLException {
69 Context current_context = Context.getCurrentContext();
69 ContextGL current_context = ContextGL.getCurrentContext();
7070 if ( current_context == null )
7171 throw new IllegalStateException("No context is current");
7272 synchronized ( current_context ) {
8888 private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
8989
9090 public void releaseCurrentContext() throws LWJGLException {
91 Context current_context = Context.getCurrentContext();
91 ContextGL current_context = ContextGL.getCurrentContext();
9292 if ( current_context == null )
9393 throw new IllegalStateException("No context is current");
9494 synchronized ( current_context ) {
141141 private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
142142
143143 public void setSwapInterval(int value) {
144 Context current_context = Context.getCurrentContext();
144 ContextGL current_context = ContextGL.getCurrentContext();
145 PeerInfo peer_info = current_context.getPeerInfo();
146
145147 if ( current_context == null )
146148 throw new IllegalStateException("No context is current");
147149 synchronized ( current_context ) {
148150 LinuxDisplay.lockAWT();
149 nSetSwapInterval(current_context.getHandle(), value);
150 LinuxDisplay.unlockAWT();
151 try {
152 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
153 try {
154 nSetSwapInterval(peer_handle, current_context.getHandle(), value);
155 } finally {
156 peer_info.unlock();
157 }
158 } catch (LWJGLException e) {
159 // API CHANGE - this methods should throw LWJGLException
160 e.printStackTrace();
161 } finally {
162 LinuxDisplay.unlockAWT();
163 }
151164 }
152165 }
153166
154 private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
167 private static native void nSetSwapInterval(ByteBuffer peer_handle, ByteBuffer context_handle, int value);
155168
156169 public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
157170 LinuxDisplay.lockAWT();
3838 */
3939
4040 import java.awt.Canvas;
41 import java.awt.event.FocusListener;
42 import java.awt.event.FocusEvent;
43
4144 import java.io.BufferedReader;
4245 import java.io.IOException;
4346 import java.io.InputStreamReader;
47 import java.nio.ByteOrder;
4448 import java.nio.ByteBuffer;
4549 import java.nio.FloatBuffer;
4650 import java.nio.IntBuffer;
51 import java.lang.reflect.InvocationTargetException;
4752
4853 import org.lwjgl.BufferUtils;
4954 import org.lwjgl.LWJGLException;
5055 import org.lwjgl.LWJGLUtil;
56 import org.lwjgl.MemoryUtil;
5157 import org.lwjgl.opengl.XRandR.Screen;
58 import org.lwjgl.opengles.EGL;
5259
5360 import java.security.AccessController;
5461 import java.security.PrivilegedAction;
7885 private static final int SetModeInsert = 0;
7986 private static final int SaveSetRoot = 1;
8087 private static final int SaveSetUnmap = 1;
88
89 private static final int X_SetInputFocus = 42;
8190
8291 /** Window mode enum */
8392 private static final int FULLSCREEN_LEGACY = 1;
119128 private DisplayMode saved_mode;
120129 private DisplayMode current_mode;
121130
122 private Screen[] savedXrandrConfig;
123131
124132 private boolean keyboard_grabbed;
125133 private boolean pointer_grabbed;
131139 private boolean close_requested;
132140 private long current_cursor;
133141 private long blank_cursor;
142 private boolean mouseInside = true;
143 private boolean resizable;
144 private boolean resized;
145
146 private int window_x;
147 private int window_y;
148 private int window_width;
149 private int window_height;
150
134151 private Canvas parent;
135152 private long parent_window;
136 private boolean xembedded;
137 private boolean parent_focus;
138 private boolean mouseInside = true;
139
153 private static boolean xembedded;
154 private long parent_proxy_focus_window;
155 private boolean parent_focused;
156 private boolean parent_focus_changed;
157 private long last_window_focus = 0;
158
140159 private LinuxKeyboard keyboard;
141160 private LinuxMouse mouse;
161
162 private String wm_class;
163
164 private final FocusListener focus_listener = new FocusListener() {
165 public void focusGained(FocusEvent e) {
166 synchronized (GlobalLock.lock) {
167 parent_focused = true;
168 parent_focus_changed = true;
169 }
170 }
171 public void focusLost(FocusEvent e) {
172 synchronized (GlobalLock.lock) {
173 parent_focused = false;
174 parent_focus_changed = true;
175 }
176 }
177 };
142178
143179 private static ByteBuffer getCurrentGammaRamp() throws LWJGLException {
144180 lockAWT();
258294 */
259295 static void incDisplay() throws LWJGLException {
260296 if (display_connection_usage_count == 0) {
261 GLContext.loadOpenGLLibrary();
297 try {
298 // TODO: Can we know if we're on desktop or ES?
299 GLContext.loadOpenGLLibrary();
300 org.lwjgl.opengles.GLContext.loadOpenGLLibrary();
301 } catch (Throwable t) {
302 }
262303 saved_error_handler = setErrorHandler();
263304 display = openDisplay();
264305 // synchronize(display, true);
271312 private static native void synchronize(long display, boolean synchronize);
272313
273314 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 {
315 if (xembedded && request_code == X_SetInputFocus) return 0; // ignore X error in xembeded mode to fix a browser issue when dragging or switching tabs
316
274317 if (display == getDisplay()) {
275318 String error_msg = getErrorText(display, error_code);
276319 throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code);
407450 ungrabKeyboard();
408451 }
409452
410 public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
453 public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
411454 lockAWT();
412455 try {
413456 incDisplay();
414457 try {
458 if ( drawable instanceof DrawableGLES )
459 peer_info = new LinuxDisplayPeerInfo();
460
415461 ByteBuffer handle = peer_info.lockAndGetHandle();
416462 try {
417463 current_window_mode = getWindowMode(Display.isFullscreen());
464
418465 // Try to enable Lecagy FullScreen Support in Compiz, else
419466 // we may have trouble with stuff overlapping our fullscreen window.
420467 if ( current_window_mode != WINDOWED )
421468 Compiz.setLegacyFullscreenSupport(true);
469
422470 // Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
423471 // managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
424472 // unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
425473 // See native/linux/org_lwjgl_opengl_Display.c, createWindow function.
426474 boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs"));
475
427476 this.parent = parent;
428477 parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
429 current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window);
478 resizable = Display.isResizable();
479 resized = false;
480 window_x = x;
481 window_y = y;
482 window_width = mode.getWidth();
483 window_height = mode.getHeight();
484
485 // overwrite arguments x and y - superclass always uses 0,0 for fullscreen windows
486 // use the coordinates of XRandRs primary screen instead
487 // this is required to let the fullscreen window appear on the primary screen
488 if (mode.isFullscreenCapable() && current_displaymode_extension == XRANDR) {
489 Screen primaryScreen = XRandR.DisplayModetoScreen(Display.getDisplayMode());
490 x = primaryScreen.xPos;
491 y = primaryScreen.yPos;
492 }
493
494 current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
495
496 // Set the WM_CLASS hint which is needed by some WM's e.g. Gnome Shell
497 wm_class = Display.getPrivilegedString("LWJGL_WM_CLASS");
498 if (wm_class == null) wm_class = Display.getTitle();
499 setClassHint(Display.getTitle(), wm_class);
500
430501 mapRaised(getDisplay(), current_window);
431502 xembedded = parent != null && isAncestorXEmbedded(parent_window);
432503 blank_cursor = createBlankCursor();
439510 grab = false;
440511 minimized = false;
441512 dirty = true;
513
514 if ( drawable instanceof DrawableGLES )
515 ((DrawableGLES)drawable).initialize(current_window, getDisplay(), EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat());
516
517 if (parent != null) {
518 parent.addFocusListener(focus_listener);
519 parent_focused = parent.isFocusOwner();
520 parent_focus_changed = true;
521 }
442522 } finally {
443523 peer_info.unlock();
444524 }
450530 unlockAWT();
451531 }
452532 }
453 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;
533 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, boolean resizable) throws LWJGLException;
454534 private static native long getRootWindow(long display, int screen);
455535 private static native boolean hasProperty(long display, long window, long property);
456536 private static native long getParentWindow(long display, long window) throws LWJGLException;
537 private static native int getChildCount(long display, long window) throws LWJGLException;
457538 private static native void mapRaised(long display, long window);
458539 private static native void reparentWindow(long display, long window, long parent, int x, int y);
540 private static native long nGetInputFocus(long display) throws LWJGLException;
541 private static native void nSetInputFocus(long display, long window, long time);
542 private static native void nSetWindowSize(long display, long window, int width, int height, boolean resizable);
543 private static native int nGetX(long display, long window);
544 private static native int nGetY(long display, long window);
545 private static native int nGetWidth(long display, long window);
546 private static native int nGetHeight(long display, long window);
459547
460548 private static boolean isAncestorXEmbedded(long window) throws LWJGLException {
461549 long xembed_atom = internAtom("_XEMBED_INFO", true);
472560
473561 private static long getHandle(Canvas parent) throws LWJGLException {
474562 AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
475 LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null);
563 LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null, null);
476564 ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
477565 try {
478566 return parent_peer_info.getDrawable();
489577 public void destroyWindow() {
490578 lockAWT();
491579 try {
580 if (parent != null) {
581 parent.removeFocusListener(focus_listener);
582 }
492583 try {
493584 setNativeCursor(null);
494585 } catch (LWJGLException e) {
519610 }
520611
521612 private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
522 incDisplay();
523 try {
524 nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
525 } finally {
526 decDisplay();
527 }
613 if (current_displaymode_extension == XRANDR) {
614 // let Xrandr set the display mode
615 XRandR.setConfiguration(false, XRandR.DisplayModetoScreen(mode));
616 } else {
617 incDisplay();
618 try {
619 nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
620 } finally {
621 decDisplay();
622 }
623 }
528624 }
529625 private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
530626
541637 public void resetDisplayMode() {
542638 lockAWT();
543639 try {
544 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
640 if( current_displaymode_extension == XRANDR )
545641 {
546642 AccessController.doPrivileged(new PrivilegedAction<Object>() {
547643 public Object run() {
548 XRandR.setConfiguration( savedXrandrConfig );
644 XRandR.restoreConfiguration();
549645 return null;
550646 }
551647 });
643739 throw new LWJGLException("No modes available");
644740 switch (current_displaymode_extension) {
645741 case XRANDR:
646 savedXrandrConfig = AccessController.doPrivileged(new PrivilegedAction<Screen[]>() {
647 public Screen[] run() {
648 return XRandR.getConfiguration();
742 saved_mode = AccessController.doPrivileged(new PrivilegedAction<DisplayMode>() {
743 public DisplayMode run() {
744 XRandR.saveConfiguration();
745 return XRandR.ScreentoDisplayMode(XRandR.getConfiguration());
649746 }
650747 });
651 saved_mode = getCurrentXRandrMode();
652748 break;
653749 case XF86VIDMODE:
654750 saved_mode = modes[0];
685781 public void setTitle(String title) {
686782 lockAWT();
687783 try {
688 nSetTitle(getDisplay(), getWindow(), title);
689 } finally {
690 unlockAWT();
691 }
692 }
693 private static native void nSetTitle(long display, long window, String title);
784 final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
785 nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
786 } finally {
787 unlockAWT();
788 }
789 }
790 private static native void nSetTitle(long display, long window, long title, int len);
791
792 /** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
793 private void setClassHint(String wm_name, String wm_class) {
794 lockAWT();
795 try {
796 final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
797 final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);
798
799 nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
800 } finally {
801 unlockAWT();
802 }
803 }
804 private static native void nSetClassHint(long display, long window, long wm_name, long wm_class);
694805
695806 public boolean isCloseRequested() {
696807 boolean result = close_requested;
712823 return result;
713824 }
714825
715 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
826 public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
716827 peer_info = new LinuxDisplayPeerInfo(pixel_format);
717828 return peer_info;
718829 }
719
720 static native void setInputFocus(long display, long window, long time);
721830
722831 private void relayEventToParent(LinuxEvent event_buffer, int event_mask) {
723832 tmp_event_buffer.copyFrom(event_buffer);
736845 relayEventToParent(event_buffer, KeyPressMask);
737846 break;
738847 case LinuxEvent.ButtonPress:
739 relayEventToParent(event_buffer, KeyPressMask);
848 if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
740849 break;
741850 case LinuxEvent.ButtonRelease:
742 relayEventToParent(event_buffer, KeyPressMask);
851 if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
743852 break;
744853 default:
745854 break;
777886 case LinuxEvent.Expose:
778887 dirty = true;
779888 break;
889 case LinuxEvent.ConfigureNotify:
890 int x = nGetX(getDisplay(), getWindow());
891 int y = nGetY(getDisplay(), getWindow());
892
893 int width = nGetWidth(getDisplay(), getWindow());
894 int height = nGetHeight(getDisplay(), getWindow());
895
896 window_x = x;
897 window_y = y;
898
899 if (window_width != width || window_height != height) {
900 resized = true;
901 window_width = width;
902 window_height = height;
903 }
904
905 break;
780906 case LinuxEvent.EnterNotify:
781907 mouseInside = true;
782908 break;
812938 public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
813939 lockAWT();
814940 try {
815 incDisplay();
816 try {
817 DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
818 return modes;
819 } finally {
820 decDisplay();
821 }
941 incDisplay();
942 if (current_displaymode_extension == XRANDR) {
943 // nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel
944 DisplayMode[] nDisplayModes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
945 int bpp = 24;
946 if (nDisplayModes.length > 0) {
947 bpp = nDisplayModes[0].getBitsPerPixel();
948 }
949 // get the resolutions and frequencys from XRandR
950 Screen[] resolutions = XRandR.getResolutions(XRandR.getScreenNames()[0]);
951 DisplayMode[] modes = new DisplayMode[resolutions.length];
952 for (int i = 0; i < modes.length; i++) {
953 modes[i] = new DisplayMode(resolutions[i].width, resolutions[i].height, bpp, resolutions[i].freq);
954 }
955 return modes;
956 } else {
957 try {
958 DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
959 return modes;
960 } finally {
961 decDisplay();
962 }
963 }
822964 } finally {
823965 unlockAWT();
824966 }
8781020 private void checkInput() {
8791021 if (parent == null) return;
8801022
881 if (parent_focus != parent.hasFocus()) {
882 parent_focus = parent.hasFocus();
883
884 if (parent_focus) {
885 setInputFocusUnsafe(current_window);
886 }
887 else if (xembedded) {
888 setInputFocusUnsafe(1);
889 }
890 }
891 //else if (parent_focus && !focused && !xembedded) {
892 // setInputFocusUnsafe(current_window);
893 //}
894 }
895
896 private void setFocused(boolean got_focus, int focus_detail) {
897 if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot)
898 return;
899 focused = got_focus;
900
901 if (focused) {
902 acquireInput();
903 if (parent != null && !xembedded) parent.setFocusable(false);
1023 if (xembedded) {
1024 long current_focus_window = 0;
1025
1026 if (last_window_focus != current_focus_window || parent_focused != focused) {
1027 if (isParentWindowActive(current_focus_window)) {
1028 if (parent_focused) {
1029 nSetInputFocus(getDisplay(), current_window, CurrentTime);
1030 last_window_focus = current_window;
1031 focused = true;
1032 }
1033 else {
1034 // return focus to the parent proxy focus window
1035 nSetInputFocus(getDisplay(), parent_proxy_focus_window, CurrentTime);
1036 last_window_focus = parent_proxy_focus_window;
1037 focused = false;
1038 }
1039 }
1040 else {
1041 last_window_focus = current_focus_window;
1042 focused = false;
1043 }
1044 }
9041045 }
9051046 else {
906 releaseInput();
907 if (parent != null && !xembedded) parent.setFocusable(true);
908 }
909 }
910 static native long nGetInputFocus(long display);
911
912 private static void setInputFocusUnsafe(long window) {
913 try {
914 setInputFocus(getDisplay(), window, CurrentTime);
915 sync(getDisplay(), false);
1047 if (parent_focus_changed && parent_focused) {
1048 setInputFocusUnsafe(getWindow());
1049 parent_focus_changed = false;
1050 }
1051 }
1052 }
1053
1054 private void setInputFocusUnsafe(long window) {
1055 try {
1056 nSetInputFocus(getDisplay(), window, CurrentTime);
1057 nSync(getDisplay(), false);
9161058 } catch (LWJGLException e) {
9171059 // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore
9181060 LWJGLUtil.log("Got exception while trying to focus: " + e);
9191061 }
9201062 }
921 private static native void sync(long display, boolean throw_away_events) throws LWJGLException;
1063
1064 private static native void nSync(long display, boolean throw_away_events) throws LWJGLException;
1065
1066 /**
1067 * This method will check if the parent window is active when running
1068 * in xembed mode. Every xembed embedder window has a focus proxy
1069 * window that recieves all the input. This method will test whether
1070 * the provided window handle is the focus proxy, if so it will get its
1071 * parent window and then test whether this is an ancestor to our
1072 * current_window. If so then parent window is active.
1073 *
1074 * @param window - the window handle to test
1075 */
1076 private boolean isParentWindowActive(long window) {
1077 try {
1078 // parent window already active as window is current_window
1079 if (window == current_window) return true;
1080
1081 // xembed focus proxy will have no children
1082 if (getChildCount(getDisplay(), window) != 0) return false;
1083
1084 // get parent, will be xembed embedder window and ancestor of current_window
1085 long parent_window = getParentWindow(getDisplay(), window);
1086
1087 // parent must not be None
1088 if (parent_window == None) return false;
1089
1090 // scroll current_window's ancestors to find parent_window
1091 long w = current_window;
1092
1093 while (w != None) {
1094 w = getParentWindow(getDisplay(), w);
1095 if (w == parent_window) {
1096 parent_proxy_focus_window = window; // save focus proxy window
1097 return true;
1098 }
1099 }
1100 } catch (LWJGLException e) {
1101 LWJGLUtil.log("Failed to detect if parent window is active: " + e.getMessage());
1102 return true; // on failure assume still active
1103 }
1104
1105 return false; // failed to find an active parent window
1106 }
1107
1108 private void setFocused(boolean got_focus, int focus_detail) {
1109 if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || xembedded)
1110 return;
1111 focused = got_focus;
1112
1113 if (focused) {
1114 acquireInput();
1115 }
1116 else {
1117 releaseInput();
1118 }
1119 }
9221120
9231121 private void releaseInput() {
9241122 if (isLegacyFullscreen() || input_released)
9251123 return;
1124 if ( keyboard != null )
1125 keyboard.releaseAll();
9261126 input_released = true;
9271127 updateInputGrab();
9281128 if (current_window_mode == FULLSCREEN_NETWM) {
9291129 nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen());
9301130 try {
931 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
1131 if( current_displaymode_extension == XRANDR )
9321132 {
9331133 AccessController.doPrivileged(new PrivilegedAction<Object>() {
9341134 public Object run() {
935 XRandR.setConfiguration( savedXrandrConfig );
1135 XRandR.restoreConfiguration();
9361136 return null;
9371137 }
9381138 });
11421342 return false;
11431343 }
11441344
1145 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
1345 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs,
11461346 IntBuffer pixelFormatCaps,
11471347 IntBuffer pBufferAttribs) throws LWJGLException {
11481348 return new LinuxPbufferPeerInfo(width, height, pixel_format);
11591359 public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
11601360 throw new UnsupportedOperationException();
11611361 }
1162
1163 private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
1164 ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity());
1165 int x;
1166 int y;
1167 byte r,g,b;
1168
1169 int depth = 4;
1170
1171 for (y = 0; y < height; y++) {
1172 for (x = 0; x < width; x++) {
1173 r = icon.get((x*4)+(y*width*4));
1174 g = icon.get((x*4)+(y*width*4)+1);
1175 b = icon.get((x*4)+(y*width*4)+2);
1176
1177 icon_rgb.put((x*depth)+(y*width*depth), b); // blue
1178 icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
1179 icon_rgb.put((x*depth)+(y*width*depth)+2, r);
1180 }
1181 }
1182 return icon_rgb;
1183 }
1184
1185 private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) {
1186 ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8);
1187 int x;
1188 int y;
1189 byte a;
1190
1191 int depth = 4;
1192
1193 for (y = 0; y < height; y++) {
1194 for (x = 0; x < width; x++) {
1195 a = icon.get((x*4)+(y*width*4)+3);
1196
1197 int mask_index = x + y*width;
1198 int mask_byte_index = mask_index/8;
1199 int mask_bit_index = mask_index%8;
1200 byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0;
1201 byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff);
1202 icon_mask.put(mask_byte_index, new_byte);
1203 }
1204 }
1205 return icon_mask;
1362
1363 /**
1364 * This method will convert icon bytebuffers into a single bytebuffer
1365 * as the icon format required by _NET_WM_ICON should be in a cardinal
1366 * 32 bit ARGB format i.e. all icons in a single buffer the data starting
1367 * with 32 bit width & height followed by the color data as 32bit ARGB.
1368 *
1369 * @param icons Array of icons in RGBA format
1370 */
1371 private static ByteBuffer convertIcons(ByteBuffer[] icons) {
1372
1373 int bufferSize = 0;
1374
1375 // calculate size of bytebuffer
1376 for ( ByteBuffer icon : icons ) {
1377 int size = icon.limit() / 4;
1378 int dimension = (int)Math.sqrt(size);
1379 if ( dimension > 0 ) {
1380 bufferSize += 2 * 4; // add 32 bit width & height, 4 bytes each
1381 bufferSize += dimension * dimension * 4;
1382 }
1383 }
1384
1385 if (bufferSize == 0) return null;
1386
1387 ByteBuffer icon_argb = BufferUtils.createByteBuffer(bufferSize);//icon.capacity()+(2*4));
1388 icon_argb.order(ByteOrder.BIG_ENDIAN);
1389
1390 for ( ByteBuffer icon : icons ) {
1391 int size = icon.limit() / 4;
1392 int dimension = (int)Math.sqrt(size);
1393
1394 icon_argb.putInt(dimension); // width
1395 icon_argb.putInt(dimension); // height
1396
1397 for (int y = 0; y < dimension; y++) {
1398 for (int x = 0; x < dimension; x++) {
1399
1400 byte r = icon.get((x*4)+(y*dimension*4));
1401 byte g = icon.get((x*4)+(y*dimension*4)+1);
1402 byte b = icon.get((x*4)+(y*dimension*4)+2);
1403 byte a = icon.get((x*4)+(y*dimension*4)+3);
1404
1405 icon_argb.put(a);
1406 icon_argb.put(r);
1407 icon_argb.put(g);
1408 icon_argb.put(b);
1409 }
1410 }
1411 }
1412
1413 return icon_argb;
12061414 }
12071415
12081416 /**
12221430 try {
12231431 incDisplay();
12241432 try {
1225 for ( ByteBuffer icon : icons ) {
1226 int size = icon.limit() / 4;
1227 int dimension = (int)Math.sqrt(size);
1228 if ( dimension > 0 ) {
1229 ByteBuffer icon_rgb = convertIcon(icon, dimension, dimension);
1230 ByteBuffer icon_mask = convertIconMask(icon, dimension, dimension);
1231 nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
1232 return 1;
1233 }
1234 }
1235 return 0;
1433 // get icons as cardinal ARGB format
1434 ByteBuffer icons_data = convertIcons(icons);
1435 if (icons_data == null) return 0;
1436 nSetWindowIcon(getDisplay(), getWindow(), icons_data, icons_data.capacity());//, icon_mask, icon_mask.capacity(), dimension, dimension);
1437 return icons.length;
12361438 } finally {
12371439 decDisplay();
12381440 }
12441446 }
12451447 }
12461448
1247 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);
1248
1449 private static native void nSetWindowIcon(long display, long window, ByteBuffer icons_data, int icons_size);
1450
1451 public int getX() {
1452 return window_x;
1453 }
1454
1455 public int getY() {
1456 return window_y;
1457 }
1458
12491459 public int getWidth() {
1250 return Display.getDisplayMode().getWidth();
1460 return window_width;
12511461 }
12521462
12531463 public int getHeight() {
1254 return Display.getDisplayMode().getHeight();
1464 return window_height;
12551465 }
12561466
12571467 public boolean isInsideWindow() {
12581468 return mouseInside;
12591469 }
12601470
1471 public void setResizable(boolean resizable) {
1472 if (this.resizable == resizable) {
1473 return;
1474 }
1475
1476 this.resizable = resizable;
1477 nSetWindowSize(getDisplay(), getWindow(), window_width, window_height, resizable);
1478 }
1479
1480 public boolean wasResized() {
1481 if (resized) {
1482 resized = false;
1483 return true;
1484 }
1485
1486 return false;
1487 }
1488
1489 public float getPixelScaleFactor() {
1490 return 1f;
1491 }
1492
12611493 /**
12621494 * Helper class for managing Compiz's workarounds. We need this to enable Legacy
12631495 * Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows
14451677 }
14461678 }
14471679
1448 }
1680 }
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
44
45 final boolean egl;
46
47 LinuxDisplayPeerInfo() throws LWJGLException {
48 egl = true;
49 org.lwjgl.opengles.GLContext.loadOpenGLLibrary();
50 }
51
4452 LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
53 egl = false;
4554 LinuxDisplay.lockAWT();
4655 try {
4756 GLContext.loadOpenGLLibrary();
7988
8089 public void destroy() {
8190 super.destroy();
82 LinuxDisplay.lockAWT();
83 LinuxDisplay.decDisplay();
84 GLContext.unloadOpenGLLibrary();
85 LinuxDisplay.unlockAWT();
91
92 if ( egl )
93 org.lwjgl.opengles.GLContext.unloadOpenGLLibrary();
94 else {
95 LinuxDisplay.lockAWT();
96 LinuxDisplay.decDisplay();
97 GLContext.unloadOpenGLLibrary();
98 LinuxDisplay.unlockAWT();
99 }
86100 }
87101 }
5252 public static final int UnmapNotify = 18;
5353 public static final int MapNotify = 19;
5454 public static final int Expose = 12;
55 public static final int ConfigureNotify = 22;
5556 public static final int ClientMessage = 33;
5657
5758 private final ByteBuffer event_buffer;
295295 return keycode;
296296 }
297297
298 private byte getKeyState(int event_type) {
298 private static byte getKeyState(int event_type) {
299299 switch (event_type) {
300300 case LinuxEvent.KeyPress:
301301 return 1;
306306 }
307307 }
308308
309 /** This is called when the window loses focus: we release all currently pressed keys. */
310 void releaseAll() {
311 for ( int i = 0; i < key_down_buffer.length; i++ ) {
312 if ( key_down_buffer[i] != 0 ) {
313 key_down_buffer[i] = 0;
314 putKeyboardEvent(i, (byte)0, 0, 0L, false);
315 }
316 }
317 }
318
309319 private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
310320 int keycode = getKeycode(event_ptr, event_state);
311321 byte key_state = getKeyState(event_type);
312322 boolean repeat = key_state == key_down_buffer[keycode];
323 if ( repeat && event_type == LinuxEvent.KeyRelease ) // This can happen for modifier keys after losing and regaining focus.
324 return;
313325 key_down_buffer[keycode] = key_state;
314326 long nanos = millis*1000000;
315327 if (event_type == LinuxEvent.KeyPress) {
4242 import org.lwjgl.input.Mouse;
4343
4444 final class LinuxMouse {
45 private static final int NUM_BUTTONS = 3;
4645 private static final int POINTER_WARP_BORDER = 10;
4746 // scale the mouse wheel according to DirectInput
4847 private static final int WHEEL_SCALE = 120;
4948
49 private int button_count;
50
5051 /* X11 constants */
5152 private static final int Button1 = 1;
5253 private static final int Button2 = 2;
5354 private static final int Button3 = 3;
5455 private static final int Button4 = 4;
5556 private static final int Button5 = 5;
57
58 private static final int Button6 = 6; // wheel tilt left *rare*
59 private static final int Button7 = 7; // wheel tilt right *rare*
60 private static final int Button8 = 8; // back button
61 private static final int Button9 = 9; // forward button
5662
5763 private static final int ButtonPress = 4;
5864 private static final int ButtonRelease = 5;
6975 private int accum_dx;
7076 private int accum_dy;
7177 private int accum_dz;
72 private byte[] buttons = new byte[NUM_BUTTONS];
78 private byte[] buttons;
7379 private EventQueue event_queue;
7480 private long last_event_nanos;
7581
7884 this.window = window;
7985 this.input_window = input_window;
8086 this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
87 button_count = nGetButtonCount(display);
88 buttons = new byte[button_count];
8189 reset(false, false);
8290 }
8391
188196 }
189197 private static native int nGetWindowHeight(long display, long window);
190198 private static native int nGetWindowWidth(long display, long window);
199
200 private static native int nGetButtonCount(long display);
191201
192202 private static native long nQueryPointer(long display, long window, IntBuffer result);
193203
212222 case Button3:
213223 button_num = (byte)1;
214224 break;
225 case Button6:
226 button_num = (byte)5;
227 break;
228 case Button7:
229 button_num = (byte)6;
230 break;
231 case Button8:
232 button_num = (byte)3; // back button
233 break;
234 case Button9:
235 button_num = (byte)4; // forward button
236 break;
215237 default:
238 if (button > Button9 && button <= button_count) {
239 button_num = (byte)(button-1);
240 break;
241 }
216242 return;
217243 }
218244 buttons[button_num] = state;
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class LinuxPbufferPeerInfo extends LinuxPeerInfo {
4444 LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
3535 /**
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3116 $
39 * $Id: LinuxPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
38 * @version $Revision$
39 * $Id$
4040 */
4141 abstract class LinuxPeerInfo extends PeerInfo {
4242 LinuxPeerInfo() {
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo {
4444 private final Canvas component;
4545
46 MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, support_pbuffer);
46 MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, ContextAttribs attribs, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, attribs, support_pbuffer);
4848 this.component = component;
4949 }
5050
3939 /**
4040 *
4141 * @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 $
42 * @version $Revision$
43 * $Id$
4444 */
4545 final class MacOSXCanvasImplementation implements AWTCanvasImplementation {
46 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
46 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
4747 try {
48 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true);
48 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, attribs, true);
4949 } catch (LWJGLException e) {
50 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, false);
50 return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, attribs, false);
5151 }
5252 }
5353
4646 private int width;
4747 private int height;
4848 private boolean context_update;
49 private boolean resized;
4950
5051 MacOSXCanvasListener(Canvas canvas) {
5152 this.canvas = canvas;
101102
102103 public void componentResized(ComponentEvent e) {
103104 setUpdate();
105 resized = true;
104106 }
105107
106108 public void componentMoved(ComponentEvent e) {
110112 public void hierarchyChanged(HierarchyEvent e) {
111113 setUpdate();
112114 }
115
116 public boolean wasResized() {
117 if (resized) {
118 resized = false;
119 return true;
120 }
121
122 return false;
123 }
113124 }
3131 package org.lwjgl.opengl;
3232
3333 import java.awt.Canvas;
34 import java.awt.event.ComponentEvent;
35 import java.awt.event.ComponentListener;
36 import java.awt.Insets;
37 import java.awt.Container;
38 import java.awt.Component;
39 import java.awt.Point;
40 import java.awt.Window;
3441 import java.nio.ByteBuffer;
3542
43 import javax.swing.SwingUtilities;
44
3645 import org.lwjgl.LWJGLException;
46 import org.lwjgl.LWJGLUtil;
3747
3848 /**
3949 *
4050 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: MacOSXCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
51 * @author kappaOne <one.kappa@gmail.com>
52 * @version $Revision$
53 * $Id$
4354 */
4455 abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
4556 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);
57 public ByteBuffer window_handle;
58
59 protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean support_pbuffer) throws LWJGLException {
60 super(pixel_format, attribs, true, true, support_pbuffer, true);
4961 }
5062
5163 protected void initHandle(Canvas component) throws LWJGLException {
52 nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
64 boolean forceCALayer = true;
65 boolean autoResizable = true; // set the CALayer to autoResize
66
67 String javaVersion = System.getProperty("java.version");
68
69 if (javaVersion.startsWith("1.5") || javaVersion.startsWith("1.6")) {
70 // On Java 7 and newer CALayer mode is the only way to use OpenGL with AWT
71 // therefore force it on all JVM's except for the older Java 5 and Java 6
72 // where the older cocoaViewRef NSView method maybe be available.
73 forceCALayer = false;
74 }
75 else if (javaVersion.startsWith("1.7")) {
76 autoResizable = false;
77 }
78
79 Insets insets = getInsets(component);
80
81 int top = insets != null ? insets.top : 0;
82 int left = insets != null ? insets.left : 0;
83
84 window_handle = nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), window_handle, forceCALayer, autoResizable, component.getX()-left, component.getY()-top);
85
86 if (javaVersion.startsWith("1.7")) {
87 // fix for CALayer position not covering Canvas due to a Java 7 bug
88 // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187
89 addComponentListener(component);
90
91 reSetLayerBounds(component, getHandle());
92 }
5393 }
54 private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
94
95 private void addComponentListener(final Canvas component) {
96
97 ComponentListener[] components = component.getComponentListeners();
98
99 // avoid adding duplicate listners by checking if one has already been added
100 for (int i = 0; i < components.length; i++) {
101 ComponentListener c = components[i];
102 if (c.toString() == "CanvasPeerInfoListener") {
103 return; // already contains the listner below return without adding
104 }
105 }
106
107 ComponentListener comp = new ComponentListener() {
108 public void componentHidden(ComponentEvent e) {
109
110 }
55111
112 public void componentMoved(ComponentEvent e) {
113
114 //nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
115 reSetLayerBounds(component, getHandle());
116 }
117
118 public void componentResized(ComponentEvent e) {
119
120 //nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
121 reSetLayerBounds(component, getHandle());
122 }
123
124 public void componentShown(ComponentEvent e) {
125
126 }
127
128 public String toString() {
129 return "CanvasPeerInfoListener";
130 }
131 };
132
133 component.addComponentListener(comp);
134 }
135
136 private static native ByteBuffer nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, ByteBuffer window_handle, boolean forceCALayer, boolean autoResizable, int x, int y) throws LWJGLException;
137
138 private static native void nSetLayerPosition(ByteBuffer peer_info_handle, int x, int y);
139
140 private static native void nSetLayerBounds(ByteBuffer peer_info_handle, int x, int y, int width, int height);
141
142 /**
143 * fix for CALayer position not covering Canvas due to a Java 7 bug
144 * {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187}
145 * @param component
146 * @param peer_info_handle
147 */
148 private static void reSetLayerBounds(Canvas component, ByteBuffer peer_info_handle) {
149 // report the root parent (peer).
150 Component peer = SwingUtilities.getRoot(component);
151
152 Point rtLoc = SwingUtilities.convertPoint(component.getParent(), component.getLocation(), peer);
153 int x = (int) rtLoc.getX(), y = (int) rtLoc.getY();
154
155 Insets insets = getInsets(component);
156 x -= insets != null ? insets.left : 0;
157 y -= insets != null ? insets.top : 0;
158
159 // http://hg.openjdk.java.net/jdk8/awt/jdk/rev/65d874d16d59
160 y = (int) peer.getHeight() - y - (int) component.getHeight();
161
162 nSetLayerBounds(peer_info_handle, x, y, component.getWidth(), component.getHeight());
163 }
164
56165 protected void doUnlock() throws LWJGLException {
57166 awt_surface.unlock();
58167 }
168
169 /**
170 * @return rootpane insets (peer insets) values.
171 */
172 private static Insets getInsets(Canvas component) {
173 Container c = SwingUtilities.getRootPane(component);
174
175 if(c != null) {
176 return c.getInsets();
177 } else {
178 return new Insets(0, 0, 0, 0);
179 }
180 }
59181 }
+0
-94
src/java/org/lwjgl/opengl/MacOSXContextAttribs.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 }
3737
3838 /**
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class MacOSXContextImplementation implements ContextImplementation {
4444
4545 public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
4646 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
4747 try {
48 return nCreate(peer_handle, attribs, shared_context_handle);
48 return nCreate(peer_handle, shared_context_handle);
4949 } finally {
5050 peer_info.unlock();
5151 }
5252 }
5353
54 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException;
54 private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
5555
5656 public void swapBuffers() throws LWJGLException {
57 Context current_context = Context.getCurrentContext();
57 ContextGL current_context = ContextGL.getCurrentContext();
5858 if ( current_context == null )
5959 throw new IllegalStateException("No context is current");
6060 synchronized ( current_context ) {
6262 }
6363 }
6464
65 native long getCGLShareGroup(ByteBuffer context_handle);
66
6567 private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException;
6668
6769 public void update(ByteBuffer context_handle) {
8284
8385 private static native void clearDrawable(ByteBuffer handle) throws LWJGLException;
8486
85 static void resetView(PeerInfo peer_info, Context context) throws LWJGLException {
87 static void resetView(PeerInfo peer_info, ContextGL context) throws LWJGLException {
8688 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
8789 try {
8890 synchronized ( context ) {
116118 private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
117119
118120 public void setSwapInterval(int value) {
119 Context current_context = Context.getCurrentContext();
121 ContextGL current_context = ContextGL.getCurrentContext();
120122 synchronized ( current_context ) {
121123 nSetSwapInterval(current_context.getHandle(), value);
122124 }
3434 * This is the Display implementation interface. Display delegates
3535 * to implementors of this interface. There is one DisplayImplementation
3636 * for each supported platform.
37 * @author elias_naur
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @author mojang
40 * @author kappaOne <one.kappa@gmail.com>
3841 */
3942
4043 import java.awt.Canvas;
41 import java.awt.Cursor;
4244 import java.awt.Robot;
4345 import java.nio.ByteBuffer;
4446 import java.nio.FloatBuffer;
4951 import java.util.ArrayList;
5052 import java.util.List;
5153
54 import org.lwjgl.input.Cursor;
55 import org.lwjgl.opengl.Display;
56 import org.lwjgl.opengl.DisplayMode;
5257 import org.lwjgl.BufferUtils;
58 import org.lwjgl.MemoryUtil;
5359 import org.lwjgl.LWJGLException;
5460 import org.lwjgl.LWJGLUtil;
55
56 import com.apple.eawt.Application;
57 import com.apple.eawt.ApplicationAdapter;
58 import com.apple.eawt.ApplicationEvent;
5961
6062 import static org.lwjgl.opengl.GL11.*;
6163
6365 private static final int PBUFFER_HANDLE_SIZE = 24;
6466 private static final int GAMMA_LENGTH = 256;
6567
66 private MacOSXCanvasListener canvas_listener;
67 private MacOSXFrame frame;
68 //private MacOSXCanvasListener canvas_listener;
6869 private Canvas canvas;
6970 private Robot robot;
7071 private MacOSXMouseEventQueue mouse_queue;
7172 private KeyboardEventQueue keyboard_queue;
72 private java.awt.DisplayMode requested_mode;
73
74 /* States */
73 private DisplayMode requested_mode;
74
75 /* Members for native window use */
76 private MacOSXNativeMouse mouse;
77 private MacOSXNativeKeyboard keyboard;
78 private ByteBuffer window;
79 private ByteBuffer context;
80
81 private boolean skipViewportValue = false;
82 private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
83
84 private boolean mouseInsideWindow;
85
7586 private boolean close_requested;
87
88 private boolean native_mode = true;
89
90 private boolean updateNativeCursor = false;
91
92 private long currentNativeCursor = 0;
93
94 private boolean enableHighDPI = false;
95
96 private float scaleFactor = 1.0f;
7697
7798 MacOSXDisplay() {
99
100 }
101
102 private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, boolean enableHighDPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
103
104 private native Object nGetCurrentDisplayMode();
105
106 private native void nGetDisplayModes(Object modesList);
107
108 private native boolean nIsMiniaturized(ByteBuffer window_handle);
109
110 private native boolean nIsFocused(ByteBuffer window_handle);
111
112 private native void nSetResizable(ByteBuffer window_handle, boolean resizable);
113
114 private native void nResizeWindow(ByteBuffer window_handle, int x, int y, int width, int height);
115
116 private native boolean nWasResized(ByteBuffer window_handle);
117
118 private native int nGetX(ByteBuffer window_handle);
119
120 private native int nGetY(ByteBuffer window_handle);
121
122 private native int nGetWidth(ByteBuffer window_handle);
123
124 private native int nGetHeight(ByteBuffer window_handle);
125
126 private native boolean nIsNativeMode(ByteBuffer peer_info_handle);
127
128 private static boolean isUndecorated() {
129 return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
130 }
131
132 public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
133 boolean fullscreen = Display.isFullscreen();
134 boolean resizable = Display.isResizable();
135 boolean parented = (parent != null) && !fullscreen;
136
137 // OS X fullscreen mode API is only available on OS X 10.7+
138 boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
139 !Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
140
141 // OS X high DPI mode is only available on OS X 10.7+
142 enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
143 (Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI") || fullscreen);
144
145 if (parented) this.canvas = parent;
146 else this.canvas = null;
147
148 close_requested = false;
149
150 DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
151 PeerInfo peer_info = gl_drawable.peer_info;
152 ByteBuffer peer_handle = peer_info.lockAndGetHandle();
153 ByteBuffer window_handle = parented ? ((MacOSXCanvasPeerInfo)peer_info).window_handle : window;
154
78155 try {
79 AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
80 public Object run() throws Exception {
81 Application.getApplication().addApplicationListener(new ApplicationAdapter() {
82 public void handleQuit(ApplicationEvent event) {
83 doHandleQuit();
84 }
85 });
86 return null;
87 }
88 });
89 } catch (Throwable e) {
90 /**
91 * In an applet environment, referencing com.apple.eawt.Application can fail with
92 * a native exception. So log any exceptions instead of re-throwing.
93 */
94 LWJGLUtil.log("Failed to register quit handler: " + e.getMessage());
95 }
96 }
97
98 public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
99 boolean fullscreen = Display.isFullscreen();
100 hideUI(fullscreen);
101 close_requested = false;
102 try {
103 if (parent == null) {
104 frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
105 canvas = frame.getCanvas();
106 } else {
107 frame = null;
108 canvas = parent;
109 }
110 canvas_listener = new MacOSXCanvasListener(canvas);
111 robot = AWTUtil.createRobot(canvas);
156
157 window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
158 fullscreen, isUndecorated(), resizable,
159 parented, enableFullscreenModeAPI, enableHighDPI, peer_handle, window_handle);
160
161 if (fullscreen) {
162 // when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
163 skipViewportValue = true;
164 // if starting in fullscreen then set initial viewport to displaymode size
165 current_viewport.put(2, mode.getWidth());
166 current_viewport.put(3, mode.getHeight());
167 }
168
169 native_mode = nIsNativeMode(peer_handle);
170
171 if (!native_mode) {
172 robot = AWTUtil.createRobot(canvas);
173 }
174
112175 } catch (LWJGLException e) {
113176 destroyWindow();
114177 throw e;
115 }
116 }
117
118 private void doHandleQuit() {
178 } finally {
179 peer_info.unlock();
180 }
181 }
182
183 public void doHandleQuit() {
119184 synchronized (this) {
120185 close_requested = true;
121186 }
122187 }
188
189 public void mouseInsideWindow(boolean inside) {
190 synchronized (this) {
191 mouseInsideWindow = inside;
192 }
193 updateNativeCursor = true;
194 }
195
196 public void setScaleFactor(float scale) {
197 synchronized (this) {
198 scaleFactor = scale;
199 }
200 }
201
202 public native void nDestroyCALayer(ByteBuffer peer_info_handle);
203
204 public native void nDestroyWindow(ByteBuffer window_handle);
123205
124206 public void destroyWindow() {
125 if (canvas_listener != null) {
126 canvas_listener.disableListeners();
127 canvas_listener = null;
128 }
129 if (frame != null) {
130 AccessController.doPrivileged(new PrivilegedAction<Object>() {
131 public Object run() {
132 if (MacOSXFrame.getDevice().getFullScreenWindow() == frame)
133 MacOSXFrame.getDevice().setFullScreenWindow(null);
134 return null;
135 }
136 });
137 if (frame.isDisplayable())
138 frame.dispose();
139 frame = null;
140 }
141 hideUI(false);
207
208 if (!native_mode) {
209 DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
210 PeerInfo peer_info = gl_drawable.peer_info;
211 if (peer_info != null) {
212 ByteBuffer peer_handle = peer_info.getHandle();
213 nDestroyCALayer(peer_handle);
214 }
215 robot = null;
216 }
217
218 nDestroyWindow(window);
142219 }
143220
144221 public int getGammaRampLength() {
154231 public String getVersion() {
155232 return null;
156233 }
157
158 private static boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
159 return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
160 && awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
234
235 private static boolean equals(DisplayMode mode1, DisplayMode mode2) {
236 return mode1.getWidth() == mode2.getWidth() && mode1.getHeight() == mode2.getHeight()
237 && mode1.getBitsPerPixel() == mode2.getBitsPerPixel() && mode1.getFrequency() == mode2.getFrequency();
161238 }
162239
163240 public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
164 java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
165 for ( java.awt.DisplayMode awt_mode : awt_modes ) {
166 if (equals(awt_mode, mode)) {
167 requested_mode = awt_mode;
241 DisplayMode[] modes = getAvailableDisplayModes();
242
243 for (DisplayMode available_mode : modes) {
244 if (equals(available_mode, mode)) {
245 requested_mode = available_mode;
168246 return;
169247 }
170248 }
249
171250 throw new LWJGLException(mode + " is not supported");
172251 }
173252
174253 public void resetDisplayMode() {
175 if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
176 MacOSXFrame.getDevice().setFullScreenWindow(null);
177 requested_mode = null;
254 requested_mode = null;
178255 restoreGamma();
179256 }
180257
181258 private native void restoreGamma();
182259
183 private static DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
184 int bit_depth;
185 int refresh_rate;
186 int awt_bit_depth = awt_mode.getBitDepth();
187 int awt_refresh_rate = awt_mode.getRefreshRate();
188 if (awt_bit_depth != java.awt.DisplayMode.BIT_DEPTH_MULTI)
189 bit_depth = awt_bit_depth;
190 else
191 bit_depth = 32; // Assume the best bit depth
192 if (awt_refresh_rate != java.awt.DisplayMode.REFRESH_RATE_UNKNOWN)
193 refresh_rate = awt_refresh_rate;
194 else
195 refresh_rate = 0;
196 return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
197 }
198
260 public Object createDisplayMode(int width, int height, int bitsPerPixel, int refreshRate) {
261 return new DisplayMode(width, height, bitsPerPixel, refreshRate);
262 }
263
199264 public DisplayMode init() throws LWJGLException {
200 return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
265 return (DisplayMode) nGetCurrentDisplayMode();
266 }
267
268 public void addDisplayMode(Object modesList, int width, int height, int bitsPerPixel, int refreshRate) {
269 List<DisplayMode> modes = (List<DisplayMode>) modesList;
270 DisplayMode displayMode = new DisplayMode(width, height, bitsPerPixel, refreshRate);
271 modes.add(displayMode);
201272 }
202273
203274 public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
204 java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
205275 List<DisplayMode> modes = new ArrayList<DisplayMode>();
206 for ( java.awt.DisplayMode awt_mode : awt_modes )
207 if ( awt_mode.getBitDepth() >= 16 )
208 modes.add(createLWJGLDisplayMode(awt_mode));
276 nGetDisplayModes(modes); // will populate the above list
277 modes.add(Display.getDesktopDisplayMode()); // add desktop resolution as scaled resolutions do not appear
209278 return modes.toArray(new DisplayMode[modes.size()]);
210279 }
211280
281 private native void nSetTitle(ByteBuffer window_handle, ByteBuffer title_buffer);
282
212283 public void setTitle(String title) {
213 if (frame != null)
214 frame.setTitle(title);
284 ByteBuffer buffer = MemoryUtil.encodeUTF8(title);
285 nSetTitle(window, buffer);
215286 }
216287
217288 public boolean isCloseRequested() {
218289 boolean result;
219290 synchronized (this) {
220 result = close_requested || (frame != null && frame.syncIsCloseRequested());
291 result = close_requested;
221292 close_requested = false;
222293 }
223294 return result;
224295 }
225296
226297 public boolean isVisible() {
227 return frame == null || frame.syncIsVisible();
298 return true;
228299 }
229300
230301 public boolean isActive() {
231 return canvas.isFocusOwner();
302 if (native_mode) {
303 return nIsFocused(window);
304 }
305 else {
306 return Display.getParent().hasFocus();
307 }
232308 }
233309
234310 public Canvas getCanvas() {
236312 }
237313
238314 public boolean isDirty() {
239 return frame != null && frame.getCanvas().syncIsDirty();
240 }
241
242 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
315 return false;
316 }
317
318 public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
243319 try {
244 return new MacOSXDisplayPeerInfo(pixel_format, true);
320 return new MacOSXDisplayPeerInfo(pixel_format, attribs, true);
245321 } catch (LWJGLException e) {
246 return new MacOSXDisplayPeerInfo(pixel_format, false);
247 }
248 }
249
250 private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
322 return new MacOSXDisplayPeerInfo(pixel_format, attribs, false);
323 }
324 }
325
251326 public void update() {
252 boolean should_update = canvas_listener.syncShouldUpdateContext();
253 /*
254 * Workaround for the "white screen in fullscreen mode" problem
255 *
256 * Sometimes, switching from windowed mode to fullscreen or simply creating the Display
257 * in fullscreen mode will result in the context not being bound to the window correctly.
258 * The program runs fine, but the canvas background (white) is shown instead of the context
259 * front buffer.
260 *
261 * I've discovered that re-binding the context with another setView() won't fix the problem, while a
262 * clearDrawable() followed by a setView() does work. A straightforward workaround would be
263 * to simply run the combination at every update(). This is not sufficient, since the clearDrawable()
264 * call makes the the background appear shortly, causing visual artifacts.
265 * What we really need is a way to detect that a setView() failed, and then do the magic combo. I've not
266 * been able to find such a detection so alternatively I'm triggering the combo if the display is fullscreen
267 * (I've not seen the white screen problem in windowed mode) and if the canvas has gotten a paint message or
268 * if its update flag was set.
269 *
270 * My testing seems to indicate that the workaround works, since I've not seen the problem after the fix.
271 *
272 * - elias
273 */
274 AbstractDrawable drawable = (AbstractDrawable)Display.getDrawable();
275 if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) {
327 boolean should_update = true;
328
329 DrawableGL drawable = (DrawableGL)Display.getDrawable();
330 if (should_update) {
331
332 // Save the current viewport size as cocoa will automatically
333 // set the viewport size to the window size on context update
334 if (skipViewportValue) skipViewportValue = false;
335 else glGetInteger(GL_VIEWPORT, current_viewport);
336
337 drawable.context.update();
338
339 // restore the original viewport size that was set before the update
340 glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
341 }
342
343 if (native_mode && updateNativeCursor) {
344 updateNativeCursor = false;
276345 try {
277 MacOSXContextImplementation.resetView(drawable.peer_info, drawable.context);
346 setNativeCursor(currentNativeCursor);
278347 } catch (LWJGLException e) {
279 LWJGLUtil.log("Failed to reset context: " + e);
280 }
281 }
282 if (should_update) {
283 drawable.context.update();
284 /* This is necessary to make sure the context won't "forget" about the view size */
285 glGetInteger(GL_VIEWPORT, current_viewport);
286 glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
287 }
288 if (frame != null && mouse_queue != null) {
289 if (frame.syncShouldReleaseCursor())
290 MacOSXMouseEventQueue.nGrabMouse(false);
291 if (frame.syncShouldWarpCursor())
292 mouse_queue.warpCursor();
293 }
294 }
295
296 /**
297 * This is an interface to the native Carbon call
298 * SetSystemUIMode. It is used to hide the dock in a way
299 * that will prevent AWT from shifting the fullscreen window
300 *
301 * The workaround is not necessary on 10.4, and since 10.4 shows
302 * instability problems calling SetSystemUIMode, we'll only call it
303 * when the OS version is 10.3 or lower.
304 */
305 private void hideUI(boolean hide) {
306 if (!LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
307 nHideUI(hide);
308 }
309
310 private native void nHideUI(boolean hide);
348 e.printStackTrace();
349 }
350 }
351 }
311352
312353 public void reshape(int x, int y, int width, int height) {
313 if (frame != null)
314 frame.resize(x, y, width, height);
354 //if (native_mode) {
355 // nResizeWindow(window, x, y, width, height);
356 //}
315357 }
316358
317359 /* Mouse */
324366 }
325367
326368 public void createMouse() throws LWJGLException {
327 this.mouse_queue = new MacOSXMouseEventQueue(canvas);
328 mouse_queue.register();
369 if (native_mode) {
370 mouse = new MacOSXNativeMouse(this, window);
371 mouse.register();
372 }
373 else {
374 this.mouse_queue = new MacOSXMouseEventQueue(canvas);
375 mouse_queue.register();
376 }
329377 }
330378
331379 public void destroyMouse() {
332 if (mouse_queue != null) {
333 MacOSXMouseEventQueue.nGrabMouse(false);
334 mouse_queue.unregister();
335 }
336 this.mouse_queue = null;
380 if (native_mode) {
381 // restore default native cursor
382 try {
383 MacOSXNativeMouse.setCursor(0);
384 } catch (LWJGLException e) {};
385
386 // release any mouse grab
387 grabMouse(false);
388
389 if (mouse != null) {
390 mouse.unregister();
391 }
392 mouse = null;
393 }
394 else {
395 if (mouse_queue != null) {
396 MacOSXMouseEventQueue.nGrabMouse(false);
397 mouse_queue.unregister();
398 }
399 this.mouse_queue = null;
400 }
337401 }
338402
339403 public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
340 mouse_queue.poll(coord_buffer, buttons_buffer);
404 if (native_mode) {
405 mouse.poll(coord_buffer, buttons_buffer);
406 }
407 else {
408 mouse_queue.poll(coord_buffer, buttons_buffer);
409 }
341410 }
342411
343412 public void readMouse(ByteBuffer buffer) {
344 mouse_queue.copyEvents(buffer);
413 if (native_mode) {
414 mouse.copyEvents(buffer);
415 }
416 else {
417 mouse_queue.copyEvents(buffer);
418 }
345419 }
346420
347421 public void grabMouse(boolean grab) {
348 mouse_queue.setGrabbed(grab);
422 if (native_mode) {
423 mouse.setGrabbed(grab);
424 }
425 else {
426 mouse_queue.setGrabbed(grab);
427 }
349428 }
350429
351430 public int getNativeCursorCapabilities() {
431 if (native_mode) {
432 return Cursor.CURSOR_ONE_BIT_TRANSPARENCY | Cursor.CURSOR_8_BIT_ALPHA | Cursor.CURSOR_ANIMATION;
433 }
434
352435 return AWTUtil.getNativeCursorCapabilities();
353436 }
354437
355438 public void setCursorPosition(int x, int y) {
356 AWTUtil.setCursorPosition(canvas, robot, x, y);
439 if (native_mode) {
440 if (mouse != null) {
441 mouse.setCursorPosition(x, y);
442 }
443 }
444 //else {
445 //MacOSXMouseEventQueue.nWarpCursor(x, y);
446 //}
357447 }
358448
359449 public void setNativeCursor(Object handle) throws LWJGLException {
360 Cursor awt_cursor = (Cursor)handle;
361 if (frame != null)
362 frame.setCursor(awt_cursor);
450 if (native_mode) {
451 currentNativeCursor = getCursorHandle(handle);
452 if (Display.isCreated()) {
453 if (mouseInsideWindow) MacOSXNativeMouse.setCursor(currentNativeCursor);
454 else MacOSXNativeMouse.setCursor(0); // restore default cursor if outside Display
455 }
456 }
363457 }
364458
365459 public int getMinCursorSize() {
366 return AWTUtil.getMinCursorSize();
460 return 1;
367461 }
368462
369463 public int getMaxCursorSize() {
370 return AWTUtil.getMaxCursorSize();
464 // as there is no max cursor size limit on OS X
465 // return the max cursor size as half the screen resolution
466 DisplayMode dm = Display.getDesktopDisplayMode();
467 return Math.min(dm.getWidth(), dm.getHeight()) / 2;
371468 }
372469
373470 /* Keyboard */
374471 public void createKeyboard() throws LWJGLException {
375 this.keyboard_queue = new KeyboardEventQueue(canvas);
376 keyboard_queue.register();
472 if (native_mode) {
473 this.keyboard = new MacOSXNativeKeyboard(window);
474 keyboard.register();
475 }
476 else {
477 this.keyboard_queue = new KeyboardEventQueue(canvas);
478 keyboard_queue.register();
479 }
377480 }
378481
379482 public void destroyKeyboard() {
380 if (keyboard_queue != null)
381 keyboard_queue.unregister();
382 this.keyboard_queue = null;
483 if (native_mode) {
484 if (keyboard != null) {
485 keyboard.unregister();
486 }
487 keyboard = null;
488 }
489 else {
490 if (keyboard_queue != null) {
491 keyboard_queue.unregister();
492 }
493 this.keyboard_queue = null;
494 }
383495 }
384496
385497 public void pollKeyboard(ByteBuffer keyDownBuffer) {
386 keyboard_queue.poll(keyDownBuffer);
498 if (native_mode) {
499 keyboard.poll(keyDownBuffer);
500 }
501 else {
502 keyboard_queue.poll(keyDownBuffer);
503 }
387504 }
388505
389506 public void readKeyboard(ByteBuffer buffer) {
390 keyboard_queue.copyEvents(buffer);
391 }
392
393 /* public int isStateKeySet(int key) {
394 int awt_key;
395 switch (key) {
396 case Keyboard.KEY_CAPITAL:
397 awt_key = KeyEvent.VK_CAPS_LOCK;
398 break;
399 case Keyboard.KEY_NUMLOCK:
400 awt_key = KeyEvent.VK_NUM_LOCK;
401 break;
402 case Keyboard.KEY_SYSRQ:
403 awt_key = KeyEvent.VK_SCROLL_LOCK;
404 break;
405 default:
406 return Keyboard.STATE_UNKNOWN;
407 }
408 try {
409 boolean state = Toolkit.getDefaultToolkit().getLockingKeyState(awt_key);
410 return state ? Keyboard.STATE_ON : Keyboard.STATE_OFF;
411 } catch (Exception e) {
412 LWJGLUtil.log("Failed to query key state: " + e);
413 return Keyboard.STATE_UNKNOWN;
414 }
415 }
416 */
507 if (native_mode) {
508 keyboard.copyEvents(buffer);
509 }
510 else {
511 keyboard_queue.copyEvents(buffer);
512 }
513 }
514
417515 /** Native cursor handles */
418516 public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
419 return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
517 if (native_mode) {
518 long cursor = MacOSXNativeMouse.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
519 return cursor;
520 }
521 else {
522 return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
523 }
420524 }
421525
422526 public void destroyCursor(Object cursor_handle) {
527 long handle = getCursorHandle(cursor_handle);
528
529 // reset current cursor if same
530 if (currentNativeCursor == handle) {
531 currentNativeCursor = 0;
532 }
533
534 MacOSXNativeMouse.destroyCursor(handle);
535 }
536
537 private static long getCursorHandle(Object cursor_handle) {
538 return cursor_handle != null ? (Long)cursor_handle : 0;
423539 }
424540
425541 public int getPbufferCapabilities() {
426 if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 3))
427 return Pbuffer.PBUFFER_SUPPORTED;
428 else
429 return 0;
542 return Pbuffer.PBUFFER_SUPPORTED;
430543 }
431544
432545 public boolean isBufferLost(PeerInfo handle) {
433546 return false;
434547 }
435548
436 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
549 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs,
437550 IntBuffer pixelFormatCaps,
438551 IntBuffer pBufferAttribs) throws LWJGLException {
439 return new MacOSXPbufferPeerInfo(width, height, pixel_format);
552 return new MacOSXPbufferPeerInfo(width, height, pixel_format, attribs);
440553 }
441554
442555 public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
464577 * @return number of icons used.
465578 */
466579 public int setIcon(ByteBuffer[] icons) {
467 /* int size = 0;
580 /*int size = 0;
468581 int biggest = -1;
469582
470583 for (int i=0;i<icons.length;i++) {
494607 // Don't use any icon, since Mac OS X windows don't have window icons
495608 return 0;
496609 }
610
611 public int getX() {
612 return nGetX(window);
613 }
614
615 public int getY() {
616 return nGetY(window);
617 }
497618
498619 public int getWidth() {
499 return Display.getDisplayMode().getWidth();
500 }
501
620 return nGetWidth(window);
621 }
622
502623 public int getHeight() {
503 return Display.getDisplayMode().getHeight();
504 }
505
506 public boolean isInsideWindow() {
507 return true;
508 }
624 return nGetHeight(window);
625 }
626
627 public boolean isInsideWindow() {
628 return mouseInsideWindow;
629 }
630
631 public void setResizable(boolean resizable) {
632 nSetResizable(window, resizable);
633 }
634
635 public boolean wasResized() {
636 return nWasResized(window);
637 }
638
639 public float getPixelScaleFactor() {
640 return (enableHighDPI && !Display.isFullscreen()) ? scaleFactor : 1f;
641 }
642
509643 }
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3418 $
41 * $Id: MacOSXDisplayPeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class MacOSXDisplayPeerInfo extends MacOSXCanvasPeerInfo {
4444 private boolean locked;
4545
46 MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, support_pbuffer);
46 MacOSXDisplayPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean support_pbuffer) throws LWJGLException {
47 super(pixel_format, attribs, support_pbuffer);
4848 }
4949
5050 protected void doLockAndInitHandle() throws LWJGLException {
+0
-228
src/java/org/lwjgl/opengl/MacOSXFrame.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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<Object>() {
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 }
9595 // If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values
9696 skip_event = isGrabbed();
9797 }
98 /* if (isGrabbed()) {
98 if (isGrabbed()) {
9999 Rectangle bounds = getComponent().getBounds();
100100 Point location_on_screen = getComponent().getLocationOnScreen();
101101 int x = location_on_screen.x + bounds.width/2;
102102 int y = location_on_screen.y + bounds.height/2;
103103 nWarpCursor(x, y);
104 }*/
104 }
105105 }
106106
107107 private static native void getMouseDeltas(IntBuffer delta_buffer);
109109 private static native void nWarpCursor(int x, int y);
110110
111111 static native void nGrabMouse(boolean grab);
112 }
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 /**
34 * A native implementation of a LWJGL compatible Keyboard event queue.
35 * @author elias_naur
36 * @author mojang
37 */
38
39 import java.awt.event.KeyEvent;
40 import java.util.HashMap;
41 import java.nio.ByteBuffer;
42
43 import org.lwjgl.input.Keyboard;
44
45 final class MacOSXNativeKeyboard extends EventQueue {
46 private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
47
48 /** Event scratch array */
49 private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
50
51 private ByteBuffer window_handle;
52
53 private boolean has_deferred_event;
54 private long deferred_nanos;
55 private int deferred_key_code;
56 private byte deferred_key_state;
57 private int deferred_character;
58
59 private HashMap<Short, Integer> nativeToLwjglMap;
60
61 MacOSXNativeKeyboard(ByteBuffer window_handle) {
62 super(Keyboard.EVENT_SIZE);
63 nativeToLwjglMap = new HashMap<Short, Integer>();
64 initKeyboardMappings();
65 this.window_handle = window_handle;
66 }
67
68 private native void nRegisterKeyListener(ByteBuffer window_handle);
69
70 private native void nUnregisterKeyListener(ByteBuffer window_handle);
71
72 // These are from: <HIToolbox/Events.h>
73 private void initKeyboardMappings() {
74 nativeToLwjglMap.put((short)0x1D, Keyboard.KEY_0);
75 nativeToLwjglMap.put((short)0x12, Keyboard.KEY_1);
76 nativeToLwjglMap.put((short)0x13, Keyboard.KEY_2);
77 nativeToLwjglMap.put((short)0x14, Keyboard.KEY_3);
78 nativeToLwjglMap.put((short)0x15, Keyboard.KEY_4);
79 nativeToLwjglMap.put((short)0x17, Keyboard.KEY_5);
80 nativeToLwjglMap.put((short)0x16, Keyboard.KEY_6);
81 nativeToLwjglMap.put((short)0x1A, Keyboard.KEY_7);
82 nativeToLwjglMap.put((short)0x1C, Keyboard.KEY_8);
83 nativeToLwjglMap.put((short)0x19, Keyboard.KEY_9);
84 nativeToLwjglMap.put((short)0x00, Keyboard.KEY_A);
85 nativeToLwjglMap.put((short)0x0B, Keyboard.KEY_B);
86 nativeToLwjglMap.put((short)0x08, Keyboard.KEY_C);
87 nativeToLwjglMap.put((short)0x02, Keyboard.KEY_D);
88 nativeToLwjglMap.put((short)0x0E, Keyboard.KEY_E);
89 nativeToLwjglMap.put((short)0x03, Keyboard.KEY_F);
90 nativeToLwjglMap.put((short)0x05, Keyboard.KEY_G);
91 nativeToLwjglMap.put((short)0x04, Keyboard.KEY_H);
92 nativeToLwjglMap.put((short)0x22, Keyboard.KEY_I);
93 nativeToLwjglMap.put((short)0x26, Keyboard.KEY_J);
94 nativeToLwjglMap.put((short)0x28, Keyboard.KEY_K);
95 nativeToLwjglMap.put((short)0x25, Keyboard.KEY_L);
96 nativeToLwjglMap.put((short)0x2E, Keyboard.KEY_M);
97 nativeToLwjglMap.put((short)0x2D, Keyboard.KEY_N);
98 nativeToLwjglMap.put((short)0x1F, Keyboard.KEY_O);
99 nativeToLwjglMap.put((short)0x23, Keyboard.KEY_P);
100 nativeToLwjglMap.put((short)0x0C, Keyboard.KEY_Q);
101 nativeToLwjglMap.put((short)0x0F, Keyboard.KEY_R);
102 nativeToLwjglMap.put((short)0x01, Keyboard.KEY_S);
103 nativeToLwjglMap.put((short)0x11, Keyboard.KEY_T);
104 nativeToLwjglMap.put((short)0x20, Keyboard.KEY_U);
105 nativeToLwjglMap.put((short)0x09, Keyboard.KEY_V);
106 nativeToLwjglMap.put((short)0x0D, Keyboard.KEY_W);
107 nativeToLwjglMap.put((short)0x07, Keyboard.KEY_X);
108 nativeToLwjglMap.put((short)0x10, Keyboard.KEY_Y);
109 nativeToLwjglMap.put((short)0x06, Keyboard.KEY_Z);
110
111 nativeToLwjglMap.put((short)0x2A, Keyboard.KEY_BACKSLASH);
112 nativeToLwjglMap.put((short)0x2B, Keyboard.KEY_COMMA);
113 nativeToLwjglMap.put((short)0x18, Keyboard.KEY_EQUALS);
114 nativeToLwjglMap.put((short)0x21, Keyboard.KEY_LBRACKET);
115 nativeToLwjglMap.put((short)0x1B, Keyboard.KEY_MINUS);
116 nativeToLwjglMap.put((short)0x27, Keyboard.KEY_APOSTROPHE);
117 nativeToLwjglMap.put((short)0x1E, Keyboard.KEY_RBRACKET);
118 nativeToLwjglMap.put((short)0x29, Keyboard.KEY_SEMICOLON);
119 nativeToLwjglMap.put((short)0x2C, Keyboard.KEY_SLASH);
120 nativeToLwjglMap.put((short)0x2F, Keyboard.KEY_PERIOD);
121 nativeToLwjglMap.put((short)0x32, Keyboard.KEY_GRAVE);
122
123 nativeToLwjglMap.put((short)0x41, Keyboard.KEY_DECIMAL);
124 nativeToLwjglMap.put((short)0x43, Keyboard.KEY_MULTIPLY);
125 nativeToLwjglMap.put((short)0x45, Keyboard.KEY_ADD);
126 nativeToLwjglMap.put((short)0x47, Keyboard.KEY_CLEAR);
127 nativeToLwjglMap.put((short)0x4B, Keyboard.KEY_DIVIDE);
128 nativeToLwjglMap.put((short)0x4C, Keyboard.KEY_NUMPADENTER);
129 nativeToLwjglMap.put((short)0x4E, Keyboard.KEY_SUBTRACT);
130 nativeToLwjglMap.put((short)0x51, Keyboard.KEY_NUMPADEQUALS);
131
132 nativeToLwjglMap.put((short)0x52, Keyboard.KEY_NUMPAD0);
133 nativeToLwjglMap.put((short)0x53, Keyboard.KEY_NUMPAD1);
134 nativeToLwjglMap.put((short)0x54, Keyboard.KEY_NUMPAD2);
135 nativeToLwjglMap.put((short)0x55, Keyboard.KEY_NUMPAD3);
136 nativeToLwjglMap.put((short)0x56, Keyboard.KEY_NUMPAD4);
137 nativeToLwjglMap.put((short)0x57, Keyboard.KEY_NUMPAD5);
138 nativeToLwjglMap.put((short)0x58, Keyboard.KEY_NUMPAD6);
139 nativeToLwjglMap.put((short)0x59, Keyboard.KEY_NUMPAD7);
140 nativeToLwjglMap.put((short)0x5B, Keyboard.KEY_NUMPAD8);
141 nativeToLwjglMap.put((short)0x5C, Keyboard.KEY_NUMPAD9);
142
143
144 nativeToLwjglMap.put((short)0x24, Keyboard.KEY_RETURN);
145 nativeToLwjglMap.put((short)0x30, Keyboard.KEY_TAB);
146 nativeToLwjglMap.put((short)0x31, Keyboard.KEY_SPACE);
147 nativeToLwjglMap.put((short)0x33, Keyboard.KEY_BACK);
148 nativeToLwjglMap.put((short)0x35, Keyboard.KEY_ESCAPE);
149 nativeToLwjglMap.put((short)0x36, Keyboard.KEY_RMETA); // not in Events.h - works on MBP
150 nativeToLwjglMap.put((short)0x37, Keyboard.KEY_LMETA);
151 nativeToLwjglMap.put((short)0x38, Keyboard.KEY_LSHIFT);
152 nativeToLwjglMap.put((short)0x39, Keyboard.KEY_CAPITAL);
153 nativeToLwjglMap.put((short)0x3A, Keyboard.KEY_LMENU);
154 nativeToLwjglMap.put((short)0x3B, Keyboard.KEY_LCONTROL);
155 nativeToLwjglMap.put((short)0x3C, Keyboard.KEY_RSHIFT);
156 nativeToLwjglMap.put((short)0x3D, Keyboard.KEY_RMENU);
157 nativeToLwjglMap.put((short)0x3E, Keyboard.KEY_RCONTROL);
158
159 nativeToLwjglMap.put((short)0x3F, Keyboard.KEY_FUNCTION);
160 nativeToLwjglMap.put((short)0x77, Keyboard.KEY_END);
161
162 nativeToLwjglMap.put((short)0x7A, Keyboard.KEY_F1);
163 nativeToLwjglMap.put((short)0x78, Keyboard.KEY_F2);
164 nativeToLwjglMap.put((short)0x63, Keyboard.KEY_F3);
165 nativeToLwjglMap.put((short)0x76, Keyboard.KEY_F4);
166 nativeToLwjglMap.put((short)0x60, Keyboard.KEY_F5);
167 nativeToLwjglMap.put((short)0x61, Keyboard.KEY_F6);
168 nativeToLwjglMap.put((short)0x62, Keyboard.KEY_F7);
169 nativeToLwjglMap.put((short)0x64, Keyboard.KEY_F8);
170 nativeToLwjglMap.put((short)0x65, Keyboard.KEY_F9);
171 nativeToLwjglMap.put((short)0x6D, Keyboard.KEY_F10);
172 nativeToLwjglMap.put((short)0x67, Keyboard.KEY_F11);
173 nativeToLwjglMap.put((short)0x6F, Keyboard.KEY_F12);
174 nativeToLwjglMap.put((short)0x69, Keyboard.KEY_F13);
175 nativeToLwjglMap.put((short)0x6B, Keyboard.KEY_F14);
176 nativeToLwjglMap.put((short)0x71, Keyboard.KEY_F15);
177 nativeToLwjglMap.put((short)0x6A, Keyboard.KEY_F16);
178 nativeToLwjglMap.put((short)0x40, Keyboard.KEY_F17);
179 nativeToLwjglMap.put((short)0x4F, Keyboard.KEY_F18);
180 nativeToLwjglMap.put((short)0x50, Keyboard.KEY_F19);
181 // nativeToLwjglMap.put((short)0x5A, Keyboard.KEY_F20);
182
183 nativeToLwjglMap.put((short)0x75, Keyboard.KEY_DELETE);
184 nativeToLwjglMap.put((short)0x72, Keyboard.KEY_INSERT); // 'Help' in Events.h
185 nativeToLwjglMap.put((short)0x73, Keyboard.KEY_HOME);
186 // nativeToLwjglMap.put((short)0xA4, Keyboard.KEY_MUTE);
187 nativeToLwjglMap.put((short)0x79, Keyboard.KEY_NEXT);
188 nativeToLwjglMap.put((short)0x74, Keyboard.KEY_PRIOR);
189 // nativeToLwjglMap.put((short)0x49, Keyboard.KEY_VOLUMEDOWN);
190 // nativeToLwjglMap.put((short)0x48, Keyboard.KEY_VOLUMEUP);
191 nativeToLwjglMap.put((short)0x7B, Keyboard.KEY_LEFT);
192 nativeToLwjglMap.put((short)0x7C, Keyboard.KEY_RIGHT);
193 nativeToLwjglMap.put((short)0x7D, Keyboard.KEY_DOWN);
194 nativeToLwjglMap.put((short)0x7E, Keyboard.KEY_UP);
195
196 nativeToLwjglMap.put((short)0x0A, Keyboard.KEY_SECTION);
197
198 nativeToLwjglMap.put((short)0x6E, Keyboard.KEY_APPS); // not in Events.h
199 nativeToLwjglMap.put((short)0x129, Keyboard.KEY_COLON); // not in Events.h -- do we need it?
200 }
201
202 public void register() {
203 nRegisterKeyListener(window_handle);
204 }
205
206 public void unregister() {
207 nUnregisterKeyListener(window_handle);
208 }
209
210 public void putKeyboardEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
211 event.clear();
212 event.putInt(key_code).put(state).putInt(character).putLong(nanos).put(repeat ? (byte)1 : (byte)0);
213 event.flip();
214 putEvent(event);
215 }
216
217 public synchronized void poll(ByteBuffer key_down_buffer) {
218 flushDeferredEvent();
219 int old_position = key_down_buffer.position();
220 key_down_buffer.put(key_states);
221 key_down_buffer.position(old_position);
222 }
223
224 public synchronized void copyEvents(ByteBuffer dest) {
225 flushDeferredEvent();
226 super.copyEvents(dest);
227 }
228
229 private synchronized void handleKey(int key_code, byte state, int character, long nanos) {
230 if (character == KeyEvent.CHAR_UNDEFINED)
231 character = Keyboard.CHAR_NONE;
232 if (state == 1) {
233 boolean repeat = false;
234 if (has_deferred_event) {
235 if ((nanos == deferred_nanos && deferred_key_code == key_code)) {
236 has_deferred_event = false;
237 repeat = true; // Repeat event
238 } else
239 flushDeferredEvent();
240 }
241 putKeyEvent(key_code, state, character, nanos, repeat);
242 } else {
243 flushDeferredEvent();
244 has_deferred_event = true;
245 deferred_nanos = nanos;
246 deferred_key_code = key_code;
247 deferred_key_state = state;
248 deferred_character = character;
249 }
250 }
251
252 private void flushDeferredEvent() {
253 if (has_deferred_event) {
254 putKeyEvent(deferred_key_code, deferred_key_state, deferred_character, deferred_nanos, false);
255 has_deferred_event = false;
256 }
257 }
258
259 public void putKeyEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
260 /* Ignore repeating presses */
261 int mapped_code = getMappedKeyCode((short)key_code);
262 if (mapped_code < 0) {
263 System.out.println("Unrecognized keycode: " + key_code);
264 /* Unrecognized / unmapped code, do nothing */
265 return;
266 }
267 if ( key_states[mapped_code] == state )
268 repeat = true;
269 key_states[mapped_code] = state;
270 int key_int_char = character & 0xffff;
271 putKeyboardEvent(mapped_code, state, key_int_char, nanos, repeat);
272 }
273
274 private int getMappedKeyCode(short key_code) {
275 if (nativeToLwjglMap.containsKey(key_code)) {
276 return nativeToLwjglMap.get(key_code);
277 }
278 return -1;
279 }
280
281 public void keyPressed(int key_code, String chars, long nanos) {
282 // use only first character of chars returned for key press
283 int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
284 handleKey(key_code, (byte)1, character, nanos);
285 }
286
287 public void keyReleased(int key_code, String chars, long nanos) {
288 // use only first character of chars returned for key release
289 int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
290 handleKey(key_code, (byte)0, character, nanos);
291 }
292
293 public void keyTyped(KeyEvent e) {
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 /**
34 * A Cocoa implementation of a LWJGL compatible Mouse.
35 * @author mojang
36 * @author kappaOne <one.kappa@gmail.com>
37 */
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 import org.lwjgl.input.Mouse;
43 import org.lwjgl.LWJGLException;
44
45 import java.lang.reflect.*;
46 import java.lang.Integer;
47 import java.lang.Long;
48
49 import org.lwjgl.BufferUtils;
50
51 final class MacOSXNativeMouse extends EventQueue {
52 private static final int WHEEL_SCALE = 120;
53 private static final int NUM_BUTTONS = 3;
54
55 private ByteBuffer window_handle;
56 private MacOSXDisplay display;
57
58 private boolean grabbed;
59
60 /** The accumulated mouse deltas returned by poll() */
61 private float accum_dx;
62 private float accum_dy;
63 private int accum_dz;
64
65 /** The last mouse position */
66 private float last_x;
67 private float last_y;
68
69 /** Saved control key state for ctrl-click right button emulation */
70 private boolean saved_control_state;
71
72 private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE);
73 private IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
74 private int skip_event;
75
76 private final byte[] buttons = new byte[NUM_BUTTONS];
77
78 MacOSXNativeMouse(MacOSXDisplay display, ByteBuffer window_handle) {
79 super(Mouse.EVENT_SIZE);
80 this.display = display;
81 this.window_handle = window_handle;
82 }
83
84 private native void nSetCursorPosition(ByteBuffer window_handle, int x, int y);
85
86 public static native void nGrabMouse(boolean grab);
87
88 private native void nRegisterMouseListener(ByteBuffer window_handle);
89
90 private native void nUnregisterMouseListener(ByteBuffer window_handle);
91
92 private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
93
94 private static native void nDestroyCursor(long cursor_handle);
95
96 private static native void nSetCursor(long cursor_handle) throws LWJGLException;
97
98 public synchronized void register() {
99 nRegisterMouseListener(window_handle);
100 }
101
102 public static long createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
103 try {
104 return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
105 } catch (LWJGLException e) {
106 throw e;
107 }
108 }
109
110 public static void destroyCursor(long cursor_handle) {
111 nDestroyCursor(cursor_handle);
112 }
113
114 public static void setCursor(long cursor_handle) throws LWJGLException {
115 try {
116 nSetCursor(cursor_handle);
117 } catch (LWJGLException e) {
118 throw e;
119 }
120 }
121
122 public synchronized void setCursorPosition(int x, int y) {
123 nSetCursorPosition(window_handle, x, y);
124 }
125
126 public synchronized void unregister() {
127 nUnregisterMouseListener(window_handle);
128 }
129
130 public synchronized void setGrabbed(boolean grabbed) {
131 this.grabbed = grabbed;
132 nGrabMouse(grabbed);
133 skip_event = 1;
134 accum_dx = accum_dy = 0;
135 }
136
137 public synchronized boolean isGrabbed() {
138 return grabbed;
139 }
140
141 protected void resetCursorToCenter() {
142 clearEvents();
143 accum_dx = accum_dy = 0;
144 if (display != null) {
145 last_x = display.getWidth() / 2;
146 last_y = display.getHeight() / 2;
147 }
148 }
149
150 private void putMouseEvent(byte button, byte state, int dz, long nanos) {
151 if (grabbed)
152 putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
153 else
154 putMouseEventWithCoords(button, state, (int)last_x, (int)last_y, dz, nanos);
155 }
156
157 protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
158 event.clear();
159 event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
160 event.flip();
161 putEvent(event);
162 }
163
164 public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
165 if (grabbed) {
166 coord_buffer.put(0, (int)accum_dx);
167 coord_buffer.put(1, (int)accum_dy);
168 } else {
169 coord_buffer.put(0, (int)last_x);
170 coord_buffer.put(1, (int)last_y);
171 }
172 coord_buffer.put(2, accum_dz);
173 accum_dx = accum_dy = accum_dz = 0;
174 int old_position = buttons_buffer.position();
175 buttons_buffer.put(buttons, 0, buttons.length);
176 buttons_buffer.position(old_position);
177 }
178
179 private void setCursorPos(float x, float y, long nanos) {
180 if ( grabbed )
181 return;
182 float dx = x - last_x;
183 float dy = y - last_y;
184 addDelta(dx, dy);
185 last_x = x;
186 last_y = y;
187 putMouseEventWithCoords((byte)-1, (byte)0, (int)x, (int)y, 0, nanos);
188 }
189
190 protected void addDelta(float dx, float dy) {
191 accum_dx += dx;
192 accum_dy += -dy;
193 }
194
195 public synchronized void setButton(int button, int state, long nanos) {
196 buttons[button] = (byte)state;
197 putMouseEvent((byte)button, (byte)state, 0, nanos);
198 }
199
200 public synchronized void mouseMoved(float x, float y, float dx, float dy, float dz, long nanos) {
201 if (skip_event > 0) {
202 skip_event--;
203 if (skip_event == 0) {
204 last_x = x;
205 last_y = y;
206 }
207 return;
208 }
209
210 if ( dz != 0 ) { // if scroll wheel event
211 // if no vertical wheel events, then map the horizontal wheel event to it
212 if (dy == 0) dy = dx;
213
214 int wheel_amount = (int)(dy * WHEEL_SCALE);
215 accum_dz += wheel_amount;
216 putMouseEvent((byte)-1, (byte)0, wheel_amount, nanos);
217 }
218 else if (grabbed) {
219 if ( dx != 0 || dy != 0 ) {
220 putMouseEventWithCoords((byte)-1, (byte)0, (int)dx, (int)-dy, 0, nanos);
221 addDelta(dx, dy);
222 }
223 } else {
224 setCursorPos(x, y, nanos);
225 }
226 }
227 }
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class MacOSXPbufferPeerInfo extends MacOSXPeerInfo {
44 MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
45 super(pixel_format, false, false, true, false);
44 MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
45 super(pixel_format, attribs, false, false, true, false);
4646 nCreate(getHandle(), width, height);
4747 }
4848 private static native void nCreate(ByteBuffer handle, int width, int height) throws LWJGLException;
3838 /**
3939 *
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: MacOSXPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 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 {
45 MacOSXPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
4646 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);
47
48 boolean gl32 = attribs != null && (3 < attribs.getMajorVersion() || (attribs.getMajorVersion() == 3 && 2 <= attribs.getMinorVersion())) && attribs.isProfileCore();
49 if ( gl32 && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) )
50 throw new LWJGLException("OpenGL 3.2+ requested, but it requires MacOS X 10.7 or newer");
51
52 choosePixelFormat(pixel_format, gl32, use_display_bpp, support_window, support_pbuffer, double_buffered);
5053 }
5154 private static native ByteBuffer createHandle();
5255
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);
56 private void choosePixelFormat(PixelFormat pixel_format, boolean gl32, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
57 nChoosePixelFormat(getHandle(), pixel_format, gl32, use_display_bpp, support_window, support_pbuffer, double_buffered);
5558 }
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;
59 private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, PixelFormat pixel_format, boolean gl32, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException;
5760
5861 public void destroy() {
5962 nDestroy(getHandle());
8080
8181 public synchronized void register() {
8282 resetCursorToCenter();
83 component.addMouseListener(this);
84 component.addMouseMotionListener(this);
85 component.addMouseWheelListener(this);
83 if (component != null) {
84 component.addMouseListener(this);
85 component.addMouseMotionListener(this);
86 component.addMouseWheelListener(this);
87 }
8688 }
8789
8890 public synchronized void unregister() {
89 component.removeMouseListener(this);
90 component.removeMouseMotionListener(this);
91 component.removeMouseWheelListener(this);
91 if (component != null) {
92 component.removeMouseListener(this);
93 component.removeMouseMotionListener(this);
94 component.removeMouseWheelListener(this);
95 }
9296 }
9397
9498 protected Component getComponent() {
104108 return grabbed;
105109 }
106110
107 private int transformY(int y) {
108 return component.getHeight() - 1 - y;
111 protected int transformY(int y) {
112 if (component != null) {
113 return component.getHeight() - 1 - y;
114 }
115 return y;
109116 }
110117
111118 protected void resetCursorToCenter() {
112119 clearEvents();
113120 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 }
121 if (component != null) {
122 Point cursor_location = AWTUtil.getCursorPosition(component);
123 if (cursor_location != null) {
124 last_x = cursor_location.x;
125 last_y = cursor_location.y;
126 }
127 }
119128 }
120129
121130 private void putMouseEvent(byte button, byte state, int dz, long nanos) {
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 org.lwjgl.BufferChecks;
35 import org.lwjgl.LWJGLUtil;
36
37 import java.nio.ByteBuffer;
38 import java.nio.IntBuffer;
39 import java.nio.LongBuffer;
40
41 /**
42 * This class exposes the platform specific functionality present in the
43 * NV_present_video extension.
44 *
45 * @author Spasi
46 * @since 20/5/2011
47 */
48 public final class NVPresentVideoUtil {
49
50 private NVPresentVideoUtil() {}
51
52 private static void checkExtension() {
53 if ( LWJGLUtil.CHECKS && !GLContext.getCapabilities().GL_NV_present_video )
54 throw new IllegalStateException("NV_present_video is not supported");
55 }
56
57 private static ByteBuffer getPeerInfo() {
58 return ContextGL.getCurrentContext().getPeerInfo().getHandle();
59 }
60
61 /**
62 * Enumerate the available video output devices. This method is the cross-platform
63 * equivalent of glXEnumerateVideoDevicesNV and wglEnumerateVideoDevicesNV. Since they are
64 * not really compatible, this method works like the WGL version. That is, you first
65 * call it with a null devices buffer, get the number of devices, then call it again
66 * with an appropriately sized buffer.
67 *
68 * @param devices the buffer to store devices in
69 *
70 * @return the number of available video output devices
71 */
72 public static int glEnumerateVideoDevicesNV(LongBuffer devices) {
73 checkExtension();
74
75 if ( devices != null )
76 BufferChecks.checkBuffer(devices, 1);
77 return nglEnumerateVideoDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position());
78 }
79
80 private static native int nglEnumerateVideoDevicesNV(ByteBuffer peer_info, LongBuffer devices, int devices_position);
81
82 /**
83 * Binds the video output device specified to one of the context's available video output slots.
84 * This method is the cross-platform equivalent of glXBindVideoDeviceNV and wglBindVideoDeviceNV.
85 * To release a video device without binding another device to the same slot, call it with
86 * video_device set to 0 (will use INVALID_HANDLE_VALUE on WGL).
87 *
88 * @param video_slot the video slot
89 * @param video_device the video device
90 * @param attrib_list the attributes to use
91 *
92 * @return true if the binding was successful
93 */
94 public static boolean glBindVideoDeviceNV(int video_slot, long video_device, IntBuffer attrib_list) {
95 checkExtension();
96
97 if ( attrib_list != null )
98 BufferChecks.checkNullTerminated(attrib_list);
99 return nglBindVideoDeviceNV(getPeerInfo(), video_slot, video_device, attrib_list, attrib_list == null ? 0 : attrib_list.position());
100 }
101
102 private static native boolean nglBindVideoDeviceNV(ByteBuffer peer_info, int video_slot, long video_device, IntBuffer attrib_list, int attrib_list_position);
103
104 /**
105 * Queries an attribute associated with the current context. This method is the cross-platform
106 * equivalent of glXQueryContext and wglQueryCurrentContextNV.
107 *
108 * @param attrib the attribute to query
109 * @param value the buffer to store the value in
110 */
111 public static boolean glQueryContextNV(int attrib, IntBuffer value) {
112 checkExtension();
113
114 BufferChecks.checkBuffer(value, 1);
115 ContextGL ctx = ContextGL.getCurrentContext();
116 return nglQueryContextNV(ctx.getPeerInfo().getHandle(), ctx.getHandle(), attrib, value, value.position());
117 }
118
119 private static native boolean nglQueryContextNV(ByteBuffer peer_info, ByteBuffer context_handle, int attrib, IntBuffer value, int value_position);
120
121 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 org.lwjgl.BufferChecks;
35 import org.lwjgl.LWJGLUtil;
36
37 import java.nio.ByteBuffer;
38 import java.nio.IntBuffer;
39 import java.nio.LongBuffer;
40
41 /**
42 * This class exposes the platform specific functionality present in the
43 * NV_video_capture extension.
44 *
45 * @author Spasi
46 * @since 20/5/2011
47 */
48 public final class NVVideoCaptureUtil {
49
50 private NVVideoCaptureUtil() {}
51
52 private static void checkExtension() {
53 if ( LWJGLUtil.CHECKS && !GLContext.getCapabilities().GL_NV_video_capture )
54 throw new IllegalStateException("NV_video_capture is not supported");
55 }
56
57 private static ByteBuffer getPeerInfo() {
58 return ContextGL.getCurrentContext().getPeerInfo().getHandle();
59 }
60
61 /**
62 * After successfully locking a video capture device, use this method to bind it
63 * to the capture slot specified in the current context. This method is the cross-
64 * platform equivalent of glXBindVideoCaptureDeviceNV and wglBindVideoCaptureDeviceNV.
65 *
66 * @param video_slot the video slot
67 * @param device the video capture device
68 *
69 * @return true if the binding was successful
70 */
71 public static boolean glBindVideoCaptureDeviceNV(int video_slot, long device) {
72 checkExtension();
73 return nglBindVideoCaptureDeviceNV(getPeerInfo(), video_slot, device);
74 }
75
76 private static native boolean nglBindVideoCaptureDeviceNV(ByteBuffer peer_info, int video_slot, long device);
77
78 /**
79 * Enumerate the available video capture devices. This method is the cross-platform
80 * equivalent of glXEnumerateVideoCaptureDevicesNV and wglEnumerateVideoCaptureDevicesNV.
81 * Since they are not really compatible, this method works like the WGL version. That is,
82 * you first call it with a null devices buffer, get the number of devices, then call it
83 * again with an appropriately sized buffer.
84 *
85 * @param devices the buffer to store devices in
86 *
87 * @return the number of available video capture devices
88 */
89 public static int glEnumerateVideoCaptureDevicesNV(LongBuffer devices) {
90 checkExtension();
91
92 if ( devices != null )
93 BufferChecks.checkBuffer(devices, 1);
94 return nglEnumerateVideoCaptureDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position());
95 }
96
97 private static native int nglEnumerateVideoCaptureDevicesNV(ByteBuffer peer_info, LongBuffer devices, int devices_position);
98
99 /**
100 * To lock a video capture device to a display connection, use this method.
101 * Before using a video capture device, it must be locked. Once a
102 * video capture device is locked by a process, no other process can
103 * lock a video capture device with the same unique ID until the lock
104 * is released or the process ends.
105 *
106 * @param device the device to lock
107 *
108 * @return true if the lock was successful
109 */
110 public static boolean glLockVideoCaptureDeviceNV(long device) {
111 checkExtension();
112 return nglLockVideoCaptureDeviceNV(getPeerInfo(), device);
113 }
114
115 private static native boolean nglLockVideoCaptureDeviceNV(ByteBuffer peer_info, long device);
116
117 /**
118 * Use this method to query the unique ID of the physical device backing a
119 * video capture device handle.
120 *
121 * @param device the device
122 * @param attribute the attribute to query
123 * @param value the buffer to store the value in
124 *
125 * @return true if the query was successful
126 */
127 public static boolean glQueryVideoCaptureDeviceNV(long device, int attribute, IntBuffer value) {
128 checkExtension();
129
130 BufferChecks.checkBuffer(value, 1);
131 return nglQueryVideoCaptureDeviceNV(getPeerInfo(), device, attribute, value, value.position());
132 }
133
134 private static native boolean nglQueryVideoCaptureDeviceNV(ByteBuffer peer_info, long device, int attribute, IntBuffer value, int value_position);
135
136 /**
137 * Use this method when finished capturing data on a locked video capture device
138 * to unlock it.
139 *
140 * @param device the device
141 *
142 * @return true if the device was unlocked successfully
143 */
144 public static boolean glReleaseVideoCaptureDeviceNV(long device) {
145 checkExtension();
146 return nglReleaseVideoCaptureDeviceNV(getPeerInfo(), device);
147 }
148
149 private static native boolean nglReleaseVideoCaptureDeviceNV(ByteBuffer peer_info, long device);
150
151 }
152
3535 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 * $Id: OpenGLException.java 2983 2008-04-07 18:36:09Z matzon $
38 * @version $Revision$
39 * $Id$
4040 */
4141 public class OpenGLException extends RuntimeException {
4242
4444 * This class is thread-safe.
4545 *
4646 * @author elias_naur <elias_naur@users.sourceforge.net>
47 * @version $Revision: 3334 $
48 * $Id: Pbuffer.java 3334 2010-04-22 23:21:48Z spasi $
47 * @version $Revision$
48 * $Id$
4949 */
50 public final class Pbuffer extends AbstractDrawable {
50 public final class Pbuffer extends DrawableGL {
5151 /**
5252 * Indicates that Pbuffers can be created.
5353 */
215215 throw new NullPointerException("Pixel format must be non-null");
216216 this.width = width;
217217 this.height = height;
218 this.peer_info = createPbuffer(width, height, pixel_format, renderTexture);
219 Context shared_context;
218 this.peer_info = createPbuffer(width, height, pixel_format, attribs, renderTexture);
219 Context shared_context = null;
220 if ( shared_drawable == null )
221 shared_drawable = Display.getDrawable(); // May be null
220222 if (shared_drawable != null)
221223 shared_context = ((DrawableLWJGL)shared_drawable).getContext();
222 else
223 shared_context = ((DrawableLWJGL)Display.getDrawable()).getContext(); // May be null
224 this.context = new Context(peer_info, attribs, shared_context);
225 }
226
227 private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
224 this.context = new ContextGL(peer_info, attribs, (ContextGL)shared_context);
225 }
226
227 private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs, RenderTexture renderTexture) throws LWJGLException {
228228 if ( renderTexture == null ) {
229229 // Though null is a perfectly valid argument, Matrox Parhelia drivers expect
230230 // a 0 terminated list, or else they crash. Supplying NULL or 0, should
231231 // cause the drivers to use default settings
232232 IntBuffer defaultAttribs = BufferUtils.createIntBuffer(1);
233 return Display.getImplementation().createPbuffer(width, height, pixel_format, null, defaultAttribs);
233 return Display.getImplementation().createPbuffer(width, height, pixel_format, attribs, null, defaultAttribs);
234234 } else
235 return Display.getImplementation().createPbuffer(width, height, pixel_format,
235 return Display.getImplementation().createPbuffer(width, height, pixel_format, attribs,
236236 renderTexture.pixelFormatCaps,
237237 renderTexture.pBufferAttribs);
238238 }
3838 /**
3939 *
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: PeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 abstract class PeerInfo {
4545 private final ByteBuffer handle;
3737 * <p/>
3838 * Instants of this class are immutable. An example of the expected way to set
3939 * the PixelFormat property values is the following:
40 * <code>PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4).withSRGB(true);</code>
40 * <code>PixelFormat pf = new PixelFormat().withDepthBits(24).withSamples(4).withSRGB(true);</code>
4141 * <p/>
4242 * WARNING: Some pixel formats are known to cause troubles on certain buggy drivers.
4343 * Example: Under Windows, specifying samples != 0 will enable the ARB
4444 * pixel format selection path, which could trigger a crash.
4545 *
4646 * @author elias_naur@sourceforge.net
47 * @version $Revision: 3355 $
47 * @version $Revision$
4848 */
49
50 public final class PixelFormat {
49 public final class PixelFormat implements PixelFormatLWJGL {
5150
5251 /**
5352 * The number of bits per pixel, exluding alpha.
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 * [INTERNAL USE ONLY]
35 *
36 * @author Spasi
37 */
38 public interface PixelFormatLWJGL {
39 // Marker interface
40 }
4343 *
4444 * @author Spasi
4545 */
46 public final class SharedDrawable extends AbstractDrawable {
46 public final class SharedDrawable extends DrawableGL {
4747
4848 public SharedDrawable(final Drawable drawable) throws LWJGLException {
49 this.context = ((DrawableLWJGL)drawable).createSharedContext();
49 this.context = (ContextGL)((DrawableLWJGL)drawable).createSharedContext();
5050 }
5151
52 public Context createSharedContext() {
52 public ContextGL createSharedContext() {
5353 throw new UnsupportedOperationException();
5454 }
5555
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Sys;
34
35 /**
36 * A highly accurate sync method that continually adapts to the system
37 * it runs on to provide reliable results.
38 *
39 * @author Riven
40 * @author kappaOne
41 */
42 class Sync {
43
44 /** number of nano seconds in a second */
45 private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L;
46
47 /** The time to sleep/yield until the next frame */
48 private static long nextFrame = 0;
49
50 /** whether the initialisation code has run */
51 private static boolean initialised = false;
52
53 /** for calculating the averages the previous sleep/yield times are stored */
54 private static RunningAvg sleepDurations = new RunningAvg(10);
55 private static RunningAvg yieldDurations = new RunningAvg(10);
56
57
58 /**
59 * An accurate sync method that will attempt to run at a constant frame rate.
60 * It should be called once every frame.
61 *
62 * @param fps - the desired frame rate, in frames per second
63 */
64 public static void sync(int fps) {
65 if (fps <= 0) return;
66 if (!initialised) initialise();
67
68 try {
69 // sleep until the average sleep time is greater than the time remaining till nextFrame
70 for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) {
71 Thread.sleep(1);
72 sleepDurations.add((t1 = getTime()) - t0); // update average sleep time
73 }
74
75 // slowly dampen sleep average if too high to avoid yielding too much
76 sleepDurations.dampenForLowResTicker();
77
78 // yield until the average yield time is greater than the time remaining till nextFrame
79 for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) {
80 Thread.yield();
81 yieldDurations.add((t1 = getTime()) - t0); // update average yield time
82 }
83 } catch (InterruptedException e) {
84
85 }
86
87 // schedule next frame, drop frame(s) if already too late for next frame
88 nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime());
89 }
90
91 /**
92 * This method will initialise the sync method by setting initial
93 * values for sleepDurations/yieldDurations and nextFrame.
94 *
95 * If running on windows it will start the sleep timer fix.
96 */
97 private static void initialise() {
98 initialised = true;
99
100 sleepDurations.init(1000 * 1000);
101 yieldDurations.init((int) (-(getTime() - getTime()) * 1.333));
102
103 nextFrame = getTime();
104
105 String osName = System.getProperty("os.name");
106
107 if (osName.startsWith("Win")) {
108 // On windows the sleep functions can be highly inaccurate by
109 // over 10ms making in unusable. However it can be forced to
110 // be a bit more accurate by running a separate sleeping daemon
111 // thread.
112 Thread timerAccuracyThread = new Thread(new Runnable() {
113 public void run() {
114 try {
115 Thread.sleep(Long.MAX_VALUE);
116 } catch (Exception e) {}
117 }
118 });
119
120 timerAccuracyThread.setName("LWJGL Timer");
121 timerAccuracyThread.setDaemon(true);
122 timerAccuracyThread.start();
123 }
124 }
125
126 /**
127 * Get the system time in nano seconds
128 *
129 * @return will return the current time in nano's
130 */
131 private static long getTime() {
132 return (Sys.getTime() * NANOS_IN_SECOND) / Sys.getTimerResolution();
133 }
134
135 private static class RunningAvg {
136 private final long[] slots;
137 private int offset;
138
139 private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms
140 private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f is exactly right!
141
142 public RunningAvg(int slotCount) {
143 this.slots = new long[slotCount];
144 this.offset = 0;
145 }
146
147 public void init(long value) {
148 while (this.offset < this.slots.length) {
149 this.slots[this.offset++] = value;
150 }
151 }
152
153 public void add(long value) {
154 this.slots[this.offset++ % this.slots.length] = value;
155 this.offset %= this.slots.length;
156 }
157
158 public long avg() {
159 long sum = 0;
160 for (int i = 0; i < this.slots.length; i++) {
161 sum += this.slots[i];
162 }
163 return sum / this.slots.length;
164 }
165
166 public void dampenForLowResTicker() {
167 if (this.avg() > DAMPEN_THRESHOLD) {
168 for (int i = 0; i < this.slots.length; i++) {
169 this.slots[i] *= DAMPEN_FACTOR;
170 }
171 }
172 }
173 }
174 }
3838 * Simple utility class.
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
41 * @version $Revision$
4242 */
4343
4444 public final class Util {
3939 /**
4040 *
4141 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3418 $
43 * $Id: WindowsAWTGLCanvasPeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
42 * @version $Revision$
43 * $Id$
4444 */
4545 final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo {
4646 private final Canvas component;
4343 /**
4444 *
4545 * @author elias_naur <elias_naur@users.sourceforge.net>
46 * @version $Revision: 3418 $
47 * $Id: WindowsCanvasImplementation.java 3418 2010-09-28 21:11:35Z spasi $
46 * @version $Revision$
47 * $Id$
4848 */
4949 final class WindowsCanvasImplementation implements AWTCanvasImplementation {
5050 static {
6565 });
6666 }
6767
68 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
68 public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
6969 return new WindowsAWTGLCanvasPeerInfo(component, pixel_format);
7070 }
7171
+0
-92
src/java/org/lwjgl/opengl/WindowsContextAttribs.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 }
3838
3939 /**
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3412 $
42 * $Id: WindowsContextImplementation.java 3412 2010-09-26 23:43:24Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 final class WindowsContextImplementation implements ContextImplementation {
4545
5959 native long getHDC(ByteBuffer peer_info_handle);
6060
6161 public void swapBuffers() throws LWJGLException {
62 Context current_context = Context.getCurrentContext();
62 ContextGL current_context = ContextGL.getCurrentContext();
6363 if ( current_context == null )
6464 throw new IllegalStateException("No context is current");
6565 synchronized ( current_context ) {
3737 * @author elias_naur
3838 */
3939
40 import java.nio.ByteBuffer;
41 import java.nio.FloatBuffer;
42 import java.nio.IntBuffer;
43 import java.awt.Canvas;
40 import java.awt.*;
41 import java.awt.event.FocusAdapter;
42 import java.awt.event.FocusEvent;
43 import java.lang.reflect.Method;
44 import java.nio.*;
45 import java.util.concurrent.atomic.AtomicBoolean;
4446
4547 import org.lwjgl.LWJGLException;
4648 import org.lwjgl.LWJGLUtil;
4749 import org.lwjgl.BufferUtils;
50 import org.lwjgl.MemoryUtil;
4851 import org.lwjgl.input.Cursor;
49 import org.lwjgl.input.Keyboard;
5052 import org.lwjgl.input.Mouse;
53 import org.lwjgl.opengles.EGL;
54
55 import javax.swing.*;
5156
5257 final class WindowsDisplay implements DisplayImplementation {
5358 private static final int GAMMA_LENGTH = 256;
5459
60 private static final int WM_WINDOWPOSCHANGED = 0x0047;
61 private static final int WM_MOVE = 0x0003;
5562 private static final int WM_CANCELMODE = 0x001F;
5663 private static final int WM_MOUSEMOVE = 0x0200;
5764 private static final int WM_LBUTTONDOWN = 0x0201;
6370 private static final int WM_MBUTTONDOWN = 0x0207;
6471 private static final int WM_MBUTTONUP = 0x0208;
6572 private static final int WM_MBUTTONDBLCLK = 0x0209;
73 private static final int WM_XBUTTONDOWN = 0x020B;
74 private static final int WM_XBUTTONUP = 0x020C;
75 private static final int WM_XBUTTONDBLCLK = 0x020D;
6676 private static final int WM_MOUSEWHEEL = 0x020A;
6777 private static final int WM_CAPTURECHANGED = 0x0215;
68 private static final int WM_MOUSELEAVE = 0x02A3;
78 private static final int WM_MOUSELEAVE = 0x02A3;
79 private static final int WM_ENTERSIZEMOVE = 0x0231;
80 private static final int WM_EXITSIZEMOVE = 0x0232;
81 private static final int WM_SIZING = 0x0214;
6982 private static final int WM_KEYDOWN = 256;
7083 private static final int WM_KEYUP = 257;
7184 private static final int WM_SYSKEYUP = 261;
7285 private static final int WM_SYSKEYDOWN = 260;
7386 private static final int WM_SYSCHAR = 262;
7487 private static final int WM_CHAR = 258;
88 private static final int WM_GETICON = 0x007F;
7589 private static final int WM_SETICON = 0x0080;
90 private static final int WM_SETCURSOR = 0x0020;
91 private static final int WM_MOUSEACTIVATE = 0x0021;
7692
7793 private static final int WM_QUIT = 0x0012;
7894 private static final int WM_SYSCOMMAND = 0x0112;
114130 private static final int WA_INACTIVE = 0;
115131 private static final int WA_ACTIVE = 1;
116132 private static final int WA_CLICKACTIVE = 2;
133 private static final int SW_NORMAL = 1;
117134 private static final int SW_SHOWMINNOACTIVE = 7;
118135 private static final int SW_SHOWDEFAULT = 10;
119136 private static final int SW_RESTORE = 9;
137 private static final int SW_MAXIMIZE = 3;
120138
121139 private static final int ICON_SMALL = 0;
122140 private static final int ICON_BIG = 1;
123141
124142 private static final IntBuffer rect_buffer = BufferUtils.createIntBuffer(4);
125143 private static final Rect rect = new Rect();
126 private static final Rect rect2 = new Rect();
144
145 private static final long HWND_TOP = 0;
146 private static final long HWND_BOTTOM = 1;
147 private static final long HWND_TOPMOST = -1;
148 private static final long HWND_NOTOPMOST = -2;
149
150 private static final int SWP_NOSIZE = 0x0001;
151 private static final int SWP_NOMOVE = 0x0002;
152 private static final int SWP_NOZORDER = 0x0004;
153 private static final int SWP_FRAMECHANGED = 0x0020;
154
155 private static final int GWL_STYLE = -16;
156 private static final int GWL_EXSTYLE = -20;
157
158 private static final int WS_THICKFRAME = 0x00040000;
159 private static final int WS_MAXIMIZEBOX = 0x00010000;
160
161 private static final int HTCLIENT = 0x01;
162
163 private static final int MK_XBUTTON1 = 0x0020;
164 private static final int MK_XBUTTON2 = 0x0040;
165 private static final int XBUTTON1 = 0x0001;
166 private static final int XBUTTON2 = 0x0002;
167
127168 private static WindowsDisplay current_display;
128169
129170 private static boolean cursor_clipped;
130171 private WindowsDisplayPeerInfo peer_info;
131172 private Object current_cursor;
173
174 private static boolean hasParent;
175
132176 private Canvas parent;
133 private static boolean hasParent;
177 private long parent_hwnd;
178 private FocusAdapter parent_focus_tracker;
179 private AtomicBoolean parent_focused;
134180
135181 private WindowsKeyboard keyboard;
136182 private WindowsMouse mouse;
145191 private boolean mode_set;
146192 private boolean isMinimized;
147193 private boolean isFocused;
148 private boolean did_maximize;
194 private boolean redoMakeContextCurrent;
149195 private boolean inAppActivate;
196 private boolean resized;
197 private boolean resizable;
198 private int x;
199 private int y;
200 private int width;
201 private int height;
150202
151203 private long hwnd;
152204 private long hdc;
153205
154206 private long small_icon;
155207 private long large_icon;
208 private boolean iconsLoaded;
156209
157210 private int captureMouse = -1;
158 private boolean trackingMouse;
159211 private boolean mouseInside;
212
213 static {
214 try {
215 Method windowProc = WindowsDisplay.class.getDeclaredMethod("handleMessage", long.class, int.class, long.class, long.class, long.class);
216 setWindowProc(windowProc);
217 } catch (NoSuchMethodException e) {
218 throw new RuntimeException(e);
219 }
220 }
160221
161222 WindowsDisplay() {
162223 current_display = this;
163224 }
164225
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;
226 public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
171227 this.parent = parent;
172228 hasParent = parent != null;
173 long parent_hwnd = parent != null ? getHwnd(parent) : 0;
229 parent_hwnd = parent != null ? getHwnd(parent) : 0;
174230 this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
231 if ( Display.isResizable() && parent == null ) {
232 setResizable(true);
233 }
234
175235 if (hwnd == 0) {
176236 throw new LWJGLException("Failed to create window");
177237 }
180240 nDestroyWindow(hwnd);
181241 throw new LWJGLException("Failed to get dc");
182242 }
243
183244 try {
184 int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, peer_info.getPixelFormat(), null, true, true, false, true);
185 WindowsPeerInfo.setPixelFormat(getHdc(), format);
245 if ( drawable instanceof DrawableGL ) {
246 int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, (PixelFormat)drawable.getPixelFormat(), null, true, true, false, true);
247 WindowsPeerInfo.setPixelFormat(getHdc(), format);
248 } else {
249 peer_info = new WindowsDisplayPeerInfo(true);
250 ((DrawableGLES)drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat());
251 }
186252 peer_info.initDC(getHwnd(), getHdc());
187253 showWindow(getHwnd(), SW_SHOWDEFAULT);
188 if (parent == null) {
254
255 updateWidthAndHeight();
256
257 if ( parent == null ) {
189258 setForegroundWindow(getHwnd());
190 setFocus(getHwnd());
191 }
259 } else {
260 parent_focused = new AtomicBoolean(false);
261 parent.addFocusListener(parent_focus_tracker = new FocusAdapter() {
262 public void focusGained(FocusEvent e) {
263 parent_focused.set(true);
264 clearAWTFocus();
265 }
266 });
267 SwingUtilities.invokeLater(new Runnable() {
268 public void run() {
269 clearAWTFocus();
270 }
271 });
272 }
273 grabFocus();
192274 } catch (LWJGLException e) {
193275 nReleaseDC(hwnd, hdc);
194276 nDestroyWindow(hwnd);
195277 throw e;
196278 }
197279 }
280
281 private void updateWidthAndHeight() {
282 getClientRect(hwnd, rect_buffer);
283 rect.copyFromBuffer(rect_buffer);
284 width = rect.right - rect.left;
285 height = rect.bottom - rect.top;
286 }
287
198288 private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException;
199289
200290 private static boolean isUndecorated() {
203293
204294 private static long getHwnd(Canvas parent) throws LWJGLException {
205295 AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
206 WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null);
296 WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null, null);
207297 ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
208298 try {
209299 return parent_peer_info.getHwnd();
213303 }
214304
215305 public void destroyWindow() {
306 if ( parent != null ) {
307 parent.removeFocusListener(parent_focus_tracker);
308 parent_focus_tracker = null;
309 }
310
216311 nReleaseDC(hwnd, hdc);
217312 nDestroyWindow(hwnd);
218313 freeLargeIcon();
219314 freeSmallIcon();
220315 resetCursorClipping();
316
317 // reset state
318 close_requested = false;
319 is_dirty = false;
320 isMinimized = false;
321 isFocused = false;
322 redoMakeContextCurrent = false;
323 mouseInside = false;
221324 }
222325 private static native void nReleaseDC(long hwnd, long hdc);
223326 private static native void nDestroyWindow(long hwnd);
260363 /*
261364 * Called when the application is alt-tabbed to or from
262365 */
263 private void appActivate(boolean active) {
366 private void appActivate(boolean active, long millis) {
264367 if (inAppActivate) {
265368 return;
266369 }
271374 restoreDisplayMode();
272375 }
273376 if (parent == null) {
274 showWindow(getHwnd(), SW_RESTORE);
275377 setForegroundWindow(getHwnd());
276 setFocus(getHwnd());
277 }
278 did_maximize = true;
378 }
379 setFocus(getHwnd());
380 redoMakeContextCurrent = true;
279381 if (Display.isFullscreen())
280382 updateClipping();
281 } else if (Display.isFullscreen()) {
282 showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
283 resetDisplayMode();
284 } else
285 updateClipping();
383 } else {
384 if ( keyboard != null )
385 keyboard.releaseAll(millis);
386 if ( Display.isFullscreen() ) {
387 showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
388 resetDisplayMode();
389 } else
390 updateClipping();
391 }
286392 updateCursor();
287393 inAppActivate = false;
288394 }
289395 private static native void showWindow(long hwnd, int mode);
290396 private static native void setForegroundWindow(long hwnd);
291397 private static native void setFocus(long hwnd);
398
399 private void clearAWTFocus() {
400 // This is needed so that the last focused component AWT remembers is NOT our Canvas
401 WindowsDisplay.this.parent.setFocusable(false);
402 WindowsDisplay.this.parent.setFocusable(true);
403
404 // Clear AWT focus owner
405 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
406 }
407
408 private void grabFocus() {
409 if ( parent == null )
410 setFocus(getHwnd());
411 else
412 SwingUtilities.invokeLater(new Runnable() {
413 public void run() {
414 parent.requestFocus();
415 }
416 });
417 }
292418
293419 private void restoreDisplayMode() {
294420 try {
394520 private static native DisplayMode getCurrentDisplayMode() throws LWJGLException;
395521
396522 public void setTitle(String title) {
397 nSetTitle(hwnd, title);
398 }
399 private static native void nSetTitle(long hwnd, String title);
523 ByteBuffer buffer = MemoryUtil.encodeUTF16(title);
524 nSetTitle(hwnd, MemoryUtil.getAddress0(buffer));
525 }
526 private static native void nSetTitle(long hwnd, long title);
400527
401528 public boolean isCloseRequested() {
402529 boolean saved = close_requested;
418545 return saved;
419546 }
420547
421 public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
422 peer_info = new WindowsDisplayPeerInfo(pixel_format);
548 public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
549 peer_info = new WindowsDisplayPeerInfo(false);
423550 return peer_info;
424551 }
425552
426553 public void update() {
427554 nUpdate();
428 if (parent != null && parent.isFocusOwner()) {
555
556 if ( !isFocused && parent != null && parent_focused.compareAndSet(true, false) ) {
429557 setFocus(getHwnd());
430558 }
431 if (did_maximize) {
432 did_maximize = false;
559
560 if (redoMakeContextCurrent) {
561 redoMakeContextCurrent = false;
433562 /**
434563 * WORKAROUND:
435564 * Making the context current (redundantly) when the window
472601 }
473602
474603 public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
475 mouse.poll(coord_buffer, buttons);
604 mouse.poll(coord_buffer, buttons, this);
476605 }
477606
478607 public void readMouse(ByteBuffer buffer) {
564693
565694 /* Keyboard */
566695 public void createKeyboard() throws LWJGLException {
567 keyboard = new WindowsKeyboard(getHwnd());
696 keyboard = new WindowsKeyboard();
568697 }
569698
570699 public void destroyKeyboard() {
571 keyboard.destroy();
572700 keyboard = null;
573701 }
574702
612740 return ((WindowsPbufferPeerInfo)handle).isBufferLost();
613741 }
614742
615 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
743 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs,
616744 IntBuffer pixelFormatCaps,
617745 IntBuffer pBufferAttribs) throws LWJGLException {
618746 return new WindowsPbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs);
667795 int size = icon.limit() / 4;
668796
669797 if ( (((int)Math.sqrt(size)) == small_icon_size) && (!done_small) ) {
798 long small_new_icon = createIcon(small_icon_size, small_icon_size, icon.asIntBuffer());
799 sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_new_icon);
670800 freeSmallIcon();
671 small_icon = createIcon(small_icon_size, small_icon_size, icon.asIntBuffer());
672 sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_icon);
801 small_icon = small_new_icon;
673802 used++;
674803 done_small = true;
675804 }
676805 if ( (((int)Math.sqrt(size)) == large_icon_size) && (!done_large) ) {
806 long large_new_icon = createIcon(large_icon_size, large_icon_size, icon.asIntBuffer());
807 sendMessage(hwnd, WM_SETICON, ICON_BIG, large_new_icon);
677808 freeLargeIcon();
678 large_icon = createIcon(large_icon_size, large_icon_size, icon.asIntBuffer());
679 sendMessage(hwnd, WM_SETICON, ICON_BIG, large_icon);
809 large_icon = large_new_icon;
680810 used++;
681811 done_large = true;
812
813 // Problem: The taskbar icon won't update until Windows sends a WM_GETICON to our window proc and we reply. But this method is usually called
814 // on init and it might take a while before the next call to nUpdate (because of resources being loaded, etc). So we wait for the next
815 // WM_GETICON message (usually received about 100ms after WM_SETICON) to make sure the taskbar icon has updated before we return to the user.
816 // (We wouldn't need to do this if the event loop was running continuously on its own thread.)
817 iconsLoaded = false;
818
819 // Track how long the wait takes and give up at 500ms, just in case.
820 long time = System.nanoTime();
821 long MAX_WAIT = 500L * 1000L * 1000L;
822 while ( true ) {
823 nUpdate();
824 if ( iconsLoaded || MAX_WAIT < System.nanoTime() - time )
825 break;
826
827 Thread.yield();
828 }
682829 }
683830 }
684831
687834 private static native long createIcon(int width, int height, IntBuffer icon);
688835 private static native void destroyIcon(long handle);
689836 private static native long sendMessage(long hwnd, long msg, long wparam, long lparam);
837 private static native long setWindowLongPtr(long hwnd, int nindex, long longPtr);
838 private static native long getWindowLongPtr(long hwnd, int nindex);
839 private static native boolean setWindowPos(long hwnd, long hwnd_after, int x, int y, int cx, int cy, long uflags);
690840
691841 private void handleMouseButton(int button, int state, long millis) {
692842 if (mouse != null) {
704854 nReleaseCapture();
705855 }
706856 }
707
708 if (parent != null && !isFocused) {
709 setFocus(getHwnd());
710 }
711857 }
712858
713859 private boolean shouldGrab() {
714860 return !isMinimized && isFocused && Mouse.isGrabbed();
715 }
716
717 private void handleMouseMoved(int x, int y, long millis) {
718 if (mouse != null) {
719 mouse.handleMouseMoved(x, y, millis, shouldGrab());
720 }
721861 }
722862
723863 private static native long nSetCapture(long hwnd);
735875 byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
736876 boolean repeat = state == previous_state;
737877 if (keyboard != null)
738 keyboard.handleChar((int)(wParam & 0xFF), millis, repeat);
878 keyboard.handleChar((int)(wParam & 0xFFFF), millis, repeat);
739879 }
740880
741881 private void handleKeyButton(long wParam, long lParam, long millis) {
882 if ( keyboard == null )
883 return;
884
742885 byte previous_state = (byte)((lParam >>> 30) & 0x1);
743886 byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
744887 boolean repeat = state == previous_state; // Repeat message
745888 byte extended = (byte)((lParam >>> 24) & 0x1);
746889 int scan_code = (int)((lParam >>> 16) & 0xFF);
747 if (keyboard != null) {
748 keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
749 }
890
891 keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
750892 }
751893
752894 private static int transformY(long hwnd, int y) {
757899
758900 private static native void clientToScreen(long hwnd, IntBuffer point);
759901
760 private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
902 private static native void setWindowProc(Method windowProc);
903
904 private static long handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
761905 if (current_display != null)
762906 return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
763907 else
764908 return defWindowProc(hwnd, msg, wParam, lParam);
765909 }
766910
767 private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam);
768
769 private void checkCursorState() {
770 updateClipping();
771 }
911 private static native long defWindowProc(long hwnd, int msg, long wParam, long lParam);
772912
773913 private void updateClipping() {
774914 if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && (getForegroundWindow() == getHwnd() || hasParent)) {
783923 }
784924
785925 private void setMinimized(boolean m) {
786 isMinimized = m;
787 checkCursorState();
788 }
789
790 private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
926 if ( m != isMinimized ) {
927 isMinimized = m;
928 updateClipping();
929 }
930 }
931
932 private long doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
933 /*switch ( msg ) {
934 case 0x0:
935 case 0x0020:
936 case 0x0084:
937 case WM_MOUSEMOVE:
938 break;
939 default:
940 WindowsEventDebug.printMessage(msg, wParam, lParam);
941 }*/
942
943 if ( parent != null && !isFocused ) {
944 switch ( msg ) {
945 case WM_LBUTTONDOWN:
946 case WM_RBUTTONDOWN:
947 case WM_MBUTTONDOWN:
948 case WM_XBUTTONDOWN:
949 sendMessage(parent_hwnd, msg, wParam, lParam);
950 }
951 }
952
791953 switch (msg) {
792954 // disable screen saver and monitor power down messages which wreak havoc
793955 case WM_ACTIVATE:
794 switch ((int)wParam) {
956 /*switch ((int)wParam) {
795957 case WA_ACTIVE:
796958 case WA_CLICKACTIVE:
797959 appActivate(true);
799961 case WA_INACTIVE:
800962 appActivate(false);
801963 break;
802 }
803 return 0;
964 }*/
965 return 0L;
804966 case WM_SIZE:
805967 switch ((int)wParam) {
806968 case SIZE_RESTORED:
807969 case SIZE_MAXIMIZED:
970 resized = true;
971 updateWidthAndHeight();
808972 setMinimized(false);
809973 break;
810974 case SIZE_MINIMIZED:
811975 setMinimized(true);
812976 break;
813977 }
814 return defWindowProc(hwnd, msg, wParam, lParam);
978 break;
979 case WM_SIZING:
980 resized = true;
981 updateWidthAndHeight();
982 break;
983 case WM_SETCURSOR:
984 if((lParam & 0xFFFF) == HTCLIENT) {
985 // if the cursor is inside the client area, reset it
986 // to the current LWJGL-cursor
987 updateCursor();
988 return -1; //TRUE
989 } else {
990 // let Windows handle cursors outside the client area for resizing, etc.
991 return defWindowProc(hwnd, msg, wParam, lParam);
992 }
815993 case WM_KILLFOCUS:
816 appActivate(false);
817 return 0;
994 appActivate(false, millis);
995 return 0L;
818996 case WM_SETFOCUS:
819 appActivate(true);
820 return 0;
997 appActivate(true, millis);
998 return 0L;
999 case WM_MOUSEACTIVATE:
1000 if ( parent != null ) {
1001 if ( !isFocused )
1002 grabFocus();
1003 return 3L; // MA_NOACTIVATE
1004 }
1005 break;
8211006 case WM_MOUSEMOVE:
822 int xPos = (int)(short)(lParam & 0xFFFF);
823 int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
824 handleMouseMoved(xPos, yPos, millis);
825 checkCursorState();
826 mouseInside = true;
827 if(!trackingMouse) {
828 trackingMouse = nTrackMouseEvent(hwnd);
829 }
830 return 0;
1007 if ( mouse != null ) {
1008 int xPos = (short)(lParam & 0xFFFF);
1009 int yPos = transformY(getHwnd(), (short)(lParam >>> 16));
1010 mouse.handleMouseMoved(xPos, yPos, millis);
1011 }
1012 if ( !mouseInside ) {
1013 mouseInside = true;
1014 updateClipping();
1015 nTrackMouseEvent(hwnd);
1016 }
1017 return 0L;
8311018 case WM_MOUSEWHEEL:
8321019 int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
8331020 handleMouseScrolled(dwheel, millis);
834 return 0;
1021 return 0L;
8351022 case WM_LBUTTONDOWN:
8361023 handleMouseButton(0, 1, millis);
837 return 0;
1024 return 0L;
8381025 case WM_LBUTTONUP:
8391026 handleMouseButton(0, 0, millis);
840 return 0;
1027 return 0L;
8411028 case WM_RBUTTONDOWN:
8421029 handleMouseButton(1, 1, millis);
843 return 0;
1030 return 0L;
8441031 case WM_RBUTTONUP:
8451032 handleMouseButton(1, 0, millis);
846 return 0;
1033 return 0L;
8471034 case WM_MBUTTONDOWN:
8481035 handleMouseButton(2, 1, millis);
849 return 0;
1036 return 0L;
8501037 case WM_MBUTTONUP:
8511038 handleMouseButton(2, 0, millis);
852 return 0;
1039 return 0L;
1040 case WM_XBUTTONUP:
1041 if((wParam >> 16) == XBUTTON1) {
1042 handleMouseButton(3, 0, millis);
1043 } else {
1044 handleMouseButton(4, 0, millis);
1045 }
1046 return 1;
1047 case WM_XBUTTONDOWN:
1048 if((wParam & 0xFF) == MK_XBUTTON1) {
1049 handleMouseButton(3, 1, millis);
1050 } else {
1051 handleMouseButton(4, 1, millis);
1052 }
1053 return 1;
8531054 case WM_SYSCHAR:
8541055 case WM_CHAR:
8551056 handleChar(wParam, lParam, millis);
856 return 0;
1057 return 0L;
8571058 case WM_SYSKEYUP:
1059 // Disable WM_SYSCOMMAND/SC_KEYMENU
1060 if ( wParam == WindowsKeycodes.VK_MENU || wParam == WindowsKeycodes.VK_F10 ) {
1061 handleKeyButton(wParam, lParam, millis);
1062 return 0L;
1063 }
8581064 /* Fall through */
8591065 case WM_KEYUP:
8601066 // SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN
8711077 /* Fall through */
8721078 case WM_KEYDOWN:
8731079 handleKeyButton(wParam, lParam, millis);
874 return defWindowProc(hwnd, msg, wParam, lParam);
1080 break;
8751081 case WM_QUIT:
8761082 close_requested = true;
877 return 0;
1083 return 0L;
8781084 case WM_SYSCOMMAND:
8791085 switch ((int)(wParam & 0xfff0)) {
880 case SC_KEYMENU:
881 case SC_MOUSEMENU:
8821086 case SC_SCREENSAVE:
8831087 case SC_MONITORPOWER:
884 return 0;
1088 return 0L;
8851089 case SC_CLOSE:
8861090 close_requested = true;
887 return 0;
888 default:
889 break;
890 }
891 return defWindowProc(hwnd, msg, wParam, lParam);
1091 return 0L;
1092 }
1093 break;
8921094 case WM_PAINT:
8931095 is_dirty = true;
894 return defWindowProc(hwnd, msg, wParam, lParam);
895 case WM_MOUSELEAVE:
896 mouseInside = false;
897 trackingMouse = false;
898 return defWindowProc(hwnd, msg, wParam, lParam);
1096 break;
1097 case WM_MOUSELEAVE:
1098 mouseInside = false;
1099 break;
8991100 case WM_CANCELMODE:
9001101 nReleaseCapture();
9011102 /* fall through */
9041105 handleMouseButton(captureMouse, 0, millis);
9051106 captureMouse = -1;
9061107 }
907 return 0;
908 default:
909 return defWindowProc(hwnd, msg, wParam, lParam);
910 }
1108 return 0L;
1109 case WM_WINDOWPOSCHANGED:
1110 if(getWindowRect(hwnd, rect_buffer)) {
1111 rect.copyFromBuffer(rect_buffer);
1112 x = rect.left;
1113 y = rect.top;
1114 } else {
1115 LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
1116 }
1117 break;
1118 case WM_GETICON:
1119 iconsLoaded = true;
1120 break;
1121 }
1122
1123 return defWindowProc(hwnd, msg, wParam, lParam);
1124 }
1125
1126 private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer);
1127
1128 public int getX() {
1129 return x;
1130 }
1131
1132 public int getY() {
1133 return y;
9111134 }
9121135
9131136 public int getWidth() {
914 return Display.getDisplayMode().getWidth();
1137 return width;
9151138 }
9161139
9171140 public int getHeight() {
918 return Display.getDisplayMode().getHeight();
919 }
920
921 private int firstMouseButtonDown() {
922 for(int i=0; i<Mouse.getButtonCount(); i++) {
923 if(Mouse.isButtonDown(i)) {
924 return i;
925 }
926 }
927 return -1;
928 }
929
930 private native boolean nTrackMouseEvent(long hwnd);
931
932 public boolean isInsideWindow() {
933 return mouseInside;
934 }
1141 return height;
1142 }
1143
1144 private native boolean nTrackMouseEvent(long hwnd);
1145
1146 public boolean isInsideWindow() {
1147 return mouseInside;
1148 }
1149
1150 public void setResizable(boolean resizable) {
1151 if ( this.resizable == resizable )
1152 return;
1153
1154 this.resized = false;
1155 this.resizable = resizable;
1156
1157 int style = (int)getWindowLongPtr(hwnd, GWL_STYLE);
1158 int styleex = (int)getWindowLongPtr(hwnd, GWL_EXSTYLE);
1159
1160 // update frame style
1161 setWindowLongPtr(
1162 hwnd,
1163 GWL_STYLE,
1164 style = resizable && !Display.isFullscreen()
1165 ? (style | (WS_THICKFRAME | WS_MAXIMIZEBOX))
1166 : (style & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))
1167 );
1168
1169 // from the existing client rect, determine the new window rect
1170 // based on the style changes - using AdjustWindowRectEx.
1171 getGlobalClientRect(hwnd, rect);
1172 rect.copyToBuffer(rect_buffer);
1173 adjustWindowRectEx(rect_buffer, style, false, styleex);
1174 rect.copyFromBuffer(rect_buffer);
1175
1176 // Apply the style changes
1177 setWindowPos(
1178 hwnd, 0L,
1179 rect.left,
1180 rect.top,
1181 rect.right - rect.left,
1182 rect.bottom - rect.top,
1183 SWP_NOZORDER | SWP_FRAMECHANGED
1184 );
1185
1186 updateWidthAndHeight();
1187 }
1188
1189 private native boolean adjustWindowRectEx(IntBuffer rectBuffer, int style, boolean menu, int styleex);
1190
1191 public boolean wasResized() {
1192 if(resized) {
1193 resized = false;
1194 return true;
1195 }
1196 return false;
1197 }
1198
1199 public float getPixelScaleFactor() {
1200 return 1f;
1201 }
9351202
9361203 private static final class Rect {
937 public int top;
938 public int bottom;
939 public int left;
940 public int right;
1204
1205 public int
1206 left,
1207 top,
1208 right,
1209 bottom;
9411210
9421211 public void copyToBuffer(IntBuffer buffer) {
943 buffer.put(0, top).put(1, bottom).put(2, left).put(3, right);
1212 buffer
1213 .put(0, left)
1214 .put(1, top)
1215 .put(2, right)
1216 .put(3, bottom);
9441217 }
9451218
9461219 public void copyFromBuffer(IntBuffer buffer) {
947 top = buffer.get(0);
948 bottom = buffer.get(1);
949 left = buffer.get(2);
950 right = buffer.get(3);
1220 left = buffer.get(0);
1221 top = buffer.get(1);
1222 right = buffer.get(2);
1223 bottom = buffer.get(3);
9511224 }
9521225
9531226 public void offset(int offset_x, int offset_y) {
9541227 left += offset_x;
1228 top += offset_y;
9551229 right += offset_x;
956 top += offset_y;
9571230 bottom += offset_y;
9581231 }
9591232
9601233 public static void intersect(Rect r1, Rect r2, Rect dst) {
1234 dst.left = Math.max(r1.left, r2.left);
9611235 dst.top = Math.max(r1.top, r2.top);
1236 dst.right = Math.min(r1.right, r2.right);
9621237 dst.bottom = Math.min(r1.bottom, r2.bottom);
963 dst.left = Math.max(r1.left, r2.left);
964 dst.right = Math.min(r1.right, r2.right);
9651238 }
9661239
9671240 public String toString() {
968 return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right;
1241 return "Rect: left = " + left + " top = " + top + " right = " + right + " bottom = " + bottom + ", width: " + (right - left) + ", height: " + (bottom - top);
9691242 }
9701243 }
9711244 }
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: WindowsDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
4343 final class WindowsDisplayPeerInfo extends WindowsPeerInfo {
44 private final PixelFormat pixel_format;
4544
46 WindowsDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
47 this.pixel_format = pixel_format;
48 GLContext.loadOpenGLLibrary();
49 }
45 final boolean egl;
5046
51 PixelFormat getPixelFormat() {
52 return pixel_format;
47 WindowsDisplayPeerInfo(boolean egl) throws LWJGLException {
48 this.egl = egl;
49
50 if ( egl)
51 org.lwjgl.opengles.GLContext.loadOpenGLLibrary();
52 else
53 GLContext.loadOpenGLLibrary();
5354 }
5455
5556 void initDC(long hwnd, long hdc) throws LWJGLException {
6768
6869 public void destroy() {
6970 super.destroy();
70 GLContext.unloadOpenGLLibrary();
71
72 if ( egl )
73 org.lwjgl.opengles.GLContext.unloadOpenGLLibrary();
74 else
75 GLContext.unloadOpenGLLibrary();
7176 }
7277 }
0 package org.lwjgl.opengl;
1
2 import org.lwjgl.LWJGLUtil;
3
4 final class WindowsEventDebug {
5
6 private WindowsEventDebug() {
7 }
8
9 static int printMessage(String msg, long wParam, long lParam) {
10 System.out.println(msg + ": 0x" + Long.toHexString(wParam).toUpperCase() + " | " + Long.toHexString(lParam).toUpperCase());
11 return 0;
12 }
13
14 static int printMessage(int msg, long wParam, long lParam) {
15 System.out.print(LWJGLUtil.toHexString(msg) + ": ");
16 switch ( msg ) {
17 case 0x0000:
18 return printMessage("WM_NULL", wParam, lParam);
19 case 0x0001:
20 return printMessage("WM_CREATE", wParam, lParam);
21 case 0x0002:
22 return printMessage("WM_DESTROY", wParam, lParam);
23 case 0x0003:
24 return printMessage("WM_MOVE", wParam, lParam);
25 case 0x0005:
26 return printMessage("WM_SIZE", wParam, lParam);
27 case 0x0006:
28 return printMessage("WM_ACTIVATE", wParam, lParam);
29 case 0x0007:
30 return printMessage("WM_SETFOCUS", wParam, lParam);
31 case 0x0008:
32 return printMessage("WM_KILLFOCUS", wParam, lParam);
33 case 0x000A:
34 return printMessage("WM_ENABLE", wParam, lParam);
35 case 0x000B:
36 return printMessage("WM_SETREDRAW", wParam, lParam);
37 case 0x000C:
38 return printMessage("WM_SETTEXT", wParam, lParam);
39 case 0x000D:
40 return printMessage("WM_GETTEXT", wParam, lParam);
41 case 0x000E:
42 return printMessage("WM_GETTEXTLENGTH", wParam, lParam);
43 case 0x000F:
44 return printMessage("WM_PAINT", wParam, lParam);
45 case 0x0010:
46 return printMessage("WM_CLOSE", wParam, lParam);
47 case 0x0011:
48 return printMessage("WM_QUERYENDSESSION", wParam, lParam);
49 case 0x0013:
50 return printMessage("WM_QUERYOPEN", wParam, lParam);
51 case 0x0016:
52 return printMessage("WM_ENDSESSION", wParam, lParam);
53 case 0x0012:
54 return printMessage("WM_QUIT", wParam, lParam);
55 case 0x0014:
56 return printMessage("WM_ERASEBKGND", wParam, lParam);
57 case 0x0015:
58 return printMessage("WM_SYSCOLORCHANGE", wParam, lParam);
59 case 0x0018:
60 return printMessage("WM_SHOWWINDOW", wParam, lParam);
61 case 0x001A:
62 return printMessage("WM_WININICHANGE", wParam, lParam);
63 case 0x001B:
64 return printMessage("WM_DEVMODECHANGE", wParam, lParam);
65 case 0x001C:
66 return printMessage("WM_ACTIVATEAPP", wParam, lParam);
67 case 0x001D:
68 return printMessage("WM_FONTCHANGE", wParam, lParam);
69 case 0x001E:
70 return printMessage("WM_TIMECHANGE", wParam, lParam);
71 case 0x001F:
72 return printMessage("WM_CANCELMODE", wParam, lParam);
73 case 0x0020:
74 return printMessage("WM_SETCURSOR", wParam, lParam);
75 case 0x0021:
76 return printMessage("WM_MOUSEACTIVATE", wParam, lParam);
77 case 0x0022:
78 return printMessage("WM_CHILDACTIVATE", wParam, lParam);
79 case 0x0023:
80 return printMessage("WM_QUEUESYNC", wParam, lParam);
81 case 0x0024:
82 return printMessage("WM_GETMINMAXINFO", wParam, lParam);
83 case 0x0026:
84 return printMessage("WM_PAINTICON", wParam, lParam);
85 case 0x0027:
86 return printMessage("WM_ICONERASEBKGND", wParam, lParam);
87 case 0x0028:
88 return printMessage("WM_NEXTDLGCTL", wParam, lParam);
89 case 0x002A:
90 return printMessage("WM_SPOOLERSTATUS", wParam, lParam);
91 case 0x002B:
92 return printMessage("WM_DRAWITEM", wParam, lParam);
93 case 0x002C:
94 return printMessage("WM_MEASUREITEM", wParam, lParam);
95 case 0x002D:
96 return printMessage("WM_DELETEITEM", wParam, lParam);
97 case 0x002E:
98 return printMessage("WM_VKEYTOITEM", wParam, lParam);
99 case 0x002F:
100 return printMessage("WM_CHARTOITEM", wParam, lParam);
101 case 0x0030:
102 return printMessage("WM_SETFONT", wParam, lParam);
103 case 0x0031:
104 return printMessage("WM_GETFONT", wParam, lParam);
105 case 0x0032:
106 return printMessage("WM_SETHOTKEY", wParam, lParam);
107 case 0x0033:
108 return printMessage("WM_GETHOTKEY", wParam, lParam);
109 case 0x0037:
110 return printMessage("WM_QUERYDRAGICON", wParam, lParam);
111 case 0x0039:
112 return printMessage("WM_COMPAREITEM", wParam, lParam);
113 case 0x003D:
114 return printMessage("WM_GETOBJECT", wParam, lParam);
115 case 0x0041:
116 return printMessage("WM_COMPACTING", wParam, lParam);
117 case 0x0044:
118 return printMessage("WM_COMMNOTIFY", wParam, lParam);
119 case 0x0046:
120 return printMessage("WM_WINDOWPOSCHANGING", wParam, lParam);
121 case 0x0047:
122 return printMessage("WM_WINDOWPOSCHANGED", wParam, lParam);
123 case 0x0048:
124 return printMessage("WM_POWER", wParam, lParam);
125 case 0x004A:
126 return printMessage("WM_COPYDATA", wParam, lParam);
127 case 0x004B:
128 return printMessage("WM_CANCELJOURNAL", wParam, lParam);
129 case 0x004E:
130 return printMessage("WM_NOTIFY", wParam, lParam);
131 case 0x0050:
132 return printMessage("WM_INPUTLANGCHANGEREQUEST", wParam, lParam);
133 case 0x0051:
134 return printMessage("WM_INPUTLANGCHANGE", wParam, lParam);
135 case 0x0052:
136 return printMessage("WM_TCARD", wParam, lParam);
137 case 0x0053:
138 return printMessage("WM_HELP", wParam, lParam);
139 case 0x0054:
140 return printMessage("WM_USERCHANGED", wParam, lParam);
141 case 0x0055:
142 return printMessage("WM_NOTIFYFORMAT", wParam, lParam);
143 case 0x007B:
144 return printMessage("WM_CONTEXTMENU", wParam, lParam);
145 case 0x007C:
146 return printMessage("WM_STYLECHANGING", wParam, lParam);
147 case 0x007D:
148 return printMessage("WM_STYLECHANGED", wParam, lParam);
149 case 0x007E:
150 return printMessage("WM_DISPLAYCHANGE", wParam, lParam);
151 case 0x007F:
152 return printMessage("WM_GETICON", wParam, lParam);
153 case 0x0080:
154 return printMessage("WM_SETICON", wParam, lParam);
155 case 0x0081:
156 return printMessage("WM_NCCREATE", wParam, lParam);
157 case 0x0082:
158 return printMessage("WM_NCDESTROY", wParam, lParam);
159 case 0x0083:
160 return printMessage("WM_NCCALCSIZE", wParam, lParam);
161 case 0x0084:
162 return printMessage("WM_NCHITTEST", wParam, lParam);
163 case 0x0085:
164 return printMessage("WM_NCPAINT", wParam, lParam);
165 case 0x0086:
166 return printMessage("WM_NCACTIVATE", wParam, lParam);
167 case 0x0087:
168 return printMessage("WM_GETDLGCODE", wParam, lParam);
169 case 0x0088:
170 return printMessage("WM_SYNCPAINT", wParam, lParam);
171 case 0x00A0:
172 return printMessage("WM_NCMOUSEMOVE", wParam, lParam);
173 case 0x00A1:
174 return printMessage("WM_NCLBUTTONDOWN", wParam, lParam);
175 case 0x00A2:
176 return printMessage("WM_NCLBUTTONUP", wParam, lParam);
177 case 0x00A3:
178 return printMessage("WM_NCLBUTTONDBLCLK", wParam, lParam);
179 case 0x00A4:
180 return printMessage("WM_NCRBUTTONDOWN", wParam, lParam);
181 case 0x00A5:
182 return printMessage("WM_NCRBUTTONUP", wParam, lParam);
183 case 0x00A6:
184 return printMessage("WM_NCRBUTTONDBLCLK", wParam, lParam);
185 case 0x00A7:
186 return printMessage("WM_NCMBUTTONDOWN", wParam, lParam);
187 case 0x00A8:
188 return printMessage("WM_NCMBUTTONUP", wParam, lParam);
189 case 0x00A9:
190 return printMessage("WM_NCMBUTTONDBLCLK", wParam, lParam);
191 case 0x00AB:
192 return printMessage("WM_NCXBUTTONDOWN", wParam, lParam);
193 case 0x00AC:
194 return printMessage("WM_NCXBUTTONUP", wParam, lParam);
195 case 0x00AD:
196 return printMessage("WM_NCXBUTTONDBLCLK", wParam, lParam);
197 case 0x00FE:
198 return printMessage("WM_INPUT_DEVICE_CHANGE", wParam, lParam);
199 case 0x00FF:
200 return printMessage("WM_INPUT", wParam, lParam);
201 case 0x0100:
202 return printMessage("WM_KEYDOWN", wParam, lParam);
203 case 0x0101:
204 return printMessage("WM_KEYUP", wParam, lParam);
205 case 0x0102:
206 return printMessage("WM_CHAR", wParam, lParam);
207 case 0x0103:
208 return printMessage("WM_DEADCHAR", wParam, lParam);
209 case 0x0104:
210 return printMessage("WM_SYSKEYDOWN", wParam, lParam);
211 case 0x0105:
212 return printMessage("WM_SYSKEYUP", wParam, lParam);
213 case 0x0106:
214 return printMessage("WM_SYSCHAR", wParam, lParam);
215 case 0x0107:
216 return printMessage("WM_SYSDEADCHAR", wParam, lParam);
217 case 0x0109:
218 return printMessage("WM_UNICHAR", wParam, lParam);
219 case 0xFFFF:
220 return printMessage("UNICODE_NOCHAR", wParam, lParam);
221 case 0x0108:
222 return printMessage("WM_KEYLAST", wParam, lParam);
223 case 0x010D:
224 return printMessage("WM_IME_STARTCOMPOSITION", wParam, lParam);
225 case 0x010E:
226 return printMessage("WM_IME_ENDCOMPOSITION", wParam, lParam);
227 case 0x010F:
228 return printMessage("WM_IME_COMPOSITION", wParam, lParam);
229 case 0x0110:
230 return printMessage("WM_INITDIALOG", wParam, lParam);
231 case 0x0111:
232 return printMessage("WM_COMMAND", wParam, lParam);
233 case 0x0112:
234 return printMessage("WM_SYSCOMMAND", wParam, lParam);
235 case 0x0113:
236 return printMessage("WM_TIMER", wParam, lParam);
237 case 0x0114:
238 return printMessage("WM_HSCROLL", wParam, lParam);
239 case 0x0115:
240 return printMessage("WM_VSCROLL", wParam, lParam);
241 case 0x0116:
242 return printMessage("WM_INITMENU", wParam, lParam);
243 case 0x0117:
244 return printMessage("WM_INITMENUPOPUP", wParam, lParam);
245 case 0x0119:
246 return printMessage("WM_GESTURE", wParam, lParam);
247 case 0x011A:
248 return printMessage("WM_GESTURENOTIFY", wParam, lParam);
249 case 0x011F:
250 return printMessage("WM_MENUSELECT", wParam, lParam);
251 case 0x0120:
252 return printMessage("WM_MENUCHAR", wParam, lParam);
253 case 0x0121:
254 return printMessage("WM_ENTERIDLE", wParam, lParam);
255 case 0x0122:
256 return printMessage("WM_MENURBUTTONUP", wParam, lParam);
257 case 0x0123:
258 return printMessage("WM_MENUDRAG", wParam, lParam);
259 case 0x0124:
260 return printMessage("WM_MENUGETOBJECT", wParam, lParam);
261 case 0x0125:
262 return printMessage("WM_UNINITMENUPOPUP", wParam, lParam);
263 case 0x0126:
264 return printMessage("WM_MENUCOMMAND", wParam, lParam);
265 case 0x0127:
266 return printMessage("WM_CHANGEUISTATE", wParam, lParam);
267 case 0x0128:
268 return printMessage("WM_UPDATEUISTATE", wParam, lParam);
269 case 0x0129:
270 return printMessage("WM_QUERYUISTATE", wParam, lParam);
271 case 0x0132:
272 return printMessage("WM_CTLCOLORMSGBOX", wParam, lParam);
273 case 0x0133:
274 return printMessage("WM_CTLCOLOREDIT", wParam, lParam);
275 case 0x0134:
276 return printMessage("WM_CTLCOLORLISTBOX", wParam, lParam);
277 case 0x0135:
278 return printMessage("WM_CTLCOLORBTN", wParam, lParam);
279 case 0x0136:
280 return printMessage("WM_CTLCOLORDLG", wParam, lParam);
281 case 0x0137:
282 return printMessage("WM_CTLCOLORSCROLLBAR", wParam, lParam);
283 case 0x0138:
284 return printMessage("WM_CTLCOLORSTATIC", wParam, lParam);
285 case 0x01E1:
286 return printMessage("MN_GETHMENU", wParam, lParam);
287 case 0x0200:
288 return printMessage("WM_MOUSEMOVE", wParam, lParam);
289 case 0x0201:
290 return printMessage("WM_LBUTTONDOWN", wParam, lParam);
291 case 0x0202:
292 return printMessage("WM_LBUTTONUP", wParam, lParam);
293 case 0x0203:
294 return printMessage("WM_LBUTTONDBLCLK", wParam, lParam);
295 case 0x0204:
296 return printMessage("WM_RBUTTONDOWN", wParam, lParam);
297 case 0x0205:
298 return printMessage("WM_RBUTTONUP", wParam, lParam);
299 case 0x0206:
300 return printMessage("WM_RBUTTONDBLCLK", wParam, lParam);
301 case 0x0207:
302 return printMessage("WM_MBUTTONDOWN", wParam, lParam);
303 case 0x0208:
304 return printMessage("WM_MBUTTONUP", wParam, lParam);
305 case 0x0209:
306 return printMessage("WM_MBUTTONDBLCLK", wParam, lParam);
307 case 0x020A:
308 return printMessage("WM_MOUSEWHEEL", wParam, lParam);
309 case 0x020B:
310 return printMessage("WM_XBUTTONDOWN", wParam, lParam);
311 case 0x020C:
312 return printMessage("WM_XBUTTONUP", wParam, lParam);
313 case 0x020D:
314 return printMessage("WM_XBUTTONDBLCLK", wParam, lParam);
315 case 0x020E:
316 return printMessage("WM_MOUSEHWHEEL", wParam, lParam);
317 case 0x0210:
318 return printMessage("WM_PARENTNOTIFY", wParam, lParam);
319 case 0x0211:
320 return printMessage("WM_ENTERMENULOOP", wParam, lParam);
321 case 0x0212:
322 return printMessage("WM_EXITMENULOOP", wParam, lParam);
323 case 0x0213:
324 return printMessage("WM_NEXTMENU", wParam, lParam);
325 case 0x0214:
326 return printMessage("WM_SIZING", wParam, lParam);
327 case 0x0215:
328 return printMessage("WM_CAPTURECHANGED", wParam, lParam);
329 case 0x0216:
330 return printMessage("WM_MOVING", wParam, lParam);
331 case 0x0218:
332 return printMessage("WM_POWERBROADCAST", wParam, lParam);
333 case 0x8013:
334 return printMessage("PBT_POWERSETTINGCHANGE", wParam, lParam);
335 case 0x0219:
336 return printMessage("WM_DEVICECHANGE", wParam, lParam);
337 case 0x0220:
338 return printMessage("WM_MDICREATE", wParam, lParam);
339 case 0x0221:
340 return printMessage("WM_MDIDESTROY", wParam, lParam);
341 case 0x0222:
342 return printMessage("WM_MDIACTIVATE", wParam, lParam);
343 case 0x0223:
344 return printMessage("WM_MDIRESTORE", wParam, lParam);
345 case 0x0224:
346 return printMessage("WM_MDINEXT", wParam, lParam);
347 case 0x0225:
348 return printMessage("WM_MDIMAXIMIZE", wParam, lParam);
349 case 0x0226:
350 return printMessage("WM_MDITILE", wParam, lParam);
351 case 0x0227:
352 return printMessage("WM_MDICASCADE", wParam, lParam);
353 case 0x0228:
354 return printMessage("WM_MDIICONARRANGE", wParam, lParam);
355 case 0x0229:
356 return printMessage("WM_MDIGETACTIVE", wParam, lParam);
357 case 0x0230:
358 return printMessage("WM_MDISETMENU", wParam, lParam);
359 case 0x0231:
360 return printMessage("WM_ENTERSIZEMOVE", wParam, lParam);
361 case 0x0232:
362 return printMessage("WM_EXITSIZEMOVE", wParam, lParam);
363 case 0x0233:
364 return printMessage("WM_DROPFILES", wParam, lParam);
365 case 0x0234:
366 return printMessage("WM_MDIREFRESHMENU", wParam, lParam);
367 case 0x0240:
368 return printMessage("WM_TOUCH", wParam, lParam);
369 case 0x0281:
370 return printMessage("WM_IME_SETCONTEXT", wParam, lParam);
371 case 0x0282:
372 return printMessage("WM_IME_NOTIFY", wParam, lParam);
373 case 0x0283:
374 return printMessage("WM_IME_CONTROL", wParam, lParam);
375 case 0x0284:
376 return printMessage("WM_IME_COMPOSITIONFULL", wParam, lParam);
377 case 0x0285:
378 return printMessage("WM_IME_SELECT", wParam, lParam);
379 case 0x0286:
380 return printMessage("WM_IME_CHAR", wParam, lParam);
381 case 0x0288:
382 return printMessage("WM_IME_REQUEST", wParam, lParam);
383 case 0x0290:
384 return printMessage("WM_IME_KEYDOWN", wParam, lParam);
385 case 0x0291:
386 return printMessage("WM_IME_KEYUP", wParam, lParam);
387 case 0x02A1:
388 return printMessage("WM_MOUSEHOVER", wParam, lParam);
389 case 0x02A3:
390 return printMessage("WM_MOUSELEAVE", wParam, lParam);
391 case 0x02A0:
392 return printMessage("WM_NCMOUSEHOVER", wParam, lParam);
393 case 0x02A2:
394 return printMessage("WM_NCMOUSELEAVE", wParam, lParam);
395 case 0x02B1:
396 return printMessage("WM_WTSSESSION_CHANGE", wParam, lParam);
397 case 0x02c0:
398 return printMessage("WM_TABLET_FIRST", wParam, lParam);
399 case 0x02df:
400 return printMessage("WM_TABLET_LAST", wParam, lParam);
401 case 0x0300:
402 return printMessage("WM_CUT", wParam, lParam);
403 case 0x0301:
404 return printMessage("WM_COPY", wParam, lParam);
405 case 0x0302:
406 return printMessage("WM_PASTE", wParam, lParam);
407 case 0x0303:
408 return printMessage("WM_CLEAR", wParam, lParam);
409 case 0x0304:
410 return printMessage("WM_UNDO", wParam, lParam);
411 case 0x0305:
412 return printMessage("WM_RENDERFORMAT", wParam, lParam);
413 case 0x0306:
414 return printMessage("WM_RENDERALLFORMATS", wParam, lParam);
415 case 0x0307:
416 return printMessage("WM_DESTROYCLIPBOARD", wParam, lParam);
417 case 0x0308:
418 return printMessage("WM_DRAWCLIPBOARD", wParam, lParam);
419 case 0x0309:
420 return printMessage("WM_PAINTCLIPBOARD", wParam, lParam);
421 case 0x030A:
422 return printMessage("WM_VSCROLLCLIPBOARD", wParam, lParam);
423 case 0x030B:
424 return printMessage("WM_SIZECLIPBOARD", wParam, lParam);
425 case 0x030C:
426 return printMessage("WM_ASKCBFORMATNAME", wParam, lParam);
427 case 0x030D:
428 return printMessage("WM_CHANGECBCHAIN", wParam, lParam);
429 case 0x030E:
430 return printMessage("WM_HSCROLLCLIPBOARD", wParam, lParam);
431 case 0x030F:
432 return printMessage("WM_QUERYNEWPALETTE", wParam, lParam);
433 case 0x0310:
434 return printMessage("WM_PALETTEISCHANGING", wParam, lParam);
435 case 0x0311:
436 return printMessage("WM_PALETTECHANGED", wParam, lParam);
437 case 0x0312:
438 return printMessage("WM_HOTKEY", wParam, lParam);
439 case 0x0317:
440 return printMessage("WM_PRINT", wParam, lParam);
441 case 0x0318:
442 return printMessage("WM_PRINTCLIENT", wParam, lParam);
443 case 0x0319:
444 return printMessage("WM_APPCOMMAND", wParam, lParam);
445 case 0x031A:
446 return printMessage("WM_THEMECHANGED", wParam, lParam);
447 case 0x031D:
448 return printMessage("WM_CLIPBOARDUPDATE", wParam, lParam);
449 case 0x031E:
450 return printMessage("WM_DWMCOMPOSITIONCHANGED", wParam, lParam);
451 case 0x031F:
452 return printMessage("WM_DWMNCRENDERINGCHANGED", wParam, lParam);
453 case 0x0320:
454 return printMessage("WM_DWMCOLORIZATIONCOLORCHANGED", wParam, lParam);
455 case 0x0321:
456 return printMessage("WM_DWMWINDOWMAXIMIZEDCHANGE", wParam, lParam);
457 case 0x0323:
458 return printMessage("WM_DWMSENDICONICTHUMBNAIL", wParam, lParam);
459 case 0x0326:
460 return printMessage("WM_DWMSENDICONICLIVEPREVIEWBITMAP", wParam, lParam);
461 case 0x033F:
462 return printMessage("WM_GETTITLEBARINFOEX", wParam, lParam);
463 case 0x0358:
464 return printMessage("WM_HANDHELDFIRST", wParam, lParam);
465 case 0x035F:
466 return printMessage("WM_HANDHELDLAST", wParam, lParam);
467 case 0x0360:
468 return printMessage("WM_AFXFIRST", wParam, lParam);
469 case 0x037F:
470 return printMessage("WM_AFXLAST", wParam, lParam);
471 case 0x0380:
472 return printMessage("WM_PENWINFIRST", wParam, lParam);
473 case 0x038F:
474 return printMessage("WM_PENWINLAST", wParam, lParam);
475 case 0x8000:
476 return printMessage("WM_APP", wParam, lParam);
477 default:
478 return printMessage("<UNKNOWN>", wParam, lParam);
479 }
480 }
481
482 }
3838 import java.nio.ByteBuffer;
3939 import java.nio.CharBuffer;
4040
41 import org.lwjgl.BufferUtils;
4241 import org.lwjgl.LWJGLException;
4342 import org.lwjgl.input.Keyboard;
4443
4544 final class WindowsKeyboard {
46 private static final int MAPVK_VK_TO_VSC = 0;
4745
48 private static final int BUFFER_SIZE = 50;
49
50 private final long hwnd;
51 private final ByteBuffer keyboard_state;
5246 private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
47 private final byte[] virt_key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
5348 private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE);
5449 private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
55
56 private boolean grabbed;
5750
5851 private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR
5952 private int retained_key_code;
6255 private long retained_millis;
6356 private boolean retained_repeat;
6457
65 WindowsKeyboard(long hwnd) throws LWJGLException {
66 this.hwnd = hwnd;
67 keyboard_state = BufferUtils.createByteBuffer(256);
58 WindowsKeyboard() throws LWJGLException {
6859 }
60
6961 private static native boolean isWindowsNT();
70
71 public void destroy() {
72 }
7362
7463 boolean isKeyDown(int lwjgl_keycode) {
7564 return key_down_buffer[lwjgl_keycode] == 1;
7665 }
7766
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 }
67 void poll(ByteBuffer keyDownBuffer) {
68 // Handle shift key release while both are pressed.
69 // Windows will not send an up event for the first button that was released in this case.
70 // There will only be one up event, for the last button only. We handle this problem
71 // here, using asynchronous state queries.
72 if ( isKeyDown(Keyboard.KEY_LSHIFT) && !isKeyPressedAsync(WindowsKeycodes.VK_LSHIFT) )
73 handleKey(WindowsKeycodes.VK_SHIFT, Keyboard.KEY_LSHIFT, false, (byte)0, 0L, false);
8974
90 public void poll(ByteBuffer keyDownBuffer) {
75 if ( isKeyDown(Keyboard.KEY_RSHIFT) && !isKeyPressedAsync(WindowsKeycodes.VK_RSHIFT) )
76 handleKey(WindowsKeycodes.VK_SHIFT, Keyboard.KEY_RSHIFT, false, (byte)0, 0L, false);
77
9178 int old_position = keyDownBuffer.position();
9279 keyDownBuffer.put(key_down_buffer);
9380 keyDownBuffer.position(old_position);
9784 private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags);
9885 private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags);
9986 private static native int GetKeyboardState(ByteBuffer lpKeyState);
100 private static native int GetKeyState(int virt_key);
87 private static native short GetKeyState(int virt_key);
88 private static native short GetAsyncKeyState(int virt_key);
10189
10290 private void putEvent(int keycode, byte state, int ch, long millis, boolean repeat) {
10391 tmp_event.clear();
10694 event_queue.putEvent(tmp_event);
10795 }
10896
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) {
97 private static int translateExtended(int virt_key, int scan_code, boolean extended) {
13398 switch (virt_key) {
13499 case WindowsKeycodes.VK_SHIFT:
135 return translateShift(scan_code, state);
100 return scan_code == 0x36 ? WindowsKeycodes.VK_RSHIFT : WindowsKeycodes.VK_LSHIFT;
136101 case WindowsKeycodes.VK_CONTROL:
137102 return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL;
138103 case WindowsKeycodes.VK_MENU:
149114 }
150115 }
151116
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);
117 private static boolean isKeyPressed(int state) {
118 return (state & 1) == 1;
119 }
120
121 private static boolean isKeyPressedAsync(int virt_key) {
122 return (GetAsyncKeyState(virt_key) & 0x8000) != 0;
123 }
124
125 /**
126 * This is called when the window loses focus: we release all currently pressed keys. If a key has been pressed (or hasn't been released at all), before we
127 * regain focus, we'll start receiving repeat press events. We'll treat the first of those as a non-repeat press.
128 */
129 void releaseAll(long millis) {
130 for ( int i = 0; i < virt_key_down_buffer.length; i++ ) {
131 if ( isKeyPressed(virt_key_down_buffer[i]) ) {
132 handleKey(i, 0, false, (byte)0, millis, false);
133 }
134 }
135 }
136
137 void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) {
138 virt_key = translateExtended(virt_key, scan_code, extended);
139 if ( !repeat && isKeyPressed(event_state) == isKeyPressed(virt_key_down_buffer[virt_key]) )
140 return;
141
154142 flushRetained();
155143 has_retained_event = true;
156144 int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key);
157 if (keycode < key_down_buffer.length)
145 if (keycode < key_down_buffer.length) {
158146 key_down_buffer[keycode] = event_state;
147 repeat &= isKeyPressed(virt_key_down_buffer[virt_key]); // Treat the first repeat event after releaseAll() as a non-repeat press.
148 virt_key_down_buffer[virt_key] = event_state;
149 }
159150 retained_key_code = keycode;
160151 retained_state = event_state;
161152 retained_millis = millis;
163154 retained_repeat = repeat;
164155 }
165156
166 public void handleChar(int event_char, long millis, boolean repeat) {
157 void handleChar(int event_char, long millis, boolean repeat) {
167158 if (has_retained_event && retained_char != 0)
168159 flushRetained();
169160 if (!has_retained_event) {
172163 retained_char = event_char;
173164 }
174165
175 public void read(ByteBuffer buffer) {
166 void read(ByteBuffer buffer) {
176167 flushRetained();
177168 event_queue.copyEvents(buffer);
178169 }
6464
6565 WindowsMouse(long hwnd) throws LWJGLException {
6666 this.hwnd = hwnd;
67 this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS);
67 this.mouse_button_count = Math.min(5, WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS));
6868 this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0;
6969 this.blank_cursor = createBlankCursor();
7070 this.button_states = new byte[mouse_button_count];
8989 return mouse_button_count;
9090 }
9191
92 public void poll(IntBuffer coord_buffer, ByteBuffer buttons) {
92 public void poll(IntBuffer coord_buffer, ByteBuffer buttons, WindowsDisplay display) {
9393 for (int i = 0; i < coord_buffer.remaining(); i++)
9494 coord_buffer.put(coord_buffer.position() + i, 0);
9595 int num_buttons = mouse_button_count;
102102 if (isGrabbed()) {
103103 coord_buffer.put(coord_buffer.position() + 0, accum_dx);
104104 coord_buffer.put(coord_buffer.position() + 1, accum_dy);
105
106 if ( display.isActive() && display.isVisible() && (accum_dx != 0 || accum_dy != 0) )
107 centerCursor();
105108 } else {
106109 coord_buffer.put(coord_buffer.position() + 0, last_x);
107110 coord_buffer.put(coord_buffer.position() + 1, last_y);
171174 WindowsDisplay.doDestroyCursor(blank_cursor);
172175 }
173176
174 public void handleMouseMoved(int x, int y, long millis, boolean should_center) {
177 public void handleMouseMoved(int x, int y, long millis) {
175178 int dx = x - last_x;
176179 int dy = y - last_y;
177180 if (dx != 0 || dy != 0) {
182185 long nanos = millis*1000000;
183186 if (mouse_grabbed) {
184187 putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
185 if (should_center)
186 centerCursor();
187188 } else {
188189 putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
189190 }
3838 /**
3939 *
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 final class WindowsPbufferPeerInfo extends WindowsPeerInfo {
4545 WindowsPbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException {
3838 /**
3939 *
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 abstract class WindowsPeerInfo extends PeerInfo {
4545 protected WindowsPeerInfo() {
2626
2727 package org.lwjgl.opengl;
2828
29 import org.lwjgl.LWJGLUtil;
30
2931 import java.io.BufferedReader;
3032 import java.io.IOException;
3133 import java.io.InputStreamReader;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
34 import java.util.*;
3635 import java.util.regex.Matcher;
3736 import java.util.regex.Pattern;
38
39 import org.lwjgl.LWJGLUtil;
4037
4138 /**
4239 * Utility for working with the xrandr commmand-line utility. Assumes
4441 *
4542 * @author ryanm
4643 */
47 public class XRandR
48 {
44 public class XRandR {
45
4946 private static Screen[] current;
5047
48 /**
49 * Either the screen marked as "primary" (if it is turned on)
50 * or the one with the largest (current) resolution.
51 */
52 private static String primaryScreenIdentifier;
53
54 /**
55 * Used to save the configuration of all output devices to
56 * restore it on exit or in case of crash.
57 */
58 private static Screen[] savedConfiguration;
59
5160 private static Map<String, Screen[]> screens;
5261
53 private static void populate()
54 {
55 if( screens == null )
56 {
57 screens = new HashMap<String, Screen[]>();
58
59 // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" );
60 // pb.redirectErrorStream();
61 try
62 {
63 // Process p= pb.start();
64 Process p = Runtime.getRuntime().exec( new String[] { "xrandr", "-q" } );
65
66 List<Screen> currentList = new ArrayList<Screen>();
67 List<Screen> possibles = new ArrayList<Screen>();
68 String name = null;
69
70 BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
71 String line;
72 while( ( line = br.readLine() ) != null )
73 {
74 line = line.trim();
75 String[] sa = line.split( "\\s+" );
76
77 if( "connected".equals(sa[1]) )
78 {
79 // found a new screen block
80 if( name != null )
81 {
82 screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) );
83 possibles.clear();
84 }
85 name = sa[ 0 ];
86
87 // record the current config
88 parseScreen( currentList, name, sa[ 2 ] );
89 }
90 else if( Pattern.matches( "\\d*x\\d*", sa[ 0 ] ) )
91 {
62 private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");
63
64 private static void populate() {
65 if ( screens != null )
66 return;
67
68 screens = new HashMap<String, Screen[]>();
69
70 try {
71 Process p = Runtime.getRuntime().exec(new String[] { "xrandr", "-q" });
72
73 List<Screen> currentList = new ArrayList<Screen>();
74 List<Screen> possibles = new ArrayList<Screen>();
75 String name = null;
76 // saves the position of the current screen. this is specified in the header of the screen block,
77 // but required later when parsing the screen modelines
78 int[] currentScreenPosition = new int[2];
79
80 BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
81 String line;
82 while ( (line = br.readLine()) != null ) {
83 line = line.trim();
84 String[] sa = WHITESPACE_PATTERN.split(line);
85
86 if ( "connected".equals(sa[1]) ) {
87 // found a new screen block
88 if ( name != null ) {
89 screens.put(name, possibles.toArray(new Screen[possibles.size()]));
90 possibles.clear();
91 }
92 name = sa[0];
93
94 // save position of this screen, will be used later when current modeline is parsed
95 if ( "primary".equals(sa[2]) ) {
96 parseScreenHeader(currentScreenPosition, sa[3]);
97 // save primary
98 primaryScreenIdentifier = name;
99 } else {
100 parseScreenHeader(currentScreenPosition, sa[2]);
101 }
102 } else {
103 Matcher m = SCREEN_MODELINE_PATTERN.matcher(sa[0]);
104 if ( m.matches() ) {
92105 // found a new mode line
93 parseScreen( possibles, name, sa[ 0 ] );
106 parseScreenModeline(
107 possibles, currentList, name,
108 Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)),
109 sa, currentScreenPosition
110 );
94111 }
95112 }
96
97 screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) );
98
99 current = currentList.toArray(new Screen[currentList.size()]);
100 }
101 catch( Throwable e )
102 {
103 LWJGLUtil.log( "Exception in XRandR.populate(): " + e.getMessage() );
104 screens.clear();
105 current = new Screen[ 0 ];
106 }
107 }
108 }
109
110 /**
111 * @return The current screen configuration, or an empty array if
112 * xrandr is not supported
113 */
114 public static Screen[] getConfiguration()
115 {
116 populate();
117
113 }
114
115 screens.put(name, possibles.toArray(new Screen[possibles.size()]));
116
117 current = currentList.toArray(new Screen[currentList.size()]);
118
119 // set primary to largest screen if not set yet
120 if ( primaryScreenIdentifier == null ) {
121 long totalPixels = Long.MIN_VALUE;
122 for ( Screen screen : current ) {
123 if ( 1l * screen.width * screen.height > totalPixels ) {
124 primaryScreenIdentifier = screen.name;
125 totalPixels = 1l * screen.width * screen.height;
126 }
127 }
128 }
129 } catch (Throwable e) {
130 LWJGLUtil.log("Exception in XRandR.populate(): " + e.getMessage());
131 screens.clear();
132 current = new Screen[0];
133 }
134 }
135
136 /**
137 * @return The current screen configuration of the primary device,
138 * or an empty array if xrandr is not supported
139 */
140 public static Screen[] getConfiguration() {
141 populate();
142
143 // find and return primary
144 for ( Screen screen : current ) {
145 if ( screen.name.equals(primaryScreenIdentifier) ) {
146 return new Screen[] { screen };
147 }
148 }
149
150 // problem with primary device, fall back to old behaviour
118151 return current.clone();
119152 }
120153
121154 /**
122 * @param screens
123 * The desired screen set, may not be <code>null</code>
124 * @throws IllegalArgumentException
125 * if no screens are specified
126 */
127 public static void setConfiguration(Screen... screens)
128 {
129 if( screens.length == 0 )
130 throw new IllegalArgumentException( "Must specify at least one screen" );
155 * @param disableOthers if screens not included in screens should be turned off (true) or left alone (false)
156 * @param screens The desired screen set, may not be <code>null</code>
157 *
158 * @throws IllegalArgumentException if no screens are specified
159 */
160 public static void setConfiguration(boolean disableOthers, Screen... screens) {
161 if ( screens.length == 0 )
162 throw new IllegalArgumentException("Must specify at least one screen");
131163
132164 List<String> cmd = new ArrayList<String>();
133 cmd.add( "xrandr" );
134
135 // switch off those in the current set not in the new set
136 for ( Screen screen : current ) {
137 boolean found = false;
138 for ( Screen screen1 : screens ) {
139 if ( screen1.name.equals(screen.name) ) {
140 found = true;
141 break;
165 cmd.add("xrandr");
166
167 if ( disableOthers ) {
168 // switch off those in the current set not in the new set
169 for ( Screen screen : current ) {
170 boolean disable = true;
171 for ( Screen screen1 : screens ) {
172 if ( screen1.name.equals(screen.name) ) {
173 disable = false;
174 break;
175 }
142176 }
143 }
144
145 if ( !found ) {
146 cmd.add("--output");
147 cmd.add(screen.name);
148 cmd.add("--off");
177
178 if ( disable ) {
179 cmd.add("--output");
180 cmd.add(screen.name);
181 cmd.add("--off");
182 }
149183 }
150184 }
151185
153187 for ( Screen screen : screens )
154188 screen.getArgs(cmd);
155189
156 try
157 {
158 // ProcessBuilder pb = new ProcessBuilder( cmd );
159 // pb.redirectErrorStream();
160 // Process p = pb.start();
161 Process p =
162 Runtime.getRuntime().exec( cmd.toArray( new String[ cmd.size() ] ) );
190 try {
191 Process p = Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
163192 // no output is expected, but check anyway
164 BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
193 BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
165194 String line;
166 while( ( line = br.readLine() ) != null )
167 {
168 LWJGLUtil.log( "Unexpected output from xrandr process: " + line );
195 while ( (line = br.readLine()) != null ) {
196 LWJGLUtil.log("Unexpected output from xrandr process: " + line);
169197 }
170198 current = screens;
171 }
172 catch( IOException e )
173 {
174 LWJGLUtil.log( "XRandR exception in setConfiguration(): " + e.getMessage() );
199 } catch (IOException e) {
200 LWJGLUtil.log("XRandR exception in setConfiguration(): " + e.getMessage());
201 }
202 }
203
204 /**
205 * Saves the current configuration for all connected display devices.
206 * This configuration can be restored on exit/crash by calling
207 * restoreConfiguration()
208 */
209 public static void saveConfiguration() {
210 populate();
211 savedConfiguration = current.clone();
212 }
213
214 /**
215 * Restores the configuration for all connected display devices.
216 * Used on exit or in case of a crash to reset all devices.
217 */
218 public static void restoreConfiguration() {
219 if ( savedConfiguration != null ) {
220 setConfiguration(true, savedConfiguration);
175221 }
176222 }
177223
178224 /**
179225 * @return the name of connected screens, or an empty array if
180 * xrandr is not supported
181 */
182 public static String[] getScreenNames()
183 {
184 populate();
185 return screens.keySet().toArray( new String[ screens.size() ] );
226 * xrandr is not supported
227 */
228 public static String[] getScreenNames() {
229 populate();
230 return screens.keySet().toArray(new String[screens.size()]);
186231 }
187232
188233 /**
189234 * @param name
235 *
190236 * @return the possible resolutions of the named screen, or
191 * <code>null</code> if there is no such screen
192 */
193 public static Screen[] getResolutions( String name )
194 {
237 * <code>null</code> if there is no such screen
238 */
239 public static Screen[] getResolutions(String name) {
195240 populate();
196241 // clone the array to prevent held copies being altered
197242 return screens.get(name).clone();
198243 }
199244
200 private static final Pattern SCREEN_PATTERN1 =
201 Pattern.compile( "^(\\d+)x(\\d+)\\+(\\d+)\\+(\\d+)$" );
202
203 private static final Pattern SCREEN_PATTERN2 = Pattern.compile( "^(\\d+)x(\\d+)$" );
204
205 /**
206 * Parses a screen configuration and adds it to the list if it's
207 * valid.
208 *
209 * @param list
210 * the list to add the Screen to if it's valid
211 * @param name
212 * the name of this screen
213 * @param what
214 * config string, format either widthxheight or
215 * widthxheight+xPos+yPos
216 */
217 private static void parseScreen( List<Screen> list, String name, String what )
218 {
219 Matcher m = SCREEN_PATTERN1.matcher( what );
220 if( !m.matches() )
221 {
222 m = SCREEN_PATTERN2.matcher( what );
223 if( !m.matches() )
224 {
225 LWJGLUtil.log( "Did not match: " + what );
245 private static final Pattern SCREEN_HEADER_PATTERN = Pattern.compile("^(\\d+)x(\\d+)[+](\\d+)[+](\\d+)$");
246 private static final Pattern SCREEN_MODELINE_PATTERN = Pattern.compile("^(\\d+)x(\\d+)$");
247 private static final Pattern FREQ_PATTERN = Pattern.compile("^(\\d+)[.](\\d+)(?:\\s*[*])?(?:\\s*[+])?$");
248
249 /**
250 * Parses a screen configuration and adds it to one of the lists if valid.
251 *
252 * @param allModes the list to add the Screen to if it's valid
253 * @param current the list to add the current screen config to
254 * @param name the name of this screen
255 * @param modeLine config string
256 * @param screenPosition position of this screen
257 */
258 private static void parseScreenModeline(List<Screen> allModes, List<Screen> current, String name, int width, int height, String[] modeLine, int[] screenPosition) {
259 for ( int i = 1; i < modeLine.length; i++ ) {
260 String freqS = modeLine[i];
261 if ( "+".equals(freqS) ) {
262 // previous rate was the "preferred" refresh rate
263 // no way to get this info to the application, so ignore it
264 continue;
265 }
266
267 Matcher m = FREQ_PATTERN.matcher(freqS);
268 if ( !m.matches() ) {
269 LWJGLUtil.log("Frequency match failed: " + Arrays.toString(modeLine));
226270 return;
227271 }
228 }
229 int width = Integer.parseInt( m.group( 1 ) );
230 int height = Integer.parseInt( m.group( 2 ) );
231 int xpos, ypos;
232 if( m.groupCount() > 3 )
233 {
234 xpos = Integer.parseInt( m.group( 3 ) );
235 ypos = Integer.parseInt( m.group( 4 ) );
236 }
237 else
238 {
239 xpos = 0;
240 ypos = 0;
241 }
242 list.add( new Screen( name, width, height, xpos, ypos ) );
243 }
244
245 /**
246 * Encapsulates the configuration of a monitor. Resolution is
247 * fixed, position is mutable
272
273 int freq = Integer.parseInt(m.group(1));
274
275 Screen s = new Screen(name, width, height, freq, 0, 0);
276 if ( freqS.contains("*") ) {
277 // current mode, save to current list with screen position
278 current.add(new Screen(name, width, height, freq, screenPosition[0], screenPosition[1]));
279 // make sure the current mode is always first
280 allModes.add(0, s);
281 } else {
282 // always add to List of all modes without screen position
283 allModes.add(s);
284 }
285 }
286 }
287
288 /**
289 * Parses a screen configuration header and extracts information about the position of the screen.
290 *
291 * @param screenPosition the int-array to write the position into
292 * @param resPos String containing resolution and position, from xrandr
293 */
294 private static void parseScreenHeader(int[] screenPosition, String resPos) {
295 Matcher m = SCREEN_HEADER_PATTERN.matcher(resPos);
296 if ( !m.matches() ) {
297 // screen not active!
298 screenPosition[0] = 0;
299 screenPosition[1] = 0;
300 return;
301 }
302 screenPosition[0] = Integer.parseInt(m.group(3));
303 screenPosition[1] = Integer.parseInt(m.group(4));
304 }
305
306 static Screen DisplayModetoScreen(DisplayMode mode) {
307 populate();
308 Screen primary = findPrimary(current);
309 return new Screen(primary.name, mode.getWidth(), mode.getHeight(), mode.getFrequency(), primary.xPos, primary.yPos);
310 }
311
312 static DisplayMode ScreentoDisplayMode(Screen... screens) {
313 populate();
314 Screen primary = findPrimary(screens);
315 return new DisplayMode(primary.width, primary.height, 24, primary.freq);
316 }
317
318 private static Screen findPrimary(Screen... screens) {
319 for ( Screen screen : screens ) {
320 if ( screen.name.equals(primaryScreenIdentifier) ) {
321 return screen;
322 }
323 }
324 // fallback
325 return screens[0];
326 }
327
328 /**
329 * Encapsulates the configuration of a monitor.
330 * Resolution and freq are fixed, position is mutable
248331 *
249332 * @author ryanm
250333 */
251 public static class Screen implements Cloneable
252 {
253 /**
254 * Name for this output
255 */
334 public static class Screen implements Cloneable {
335 /** Name for this output */
256336 public final String name;
257337
258 /**
259 * Width in pixels
260 */
338 /** Width in pixels */
261339 public final int width;
262340
263 /**
264 * Height in pixels
265 */
341 /** Height in pixels */
266342 public final int height;
267343
268 /**
269 * Position on the x-axis, in pixels
270 */
344 /** Frequency in Hz */
345 public final int freq;
346
347 /** Position on the x-axis, in pixels */
271348 public int xPos;
272349
273 /**
274 * Position on the y-axis, in pixels
275 */
350 /** Position on the y-axis, in pixels */
276351 public int yPos;
277352
278 private Screen( String name, int width, int height, int xPos, int yPos )
279 {
353 Screen(String name, int width, int height, int freq, int xPos, int yPos) {
280354 this.name = name;
281355 this.width = width;
282356 this.height = height;
357 this.freq = freq;
283358 this.xPos = xPos;
284359 this.yPos = yPos;
285360 }
286361
287 private void getArgs( List<String> argList )
288 {
289 argList.add( "--output" );
290 argList.add( name );
291 argList.add( "--mode" );
292 argList.add( width + "x" + height );
293 argList.add( "--pos" );
294 argList.add( xPos + "x" + yPos );
362 private void getArgs(List<String> argList) {
363 argList.add("--output");
364 argList.add(name);
365 argList.add("--mode");
366 argList.add(width + "x" + height);
367 argList.add("--rate");
368 argList.add(Integer.toString(freq));
369 argList.add("--pos");
370 argList.add(xPos + "x" + yPos);
295371 }
296372
297373 //@Override
298 public String toString()
299 {
300 return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos;
374 public String toString() {
375 return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos + " with " + freq + "Hz";
301376 }
302377 }
303378 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.MemoryUtil;
36 import org.lwjgl.PointerBuffer;
37
38 import java.nio.ByteBuffer;
39 import java.nio.FloatBuffer;
40 import java.nio.IntBuffer;
41 import java.nio.LongBuffer;
42
43 /**
44 * Utility class for OpenGL ES API calls.
45 *
46 * @author spasi
47 */
48 final class APIUtil {
49
50 private static final int INITIAL_BUFFER_SIZE = 256;
51 private static final int INITIAL_LENGTHS_SIZE = 4;
52
53 private static final int BUFFERS_SIZE = 32;
54
55 private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() {
56 protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
57 };
58
59 private static final ThreadLocal<ByteBuffer> bufferTL = new ThreadLocal<ByteBuffer>() {
60 protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
61 };
62
63 private static final ThreadLocal<PointerBuffer> bufferPointerTL = new ThreadLocal<PointerBuffer>() {
64 protected PointerBuffer initialValue() { return BufferUtils.createPointerBuffer(INITIAL_BUFFER_SIZE); }
65 };
66
67 private static final ThreadLocal<IntBuffer> lengthsTL = new ThreadLocal<IntBuffer>() {
68 protected IntBuffer initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); }
69 };
70
71 private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() {
72 protected Buffers initialValue() { return new Buffers(); }
73 };
74
75 private APIUtil() {
76 }
77
78 private static char[] getArray(final int size) {
79 char[] array = arrayTL.get();
80
81 if ( array.length < size ) {
82 int sizeNew = array.length << 1;
83 while ( sizeNew < size )
84 sizeNew <<= 1;
85
86 array = new char[size];
87 arrayTL.set(array);
88 }
89
90 return array;
91 }
92
93 static ByteBuffer getBufferByte(final int size) {
94 ByteBuffer buffer = bufferTL.get();
95
96 if ( buffer.capacity() < size ) {
97 int sizeNew = buffer.capacity() << 1;
98 while ( sizeNew < size )
99 sizeNew <<= 1;
100
101 buffer = BufferUtils.createByteBuffer(size);
102 bufferTL.set(buffer);
103 } else
104 buffer.clear();
105
106 return buffer;
107 }
108
109 private static ByteBuffer getBufferByteOffset(final int size) {
110 ByteBuffer buffer = bufferTL.get();
111
112 if ( buffer.capacity() < size ) {
113 int sizeNew = buffer.capacity() << 1;
114 while ( sizeNew < size )
115 sizeNew <<= 1;
116
117 final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
118 bufferNew.put(buffer);
119 bufferTL.set(buffer = bufferNew);
120 } else {
121 buffer.position(buffer.limit());
122 buffer.limit(buffer.capacity());
123 }
124
125 return buffer;
126 }
127
128 static PointerBuffer getBufferPointer(final int size) {
129 PointerBuffer buffer = bufferPointerTL.get();
130
131 if ( buffer.capacity() < size ) {
132 int sizeNew = buffer.capacity() << 1;
133 while ( sizeNew < size )
134 sizeNew <<= 1;
135
136 buffer = BufferUtils.createPointerBuffer(size);
137 bufferPointerTL.set(buffer);
138 } else
139 buffer.clear();
140
141 return buffer;
142 }
143
144 static IntBuffer getBufferInt() { return buffersTL.get().ints; }
145
146 static LongBuffer getBufferLong() { return buffersTL.get().longs; }
147
148 static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
149
150 static IntBuffer getLengths() {
151 return getLengths(1);
152 }
153
154 static IntBuffer getLengths(final int size) {
155 IntBuffer lengths = lengthsTL.get();
156
157 if ( lengths.capacity() < size ) {
158 int sizeNew = lengths.capacity();
159 while ( sizeNew < size )
160 sizeNew <<= 1;
161
162 lengths = BufferUtils.createIntBuffer(size);
163 lengthsTL.set(lengths);
164 } else
165 lengths.clear();
166
167 return lengths;
168 }
169
170 /**
171 * Simple ASCII encoding.
172 *
173 * @param buffer The target buffer
174 * @param string The source string
175 */
176 private static ByteBuffer encode(final ByteBuffer buffer, final CharSequence string) {
177 for ( int i = 0; i < string.length(); i++ ) {
178 final char c = string.charAt(i);
179 if ( LWJGLUtil.DEBUG && 0x80 <= c ) // Silently ignore and map to 0x1A.
180 buffer.put((byte)0x1A);
181 else
182 buffer.put((byte)c);
183 }
184
185 return buffer;
186 }
187
188 /**
189 * Reads a byte string from the specified buffer.
190 *
191 * @param buffer
192 *
193 * @return the buffer as a String.
194 */
195 static String getString(final ByteBuffer buffer) {
196 final int length = buffer.remaining();
197 final char[] charArray = getArray(length);
198
199 for ( int i = buffer.position(); i < buffer.limit(); i++ )
200 charArray[i - buffer.position()] = (char)buffer.get(i);
201
202 return new String(charArray, 0, length);
203 }
204
205 /**
206 * Returns a buffer containing the specified string as bytes.
207 *
208 * @param string
209 *
210 * @return the String as a ByteBuffer
211 */
212 static long getBuffer(final CharSequence string) {
213 final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
214 buffer.flip();
215 return MemoryUtil.getAddress0(buffer);
216 }
217
218 /**
219 * Returns a buffer containing the specified string as bytes, starting at the specified offset.
220 *
221 * @param string
222 *
223 * @return the String as a ByteBuffer
224 */
225 static long getBuffer(final CharSequence string, final int offset) {
226 final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
227 buffer.flip();
228 return MemoryUtil.getAddress(buffer);
229 }
230
231 /**
232 * Returns a buffer containing the specified string as bytes, including null-termination.
233 *
234 * @param string
235 *
236 * @return the String as a ByteBuffer
237 */
238 static long getBufferNT(final CharSequence string) {
239 final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
240 buffer.put((byte)0);
241 buffer.flip();
242 return MemoryUtil.getAddress0(buffer);
243 }
244
245 static int getTotalLength(final CharSequence[] strings) {
246 int length = 0;
247 for ( CharSequence string : strings )
248 length += string.length();
249
250 return length;
251 }
252
253 /**
254 * Returns a buffer containing the specified strings as bytes.
255 *
256 * @param strings
257 *
258 * @return the Strings as a ByteBuffer
259 */
260 static long getBuffer(final CharSequence[] strings) {
261 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
262
263 for ( CharSequence string : strings )
264 encode(buffer, string);
265
266 buffer.flip();
267 return MemoryUtil.getAddress0(buffer);
268 }
269
270 /**
271 * Returns a buffer containing the specified strings as bytes, including null-termination.
272 *
273 * @param strings
274 *
275 * @return the Strings as a ByteBuffer
276 */
277 static long getBufferNT(final CharSequence[] strings) {
278 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
279
280 for ( CharSequence string : strings ) {
281 encode(buffer, string);
282 buffer.put((byte)0);
283 }
284
285 buffer.flip();
286 return MemoryUtil.getAddress0(buffer);
287 }
288
289 /**
290 * Returns a buffer containing the lengths of the specified strings.
291 *
292 * @param strings
293 *
294 * @return the String lengths in an IntBuffer
295 */
296 static long getLengths(final CharSequence[] strings) {
297 IntBuffer buffer = getLengths(strings.length);
298
299 for ( CharSequence string : strings )
300 buffer.put(string.length());
301
302 buffer.flip();
303 return MemoryUtil.getAddress0(buffer);
304 }
305
306 static long getInt(final int value) {
307 return MemoryUtil.getAddress(getBufferInt().put(0, value), 0);
308 }
309
310 static long getBufferByte0() {
311 return MemoryUtil.getAddress0(getBufferByte(0));
312 }
313
314 private static class Buffers {
315
316 final IntBuffer ints;
317 final LongBuffer longs;
318 final FloatBuffer floats;
319
320 Buffers() {
321 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
322 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
323 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
324 }
325
326 }
327
328 }
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.opengles;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 /**
37 * Utility class that handles OpenGL API callbacks.
38 *
39 * @author Spasi
40 */
41 final class CallbackUtil {
42
43 /** Context -> Long */
44 private static final Map<ContextCapabilities, Long> contextUserParamsKHR = new HashMap<ContextCapabilities, Long>();
45
46 private CallbackUtil() {}
47
48 /**
49 * Creates a new global reference to the specified Object.
50 *
51 * @param obj the Object
52 *
53 * @return the GlobalRef memory address or 0 if the Object is null.
54 */
55 static long createGlobalRef(final Object obj) {
56 return obj == null ? 0 : ncreateGlobalRef(obj);
57 }
58
59 /**
60 * Creates a new global reference to the specified Object.
61 *
62 * @param obj the Object
63 *
64 * @return the GlobalRef memory address.
65 */
66 private static native long ncreateGlobalRef(Object obj);
67
68 /**
69 * Deletes a global reference.
70 *
71 * @param ref the GlobalRef memory address.
72 */
73 private static native void deleteGlobalRef(long ref);
74
75 // --------- [ XXX_debug_output ] ---------
76
77 /**
78 * Associates the current OpenGL context with the specified global reference. If there
79 * is no context current, the global reference is deleted and an exception is thrown.
80 * Any previous callback registrations will be cleared.
81 *
82 * @param userParam the global reference pointer
83 */
84 private static void registerContextCallback(final long userParam, final Map<ContextCapabilities, Long> contextUserData) {
85 ContextCapabilities caps = GLContext.getCapabilities();
86 if ( caps == null ) {
87 deleteGlobalRef(userParam);
88 throw new IllegalStateException("No context is current.");
89 }
90
91 final Long userParam_old = contextUserData.remove(caps);
92 if ( userParam_old != null )
93 deleteGlobalRef(userParam_old);
94
95 if ( userParam != 0 )
96 contextUserData.put(caps, userParam);
97 }
98
99 /**
100 * Releases references to any callbacks associated with the specified GL context.
101 *
102 * @param context the Context to unregister
103 */
104 static void unregisterCallbacks(final Object context) {
105 // TODO: This is never called for custom contexts. Need to fix for LWJGL 3.0
106 final ContextCapabilities caps = GLContext.getCapabilities();
107
108 Long userParam = contextUserParamsKHR.remove(caps);
109 if ( userParam != null )
110 deleteGlobalRef(userParam);
111 }
112
113 // --------- [ KHR_debug ] ---------
114
115 /**
116 * Returns the memory address of the native function we pass to glDebugMessageCallback.
117 *
118 * @return the callback function address
119 */
120 static native long getDebugCallbackKHR();
121
122 /**
123 * Associates the current OpenGL context with the specified global reference. If there
124 * is no context current, the global reference is deleted and an exception is thrown.
125 * Any previous callback registrations will be cleared.
126 *
127 * @param userParam the global reference pointer
128 */
129 static void registerContextCallbackKHR(final long userParam) {
130 registerContextCallback(userParam, contextUserParamsKHR);
131 }
132
133 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.BufferUtils;
34
35 import java.nio.IntBuffer;
36
37 import static org.lwjgl.opengles.EGL.*;
38
39 /**
40 * This class represents the context attributes passed to EGL's eglCreateContext.
41 * The only attribute allowed is EGL_CONTEXT_CLIENT_VERSION and it must be 2 or 3 (LWJGL does not support GLES 1.x).
42 */
43 public final class ContextAttribs {
44
45 private int version;
46
47 public ContextAttribs() {
48 this(2);
49 }
50
51 public ContextAttribs(final int version) {
52 if ( 3 < version )
53 throw new IllegalArgumentException("Invalid OpenGL ES version specified: " + version);
54
55 this.version = version;
56 }
57
58 private ContextAttribs(final ContextAttribs attribs) {
59 this.version = attribs.version;
60 }
61
62 public int getVersion() {
63 return version;
64 }
65
66 public IntBuffer getAttribList() {
67 int attribCount = 1;
68
69 final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);
70
71 attribs.put(EGL_CONTEXT_CLIENT_VERSION).put(version);
72
73 attribs.put(EGL_NONE);
74 attribs.rewind();
75 return attribs;
76 }
77
78 public String toString() {
79 StringBuilder sb = new StringBuilder(32);
80
81 sb.append("ContextAttribs:");
82 sb.append(" Version=").append(version);
83
84 return sb.toString();
85 }
86
87 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.BufferChecks;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.MemoryUtil;
36 import org.lwjgl.PointerBuffer;
37
38 import java.nio.IntBuffer;
39
40 /** EGL wrapper class. */
41 public final class EGL {
42
43 /** EGL aliases */
44 public static final int
45 EGL_FALSE = 0,
46 EGL_TRUE = 1;
47
48 /** Out-of-band handle values */
49 public static final int
50 EGL_DEFAULT_DISPLAY = 0,
51 EGL_NO_CONTEXT = 0,
52 EGL_NO_DISPLAY = 0,
53 EGL_NO_SURFACE = 0;
54
55 /** Out-of-band attribute value */
56 public static final int EGL_DONT_CARE = -1;
57
58 /** Errors / GetError return values */
59 public static final int
60 EGL_SUCCESS = 0x3000,
61 EGL_NOT_INITIALIZED = 0x3001,
62 EGL_BAD_ACCESS = 0x3002,
63 EGL_BAD_ALLOC = 0x3003,
64 EGL_BAD_ATTRIBUTE = 0x3004,
65 EGL_BAD_CONFIG = 0x3005,
66 EGL_BAD_CONTEXT = 0x3006,
67 EGL_BAD_CURRENT_SURFACE = 0x3007,
68 EGL_BAD_DISPLAY = 0x3008,
69 EGL_BAD_MATCH = 0x3009,
70 EGL_BAD_NATIVE_PIXMAP = 0x300A,
71 EGL_BAD_NATIVE_WINDOW = 0x300B,
72 EGL_BAD_PARAMETER = 0x300C,
73 EGL_BAD_SURFACE = 0x300D,
74 EGL_CONTEXT_LOST = 0x300E; // EGL 1.1 - IMG_power_management
75
76 /** Reserved =0x300F;-=0x301F; for additional errors */
77
78 /** Config attributes */
79 public static final int
80 EGL_BUFFER_SIZE = 0x3020,
81 EGL_ALPHA_SIZE = 0x3021,
82 EGL_BLUE_SIZE = 0x3022,
83 EGL_GREEN_SIZE = 0x3023,
84 EGL_RED_SIZE = 0x3024,
85 EGL_DEPTH_SIZE = 0x3025,
86 EGL_STENCIL_SIZE = 0x3026,
87 EGL_CONFIG_CAVEAT = 0x3027,
88 EGL_CONFIG_ID = 0x3028,
89 EGL_LEVEL = 0x3029,
90 EGL_MAX_PBUFFER_HEIGHT = 0x302A,
91 EGL_MAX_PBUFFER_PIXELS = 0x302B,
92 EGL_MAX_PBUFFER_WIDTH = 0x302C,
93 EGL_NATIVE_RENDERABLE = 0x302D,
94 EGL_NATIVE_VISUAL_ID = 0x302E,
95 EGL_NATIVE_VISUAL_TYPE = 0x302F,
96 EGL_SAMPLES = 0x3031,
97 EGL_SAMPLE_BUFFERS = 0x3032,
98 EGL_SURFACE_TYPE = 0x3033,
99 EGL_TRANSPARENT_TYPE = 0x3034,
100 EGL_TRANSPARENT_BLUE_VALUE = 0x3035,
101 EGL_TRANSPARENT_GREEN_VALUE = 0x3036,
102 EGL_TRANSPARENT_RED_VALUE = 0x3037,
103 EGL_NONE = 0x3038, // Attrib list terminator
104 EGL_BIND_TO_TEXTURE_RGB = 0x3039,
105 EGL_BIND_TO_TEXTURE_RGBA = 0x303A,
106 EGL_MIN_SWAP_INTERVAL = 0x303B,
107 EGL_MAX_SWAP_INTERVAL = 0x303C,
108 EGL_LUMINANCE_SIZE = 0x303D,
109 EGL_ALPHA_MASK_SIZE = 0x303E,
110 EGL_COLOR_BUFFER_TYPE = 0x303F,
111 EGL_RENDERABLE_TYPE = 0x3040,
112 EGL_MATCH_NATIVE_PIXMAP = 0x3041, // Pseudo-attribute (not queryable)
113 EGL_CONFORMANT = 0x3042;
114
115 /** Reserved =0x3041;-=0x304F; for additional config attributes */
116
117 /** Config attribute values */
118 public static final int
119 EGL_SLOW_CONFIG = 0x3050, // EGL_CONFIG_CAVEAT value
120 EGL_NON_CONFORMANT_CONFIG = 0x3051, // EGL_CONFIG_CAVEAT value
121 EGL_TRANSPARENT_RGB = 0x3052, // EGL_TRANSPARENT_TYPE value
122 EGL_RGB_BUFFER = 0x308E, // EGL_COLOR_BUFFER_TYPE value
123 EGL_LUMINANCE_BUFFER = 0x308F; // EGL_COLOR_BUFFER_TYPE value
124
125 /** More config attribute values, for EGL_TEXTURE_FORMAT */
126 public static final int
127 EGL_NO_TEXTURE = 0x305C,
128 EGL_TEXTURE_RGB = 0x305D,
129 EGL_TEXTURE_RGBA = 0x305E,
130 EGL_TEXTURE_2D = 0x305F;
131
132 /** EGL_SURFACE_TYPE mask bits */
133 public static final int
134 EGL_PBUFFER_BIT = 0x0001,
135 EGL_PIXMAP_BIT = 0x0002,
136 EGL_WINDOW_BIT = 0x0004,
137 EGL_VG_COLORSPACE_LINEAR_BIT = 0x0020,
138 EGL_VG_ALPHA_FORMAT_PRE_BIT = 0x0040,
139 EGL_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200,
140 EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
141
142 /** EGL_RENDERABLE_TYPE mask bits */
143 public static final int
144 EGL_OPENGL_ES_BIT = 0x0001,
145 EGL_OPENVG_BIT = 0x0002,
146 EGL_OPENGL_ES2_BIT = 0x0004,
147 EGL_OPENGL_BIT = 0x0008;
148
149 /** QueryString targets */
150 public static final int
151 EGL_VENDOR = 0x3053,
152 EGL_VERSION = 0x3054,
153 EGL_EXTENSIONS = 0x3055,
154 EGL_CLIENT_APIS = 0x308D;
155
156 /** QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
157 public static final int
158 EGL_HEIGHT = 0x3056,
159 EGL_WIDTH = 0x3057,
160 EGL_LARGEST_PBUFFER = 0x3058,
161 EGL_TEXTURE_FORMAT = 0x3080,
162 EGL_TEXTURE_TARGET = 0x3081,
163 EGL_MIPMAP_TEXTURE = 0x3082,
164 EGL_MIPMAP_LEVEL = 0x3083,
165 EGL_RENDER_BUFFER = 0x3086,
166 EGL_VG_COLORSPACE = 0x3087,
167 EGL_VG_ALPHA_FORMAT = 0x3088,
168 EGL_HORIZONTAL_RESOLUTION = 0x3090,
169 EGL_VERTICAL_RESOLUTION = 0x3091,
170 EGL_PIXEL_ASPECT_RATIO = 0x3092,
171 EGL_SWAP_BEHAVIOR = 0x3093,
172 EGL_MULTISAMPLE_RESOLVE = 0x3099;
173
174 /** EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
175 public static final int
176 EGL_BACK_BUFFER = 0x3084,
177 EGL_SINGLE_BUFFER = 0x3085;
178
179 /** OpenVG color spaces */
180 public static final int
181 EGL_VG_COLORSPACE_sRGB = 0x3089, // EGL_VG_COLORSPACE value
182 EGL_VG_COLORSPACE_LINEAR = 0x308A; // EGL_VG_COLORSPACE value
183
184 /** OpenVG alpha formats */
185 public static final int
186 EGL_VG_ALPHA_FORMAT_NONPRE = 0x308B, // EGL_ALPHA_FORMAT value
187 EGL_VG_ALPHA_FORMAT_PRE = 0x308C; // EGL_ALPHA_FORMAT
188
189 /**
190 * Constant scale factor by which fractional display resolutions &
191 * aspect ratio are scaled when queried as integer values.
192 */
193 public static final int EGL_DISPLAY_SCALING = 10000;
194
195 /** Unknown display resolution/aspect ratio */
196 public static final int EGL_UNKNOWN = -1;
197
198 /** Back buffer swap behaviors */
199 public static final int
200 EGL_BUFFER_PRESERVED = 0x3094, // EGL_SWAP_BEHAVIOR value
201 EGL_BUFFER_DESTROYED = 0x3095; // EGL_SWAP_BEHAVIOR value
202
203 /** CreatePbufferFromClientBuffer buffer types */
204 static final int EGL_OPENVG_IMAGE = 0x3096;
205
206 /** QueryContext targets */
207 public static final int EGL_CONTEXT_CLIENT_TYPE = 0x3097;
208
209 /** CreateContext attributes */
210 public static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
211
212 /** Multisample resolution behaviors */
213 public static final int
214 EGL_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A, // EGL_MULTISAMPLE_RESOLVE value
215 EGL_MULTISAMPLE_RESOLVE_BOX = 0x309B; // EGL_MULTISAMPLE_RESOLVE value
216
217 /** BindAPI/QueryAPI targets */
218 public static final int
219 EGL_OPENGL_ES_API = 0x30A0,
220 EGL_OPENVG_API = 0x30A1,
221 EGL_OPENGL_API = 0x30A2;
222
223 /** GetCurrentSurface targets */
224 public static final int
225 EGL_DRAW = 0x3059,
226 EGL_READ = 0x305A;
227
228 /** WaitNative engines */
229 static final int EGL_CORE_NATIVE_ENGINE = 0x305B;
230
231 private EGL() {
232 }
233
234 public static native int eglGetError();
235
236 /**
237 * Obtains an EGL display from the specified native display and initializes it.
238 *
239 * @param display_id the handle to the native display.
240 *
241 * @return the EGL Display
242 *
243 * @throws org.lwjgl.LWJGLException if no display is available or an EGL error occurs
244 */
245 public static EGLDisplay eglGetDisplay(long display_id) throws LWJGLException {
246 //LWJGLUtil.log("eglGetDisplay");
247 final long pointer = neglGetDisplay(display_id);
248
249 if ( pointer == EGL_NO_DISPLAY ) // No error is generated when this happens
250 throw new LWJGLException("Failed to get EGL display from native display handle: " + display_id);
251
252 return new EGLDisplay(pointer);
253 }
254
255 private static native long neglGetDisplay(long display_id);
256
257 /**
258 * Initializes the specified EGL display.
259 *
260 * @param dpy the EGL display to initialize
261 * @param version the EGL major and minor version will be returned in this buffer.
262 *
263 * @throws org.lwjgl.LWJGLException if an EGL error occurs
264 */
265 static void eglInitialize(EGLDisplay dpy, IntBuffer version) throws LWJGLException {
266 //LWJGLUtil.log("eglInitialize");
267 BufferChecks.checkBuffer(version, 2);
268 if ( !neglInitialize(dpy.getPointer(), MemoryUtil.getAddress(version)) )
269 throwEGLError("Failed to initialize EGL display.");
270 }
271
272 private static native boolean neglInitialize(long dpy_ptr, long version);
273
274 /**
275 * Release the resources associated with the specified EGL display.
276 *
277 * @param dpy the EGL display to terminate
278 */
279 static void eglTerminate(EGLDisplay dpy) throws LWJGLException {
280 //LWJGLUtil.log("eglTerminate");
281 if ( !neglTerminate(dpy.getPointer()) )
282 throwEGLError("Failed to terminate EGL display.");
283 }
284
285 private static native boolean neglTerminate(long dpy_ptr);
286
287 /**
288 * Returns a string describing some aspect of the EGL implementation running on the specified display.
289 *
290 * @param dpy the EGL display to query
291 * @param name the value to query
292 *
293 * @return the description
294 */
295 public static String eglQueryString(EGLDisplay dpy, int name) {
296 //LWJGLUtil.log("eglQueryString");
297 return neglQueryString(dpy.getPointer(), name);
298 }
299
300 private static native String neglQueryString(long dpy, int name);
301
302 /**
303 * Returns the number of EGLConfigs that are available on the specified display.
304 *
305 * @param dpy the EGLDisplay
306 *
307 * @return the number of EGLConfigs available
308 *
309 * @throws org.lwjgl.LWJGLException if an EGL error occurs
310 * @see #eglGetConfigs(EGLDisplay, EGLConfig[], IntBuffer)
311 */
312 static int eglGetConfigsNum(EGLDisplay dpy) throws LWJGLException {
313 //LWJGLUtil.log("eglGetConfigsNum");
314 IntBuffer num_config = APIUtil.getBufferInt();
315
316 if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress0(num_config)) )
317 throwEGLError("Failed to get EGL configs.");
318
319 return num_config.get(0);
320 }
321
322 /**
323 * Returns the available EGLConfigs on the speficied display. The number of available EGLConfigs
324 * is returned in the num_config parameter. The configs array may be null. If it is null, a new
325 * array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)} eglGetConfigsNum}.
326 * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger
327 * than the number of available EGLConfigs, the remaining array elements will not be affected.
328 *
329 * @param dpy the EGLDisplay
330 * @param configs the EGLConfigs array
331 * @param num_config the number of available EGLConfigs returned
332 *
333 * @return the available EGLConfigs
334 *
335 * @throws org.lwjgl.LWJGLException if an EGL error occurs
336 */
337 static EGLConfig[] eglGetConfigs(EGLDisplay dpy, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
338 //LWJGLUtil.log("eglGetConfigs");
339 BufferChecks.checkBuffer(num_config, 1);
340
341 if ( configs == null ) {
342 if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress(num_config)) )
343 throwEGLError("Failed to get number of available EGL configs.");
344
345 configs = new EGLConfig[num_config.get(num_config.position())];
346 }
347
348 final PointerBuffer configs_buffer = APIUtil.getBufferPointer(configs.length);
349 if ( !neglGetConfigs(dpy.getPointer(), MemoryUtil.getAddress0(configs_buffer), configs.length, MemoryUtil.getAddress(num_config)) )
350 throwEGLError("Failed to get EGL configs.");
351
352 final int config_size = num_config.get(num_config.position());
353 for ( int i = 0; i < config_size; i++ )
354 configs[i] = new EGLConfig(dpy, configs_buffer.get(i));
355
356 return configs;
357 }
358
359 private static native boolean neglGetConfigs(long dpy_ptr, long configs, int config_size, long num_config);
360
361 /**
362 * Returns the number of EGLConfigs that are available on the specified display and
363 * match the speficied list of attributes.
364 *
365 * @param dpy the EGLDisplay
366 * @param attrib_list the attribute list (may be null)
367 *
368 * @return the number of EGLConfigs available that satisft the attribute list
369 *
370 * @throws org.lwjgl.LWJGLException if an EGL error occurs
371 * @see #eglChooseConfig(EGLDisplay, IntBuffer, EGLConfig[], IntBuffer)
372 */
373 static int eglChooseConfigNum(EGLDisplay dpy, IntBuffer attrib_list) throws LWJGLException {
374 //LWJGLUtil.log("eglChooseConfigNum");
375 checkAttribList(attrib_list);
376 IntBuffer num_config = APIUtil.getBufferInt();
377
378 if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress0(num_config)) )
379 throwEGLError("Failed to get EGL configs.");
380
381 return num_config.get(0);
382 }
383
384 /**
385 * Returns the available EGLConfigs on the speficied display that satisfy the specified list of attributes.
386 * The number of available EGLConfigs is returned in the num_config parameter. The configs array may be null.
387 * If it is null, a new array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)} eglGetConfigsNum}.
388 * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger
389 * than the number of available EGLConfigs, the remaining array elements will not be affected.
390 *
391 * @param dpy the EGLDisplay
392 * @param attrib_list the attribute list (may be null)
393 * @param configs the EGLConfigs array
394 * @param num_config the number of available EGLConfigs returned
395 *
396 * @return the available EGLConfigs that satisfy the attribute list
397 *
398 * @throws org.lwjgl.LWJGLException if an EGL error occurs
399 */
400 static EGLConfig[] eglChooseConfig(EGLDisplay dpy, IntBuffer attrib_list, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
401 //LWJGLUtil.log("eglChooseConfig");
402 checkAttribList(attrib_list);
403 BufferChecks.checkBuffer(num_config, 1);
404
405 int config_size;
406 if ( configs == null ) {
407 if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress(num_config)) )
408 throwEGLError("Failed to get number of available EGL configs.");
409
410 config_size = num_config.get(num_config.position());
411 } else
412 config_size = configs.length;
413
414 //LWJGLUtil.log("config_size = " + config_size);
415 PointerBuffer configs_buffer = APIUtil.getBufferPointer(config_size);
416 if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), MemoryUtil.getAddress0(configs_buffer), config_size, MemoryUtil.getAddress(num_config)) )
417 throwEGLError("Failed to choose EGL config.");
418
419 // Get the true number of configurations (the first neglChooseConfig call may return more than the second)
420 config_size = num_config.get(num_config.position());
421 if ( configs == null )
422 configs = new EGLConfig[config_size];
423 for ( int i = 0; i < config_size; i++ )
424 configs[i] = new EGLConfig(dpy, configs_buffer.get(i));
425
426 return configs;
427 }
428
429 private static native boolean neglChooseConfig(long dpy_ptr, long attrib_list, long configs, int config_size, long num_config);
430
431 /**
432 * Returns the value of an EGL config attribute.
433 *
434 * @param dpy the EGL display
435 * @param config the EGL config
436 * @param attribute the attribute
437 *
438 * @throws org.lwjgl.LWJGLException if an EGL error occurs
439 */
440 static int eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute) throws LWJGLException {
441 //LWJGLUtil.log("eglGetConfigAttrib");
442 final IntBuffer value = APIUtil.getBufferInt();
443
444 if ( !neglGetConfigAttrib(dpy.getPointer(), config.getPointer(), attribute, MemoryUtil.getAddress(value)) )
445 throwEGLError("Failed to get EGL config attribute.");
446
447 return value.get(0);
448 }
449
450 private static native boolean neglGetConfigAttrib(long dpy_ptr, long config_ptr, int attribute, long value);
451
452 /**
453 * Creates an on-screen rendering surface on the specified EGL display.
454 *
455 * @param dpy the EGL display
456 * @param config the EGL config
457 * @param win the native window handle
458 * @param attrib_list an attribute list (may be null)
459 *
460 * @return the created EGL surface
461 *
462 * @throws org.lwjgl.LWJGLException if an EGL error occurs
463 */
464 static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, long win, IntBuffer attrib_list) throws LWJGLException {
465 //LWJGLUtil.log("eglCreateWindowSurface");
466 checkAttribList(attrib_list);
467 final long pointer = neglCreateWindowSurface(dpy.getPointer(), config.getPointer(), win, MemoryUtil.getAddressSafe(attrib_list));
468
469 if ( pointer == EGL_NO_SURFACE )
470 throwEGLError("Failed to create EGL window surface.");
471
472 return new EGLSurface(dpy, config, pointer);
473 }
474
475 private static native long neglCreateWindowSurface(long dpy_ptr, long config_ptr, long win, long attrib_list);
476
477 /**
478 * Creates an off-screen rendering surface on the specified EGL display.
479 *
480 * @param dpy the EGL display
481 * @param config the EGL config
482 * @param attrib_list an attribute list (may be null)
483 *
484 * @return the created EGL surface
485 *
486 * @throws org.lwjgl.LWJGLException if an EGL error occurs
487 */
488 static EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, IntBuffer attrib_list) throws LWJGLException {
489 //LWJGLUtil.log("eglCreatePbufferSurface");
490 checkAttribList(attrib_list);
491 final long pointer = neglCreatePbufferSurface(dpy.getPointer(), config.getPointer(), MemoryUtil.getAddressSafe(attrib_list));
492
493 if ( pointer == EGL_NO_SURFACE )
494 throwEGLError("Failed to create EGL pbuffer surface.");
495
496 return new EGLSurface(dpy, config, pointer);
497 }
498
499 private static native long neglCreatePbufferSurface(long dpy_ptr, long config_ptr, long attrib_list);
500
501 /*
502 EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
503 */
504
505 /**
506 * Sets the specified EGL surface attribute to the specified value.
507 *
508 * @param dpy the EGL display
509 * @param surface the EGL surface
510 * @param attribute the attribute
511 * @param value the attribute value
512 *
513 * @throws org.lwjgl.LWJGLException if an EGL error occurs
514 */
515 static void eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value) throws LWJGLException {
516 //LWJGLUtil.log("eglSurfaceAttrib");
517 if ( !neglSurfaceAttrib(dpy.getPointer(), surface.getPointer(), attribute, value) )
518 throwEGLError("Failed to set surface attribute.");
519 }
520
521 private static native boolean neglSurfaceAttrib(long dpy_ptr, long surface_ptr, int attribute, int value);
522
523 /**
524 * Destroys the specified EGL surface.
525 *
526 * @param dpy the EGL display
527 * @param surface the EGL surface to destroy
528 *
529 * @throws org.lwjgl.LWJGLException if an EGL error occurs
530 */
531 static void eglDestroySurface(EGLDisplay dpy, EGLSurface surface) throws LWJGLException {
532 //LWJGLUtil.log("eglDestroySurface");
533 if ( !neglDestroySurface(dpy.getPointer(), surface.getPointer()) )
534 throwEGLError("Failed to destroy EGL surface.");
535 }
536
537 private static native boolean neglDestroySurface(long dpy_ptr, long surface_ptr);
538
539 /**
540 * Returns the value of the specified EGL surface attribute in the value parameter.
541 *
542 * @param dpy the EGL display
543 * @param surface the EGL surface
544 * @param attribute the surface attribute
545 * @param value the attribute value will be returned here
546 *
547 * @throws org.lwjgl.LWJGLException if an EGL error occurs
548 */
549 public static void eglQuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, IntBuffer value) throws LWJGLException {
550 //LWJGLUtil.log("eglQuerySurface");
551 BufferChecks.checkBuffer(value, 1);
552 if ( !neglQuerySurface(dpy.getPointer(), surface.getPointer(), attribute, MemoryUtil.getAddress(value)) )
553 throwEGLError("Failed to query surface attribute.");
554 }
555
556 private static native boolean neglQuerySurface(long dpy_ptr, long surface_ptr, int attribute, long value);
557
558 /**
559 * Binds the specified rendering API to the current thread.
560 *
561 * @param api the API to bind
562 *
563 * @return true if the bind was successful, false if an EGL error occurs
564 */
565 public static native boolean eglBindAPI(int api);
566
567 /**
568 * Returns the current rendering API.
569 *
570 * @return the rendering API bound to the current thread
571 */
572 public static native int eglQueryAPI();
573
574 /**
575 * Returns EGL to its state at thread initialization. This includes the following:<br>
576 * <p>
577 * For each client API supported by EGL, if there is a currently bound context,
578 * that context is released. This is equivalent to calling eglMakeCurrent
579 * with ctx set to EGL_NO_CONTEXT and both draw and read set to EGL_NO_SURFACE
580 * </p><br>
581 * <p>The current rendering API is reset to its value at thread initialization</p><br>
582 * <p>Any additional implementation-dependent per-thread state maintained by EGL
583 * is marked for deletion as soon as possible.</p>
584 *
585 * @return true if thread state was released successfully, false is an EGL error occurs
586 */
587 static native boolean eglReleaseThread();
588
589 /*
590 EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
591 EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
592 EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
593 */
594
595 /**
596 * Specifies the minimum number of video frame periods per buffer swap for
597 * the window associated with the current context.
598 *
599 * @param dpy the EGL display
600 * @param interval the frame interval
601 *
602 * @throws org.lwjgl.LWJGLException if an EGL error occurs
603 */
604 static void eglSwapInterval(EGLDisplay dpy, int interval) throws LWJGLException {
605 //LWJGLUtil.log("eglSwapInterval");
606 if ( !neglSwapInterval(dpy.getPointer(), interval) )
607 throwEGLError("Failed to set swap interval.");
608 }
609
610 private static native boolean neglSwapInterval(long dpy_ptr, int interval);
611
612 /**
613 * Creates a new EGL context for the current rendering API.
614 *
615 * @param dpy the EGL display
616 * @param config the EGL config
617 * @param share_context the EGL context to share data with
618 * @param attrib_list the attribute list (may be null)
619 *
620 * @return the created EGL context
621 *
622 * @throws org.lwjgl.LWJGLException if an EGL error occurs
623 */
624 static EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, IntBuffer attrib_list) throws LWJGLException {
625 //LWJGLUtil.log("eglCreateContext");
626 checkAttribList(attrib_list);
627 final long pointer = neglCreateContext(dpy.getPointer(), config.getPointer(),
628 share_context == null ? EGL_NO_CONTEXT : share_context.getPointer(),
629 MemoryUtil.getAddressSafe(attrib_list));
630
631 if ( pointer == EGL_NO_CONTEXT )
632 throwEGLError("Failed to create EGL context.");
633
634 return new EGLContext(dpy, config, pointer);
635 }
636
637 private static native long neglCreateContext(long dpy_ptr, long config_ptr, long share_context_ptr, long attrib_list);
638
639 /**
640 * Destroys a rendering context.
641 *
642 * @param dpy the EGL display
643 * @param ctx the EGL context
644 *
645 * @throws org.lwjgl.LWJGLException if an EGL error occurs
646 */
647 static void eglDestroyContext(EGLDisplay dpy, EGLContext ctx) throws LWJGLException {
648 //LWJGLUtil.log("eglDestroyContext");
649 if ( !neglDestroyContext(dpy.getPointer(), ctx.getPointer()) )
650 throwEGLError("Failed to destroy context.");
651 }
652
653 private static native boolean neglDestroyContext(long dpy_ptr, long ctx_ptr);
654
655 /**
656 * Binds the specified context to the current thread and to the draw and read surfaces.
657 *
658 * @param dpy the EGL display
659 * @param draw the draw EGL surface
660 * @param read the read EGL surface
661 * @param ctx the EGL context to make current
662 *
663 * @throws org.lwjgl.LWJGLException if an EGL error occurs
664 * @throws PowerManagementEventException if an EGL power management event occurs
665 */
666 static void eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) throws LWJGLException, PowerManagementEventException {
667 //LWJGLUtil.log("eglMakeCurrent");
668 if ( !neglMakeCurrent(dpy.getPointer(),
669 draw == null ? EGL_NO_SURFACE : draw.getPointer(),
670 read == null ? EGL_NO_SURFACE : read.getPointer(),
671 ctx == null ? EGL_NO_CONTEXT : ctx.getPointer()) ) {
672 final int error = eglGetError();
673 if ( error == EGL_CONTEXT_LOST )
674 throw new PowerManagementEventException();
675 else
676 throwEGLError("Failed to change the current context.", error);
677 }
678 }
679
680 /**
681 * Releases the current context without assigning a new one.
682 *
683 * @param dpy the EGL display
684 *
685 * @throws org.lwjgl.LWJGLException if an EGL error occurs
686 * @throws PowerManagementEventException if an EGL power management event occurs
687 * @see #eglMakeCurrent(EGLDisplay, EGLSurface, EGLSurface, EGLContext)
688 */
689 public static void eglReleaseCurrent(EGLDisplay dpy) throws LWJGLException, PowerManagementEventException {
690 //LWJGLUtil.log("eglReleaseCurrent");
691 eglMakeCurrent(dpy, null, null, null);
692 }
693
694 private static native boolean neglMakeCurrent(long dpy_ptr, long draw_ptr, long read_ptr, long ctx_ptr);
695
696 /**
697 * Returns the current EGL context for the current rendering API.
698 * If there is no context current, null is returned.
699 *
700 * @return the current context
701 *
702 * @throws org.lwjgl.LWJGLException if an EGL error occurs
703 */
704 public static EGLContext eglGetCurrentContext() throws LWJGLException {
705 //LWJGLUtil.log("eglGetCurrentContext");
706 // Get current context
707 final long ctx = neglGetCurrentContext();
708 if ( ctx == EGL_NO_CONTEXT )
709 return null;
710
711 // Get current display
712 final EGLDisplay display = eglGetCurrentDisplay();
713
714 // Query context's CONFIG_ID
715 final IntBuffer attrib_list = APIUtil.getBufferInt();
716 neglQueryContext(display.getPointer(), ctx, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list));
717
718 final EGLConfig config = getEGLConfig(display, attrib_list);
719
720 // Create the context handle
721 return new EGLContext(display, config, ctx);
722 }
723
724 /**
725 * Returns true if the specified EGL context is the current context.
726 * This method is faster than using {@code #eglGetCurrentContext}
727 * and comparing the two EGLContext objects.
728 *
729 * @param context the EGL context
730 *
731 * @return true if the EGL context is current
732 *
733 * @see #eglGetCurrentContext()
734 */
735 public static boolean eglIsCurrentContext(EGLContext context) {
736 //LWJGLUtil.log("eglIsCurrentContext");
737 return neglGetCurrentContext() == context.getPointer();
738 }
739
740 private static native long neglGetCurrentContext();
741
742 /**
743 * Returns the EGL surfaces used for rendering by the current context.
744 * If there is no context current, null is returned.
745 *
746 * @param readdraw the read or draw surface
747 *
748 * @return the current surface
749 *
750 * @throws org.lwjgl.LWJGLException if an EGL error occurs
751 */
752 public static EGLSurface eglGetCurrentSurface(int readdraw) throws LWJGLException {
753 //LWJGLUtil.log("eglGetCurrentSurface");
754 final long surface = neglGetCurrentSurface(readdraw);
755 if ( surface == EGL_NO_SURFACE )
756 return null;
757
758 // Get current display
759 EGLDisplay display = eglGetCurrentDisplay();
760
761 // Query context's CONFIG_ID
762 final IntBuffer attrib_list = APIUtil.getBufferInt();
763 if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
764 throwEGLError("Failed to query surface EGL config ID.");
765
766 final EGLConfig config = getEGLConfig(display, attrib_list);
767
768 // Create the surface handle
769 return new EGLSurface(display, config, surface);
770 }
771
772 private static native long neglGetCurrentSurface(int readdraw);
773
774 /**
775 * Returns the EGL display associated with the current context.
776 *
777 * @return the current display
778 *
779 * @throws org.lwjgl.LWJGLException if an EGL error occurs
780 */
781 public static EGLDisplay eglGetCurrentDisplay() throws LWJGLException {
782 //LWJGLUtil.log("eglGetCurrentDisplay");
783 return new EGLDisplay(neglGetCurrentDisplay());
784 }
785
786 private static native long neglGetCurrentDisplay();
787
788 /**
789 * Returns the value of the specified EGL context attribute in the value parameter.
790 *
791 * @param dpy the EGL display
792 * @param ctx the EGL context
793 * @param attribute the context attribute
794 * @param value the attribute value will be returned here
795 *
796 * @throws org.lwjgl.LWJGLException if an EGL error occurs
797 */
798 public static void eglQueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, IntBuffer value) throws LWJGLException {
799 //LWJGLUtil.log("eglQueryContext");
800 BufferChecks.checkBuffer(value, 1);
801 if ( !neglQueryContext(dpy.getPointer(), ctx.getPointer(), attribute, MemoryUtil.getAddress(value)) )
802 throwEGLError("Failed to query context attribute.");
803 }
804
805 private static native boolean neglQueryContext(long dpy_ptr, long ctx_ptr, int attribute, long value);
806
807 /**
808 * Prevents native rendering API functions from executing until any
809 * outstanding client API rendering affecting the same surface is complete.
810 *
811 * @return true if the wait was successful, false is an EGL error occurs
812 */
813 public static native boolean eglWaitClient();
814
815 /**
816 * This method does the equivalent of:<br>
817 * <code>
818 * EGLenum api = eglQueryAPI();
819 * eglBindAPI(EGL_OPENGL_ES_API);
820 * eglWaitClient();
821 * eglBindAPI(api);
822 * </code>
823 *
824 * @return true if the wait was successful, false if an EGL error occurs
825 */
826 public static native boolean eglWaitGL();
827
828 /**
829 * Prevents a client API command sequence from executing until any outstanding
830 * native rendering affecting the same surface is complete.
831 *
832 * @param engine the native rendering engine
833 *
834 * @return true if the wait was successful, false if an EGL error occurs
835 */
836 public static native boolean eglWaitNative(int engine);
837
838 /**
839 * Posts the color buffer to the window.
840 *
841 * @param dpy the EGL display
842 * @param surface the EGL back-buffered window surface
843 *
844 * @throws org.lwjgl.LWJGLException if an EGL occurs
845 * @throws PowerManagementEventException if an EGL power management event occurs
846 */
847 static void eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) throws LWJGLException, PowerManagementEventException {
848 //LWJGLUtil.log("eglSwapBuffers");
849 if ( !neglSwapBuffers(dpy.getPointer(), surface.getPointer()) ) {
850 final int error = eglGetError();
851 if ( error == EGL_CONTEXT_LOST )
852 throw new PowerManagementEventException();
853 else
854 throwEGLError("Failed to swap buffers.", error);
855 }
856 }
857
858 private static native boolean neglSwapBuffers(long dpy_ptr, long surface_ptr);
859
860 //EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
861
862 /* --------------------------------
863 HELPER METHODS
864 -------------------------------- */
865
866 static void checkAttribList(IntBuffer attrib_list) {
867 if ( attrib_list == null )
868 return;
869
870 //BufferChecks.checkDirect(attrib_list);
871 if ( attrib_list.remaining() % 2 != 1 )
872 throw new IllegalArgumentException("Invalid number of values in attribute list.");
873 if ( attrib_list.get(attrib_list.limit() - 1) != EGL_NONE )
874 throw new IllegalArgumentException("The attribute list is not terminated with EGL_NONE.");
875 }
876
877 private static EGLConfig getEGLConfig(final EGLDisplay dpy, final IntBuffer attrib_list) throws LWJGLException {
878 final int configID = attrib_list.get(0);
879
880 // -- This fails on the emulator
881 // Get EGL config used by the context
882 attrib_list.put(0, EGL_CONFIG_ID).put(1, configID).put(2, EGL_NONE);
883
884 final PointerBuffer configs_buffer = APIUtil.getBufferPointer(1);
885 if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddress(attrib_list), MemoryUtil.getAddress0(configs_buffer), 1, MemoryUtil.getAddress(attrib_list, 3)) )
886 throwEGLError("Failed to choose EGL config.");
887
888 return new EGLConfig(dpy, configs_buffer.get(0));
889
890 // -- Emulator workaround
891 /*
892 EGLConfig config = null;
893
894 final EGLConfig[] configs = eglGetConfigs(dpy, null, attrib_list);
895 final int config_size = attrib_list.get(0);
896 for ( int i = 0; i < config_size; i++ ) {
897 if ( configs[i].getConfigID() == configID ) {
898 config = configs[i];
899 break;
900 }
901 }
902
903 if ( config == null )
904 throwEGLError("Failed to retrieve EGL config for current context.");
905
906 return config;
907 //*/
908 }
909
910 static void throwEGLError(final String msg) throws LWJGLException {
911 throwEGLError(msg, eglGetError());
912 }
913
914 static void throwEGLError(String msg, final int error) throws LWJGLException {
915 if ( error != EGL_SUCCESS )
916 msg += " EGL error: " + Util.translateEGLErrorString(error);
917
918 throw new LWJGLException(msg);
919 }
920
921 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.PointerWrapperAbstract;
35
36 import static org.lwjgl.opengles.EGL.*;
37
38 /** EGLConfig wrapper class. */
39 public final class EGLConfig extends PointerWrapperAbstract {
40
41 private final EGLDisplay display;
42
43 private final int configID;
44
45 EGLConfig(final EGLDisplay display, final long pointer) throws LWJGLException {
46 super(pointer);
47
48 this.display = display;
49 this.configID = getAttribute(EGL_CONFIG_ID);
50 }
51
52 /**
53 * Returns the EGL display from which this EGL config was retrieved.
54 *
55 * @return the EGL display
56 */
57 public EGLDisplay getDisplay() {
58 return display;
59 }
60
61 /**
62 * Returns the EGL_CONFIG_ID attribute of this EGLConfig.
63 *
64 * @return the EGL_CONFIG_ID
65 */
66 public int getConfigID() {
67 return configID;
68 }
69
70 /**
71 * Returns the value of the specified EGL config attribute.
72 *
73 * @param attribute the attribute
74 *
75 * @return the attribute value
76 */
77 public int getAttribute(final int attribute) throws LWJGLException {
78 return eglGetConfigAttrib(display, this, attribute);
79 }
80
81 public boolean equals(final Object obj) {
82 if ( obj == null || !(obj instanceof EGLConfig) )
83 return false;
84
85 return getPointer() == ((EGLConfig)obj).getPointer();
86 }
87
88 public String toString() {
89 final StringBuilder sb = new StringBuilder(512);
90
91 sb.append("EGLConfig (").append(configID).append(")");
92 sb.append("\n------------");
93
94 try {
95 sb.append("\nEGL_LEVEL").append(": ").append(getAttribute(EGL_LEVEL));
96 sb.append("\nEGL_RENDERABLE_TYPE").append(": ").append(Integer.toBinaryString(getAttribute(EGL_RENDERABLE_TYPE)));
97 sb.append("\nEGL_NATIVE_RENDERABLE").append(": ").append(getAttribute(EGL_NATIVE_RENDERABLE) == EGL_TRUE);
98 sb.append("\nEGL_SURFACE_TYPE").append(": ").append(Integer.toBinaryString(getAttribute(EGL_SURFACE_TYPE)));
99 } catch (LWJGLException e) {
100 }
101
102 final PixelFormat.Attrib[] attribEnums = PixelFormat.Attrib.values();
103 for ( PixelFormat.Attrib attribEnum : attribEnums ) {
104 if ( attribEnum.isSurfaceAttrib() )
105 continue;
106
107 try {
108 final int attrib = getAttribute(attribEnum.getEGLAttrib());
109 sb.append("\nEGL_").append(attribEnum.name()).append(": ").append(attrib);
110 } catch (LWJGLException e) {
111 //System.out.println("Failed to retrieve: " + attribEnum.name());
112 // Ignore, can happen when querying unsupported attributes (e.g. extension ones)
113 }
114 }
115
116 return sb.toString();
117 }
118
119 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.PointerWrapperAbstract;
35
36 import java.nio.IntBuffer;
37
38 import static org.lwjgl.opengles.EGL.*;
39
40 /** EGLContext wrapper class. */
41 public final class EGLContext extends PointerWrapperAbstract {
42
43 private EGLDisplay display;
44 private final EGLConfig config;
45
46 private boolean destroyed;
47
48 EGLContext(final EGLDisplay display, final EGLConfig config, final long pointer) {
49 super(pointer);
50
51 if ( !display.isInitialized() )
52 throw new IllegalStateException("Invalid EGL display specified.");
53
54 if ( config.getDisplay() != display )
55 throw new IllegalStateException("Invalid EGL config specified.");
56
57 this.display = display;
58 this.config = config;
59 }
60
61 public void setDisplay(EGLDisplay display) {
62 this.display = display;
63 }
64
65 EGLDisplay getDisplay() {
66 return display;
67 }
68
69 EGLConfig getConfig() {
70 return config;
71 }
72
73 private void checkDestroyed() {
74 if ( destroyed )
75 throw new IllegalStateException("The EGL surface has been destroyed.");
76 }
77
78 public void destroy() throws LWJGLException {
79 eglDestroyContext(display, this);
80 destroyed = true;
81 }
82
83 /**
84 * Returns the value of the specified EGL context attribute.
85 *
86 * @param attribute the context attribute
87 *
88 * @return the attribute value
89 */
90 int getAttribute(final int attribute) throws LWJGLException {
91 checkDestroyed();
92
93 IntBuffer value = APIUtil.getBufferInt();
94 eglQueryContext(display, this, attribute, value);
95 return value.get(0);
96 }
97
98 public void makeCurrent(final EGLSurface surface) throws LWJGLException, PowerManagementEventException {
99 makeCurrent(surface, surface);
100 }
101
102 public void makeCurrent(final EGLSurface draw, final EGLSurface read) throws LWJGLException, PowerManagementEventException {
103 eglMakeCurrent(display, draw, read, this);
104 }
105
106 public boolean equals(final Object obj) {
107 if ( obj == null || !(obj instanceof EGLContext) )
108 return false;
109
110 return getPointer() == ((EGLContext)obj).getPointer();
111 }
112
113 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.PointerWrapperAbstract;
35
36 import java.nio.IntBuffer;
37 import java.util.HashSet;
38 import java.util.Set;
39 import java.util.StringTokenizer;
40
41 import static org.lwjgl.opengles.EGL.*;
42
43 /** EGLDisplay wrapper class. */
44 public final class EGLDisplay extends PointerWrapperAbstract {
45
46 private int majorVersion;
47 private int minorVersion;
48
49 private Set<String> extensions;
50
51 private boolean initialized;
52
53 EGLDisplay(final long pointer) throws LWJGLException {
54 super(pointer);
55
56 initialize();
57
58 /*final EGLConfig[] configs = eglGetConfigs(this, null, APIUtil.getBufferInt());
59 for ( EGLConfig config : configs ) {
60 System.out.println(config);
61 System.out.println("");
62 }*/
63 }
64
65 /**
66 * Returns the major EGL version of this EGL display.
67 *
68 * @return the major EGL version
69 */
70 public int getMajorVersion() {
71 return majorVersion;
72 }
73
74 /**
75 * Returns the minor EGL version of this EGL display.
76 *
77 * @return the minor EGL version
78 */
79 public int getMinorVersion() {
80 return minorVersion;
81 }
82
83 /**
84 * Returns true if the specified EGL extension is supported by this EGL display.
85 *
86 * @param eglExtension the EGL extension
87 *
88 * @return true if the extension is supported
89 */
90 public boolean isExtensionSupported(final String eglExtension) {
91 checkInitialized();
92 if ( extensions == null ) {
93 extensions = new HashSet<String>(16);
94
95 final StringTokenizer tokenizer = new StringTokenizer(eglQueryString(this, EGL_EXTENSIONS));
96 while ( tokenizer.hasMoreTokens() )
97 extensions.add(tokenizer.nextToken());
98 }
99
100 return extensions.contains(eglExtension);
101 }
102
103 boolean isInitialized() {
104 return initialized;
105 }
106
107 private void initialize() throws LWJGLException {
108 IntBuffer version = APIUtil.getBufferInt();
109 eglInitialize(this, version);
110
111 majorVersion = version.get(0);
112 minorVersion = version.get(1);
113
114 initialized = true;
115 }
116
117 private void checkInitialized() {
118 if ( !initialized )
119 throw new IllegalStateException("The EGL display needs to be initialized first.");
120 }
121
122 /** Release the resources associated with this EGL display. */
123 public void terminate() throws LWJGLException {
124 eglTerminate(this);
125
126 majorVersion = 0;
127 minorVersion = 0;
128
129 initialized = false;
130 }
131
132 /**
133 * Returns a string describing some aspect of the EGL implementation running on the specified display.
134 *
135 * @param name the value to query
136 *
137 * @return the description
138 */
139 public String query(int name) {
140 checkInitialized();
141 return eglQueryString(this, name);
142 }
143
144 int getConfigsNum() throws LWJGLException {
145 checkInitialized();
146 return eglGetConfigsNum(this);
147 }
148
149 EGLConfig[] getConfigs(EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
150 checkInitialized();
151 return eglGetConfigs(this, configs, num_config);
152 }
153
154 int getConfigNum(IntBuffer attrib_list) throws LWJGLException {
155 checkInitialized();
156 return eglChooseConfigNum(this, attrib_list);
157 }
158
159 /** Returns the available EGL configs on this display that satisfy the specified list of attributes. */
160 public EGLConfig[] chooseConfig(IntBuffer attrib_list, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
161 checkInitialized();
162 return eglChooseConfig(this, attrib_list, configs, num_config);
163 }
164
165 /**
166 * Creates an on-screen rendering surface on this EGL display.
167 *
168 * @param config the EGL config
169 * @param window the native window handle
170 * @param attrib_list an attribute list (may be null)
171 *
172 * @return the EGL surface
173 */
174 public EGLSurface createWindowSurface(EGLConfig config, long window, IntBuffer attrib_list) throws LWJGLException {
175 checkInitialized();
176
177 if ( config.getDisplay() != this )
178 throw new IllegalArgumentException("Invalid EGL config specified.");
179
180 return eglCreateWindowSurface(this, config, window, attrib_list);
181 }
182
183 EGLSurface createPbufferSurface(EGLConfig config, IntBuffer attrib_list) throws LWJGLException {
184 checkInitialized();
185
186 if ( config.getDisplay() != this )
187 throw new IllegalArgumentException("Invalid EGL config specified.");
188
189 return eglCreatePbufferSurface(this, config, attrib_list);
190 }
191
192 public EGLContext createContext(EGLConfig config, EGLContext shareContext, IntBuffer attrib_list) throws LWJGLException {
193 checkInitialized();
194
195 if ( config.getDisplay() != this )
196 throw new IllegalStateException("Invalid EGL config specified.");
197
198 if ( shareContext != null && shareContext.getDisplay() != this )
199 throw new IllegalStateException("Invalid shared EGL context specified.");
200
201 return eglCreateContext(this, config, shareContext, attrib_list);
202 }
203
204 public void setSwapInterval(final int interval) throws LWJGLException {
205 eglSwapInterval(this, interval);
206 }
207
208 public boolean equals(final Object obj) {
209 if ( obj == null || !(obj instanceof EGLDisplay) )
210 return false;
211
212 return getPointer() == ((EGLDisplay)obj).getPointer();
213 }
214
215 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /** EGLImageOES wrapper class. */
36 public final class EGLImageOES extends PointerWrapperAbstract {
37
38 public EGLImageOES(final long pointer) {
39 super(pointer);
40 }
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.MemoryUtil;
35
36 import java.nio.IntBuffer;
37
38 import static org.lwjgl.opengles.EGL.*;
39
40 /** EGL_KHR_fence_sync wrapper class. */
41 public final class EGLKHRFenceSync {
42
43 /**
44 * Accepted by the &lt;type&gt; parameter of eglCreateSyncKHR, and returned
45 * in &lt;value&gt; when eglGetSyncAttribKHR is called with &lt;attribute&gt;
46 * EGL_SYNC_TYPE_KHR:
47 */
48 public static final int EGL_SYNC_FENCE_KHR = 0x30F9;
49
50 /** Accepted by the &lt;attribute&gt; parameter of eglGetSyncAttribKHR: */
51 public static final int EGL_SYNC_TYPE_KHR = 0x30F7,
52 EGL_SYNC_STATUS_KHR = 0x30F1,
53 EGL_SYNC_CONDITION_KHR = 0x30F8;
54
55 /**
56 * Returned in &lt;value&gt; when eglGetSyncAttribKHR is called with
57 * &lt;attribute&gt; EGL_SYNC_STATUS_KHR:
58 */
59 public static final int EGL_SIGNALED_KHR = 0x30F2,
60 EGL_UNSIGNALED_KHR = 0x30F3;
61
62 /**
63 * Returned in &lt;value&gt; when eglGetSyncAttribKHR is called with
64 * &lt;attribute&gt; EGL_SYNC_CONDITION_KHR:
65 */
66 public static final int EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR = 0x30F0;
67
68 /** Accepted in the &lt;flags&gt; parameter of eglClientWaitSyncKHR: */
69 public static final int EGL_SYNC_FLUSH_COMMANDS_BIT_KHR = 0x0001;
70
71 /** Accepted in the &lt;timeout&gt; parameter of eglClientWaitSyncKHR: */
72 public static final long EGL_FOREVER_KHR = 0xFFFFFFFFFFFFFFFFl;
73
74 /** Returned by eglClientWaitSyncKHR: */
75 public static final int EGL_TIMEOUT_EXPIRED_KHR = 0x30F5,
76 EGL_CONDITION_SATISFIED_KHR = 0x30F6;
77
78 /** Returned by eglCreateSyncKHR in the event of an error: */
79 public static final long EGL_NO_SYNC_KHR = 0;
80
81 static {
82 initNativeStubs();
83 }
84
85 private EGLKHRFenceSync() {
86 }
87
88 private static native void initNativeStubs();
89
90 /**
91 * Creates a fence sync object for the specified EGL display and returns
92 * a handle to the new object.
93 *
94 * @param dpy the EGL display
95 * @param type the sync type
96 * @param attrib_list an attribute list (may be null)
97 *
98 * @return the created fence sync object
99 *
100 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
101 */
102 public static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, int type, IntBuffer attrib_list) throws LWJGLException {
103 checkAttribList(attrib_list);
104
105 final long pointer = neglCreateSyncKHR(dpy.getPointer(), type, MemoryUtil.getAddressSafe(attrib_list));
106
107 if ( pointer == EGL_NO_SYNC_KHR )
108 throwEGLError("Failed to create KHR fence sync object.");
109
110 return new EGLSyncKHR(pointer);
111 }
112
113 private static native long neglCreateSyncKHR(long dpy_ptr, int type, long attrib_list);
114
115 /**
116 * Destroys an existing sync object.
117 *
118 * @param sync the sync object
119 *
120 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
121 */
122 public static void eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) throws LWJGLException {
123 if ( !neglDestroySyncKHR(dpy.getPointer(), sync.getPointer()) )
124 throwEGLError("Failed to destroy KHR fence sync object.");
125 }
126
127 private static native boolean neglDestroySyncKHR(long dpy_ptr, long sync_ptr);
128
129 /**
130 * Blocks the calling thread until the specified sync object is
131 * signaled, or until a specified timeout value expires.
132 *
133 * @param sync the sync object
134 * @param flags the block flags
135 * @param timeout the block timeout
136 *
137 * @return the sync object status
138 *
139 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
140 */
141 public static int eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, int flags, long timeout) throws LWJGLException {
142 final int status = neglClientWaitSyncKHR(dpy.getPointer(), sync.getPointer(), flags, timeout);
143
144 if ( status == EGL_FALSE )
145 throwEGLError("Failed to block on KHR fence sync object.");
146
147 return status;
148 }
149
150 private static native int neglClientWaitSyncKHR(long dpy_ptr, long sync_ptr, int flags, long timeout);
151
152 /**
153 * Returns the value of the sync object attribute.
154 *
155 * @param sync the sync object
156 * @param attribute the attribute to query
157 *
158 * @return the attribute value
159 *
160 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
161 */
162 public static int eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, int attribute) throws LWJGLException {
163 final IntBuffer value = APIUtil.getBufferInt();
164
165 if ( !neglGetSyncAttribKHR(dpy.getPointer(), sync.getPointer(), attribute, MemoryUtil.getAddress(value)) )
166 throwEGLError("Failed to get KHR fence sync object attribute.");
167
168 return value.get(0);
169 }
170
171 private static native boolean neglGetSyncAttribKHR(long dpy_ptr, long sync_ptr, int attribute, long value);
172
173 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34
35 import java.nio.IntBuffer;
36
37 import static org.lwjgl.opengles.EGL.*;
38
39 /** EGL_KHR_reusable_sync wrapper class. */
40 public final class EGLKHRReusableSync {
41
42 /**
43 * Accepted by the &lt;type&gt; parameter of eglCreateSyncKHR, and returned
44 * in &lt;value&gt; when eglGetSyncAttribKHR is called with &lt;attribute&gt;
45 * EGL_SYNC_TYPE_KHR:
46 */
47 public static final int EGL_SYNC_REUSABLE_KHR = 0x30FA;
48
49 /** Accepted by the &lt;attribute&gt; parameter of eglGetSyncAttribKHR: */
50 public static final int EGL_SYNC_TYPE_KHR = 0x30F7,
51 EGL_SYNC_STATUS_KHR = 0x30F1;
52
53 /**
54 * Returned in &lt;value&gt; when eglGetSyncAttribKHR is called with
55 * &lt;attribute&gt; EGL_SYNC_STATUS_KHR:
56 */
57 public static final int EGL_SIGNALED_KHR = 0x30F2,
58 EGL_UNSIGNALED_KHR = 0x30F3;
59
60 /** Accepted in the &lt;flags&gt; parameter of eglClientWaitSyncKHR: */
61 public static final int EGL_SYNC_FLUSH_COMMANDS_BIT_KHR = 0x0001;
62
63 /** Accepted in the &lt;timeout&gt; parameter of eglClientWaitSyncKHR: */
64 public static final long EGL_FOREVER_KHR = 0xFFFFFFFFFFFFFFFFl;
65
66 /** Returned by eglClientWaitSyncKHR: */
67 public static final int EGL_TIMEOUT_EXPIRED_KHR = 0x30F5,
68 EGL_CONDITION_SATISFIED_KHR = 0x30F6;
69
70 /** Returned by eglCreateSyncKHR in the event of an error: */
71 public static final long EGL_NO_SYNC_KHR = 0;
72
73 static {
74 initNativeStubs();
75 }
76
77 private EGLKHRReusableSync() {
78 }
79
80 private static native void initNativeStubs();
81
82 /**
83 * Creates a fence sync object for the specified EGL display and returns
84 * a handle to the new object.
85 *
86 * @param dpy the EGL display
87 * @param type the sync type
88 * @param attrib_list an attribute list (may be null)
89 *
90 * @return the created fence sync object
91 *
92 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
93 */
94 public static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, int type, IntBuffer attrib_list) throws LWJGLException {
95 return EGLKHRFenceSync.eglCreateSyncKHR(dpy, type, attrib_list);
96 }
97
98 /**
99 * Destroys an existing sync object.
100 *
101 * @param sync the sync object
102 *
103 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
104 */
105 public static void eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) throws LWJGLException {
106 EGLKHRFenceSync.eglDestroySyncKHR(dpy, sync);
107 }
108
109 /**
110 * Blocks the calling thread until the specified sync object is
111 * signaled, or until a specified timeout value expires.
112 *
113 * @param sync the sync object
114 * @param flags the block flags
115 * @param timeout the block timeout
116 *
117 * @return the sync object status
118 *
119 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
120 */
121 public static int eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, int flags, long timeout) throws LWJGLException {
122 return EGLKHRFenceSync.eglClientWaitSyncKHR(dpy, sync, flags, timeout);
123 }
124
125 /**
126 * Signals or unsignals the sync object by changing its status to
127 * the specified mode.
128 *
129 * @param sync the sync object
130 * @param mode the mode
131 *
132 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
133 */
134 public static void eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, int mode) throws LWJGLException {
135 if ( !neglSignalSyncKHR(dpy.getPointer(), sync.getPointer(), mode) )
136 throwEGLError("Failed to signal the KHR fence sync object.");
137 }
138
139 private static native boolean neglSignalSyncKHR(long dpy_ptr, long sync_ptr, int mode);
140
141 /**
142 * Returns the value of the sync object attribute.
143 *
144 * @param sync the sync object
145 * @param attribute the attribute to query
146 *
147 * @return the attribute value
148 *
149 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
150 */
151 public static int eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, int attribute) throws LWJGLException {
152 return EGLKHRFenceSync.eglGetSyncAttribKHR(dpy, sync, attribute);
153 }
154
155 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.MemoryUtil;
35
36 import java.nio.IntBuffer;
37
38 import static org.lwjgl.opengles.EGL.*;
39
40 /** EGL_NV_sync wrapper class. */
41 public final class EGLNVSync {
42
43 /**
44 * Accepted in the &lt;condition&gt; parameter of eglCreateFenceSyncNV, and
45 * returned in &lt;value&gt; when eglGetSyncAttribNV is called with &lt;attribute&gt;
46 * EGL_SYNC_CONDITION_NV:
47 */
48 public static final int EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV = 0x30E6;
49
50 /**
51 * Accepted as an attribute name in the &lt;attrib_list&gt; parameter of
52 * eglCreateFenceSyncNV, and by the &lt;attribute&gt; parameter of
53 * eglGetSyncAttribNV:
54 */
55 public static final int EGL_SYNC_STATUS_NV = 0x30E7;
56
57 /**
58 * Accepted as an attribute value in the &lt;attrib_list&gt; parameter of
59 * eglCreateFenceSyncNV for the EGL_SYNC_STATUS_NV attribute, by
60 * the &lt;mode&gt; parameter of eglSignalSyncNV and returned in &lt;value&gt;
61 * when eglGetSyncAttribNV is called with &lt;attribute&gt;
62 * EGL_SYNC_STATUS_NV:
63 */
64 public static final int EGL_SIGNALED_NV = 0x30E8,
65 EGL_UNSIGNALED_NV = 0x30E9;
66
67 /** Accepted in the &lt;flags&gt; parameter of eglClientWaitSyncNV: */
68 public static final int EGL_SYNC_FLUSH_COMMANDS_BIT_NV = 0x0001;
69
70 /** Accepted in the &lt;timeout&gt; parameter of eglClientWaitSyncNV: */
71 public static final long EGL_FOREVER_NV = 0xFFFFFFFFFFFFFFFFL;
72
73 /** Returned by eglClientWaitSyncNV: */
74 public static final int EGL_ALREADY_SIGNALED_NV = 0x30EA,
75 EGL_TIMEOUT_EXPIRED_NV = 0x30EB,
76 EGL_CONDITION_SATISFIED_NV = 0x30EC;
77
78 /** Accepted in the &lt;attribute&gt; parameter of eglGetSyncAttribNV: */
79 public static final int EGL_SYNC_TYPE_NV = 0x30ED,
80 EGL_SYNC_CONDITION_NV = 0x30EE;
81
82 /**
83 * Returned in &lt;value&gt; when eglGetSyncAttribNV is called with
84 * &lt;attribute&gt; EGL_SYNC_TYPE_NV:
85 */
86 public static final int EGL_SYNC_FENCE_NV = 0x30EF;
87
88 /** Returned by eglCreateFenceSyncNV in the event of an error: */
89 public static final long EGL_NO_SYNC_NV = 0;
90
91 static {
92 initNativeStubs();
93 }
94
95 private EGLNVSync() {
96 }
97
98 private static native void initNativeStubs();
99
100 /**
101 * Creates a fence sync object for the specified EGL display and returns
102 * a handle to the new object.
103 *
104 * @param dpy the EGL display
105 * @param condition the sync condition
106 * @param attrib_list an attribute list (may be null)
107 *
108 * @return the created fence sync object
109 *
110 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
111 */
112 public static EGLSyncNV eglCreateFenceSyncNV(EGLDisplay dpy, int condition, IntBuffer attrib_list) throws LWJGLException {
113 checkAttribList(attrib_list);
114
115 final long pointer = neglCreateFenceSyncNV(dpy.getPointer(), condition, MemoryUtil.getAddressSafe(attrib_list));
116
117 if ( pointer == EGL_NO_SYNC_NV )
118 throwEGLError("Failed to create NV fence sync object.");
119
120 return new EGLSyncNV(pointer);
121 }
122
123 private static native long neglCreateFenceSyncNV(long dpy_ptr, int condition, long attrib_list);
124
125 /**
126 * Destroys an existing sync object.
127 *
128 * @param sync the sync object
129 *
130 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
131 */
132 public static void eglDestroySyncNV(EGLSyncNV sync) throws LWJGLException {
133 if ( !neglDestroySyncNV(sync.getPointer()) )
134 throwEGLError("Failed to destroy NV fence sync object.");
135 }
136
137 private static native boolean neglDestroySyncNV(long sync_ptr);
138
139 /**
140 * Inserts a fence command into the command stream of the bound API's current
141 * context and associates it with sync object.
142 *
143 * @param sync the sync object
144 *
145 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
146 */
147 public static void eglFenceNV(EGLSyncNV sync) throws LWJGLException {
148 if ( !neglFenceNV(sync.getPointer()) )
149 throwEGLError("Failed to insert NV fence command.");
150 }
151
152 private static native boolean neglFenceNV(long sync_ptr);
153
154 /**
155 * Blocks the calling thread until the specified sync object is
156 * signaled, or until a specified timeout value expires.
157 *
158 * @param sync the sync object
159 * @param flags the block flags
160 * @param timeout the block timeout
161 *
162 * @return the sync object status
163 *
164 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
165 */
166 public static int eglClientWaitSyncNV(EGLSyncNV sync, int flags, long timeout) throws LWJGLException {
167 final int status = neglClientWaitSyncNV(sync.getPointer(), flags, timeout);
168
169 if ( status == EGL_FALSE )
170 throwEGLError("Failed to block on NV fence sync object.");
171
172 return status;
173 }
174
175 private static native int neglClientWaitSyncNV(long sync_ptr, int flags, long timeout);
176
177 /**
178 * Signals or unsignals the sync object by changing its status to
179 * the specified mode.
180 *
181 * @param sync the sync object
182 * @param mode the mode
183 *
184 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
185 */
186 public static void eglSignalSyncNV(EGLSyncNV sync, int mode) throws LWJGLException {
187 if ( !neglSignalSyncNV(sync.getPointer(), mode) )
188 throwEGLError("Failed to signal the NV fence sync object.");
189 }
190
191 private static native boolean neglSignalSyncNV(long sync_ptr, int mode);
192
193 /**
194 * Returns the value of the sync object attribute.
195 *
196 * @param sync the sync object
197 * @param attribute the attribute to query
198 *
199 * @return the attribute value
200 *
201 * @throws org.lwjgl.LWJGLException if an EGL error occurs.
202 */
203 public static int eglGetSyncAttribNV(EGLSyncNV sync, int attribute) throws LWJGLException {
204 final IntBuffer value = APIUtil.getBufferInt();
205
206 if ( !neglGetSyncAttribNV(sync.getPointer(), attribute, MemoryUtil.getAddress0(value)) )
207 throwEGLError("Failed to get NV fence sync object attribute.");
208
209 return value.get(0);
210 }
211
212 private static native boolean neglGetSyncAttribNV(long sync_ptr, int attribute, long value);
213
214 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.PointerWrapperAbstract;
35
36 import java.nio.IntBuffer;
37
38 import static org.lwjgl.opengles.EGL.*;
39
40 /** EGLSurface wrapper class. */
41 public final class EGLSurface extends PointerWrapperAbstract {
42
43 private final EGLDisplay display;
44 private final EGLConfig config;
45
46 private boolean destroyed;
47
48 EGLSurface(final EGLDisplay display, final EGLConfig config, final long pointer) {
49 super(pointer);
50
51 if ( !display.isInitialized() )
52 throw new IllegalStateException("Invalid EGL display specified.");
53
54 this.display = display;
55 this.config = config;
56 }
57
58 /**
59 * Returns the EGL display from which this EGL surface was created.
60 *
61 * @return the EGL display
62 */
63 public EGLDisplay getDisplay() {
64 return display;
65 }
66
67 /**
68 * Returns the EGL config associated with this EGL surface.
69 *
70 * @return the EGL config
71 */
72 public EGLConfig getConfig() {
73 return config;
74 }
75
76 private void checkDestroyed() {
77 if ( destroyed )
78 throw new IllegalStateException("The EGL surface has been destroyed.");
79 }
80
81 /** Destroys this EGL surface. */
82 public void destroy() throws LWJGLException {
83 eglDestroySurface(display, this);
84 destroyed = true;
85 }
86
87 void setAttribute(int attribute, int value) throws LWJGLException {
88 checkDestroyed();
89 eglSurfaceAttrib(display, this, attribute, value);
90 }
91
92 /**
93 * Returns the value of the specified EGL surface attribute.
94 *
95 * @param attribute the surface attribute
96 *
97 * @return the attribute value
98 */
99 public int getAttribute(int attribute) throws LWJGLException {
100 checkDestroyed();
101
102 IntBuffer value = APIUtil.getBufferInt();
103 eglQuerySurface(display, this, attribute, value);
104 return value.get(0);
105 }
106
107 public void swapBuffers() throws LWJGLException, PowerManagementEventException {
108 checkDestroyed();
109 eglSwapBuffers(display, this);
110 }
111
112 public boolean equals(final Object obj) {
113 if ( obj == null || !(obj instanceof EGLSurface) )
114 return false;
115
116 return getPointer() == ((EGLSurface)obj).getPointer();
117 }
118
119 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /** EGLSyncKHR wrapper class. */
36 public class EGLSyncKHR extends PointerWrapperAbstract {
37
38 public EGLSyncKHR(final long pointer) {
39 super(pointer);
40 }
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /** EGLSyncNV wrapper class. */
36 public class EGLSyncNV extends PointerWrapperAbstract {
37
38 public EGLSyncNV(final long pointer) {
39 super(pointer);
40 }
41
42 }
0 /*
1 * Copyright 2002-2004 The Apache Software Foundation.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4 * License. You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
9 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12 package org.lwjgl.opengles;
13
14 import java.util.Iterator;
15
16 /**
17 * A hash map using primitive ints as keys rather than objects.
18 *
19 * @author Justin Couch
20 * @author Alex Chaffee (alex@apache.org)
21 * @author Stephen Colebourne
22 * @author Nathan Sweet
23 */
24 final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
25
26 private Entry[] table;
27 private int size, mask, capacity, threshold;
28
29 /** Same as: FastIntMap(16, 0.75f); */
30 FastIntMap() {
31 this(16, 0.75f);
32 }
33
34 /** Same as: FastIntMap(initialCapacity, 0.75f); */
35 FastIntMap(int initialCapacity) {
36 this(initialCapacity, 0.75f);
37 }
38
39 FastIntMap(int initialCapacity, float loadFactor) {
40 if ( initialCapacity > 1 << 30 ) throw new IllegalArgumentException("initialCapacity is too large.");
41 if ( initialCapacity < 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
42 if ( loadFactor <= 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
43 capacity = 1;
44 while ( capacity < initialCapacity )
45 capacity <<= 1;
46 this.threshold = (int)(capacity * loadFactor);
47 this.table = new Entry[capacity];
48 this.mask = capacity - 1;
49 }
50
51 private int index(final int key) {
52 return index(key, mask);
53 }
54
55 private static int index(final int key, final int mask) {
56 return key & mask;
57 }
58
59 public V put(int key, V value) {
60 final Entry<V>[] table = this.table;
61 int index = index(key);
62
63 // Check if key already exists.
64 for ( Entry<V> e = table[index]; e != null; e = e.next ) {
65 if ( e.key != key ) continue;
66 V oldValue = e.value;
67 e.value = value;
68 return oldValue;
69 }
70
71 table[index] = new Entry<V>(key, value, table[index]);
72
73 if ( size++ >= threshold )
74 rehash(table);
75
76 return null;
77 }
78
79 private void rehash(final Entry<V>[] table) {
80 final int newCapacity = 2 * capacity;
81 final int newMask = newCapacity - 1;
82
83 final Entry<V>[] newTable = new Entry[newCapacity];
84
85 for ( int i = 0, index; i < table.length; i++ ) {
86 Entry<V> e = table[i];
87 if ( e == null ) continue;
88 do {
89 final Entry<V> next = e.next;
90 index = index(e.key, newMask);
91 e.next = newTable[index];
92 newTable[index] = e;
93 e = next;
94 } while ( e != null );
95 }
96
97 this.table = newTable;
98 capacity = newCapacity;
99 mask = newMask;
100 threshold *= 2;
101 }
102
103 public V get(int key) {
104 final int index = index(key);
105 for ( Entry<V> e = table[index]; e != null; e = e.next )
106 if ( e.key == key ) return e.value;
107 return null;
108 }
109
110 public boolean containsValue(Object value) {
111 final Entry<V>[] table = this.table;
112 for ( int i = table.length - 1; i >= 0; i-- )
113 for ( Entry<V> e = table[i]; e != null; e = e.next )
114 if ( e.value.equals(value) ) return true;
115 return false;
116 }
117
118 public boolean containsKey(int key) {
119 final int index = index(key);
120 for ( Entry<V> e = table[index]; e != null; e = e.next )
121 if ( e.key == key ) return true;
122 return false;
123 }
124
125 public V remove(int key) {
126 final int index = index(key);
127
128 Entry<V> prev = table[index];
129 Entry<V> e = prev;
130 while ( e != null ) {
131 Entry<V> next = e.next;
132 if ( e.key == key ) {
133 size--;
134 if ( prev == e )
135 table[index] = next;
136 else
137 prev.next = next;
138 return e.value;
139 }
140 prev = e;
141 e = next;
142 }
143 return null;
144 }
145
146 public int size() {
147 return size;
148 }
149
150 public boolean isEmpty() {
151 return size == 0;
152 }
153
154 public void clear() {
155 final Entry<V>[] table = this.table;
156 for ( int index = table.length - 1; index >= 0; index-- )
157 table[index] = null;
158 size = 0;
159 }
160
161 public EntryIterator iterator() {
162 return new EntryIterator();
163 }
164
165 public class EntryIterator implements Iterator<Entry<V>> {
166
167 private int nextIndex;
168 private Entry<V> current;
169
170 EntryIterator() {
171 reset();
172 }
173
174 public void reset() {
175 current = null;
176 // Find first bucket.
177 final Entry<V>[] table = FastIntMap.this.table;
178 int i;
179 for ( i = table.length - 1; i >= 0; i-- )
180 if ( table[i] != null ) break;
181 nextIndex = i;
182 }
183
184 public boolean hasNext() {
185 if ( nextIndex >= 0 ) return true;
186 Entry e = current;
187 return e != null && e.next != null;
188 }
189
190 public Entry<V> next() {
191 // Next entry in current bucket.
192 Entry<V> e = current;
193 if ( e != null ) {
194 e = e.next;
195 if ( e != null ) {
196 current = e;
197 return e;
198 }
199 }
200 // Use the bucket at nextIndex and find the next nextIndex.
201 final Entry<V>[] table = FastIntMap.this.table;
202 int i = nextIndex;
203 e = current = table[i];
204 while ( --i >= 0 )
205 if ( table[i] != null ) break;
206 nextIndex = i;
207 return e;
208 }
209
210 public void remove() {
211 FastIntMap.this.remove(current.key);
212 }
213 }
214
215 static final class Entry<T> {
216
217 final int key;
218 T value;
219 Entry<T> next;
220
221 Entry(int key, T value, Entry<T> next) {
222 this.key = key;
223 this.value = value;
224 this.next = next;
225 }
226
227 public int getKey() {
228 return key;
229 }
230
231 public T getValue() {
232 return value;
233 }
234
235 }
236
237 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.opengl.OpenGLException;
36
37 import java.nio.Buffer;
38
39 import static org.lwjgl.opengles.GLES20.*;
40
41 /**
42 * A class to check buffer boundaries in GL methods. Many GL
43 * methods read data from the GL into a native Buffer at its current position. If there is unsufficient space in the buffer when
44 * the call is made then a buffer overflow would otherwise occur and cause unexpected behaviour, a crash, or worse, a security
45 * risk. Therefore in those methods where GL reads data back into a buffer, we will call a bounds check method from this class
46 * to ensure that there is sufficient space in the buffer.
47 * <p/>
48 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
49 *
50 * @author cix_foo <cix_foo@users.sourceforge.net>
51 * @version $Revision: 3459 $
52 * $Id: GLChecks.java 3459 2010-11-29 17:21:05Z spasi $
53 */
54 class GLChecks {
55
56 /** Static methods only! */
57 private GLChecks() {
58 }
59
60 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
61 static void ensureArrayVBOdisabled() {
62 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().arrayBuffer != 0 )
63 throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
64 }
65
66 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
67 static void ensureArrayVBOenabled() {
68 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().arrayBuffer == 0 )
69 throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
70 }
71
72 /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
73 static void ensureElementVBOdisabled() {
74 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().elementArrayBuffer != 0 )
75 throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
76 }
77
78 /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
79 static void ensureElementVBOenabled() {
80 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().elementArrayBuffer == 0 )
81 throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
82 }
83
84 /** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
85 static void ensurePackPBOdisabled() {
86 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().pixelPackBuffer != 0 )
87 throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
88 }
89
90 /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
91 static void ensurePackPBOenabled() {
92 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().pixelPackBuffer == 0 )
93 throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
94 }
95
96 /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
97 static void ensureUnpackPBOdisabled() {
98 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().pixelUnpackBuffer != 0 )
99 throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
100 }
101
102 /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
103 static void ensureUnpackPBOenabled() {
104 if ( LWJGLUtil.CHECKS && StateTracker.getTracker().pixelUnpackBuffer == 0 )
105 throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
106 }
107
108 /**
109 * Calculate the storage required for an image in elements
110 *
111 * @param format The format of the image (example: GL_RGBA)
112 * @param type The type of the image elements (example: GL_UNSIGNED_BYTE)
113 * @param width The width of the image
114 * @param height The height of the image (1 for 1D images)
115 * @param depth The depth of the image (1 for 2D images)
116 *
117 * @return the size, in elements, of the image
118 */
119 static int calculateImageStorage(Buffer buffer, int format, int type, int width, int height, int depth) {
120 return LWJGLUtil.CHECKS ? calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer) : 0;
121 }
122
123 static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width) {
124 return LWJGLUtil.CHECKS ? calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer) : 0;
125 }
126
127 static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height) {
128 return LWJGLUtil.CHECKS ? calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer) : 0;
129 }
130
131 static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth) {
132 return LWJGLUtil.CHECKS ? calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer) : 0;
133 }
134
135 /**
136 * Calculate the storage required for an image in bytes.
137 *
138 * @param format The format of the image (example: GL_RGBA)
139 * @param type The type of the image elements (example: GL_UNSIGNED_BYTE)
140 * @param width The width of the image
141 * @param height The height of the image (1 for 1D images)
142 * @param depth The depth of the image (1 for 2D images)
143 *
144 * @return the size, in bytes, of the image
145 */
146 private static int calculateImageStorage(int format, int type, int width, int height, int depth) {
147 return calculateBytesPerPixel(format, type) * width * height * depth;
148 }
149
150 private static int calculateTexImage1DStorage(int format, int type, int width) {
151 return calculateBytesPerPixel(format, type) * width;
152 }
153
154 private static int calculateTexImage2DStorage(int format, int type, int width, int height) {
155 return calculateTexImage1DStorage(format, type, width) * height;
156 }
157
158 private static int calculateTexImage3DStorage(int format, int type, int width, int height, int depth) {
159 return calculateTexImage2DStorage(format, type, width, height) * depth;
160 }
161
162 private static int calculateBytesPerPixel(int format, int type) {
163 int bpe;
164 switch ( type ) {
165 case GL_UNSIGNED_BYTE:
166 case GL_BYTE:
167 bpe = 1;
168 break;
169 case GL_UNSIGNED_SHORT:
170 case GL_SHORT:
171 bpe = 2;
172 break;
173 case GL_UNSIGNED_INT:
174 case GL_INT:
175 case GL_FLOAT:
176 bpe = 4;
177 break;
178 default:
179 // TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8
180 return 0;
181 // throw new IllegalArgumentException("Unknown type " + type);
182 }
183 int epp;
184 switch ( format ) {
185 case GL_LUMINANCE:
186 case GL_ALPHA:
187 epp = 1;
188 break;
189
190 case GL_LUMINANCE_ALPHA:
191 epp = 2;
192 break;
193 case GL_RGB:
194 epp = 3;
195 break;
196 case GL_RGBA:
197 epp = 4;
198 break;
199 default:
200 // TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT)
201 return 0;
202 }
203
204 return bpe * epp;
205 }
206
207 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36
37 import java.lang.reflect.InvocationTargetException;
38 import java.lang.reflect.Method;
39 import java.security.AccessController;
40 import java.security.PrivilegedActionException;
41 import java.security.PrivilegedExceptionAction;
42 import java.util.Map;
43 import java.util.Set;
44 import java.util.StringTokenizer;
45 import java.util.WeakHashMap;
46
47 import static org.lwjgl.opengles.GLES20.*;
48
49 /**
50 * <p/>
51 * Manages GL contexts. Before any rendering is done by a LWJGL system, a call should be made to GLContext.useContext() with a
52 * context. This will ensure that GLContext has an accurate reflection of the current context's capabilities and function
53 * pointers.
54 * <p/>
55 * This class is thread-safe in the sense that multiple threads can safely call all public methods. The class is also
56 * thread-aware in the sense that it tracks a per-thread current context (including capabilities and function pointers).
57 * That way, multiple threads can have multiple contexts current and render to them concurrently.
58 *
59 * @author elias_naur <elias_naur@users.sourceforge.net>
60 * @version $Revision: 3279 $
61 * $Id: GLContext.java 3279 2010-03-11 21:06:49Z spasi $
62 */
63 public final class GLContext {
64
65 /** Maps threads to their current context's ContextCapabilities, if any */
66 private static final ThreadLocal<ContextCapabilities> current_capabilities = new ThreadLocal<ContextCapabilities>();
67
68 /**
69 * The getCapabilities() method is a potential hot spot in any LWJGL application, since
70 * it is needed for context capability discovery (e.g. is OpenGL 2.0 supported?), and
71 * for the function pointers of gl functions. However, the 'current_capabilities' ThreadLocal
72 * is (relatively) expensive to look up, and since most OpenGL applications use are single threaded
73 * rendering, the following two is an optimization for this case.
74 * <p/>
75 * ThreadLocals can be thought of as a mapping between threads and values, so the idea
76 * is to use a lock-less cache of mappings between threads and the current ContextCapabilities. The cache
77 * could be any size, but in our case, we want a single sized cache for optimal performance
78 * in the single threaded case.
79 * <p/>
80 * 'fast_path_cache' is the most recent ContextCapabilities (potentially null) and its owner. By
81 * recent I mean the last thread setting the value in setCapabilities(). When getCapabilities()
82 * is called, a check to see if the current is the owner of the ContextCapabilities instance in
83 * fast_path_cache. If so, the instance is returned, if not, some thread has since taken ownership
84 * of the cache entry and the slower current_capabilities ThreadLocal is queried instead.
85 * <p/>
86 * No locks are needed in get/setCapabilities, because even though fast_path_cache can be accessed
87 * from multiple threads at once, we are guaranteed by the JVM spec that its value is always valid.
88 * Furthermore, if the ownership test in getCapabilities() succeeds, the cache entry can only contain
89 * the correct ContextCapabilites (that is, the one from getThreadLocalCapabilites()),
90 * since no other thread can set the owner to anyone else than itself.
91 */
92 private static CapabilitiesCacheEntry fast_path_cache = new CapabilitiesCacheEntry();
93
94 /**
95 * Simple lock-free cache of CapabilitesEntryCache to avoid allocating more than one
96 * cache entry per thread
97 */
98 private static final ThreadLocal<CapabilitiesCacheEntry> thread_cache_entries = new ThreadLocal<CapabilitiesCacheEntry>();
99
100 /**
101 * The weak mapping from context Object instances to ContextCapabilities. Used
102 * to avoid recreating a ContextCapabilities every time a context is made current.
103 */
104 private static final Map<Object, ContextCapabilities> capability_cache = new WeakHashMap<Object, ContextCapabilities>();
105
106 /** Reference count of the native opengl implementation library */
107 private static int gl_ref_count;
108 private static boolean did_auto_load;
109
110 static {
111 Sys.initialize();
112 }
113
114 /**
115 * Get the current capabilities instance. It contains the flags used
116 * to test for support of a particular extension.
117 *
118 * @return The current capabilities instance.
119 */
120 public static ContextCapabilities getCapabilities() {
121 CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
122 // Check owner of cache entry
123 if ( recent_cache_entry.owner == Thread.currentThread() ) {
124 /* The owner ship test succeeded, so the cache must contain the current ContextCapabilities instance
125 * assert recent_cache_entry.capabilities == getThreadLocalCapabilities();
126 */
127 return recent_cache_entry.capabilities;
128 } else // Some other thread has written to the cache since, and we fall back to the slower path
129 return getThreadLocalCapabilities();
130 }
131
132 private static ContextCapabilities getThreadLocalCapabilities() {
133 return current_capabilities.get();
134 }
135
136 /**
137 * Set the current capabilities instance. It contains the flags used
138 * to test for support of a particular extension.
139 *
140 * @return The current capabilities instance.
141 */
142 static void setCapabilities(ContextCapabilities capabilities) {
143 current_capabilities.set(capabilities);
144
145 CapabilitiesCacheEntry thread_cache_entry = thread_cache_entries.get();
146 if ( thread_cache_entry == null ) {
147 thread_cache_entry = new CapabilitiesCacheEntry();
148 thread_cache_entries.set(thread_cache_entry);
149 }
150 thread_cache_entry.owner = Thread.currentThread();
151 thread_cache_entry.capabilities = capabilities;
152
153 fast_path_cache = thread_cache_entry;
154 }
155
156 /**
157 * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
158 *
159 * @param supported_extensions the Set to fill with the available extension names
160 *
161 * @return the context profile mask, will be 0 for any version < 3.2
162 */
163 static void getSupportedExtensions(final Set<String> supported_extensions) {
164 // Detect OpenGL version first
165 final String version = glGetString(GL_VERSION);
166 if ( version == null )
167 throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context.");
168
169 final String VERSION_PREFIX = "OpenGL ES ";
170 final StringTokenizer version_tokenizer = new StringTokenizer(version.substring(VERSION_PREFIX.length()), ". ");
171
172 int majorVersion = 0;
173 int minorVersion = 0;
174 try {
175 majorVersion = Integer.parseInt(version_tokenizer.nextToken());
176 minorVersion = Integer.parseInt(version_tokenizer.nextToken());
177 } catch (NumberFormatException e) {
178 LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
179 }
180
181 // ----------------------[ 2.X ]----------------------
182 if ( 3 <= majorVersion )
183 supported_extensions.add("OpenGLES30");
184 if ( 2 <= majorVersion )
185 supported_extensions.add("OpenGLES20");
186
187 // Parse EXTENSIONS string
188 final String extensions_string = glGetString(GL_EXTENSIONS);
189 if ( extensions_string == null )
190 throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?");
191
192 final StringTokenizer tokenizer = new StringTokenizer(extensions_string);
193 while ( tokenizer.hasMoreTokens() )
194 supported_extensions.add(tokenizer.nextToken());
195 }
196
197 /**
198 * Helper method to ContextCapabilities. It will try to initialize the native stubs,
199 * and remove the given extension name from the extension set if the initialization fails.
200 */
201 static void initNativeStubs(final Class extension_class, Set<String> supported_extensions, String ext_name) {
202 //resetNativeStubs(extension_class);
203 if ( supported_extensions.contains(ext_name) ) {
204 try {
205 doInitNativeStubs(extension_class);
206 } catch (LWJGLException e) {
207 LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e);
208 supported_extensions.remove(ext_name);
209 }
210 }
211 }
212
213 static void doInitNativeStubs(final Class<?> extension_class) throws LWJGLException {
214 try {
215 AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
216 public Object run() throws Exception {
217 Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs");
218 init_stubs_method.invoke(null);
219 return null;
220 }
221 });
222 } catch (PrivilegedActionException e) {
223 final Throwable c = e.getCause();
224 if ( c instanceof InvocationTargetException )
225 throw new LWJGLException(c.getCause());
226 else
227 throw new LWJGLException(c);
228 }
229 }
230
231 /**
232 * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to
233 * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and
234 * function pointers. Use useContext(null) when no context is active. <p>If the context is the same as last time, then this is
235 * a no-op. <p>If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set
236 * of caps and function pointers will be used. <p>The reference to the context is held in a weak reference; therefore if no
237 * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the
238 * future, freeing up a little RAM.
239 *
240 * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are
241 * unloaded.
242 *
243 * @throws org.lwjgl.LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded
244 */
245 public static synchronized void useContext(Object context) throws LWJGLException {
246 if ( context == null ) {
247 // Moved this to the shutdown hook
248 ContextCapabilities.unloadAllStubs();
249 setCapabilities(null);
250 if ( did_auto_load )
251 unloadOpenGLLibrary();
252 return;
253 }
254
255 if ( gl_ref_count == 0 ) {
256 loadOpenGLLibrary();
257 did_auto_load = true;
258 }
259
260 try {
261 ContextCapabilities capabilities = capability_cache.get(context);
262 if ( capabilities == null ) {
263 /*
264 * The capabilities object registers itself as current. This behaviour is caused
265 * by a chicken-and-egg situation where the constructor needs to call GL functions
266 * as part of its capability discovery, but GL functions cannot be called before
267 * a capabilities object has been set.
268 */
269 new ContextCapabilities();
270 capability_cache.put(context, getCapabilities());
271 } else
272 setCapabilities(capabilities);
273 } catch (LWJGLException e) {
274 if ( did_auto_load )
275 unloadOpenGLLibrary();
276 throw e;
277
278 }
279 }
280
281 /** If the OpenGL reference count is 0, the library is loaded. The reference count is then incremented. */
282 public static synchronized void loadOpenGLLibrary() throws LWJGLException {
283 if ( gl_ref_count == 0 )
284 nLoadOpenGLLibrary();
285 gl_ref_count++;
286 }
287
288 private static native void nLoadOpenGLLibrary() throws LWJGLException;
289
290 /** The OpenGL library reference count is decremented, and if it reaches 0, the library is unloaded. */
291 public static synchronized void unloadOpenGLLibrary() {
292 gl_ref_count--;
293 /*
294 * Unload the native OpenGL library unless we're on linux, since
295 * some drivers (NVIDIA proprietary) crash on exit when unloading the library.
296 */
297 if ( gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX )
298 nUnloadOpenGLLibrary();
299 }
300
301 private static native void nUnloadOpenGLLibrary();
302
303 /** Native method to clear native stub bindings */
304 static native void resetNativeStubs(Class clazz);
305
306 private static final class CapabilitiesCacheEntry {
307
308 Thread owner;
309 ContextCapabilities capabilities;
310 }
311 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * This class is a wrapper around a GLsync pointer.
37 *
38 * @author spasi <spasi@users.sourceforge.net>
39 */
40 public final class GLSync extends PointerWrapperAbstract {
41
42 GLSync(final long sync) {
43 super(sync);
44 }
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.opengles;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Instances of this class are needed to use the callback functionality of the KHR_debug extension.
37 * Users of this class may provide implementations of the {@code Handler} interface to receive notifications.
38 * The same {@code Handler} instance may be used by different contexts but it is not recommended.
39 * Handler notifications are synchronized.
40 *
41 * @author Spasi
42 */
43 public final class KHRDebugCallback extends PointerWrapperAbstract {
44
45 /** Severity levels. */
46 private static final int
47 GL_DEBUG_SEVERITY_HIGH = 0x9146,
48 GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
49 GL_DEBUG_SEVERITY_LOW = 0x9148,
50 GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
51
52 /** Sources. */
53 private static final int
54 GL_DEBUG_SOURCE_API = 0x8246,
55 GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
56 GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
57 GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
58 GL_DEBUG_SOURCE_APPLICATION = 0x824A,
59 GL_DEBUG_SOURCE_OTHER = 0x824B;
60
61 /** Types. */
62 private static final int
63 GL_DEBUG_TYPE_ERROR = 0x824C,
64 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
65 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
66 GL_DEBUG_TYPE_PORTABILITY = 0x824F,
67 GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
68 GL_DEBUG_TYPE_OTHER = 0x8251,
69 GL_DEBUG_TYPE_MARKER = 0x8268;
70
71 private static final long CALLBACK_POINTER;
72
73 static {
74 long pointer = 0;
75 try {
76 // Call reflectively so that we can compile this class for the Generator.
77 pointer = (Long)Class.forName("org.lwjgl.opengles.CallbackUtil").getDeclaredMethod("getDebugCallbackKHR").invoke(null);
78 } catch (Exception e) {
79 // ignore
80 }
81 CALLBACK_POINTER = pointer;
82 }
83
84 private final Handler handler;
85
86 /**
87 * Creates an KHRebugCallback with a default callback handler.
88 * The default handler will simply print the message on System.err.
89 */
90 public KHRDebugCallback() {
91 this(new Handler() {
92 public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
93 System.err.println("[LWJGL] KHR_debug message");
94 System.err.println("\tID: " + id);
95
96 String description;
97 switch ( source ) {
98 case GL_DEBUG_SOURCE_API:
99 description = "API";
100 break;
101 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
102 description = "WINDOW SYSTEM";
103 break;
104 case GL_DEBUG_SOURCE_SHADER_COMPILER:
105 description = "SHADER COMPILER";
106 break;
107 case GL_DEBUG_SOURCE_THIRD_PARTY:
108 description = "THIRD PARTY";
109 break;
110 case GL_DEBUG_SOURCE_APPLICATION:
111 description = "APPLICATION";
112 break;
113 case GL_DEBUG_SOURCE_OTHER:
114 description = "OTHER";
115 break;
116 default:
117 description = "Unknown (" + Integer.toHexString(source) + ")";
118 }
119 System.err.println("\tSource: " + description);
120
121 switch ( type ) {
122 case GL_DEBUG_TYPE_ERROR:
123 description = "ERROR";
124 break;
125 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
126 description = "DEPRECATED BEHAVIOR";
127 break;
128 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
129 description = "UNDEFINED BEHAVIOR";
130 break;
131 case GL_DEBUG_TYPE_PORTABILITY:
132 description = "PORTABILITY";
133 break;
134 case GL_DEBUG_TYPE_PERFORMANCE:
135 description = "PERFORMANCE";
136 break;
137 case GL_DEBUG_TYPE_OTHER:
138 description = "OTHER";
139 break;
140 case GL_DEBUG_TYPE_MARKER:
141 description = "MARKER";
142 break;
143 default:
144 description = "Unknown (" + Integer.toHexString(source) + ")";
145 }
146 System.err.println("\tType: " + description);
147
148 switch ( severity ) {
149 case GL_DEBUG_SEVERITY_HIGH:
150 description = "HIGH";
151 break;
152 case GL_DEBUG_SEVERITY_MEDIUM:
153 description = "MEDIUM";
154 break;
155 case GL_DEBUG_SEVERITY_LOW:
156 description = "LOW";
157 break;
158 case GL_DEBUG_SEVERITY_NOTIFICATION:
159 description = "NOTIFICATION";
160 break;
161 default:
162 description = "Unknown (" + Integer.toHexString(source) + ")";
163 }
164 System.err.println("\tSeverity: " + description);
165
166 System.err.println("\tMessage: " + message);
167 }
168 });
169 }
170
171 /**
172 * Creates an ARBDebugOutputCallback with the specified callback handler.
173 * The handler's {@code handleMessage} method will be called whenever
174 * debug output is generated by the GL.
175 *
176 * @param handler the callback handler
177 */
178 public KHRDebugCallback(final Handler handler) {
179 super(CALLBACK_POINTER);
180
181 this.handler = handler;
182 }
183
184 Handler getHandler() {
185 return handler;
186 }
187
188 /** Implementations of this interface can be used to receive ARB_debug_output notifications. */
189 public interface Handler {
190
191 /**
192 * This method will be called when an ARB_debug_output message is generated.
193 *
194 * @param id the message ID
195 * @param source the message source
196 * @param type the message type
197 * @param severity the message severity
198 * @param message the string representation of the message.
199 */
200 void handleMessage(int source, int type, int id, int severity, String message);
201
202 }
203
204 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35
36 import java.nio.ByteBuffer;
37
38 /**
39 *
40 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: PeerInfo.java 3418 2010-09-28 21:11:35Z 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 final synchronized 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 final synchronized 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 final ByteBuffer getHandle() {
91 return handle;
92 }
93
94 public void destroy() {
95 }
96 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.LWJGLUtil;
36 import org.lwjgl.opengl.PixelFormatLWJGL;
37
38 import java.nio.IntBuffer;
39 import java.util.HashMap;
40 import java.util.HashSet;
41 import java.util.Map;
42 import java.util.Set;
43
44 import static org.lwjgl.opengles.EGL.*;
45 import static org.lwjgl.opengles.NVCoverageSample.*;
46 import static org.lwjgl.opengles.NVDepthNonlinear.*;
47 import static org.lwjgl.opengles.PixelFormat.Attrib.*;
48
49 /**
50 * This class describes the configuration settings for an EGL surface. Instances
51 * of this class are used as arguments to Display.create(). The attributes specified
52 * in this class will be used to get EGLConfigs from an EGLDisplay. PixelFormat
53 * is not the best name for this class, but it matches the corresponding class
54 * in the official desktop LWJGL.
55 * <p/>
56 * Instances of this class are immutable. An example of the expected way to set
57 * the PixelFormat property values is the following:
58 * <code>PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4);</code>
59 * <p/>
60 * Attributes that correspond to EGL extensions will be silently ignored if those
61 * extensions are not supported by the EGLDisplay.
62 */
63 public final class PixelFormat implements PixelFormatLWJGL {
64
65 public static enum Attrib {
66 // CORE ATTRIBUTES
67
68 RED_SIZE(EGL_RED_SIZE, 0),
69 GREEN_SIZE(EGL_GREEN_SIZE, 0),
70 BLUE_SIZE(EGL_BLUE_SIZE, 0),
71 ALPHA_SIZE(EGL_ALPHA_SIZE, 0),
72
73 LUMINANCE_SIZE(EGL_LUMINANCE_SIZE, 0),
74
75 DEPTH_SIZE(EGL_DEPTH_SIZE, 0),
76 STENCIL_SIZE(EGL_STENCIL_SIZE, 0),
77
78 MIN_SWAP_INTERVAL(EGL_MIN_SWAP_INTERVAL, EGL_DONT_CARE),
79 MAX_SWAP_INTERVAL(EGL_MAX_SWAP_INTERVAL, EGL_DONT_CARE),
80
81 SAMPLES(EGL_SAMPLES, 0),
82 SAMPLE_BUFFERS(EGL_SAMPLE_BUFFERS, 0),
83
84 TRANSPARENT_TYPE(EGL_TRANSPARENT_TYPE, EGL_NONE),
85 TRANSPARENT_RED_VALUE(EGL_TRANSPARENT_RED_VALUE, EGL_DONT_CARE),
86 TRANSPARENT_GREEN_VALUE(EGL_TRANSPARENT_GREEN_VALUE, EGL_DONT_CARE),
87 TRANSPARENT_BLUE_VALUE(EGL_TRANSPARENT_BLUE_VALUE, EGL_DONT_CARE),
88
89 // SURFACE ATTRIBUTES
90
91 MULTISAMPLE_RESOLVE(EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_DEFAULT, true),
92 SWAP_BEHAVIOR(EGL_SWAP_BEHAVIOR, EGL_DONT_CARE, true),
93
94 // EXTENSION ATTRIBUTES
95
96 COVERAGE_SAMPLES_NV(EGL_COVERAGE_SAMPLES_NV, 0),
97 COVERAGE_BUFFERS_NV(EGL_COVERAGE_BUFFERS_NV, 0),
98
99 DEPTH_ENCODING_NONLINEAR_NV(EGL_DEPTH_ENCODING_NONLINEAR_NV, EGL_DONT_CARE);
100
101 private final int eglAttrib;
102 private final int defaultValue;
103
104 private final boolean surfaceAttrib;
105
106 Attrib(final int eglAttrib, final int defaultValue) {
107 this(eglAttrib, defaultValue, false);
108 }
109
110 Attrib(final int eglAttrib, final int defaultValue, final boolean surfaceAttrib) {
111 this.eglAttrib = eglAttrib;
112 this.defaultValue = defaultValue;
113
114 this.surfaceAttrib = surfaceAttrib;
115 }
116
117 /**
118 * Returns the EGL token that corresponds to this attribute.
119 *
120 * @return the EGL attribute token
121 */
122 public int getEGLAttrib() {
123 return eglAttrib;
124 }
125
126 /**
127 * Returns the default value of this attribute. Attributes
128 * with default values will be ignored when choosing the EGLConfig.
129 *
130 * @return the default value
131 */
132 public int getDefaultValue() {
133 return defaultValue;
134 }
135
136 public boolean isSurfaceAttrib() {
137 return surfaceAttrib;
138 }
139
140 }
141
142 private final Map<Attrib, Integer> config = new HashMap<Attrib, Integer>(16);
143
144 /**
145 * Creates a new PixelFormat with rgbSize = 8, alphaSize = 8 and depthSize = 16.
146 *
147 * @see #PixelFormat(int, int, int, int, int, int)
148 */
149 public PixelFormat() {
150 this(8, 16, 0);
151 }
152
153 /**
154 * Creates a new PixelFormat with rgbSize = 8 and the specified
155 * alphaSize, depthSize and stencilSize.
156 *
157 * @param alphaSize the EGL_ALPHA_SIZE value
158 * @param depthSize the EGL_DEPTH_SIZE value
159 * @param stencilSize the EGL_STENCIL_SIZE value
160 *
161 * @see #PixelFormat(int, int, int, int, int, int)
162 */
163 public PixelFormat(int alphaSize, int depthSize, int stencilSize) {
164 this(alphaSize, depthSize, stencilSize, 0);
165 }
166
167 /**
168 * Creates a new PixelFormat with rgbSize = 8 and the specified
169 * alphaSize, depthSize, stencilSize and samples.
170 *
171 * @param alphaSize the EGL_ALPHA_SIZE value
172 * @param depthSize the EGL_DEPTH_SIZE value
173 * @param stencilSize the EGL_STENCIL_SIZE value
174 * @param samples the EGL_SAMPLE_SIZE value
175 *
176 * @see #PixelFormat(int, int, int, int, int, int)
177 */
178 public PixelFormat(int alphaSize, int depthSize, int stencilSize, int samples) {
179 this(8, alphaSize, 0, depthSize, stencilSize, samples);
180 }
181
182 /**
183 * Creates a new PixelFormat with the specified RGB sizes, EGL_ALPHA_SIZE,
184 * EGL_LUMINANCE_SIZE, EGL_DEPTH_SIZE, EGL_STENCIL_SIZE, EGL_SAMPLES.
185 * All values must be greater than or equal to 0. rgbSize and luminanceSize
186 * cannot both be greater than 0. depthSize greater than 24 and stencilSize
187 * greater than 8 are not recommended.
188 * The corresponding EGL_SAMPLE_BUFFERS value will become 0 if samples is 0,
189 * or 1 if samples is greater than 0.
190 *
191 * @param rgbSize the RGB sizes
192 * @param alphaSize the EGL_ALPHA_SIZE value
193 * @param luminanceSize the EGL_LUMINANCE_SIZE value
194 * @param depthSize the EGL_DEPTH_SIZE value
195 * @param stencilSize the EGL_STENCIL_SIZE value
196 * @param samples the EGL_SAMPLE_SIZE value
197 */
198 public PixelFormat(int rgbSize, int alphaSize, int luminanceSize, int depthSize, int stencilSize, int samples) {
199 if ( rgbSize < 0 )
200 throw new IllegalArgumentException("Invalid RGB size specified: " + rgbSize);
201
202 if ( alphaSize < 0 )
203 throw new IllegalArgumentException("Invalid EGL_ALPHA_SIZE specified: " + alphaSize);
204
205 if ( luminanceSize < 0 || (0 < luminanceSize && 0 < rgbSize) )
206 throw new IllegalArgumentException("Invalid EGL_LUMINANCE_SIZE specified: " + luminanceSize);
207
208 if ( depthSize < 0 )
209 throw new IllegalArgumentException("Invalid EGL_DEPTH_SIZE specified: " + depthSize);
210
211 if ( stencilSize < 0 )
212 throw new IllegalArgumentException("Invalid EGL_STENCIL_SIZE specified: " + stencilSize);
213
214 if ( samples < 0 )
215 throw new IllegalArgumentException("Invalid EGL_SAMPLES specified: " + samples);
216
217 if ( 0 < rgbSize ) {
218 setAttrib(RED_SIZE, rgbSize);
219 setAttrib(GREEN_SIZE, rgbSize);
220 setAttrib(BLUE_SIZE, rgbSize);
221 }
222 setAttrib(ALPHA_SIZE, alphaSize);
223
224 setAttrib(LUMINANCE_SIZE, luminanceSize);
225
226 setAttrib(DEPTH_SIZE, depthSize);
227 setAttrib(STENCIL_SIZE, stencilSize);
228
229 setAttrib(SAMPLES, samples);
230 setAttrib(SAMPLE_BUFFERS, samples == 0 ? 0 : 1);
231 }
232
233 /**
234 * Creates a new PixelFormat that is a copy of the specified PixelFormat.
235 *
236 * @param pf the source PixelFormat
237 */
238 private PixelFormat(final PixelFormat pf) {
239 config.clear();
240 config.putAll(pf.config);
241 }
242
243 /**
244 * Sets the value of an attribute to the current configuration.
245 * If the value matches the default attribute value, the
246 * attribute will be removed from the configuration.
247 *
248 * @param attrib the attribute
249 * @param value the new value
250 */
251 private void setAttrib(final Attrib attrib, final int value) {
252 if ( attrib.defaultValue == value )
253 config.remove(attrib);
254 else
255 config.put(attrib, value);
256 }
257
258 /**
259 * Returns an IntBuffer that can be used to get/choose EGLConfigs.
260 * The contents of the IntBuffer will be the sum of the source
261 * LWJGL attributes and the user-defined attributes from this
262 * PixelFormat's configuration.
263 * <p/>
264 * The source LWJGL attributes should not contain the EGL_SURFACE_TYPE
265 * attirube, or any attributes that are handled by PixelFormat.
266 * <p/>
267 * Attributes that correspond to EGL extensions will be checked
268 * against the extensions supported in the specified EGLDisplay.
269 * Attributes that correspond to unsupported extensions will not
270 * be included in the final EGLConfig query.
271 *
272 * @param display the EGL display from which the EGLConfig is going to be retrieved
273 * @param lwjglAttribs the LWJGL attributes
274 *
275 * @return the IntBuffer
276 */
277 public IntBuffer getAttribBuffer(final EGLDisplay display, int surfaceType, final int[] lwjglAttribs) {
278 // Create a copy of the configuration attributes
279 Set<Attrib> keys = new HashSet<Attrib>(config.keySet());
280
281 // Handle surface type bits
282 if ( keys.contains(MULTISAMPLE_RESOLVE) ) {
283 if ( display.getMajorVersion() == 1 && display.getMinorVersion() < 4 )
284 keys.remove(MULTISAMPLE_RESOLVE);
285 else if ( getAttrib(MULTISAMPLE_RESOLVE) == EGL_MULTISAMPLE_RESOLVE_BOX )
286 surfaceType |= EGL_MULTISAMPLE_RESOLVE_BOX_BIT;
287 }
288
289 if ( keys.contains(SWAP_BEHAVIOR) ) {
290 if ( display.getMajorVersion() == 1 && display.getMinorVersion() < 4 )
291 keys.remove(SWAP_BEHAVIOR);
292 else if ( getAttrib(SWAP_BEHAVIOR) == EGL_BUFFER_PRESERVED )
293 surfaceType |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
294 }
295
296 // Check NV_coverage_sample
297 if ( keys.contains(COVERAGE_BUFFERS_NV) && !display.isExtensionSupported("EGL_NV_coverage_sample") ) {
298 keys.remove(COVERAGE_BUFFERS_NV);
299 keys.remove(COVERAGE_SAMPLES_NV);
300 }
301
302 // Check NV_depth_nonlinear
303 if ( keys.contains(DEPTH_ENCODING_NONLINEAR_NV) && !display.isExtensionSupported("EGL_NV_depth_nonlinear") )
304 keys.remove(DEPTH_ENCODING_NONLINEAR_NV);
305
306 // Create IntBuffer and insert the attributes
307 final IntBuffer attribs = BufferUtils.createIntBuffer(
308 2 // SURFACE_TYPE
309 + lwjglAttribs.length // Source LWJGL attributes
310 + (keys.size() * 2) // PixelFormat attributes
311 + 1 // Termination
312 );
313
314 attribs.put(EGL_SURFACE_TYPE).put(surfaceType);
315 attribs.put(lwjglAttribs);
316
317 for ( Attrib key : keys ) {
318 if ( !key.isSurfaceAttrib() )
319 attribs.put(key.eglAttrib).put(config.get(key));
320 }
321
322 // Finish the attribute list
323 attribs.put(EGL_NONE);
324 attribs.flip();
325
326 return attribs;
327 }
328
329 /**
330 * Returns true if the requested attribute matches the attribute in the specified EGL config.
331 *
332 * @param attrib the requested attribute
333 * @param config the EGL config
334 *
335 * @return true if the two attributes match
336 *
337 * @throws org.lwjgl.LWJGLException if an EGL error occurs
338 */
339 private boolean matches(final Attrib attrib, final EGLConfig config) throws LWJGLException {
340 return getAttrib(attrib) == config.getAttribute(attrib.getEGLAttrib());
341 }
342
343 /**
344 * Returns true if the requested attribute matches the attribute in the specified EGL config.
345 * If the requested attribute is equal to 1, then it will match with any EGL config attribute
346 * that is greater than 0.
347 *
348 * @param attrib the requested attribute
349 * @param config the EGL config
350 *
351 * @return true if the two attributes match
352 *
353 * @throws org.lwjgl.LWJGLException if an EGL error occurs
354 */
355 private boolean matchesNonZero(final Attrib attrib, final EGLConfig config) throws LWJGLException {
356 final int reqValue = getAttrib(attrib);
357 final int cfgValue = config.getAttribute(attrib.getEGLAttrib());
358
359 return reqValue == cfgValue || (reqValue == 1 && cfgValue > 0);
360 }
361
362 /**
363 * Returns the EGL config from the specified array that best matches this PixelFormat.
364 *
365 * @param configs the EGL configs
366 *
367 * @return the best match
368 */
369 public EGLConfig getBestMatch(final EGLConfig[] configs) throws LWJGLException {
370 if ( configs == null || configs.length == 0 )
371 throw new IllegalArgumentException("No EGLConfigs specified.");
372
373 if ( configs.length == 1 )
374 return configs[0];
375
376 /*System.out.println("\nASKED FOR:");
377 for ( Attrib attrib : config.keySet() ) {
378 System.out.println("EGL_" + attrib.name() + ": " + getAttrib(attrib));
379 }
380
381 for ( EGLConfig config : configs ) {
382 if ( config == null )
383 continue;
384
385 System.out.println("\n----");
386 System.out.println(config);
387 }*/
388
389 for ( EGLConfig config : configs ) {
390 if ( config == null )
391 continue;
392
393 if ( !(matches(ALPHA_SIZE, config) && matchesNonZero(DEPTH_SIZE, config) && matchesNonZero(STENCIL_SIZE, config)) )
394 continue;
395
396 final int luminance = getAttrib(LUMINANCE_SIZE);
397 if ( 0 < luminance && !matches(LUMINANCE_SIZE, config) )
398 continue;
399
400 if ( luminance == 0 && !(matches(RED_SIZE, config) && matches(GREEN_SIZE, config) && matches(BLUE_SIZE, config)) )
401 continue;
402
403 if ( !(matches(SAMPLE_BUFFERS, config) && matches(SAMPLES, config)) )
404 continue;
405
406 // TODO: Add more? NV's Tegra SDK checks a hardcoded 5 value for COVERAGE_SAMPLES_NV (nv_main.c, line: 1823)
407
408 return config;
409 }
410
411 // No match found, use the one recommended by the EGL implementation.
412 LWJGLUtil.log("Could not find an exact EGLConfig match for the PixelFormat requested, using first returned.");
413 return configs[0];
414 }
415
416 /**
417 * Applies this PixelFormat's surface attributes to the specified EGL surface.
418 *
419 * @param surface the EGL surface
420 */
421 public void setSurfaceAttribs(final EGLSurface surface) throws LWJGLException {
422 setSurfaceAttrib(surface, SWAP_BEHAVIOR);
423 setSurfaceAttrib(surface, MULTISAMPLE_RESOLVE);
424 }
425
426 private void setSurfaceAttrib(final EGLSurface surface, final Attrib attrib) throws LWJGLException {
427 final int value = getAttrib(attrib);
428 if ( value != attrib.getDefaultValue() )
429 surface.setAttribute(attrib.getEGLAttrib(), value);
430 }
431
432 /**
433 * Returns the value of the specified attribute.
434 *
435 * @param attrib the attribute to retrieve
436 *
437 * @return the attribute's value
438 */
439 public int getAttrib(final Attrib attrib) {
440 final Integer value = config.get(attrib);
441 if ( value == null )
442 return attrib.defaultValue;
443
444 return value;
445 }
446
447 /* -----------------------------------------
448 CORE ATTRIBUTES
449 ----------------------------------------- */
450
451 /**
452 * Returns a new PixelFormat with the specified RGB sizes.
453 *
454 * @param rgb the new EGL_RED_SIZE, EGL_GREEN_SIZE and EGL_BLUE_SIZE
455 *
456 * @return the new PixelFormat
457 *
458 * @see #withRGBSize(int, int, int)
459 */
460 public PixelFormat withRGBSize(final int rgb) {
461 return withRGBSize(rgb, rgb, rgb);
462 }
463
464 /**
465 * Returns a new PixelFormat with the specified EGL_RED_SIZE, EGL_GREEN_SIZE and EGL_BLUE_SIZE.
466 * All 3 values must be greater than or equal to 0. If any of the 3 values is greater than 0,
467 * the luminanceSize will be set to 0.
468 *
469 * @param r the new EGL_RED_SIZE
470 * @param g the new EGL_GREEN_SIZE
471 * @param b the new EGL_BLUE_SIZE
472 *
473 * @return the new PixelFormat
474 */
475 public PixelFormat withRGBSize(final int r, final int g, final int b) {
476 if ( r < 0 || g < 0 || b < 0 )
477 throw new IllegalArgumentException("Invalid RGB sizes specified: " + r + ", " + g + ", " + b);
478
479 final PixelFormat pf = new PixelFormat(this);
480 pf.setAttrib(RED_SIZE, r);
481 pf.setAttrib(GREEN_SIZE, g);
482 pf.setAttrib(BLUE_SIZE, b);
483 if ( 0 < r || 0 < g || 0 < b )
484 pf.setAttrib(LUMINANCE_SIZE, 0);
485 return pf;
486 }
487
488 /**
489 * Returns a new PixelFormat with the specified EGL_ALPHA_SIZE.
490 * The alphaSize value must be greater than or equal to 0.
491 *
492 * @param alphaSize the new EGL_ALPHA_SIZE
493 *
494 * @return the new PixelFormat
495 */
496 public PixelFormat withAlphaSize(final int alphaSize) {
497 if ( alphaSize < 0 )
498 throw new IllegalArgumentException("Invalid EGL_ALPHA_SIZE specified: " + alphaSize);
499
500 final PixelFormat pf = new PixelFormat(this);
501 pf.setAttrib(ALPHA_SIZE, alphaSize);
502 return pf;
503 }
504
505 /**
506 * Returns a new PixelFormat with the specified EGL_LUMINANCE_SIZE.
507 * The luminanceSize value must be greater than or equal to 0. If
508 * luminanceSize is greater than 0, the RGB sizes will be set to 0.
509 *
510 * @param luminanceSize the new EGL_LUMINANCE_SIZE
511 *
512 * @return the new PixelFormat
513 */
514 public PixelFormat withLuminanceSize(final int luminanceSize) {
515 if ( luminanceSize < 0 )
516 throw new IllegalArgumentException("Invalid EGL_LUMINANCE_SIZE specified: " + luminanceSize);
517
518 final PixelFormat pf = new PixelFormat(this);
519 pf.setAttrib(LUMINANCE_SIZE, luminanceSize);
520 if ( 0 < luminanceSize ) {
521 pf.setAttrib(RED_SIZE, 0);
522 pf.setAttrib(GREEN_SIZE, 0);
523 pf.setAttrib(BLUE_SIZE, 0);
524 }
525 return pf;
526 }
527
528 /**
529 * Returns a new PixelFormat with the specified EGL_DEPTH_SIZE.
530 * The depthSize value must be greater than or equal to 0.
531 * Values greater than 24 are not recommended.
532 *
533 * @param depthSize the new EGL_DEPTH_SIZE
534 *
535 * @return the new PixelFormat
536 */
537 public PixelFormat withDepthSize(final int depthSize) {
538 if ( depthSize < 0 )
539 throw new IllegalArgumentException("Invalid EGL_DEPTH_SIZE specified: " + depthSize);
540
541 final PixelFormat pf = new PixelFormat(this);
542 pf.setAttrib(DEPTH_SIZE, depthSize);
543 return pf;
544 }
545
546 /**
547 * Returns a new PixelFormat with the specified EGL_STENCIL_SIZE.
548 * The stencilSize value must be greater than or equal to 0.
549 * Values greater than 8 are not recommended.
550 *
551 * @param stencilSize the new EGL_STENCIL_SIZE
552 *
553 * @return the new PixelFormat
554 */
555 public PixelFormat withStencilSize(final int stencilSize) {
556 if ( stencilSize < 0 )
557 throw new IllegalArgumentException("Invalid EGL_STENCIL_SIZE specified: " + stencilSize);
558
559 final PixelFormat pf = new PixelFormat(this);
560 pf.setAttrib(STENCIL_SIZE, stencilSize);
561 return pf;
562 }
563
564 /**
565 * Returns a new PixelFormat with the specified EGL_MIN_SWAP_INTERVAL.
566 * The minSwapInterval value must be between 0 and this PixelFormat's EGL_MAX_SWAP_INTERVAL.
567 *
568 * @param minSwapInterval the new EGL_MIN_SWAP_INTERVAL value
569 *
570 * @return the new PixelFormat
571 */
572 public PixelFormat withMinSwapInterval(final int minSwapInterval) {
573 final int maxSwapInterval = getAttrib(MAX_SWAP_INTERVAL);
574 if ( minSwapInterval != EGL_DONT_CARE && (minSwapInterval < 0 || (maxSwapInterval != EGL_DONT_CARE && maxSwapInterval < minSwapInterval)) )
575 throw new IllegalArgumentException("Invalid EGL_MIN_SWAP_INTERVAL specified: " + minSwapInterval);
576
577 final PixelFormat pf = new PixelFormat(this);
578 pf.setAttrib(MIN_SWAP_INTERVAL, minSwapInterval);
579 return pf;
580 }
581
582 /**
583 * Returns a new PixelFormat with the specified EGL_MAX_SWAP_INTERVAL.
584 * The maxSwapInterval value must be greater than or equal to this PixelFormat's EGL_MIN_SWAP_INTERVAL.
585 *
586 * @param maxSwapInterval the new EGL_MAX_SWAP_INTERVAL value
587 *
588 * @return the new PixelFormat
589 */
590 public PixelFormat withMaxSwapInterval(final int maxSwapInterval) {
591 if ( maxSwapInterval < getAttrib(MIN_SWAP_INTERVAL) )
592 throw new IllegalArgumentException("Invalid EGL_MAX_SWAP_INTERVAL specified: " + maxSwapInterval);
593
594 final PixelFormat pf = new PixelFormat(this);
595 pf.setAttrib(MAX_SWAP_INTERVAL, maxSwapInterval);
596 return pf;
597 }
598
599 /**
600 * Returns a new PixelFormat with the specified number of EGL_SAMPLES.
601 * The samples value must be either 0 or greater than or equal to 2. The related
602 * EGL_SAMPLE_BUFFERS value will become 0 if samples is 0, or 1 if samples
603 * is greater than or equal to 2.
604 *
605 * @param samples the new EGL_SAMPLES value
606 *
607 * @return the new PixelFormat
608 */
609 public PixelFormat withSamples(final int samples) {
610 if ( samples != 0 && samples < 2 )
611 throw new IllegalArgumentException("Invalid number of EGL_SAMPLES specified: " + samples);
612
613 final PixelFormat pf = new PixelFormat(this);
614 pf.setAttrib(SAMPLES, samples);
615 pf.setAttrib(SAMPLE_BUFFERS, samples == 0 ? 0 : 1);
616 return pf;
617 }
618
619 private static int maxValue(final int bits) {
620 return (2 << bits) - 1;
621 }
622
623 /**
624 * Returns a new PixelFormat with the specified EGL_TRANSPARENT_TYPE and
625 * the specified transparent RGB values. The transparentType must be
626 * either EGL_NONE or EGL_TRANSPARENT_RGB. When it is EGL_NONE, the RGB
627 * values are set to zero and ignored. When it is EGL_TRANSPARENT_RGB,
628 * the RGB values must be between 0 and 2^rgbSize - 1.
629 *
630 * @param transparentType the new EGL_TRANSPARENT_TYPE value
631 * @param r the new EGL_TRANSPARENT_RED_VALUE
632 * @param g the new EGL_TRANSPARENT_GREEN_VALUE
633 * @param b the new EGL_TRANSPARENT_BLUE_VALUE
634 *
635 * @return the new PixelFormat
636 */
637 public PixelFormat withTransparentType(final int transparentType, int r, int g, int b) {
638 if ( transparentType == EGL_TRANSPARENT_RGB ) {
639 final int redSize = getAttrib(RED_SIZE);
640 final int greenSize = getAttrib(GREEN_SIZE);
641 final int blueSize = getAttrib(BLUE_SIZE);
642 if ( r < 0 || (0 < redSize && maxValue(redSize) < r) )
643 throw new IllegalArgumentException("Invalid EGL_TRANSPARENT_RED_VALUE specified: " + r);
644
645 if ( r < 0 || (0 < greenSize && maxValue(greenSize) < g) )
646 throw new IllegalArgumentException("Invalid EGL_TRANSPARENT_GREEN_VALUE specified: " + g);
647
648 if ( r < 0 || (0 < blueSize && maxValue(blueSize) < b) )
649 throw new IllegalArgumentException("Invalid EGL_TRANSPARENT_BLUE_VALUE specified: " + b);
650 } else if ( transparentType != EGL_NONE )
651 throw new IllegalArgumentException("Invalid EGL_TRANSPARENT_TYPE specified: " + transparentType);
652 else
653 r = g = b = EGL_DONT_CARE;
654
655 final PixelFormat pf = new PixelFormat(this);
656
657 pf.setAttrib(TRANSPARENT_TYPE, transparentType);
658
659 pf.setAttrib(TRANSPARENT_RED_VALUE, r);
660 pf.setAttrib(TRANSPARENT_GREEN_VALUE, g);
661 pf.setAttrib(TRANSPARENT_BLUE_VALUE, b);
662
663 return pf;
664 }
665
666 /* -----------------------------------------
667 SURFACE ATTRIBUTES
668 ----------------------------------------- */
669
670 /**
671 * Returns a new PixelFormat with the specified EGL_MULTISAMPLE_RESOLVE value.
672 * Valid values for multisampleResolve are EGL_MULTISAMPLE_RESOLVE_DEFAULT
673 * and EGL_MULTISAMPLE_RESOLVE_BOX.
674 * <p/>
675 * An IllegalStateException will be thrown if EGL_SAMPLES has not been previously defined
676 * to be greater than or equal to 2.
677 *
678 * @param multisampleResolve the new EGL_MULTISAMPLE_RESOLVE value
679 *
680 * @return the new PixelFormat
681 */
682 public PixelFormat withMultisampleResolve(final int multisampleResolve) {
683 if ( multisampleResolve != EGL_MULTISAMPLE_RESOLVE_DEFAULT && multisampleResolve != EGL_MULTISAMPLE_RESOLVE_BOX )
684 throw new IllegalArgumentException("Invalid EGL_MULTISAMPLE_RESOLVE value specified: " + multisampleResolve);
685
686 if ( getAttrib(SAMPLE_BUFFERS) == 0 )
687 throw new IllegalStateException("An EGL_MULTISAMPLE_RESOLVE value cannot be specified unless EGL_SAMPLE_BUFFERS is 1.");
688
689 final PixelFormat pf = new PixelFormat(this);
690 pf.setAttrib(MULTISAMPLE_RESOLVE, multisampleResolve);
691 return pf;
692 }
693
694 /**
695 * Returns a new PixelFormat with the specified EGL_SWAP_BEHAVIOR value.
696 * Valid values for swapBehavior are EGL_DONT_CARE, EGL_BUFFER_PRESERVED
697 * and EGL_BUFFER_DESTROYED.
698 *
699 * @param swapBehavior the new EGL_SWAP_BEHAVIOR value
700 *
701 * @return the new PixelFormat
702 */
703 public PixelFormat withSwapBehavior(final int swapBehavior) {
704 switch ( swapBehavior ) {
705 case EGL_DONT_CARE:
706 case EGL_BUFFER_PRESERVED:
707 case EGL_BUFFER_DESTROYED:
708 break;
709 default:
710 throw new IllegalArgumentException("Invalid EGL_SWAP_BEHAVIOR value specified: " + swapBehavior);
711 }
712
713 final PixelFormat pf = new PixelFormat(this);
714 pf.setAttrib(SWAP_BEHAVIOR, swapBehavior);
715 return pf;
716 }
717
718 /* -----------------------------------------
719 EXTENSION ATTRIBUTES
720 ----------------------------------------- */
721
722 /**
723 * Returns a new PixelFormat with the specified number of EGL_COVERAGE_SAMPLES_NV.
724 * The samples value must be greater than or equal to 0. The related
725 * EGL_COVERAGE_BUFFERS_NV value will become 0 if samples is 0, or 1 if samples
726 * is greater than 0.
727 *
728 * @param samples the new EGL_SAMPLES value
729 *
730 * @return the new PixelFormat
731 */
732 public PixelFormat withCoverageSamplesNV(final int samples) {
733 if ( samples < 0 )
734 throw new IllegalArgumentException("Invalid number of EGL_COVERAGE_SAMPLES_NV specified: " + samples);
735
736 final PixelFormat pf = new PixelFormat(this);
737 pf.setAttrib(COVERAGE_SAMPLES_NV, samples);
738 pf.setAttrib(COVERAGE_BUFFERS_NV, samples == 0 ? 0 : 1);
739 return pf;
740 }
741
742 /**
743 * Returns a new PixelFormat with the specified EGL_DEPTH_ENCODING_NONLINEAR_NV.
744 * Valid values for depthEncoding are EGL_DONT_CARE, EGL_DEPTH_ENCODING_NONE_NV
745 * and EGL_DEPTH_ENCODING_NONLINEAR_NV.
746 *
747 * @param depthEncoding the new EGL_DEPTH_ENCODING_NONLINEAR_NV value
748 *
749 * @return the new PixelFormat
750 */
751 public PixelFormat withDepthEncodingNonlinearNV(final int depthEncoding) {
752 switch ( depthEncoding ) {
753 case EGL_DONT_CARE:
754 case EGL_DEPTH_ENCODING_NONE_NV:
755 case EGL_DEPTH_ENCODING_NONLINEAR_NV:
756 break;
757 default:
758 throw new IllegalArgumentException("Invalid EGL_DEPTH_ENCODING_NONLINEAR_NV value specified: " + depthEncoding);
759 }
760
761 final PixelFormat pf = new PixelFormat(this);
762 pf.setAttrib(DEPTH_ENCODING_NONLINEAR_NV, depthEncoding);
763 return pf;
764 }
765
766 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 /**
34 * A PowerManagementEventException exception will be thrown when a call
35 * to eglSwapBuffers, eglCopyBuffers or eglMakeCurrent returns EGL_FALSE
36 * and the EGL_ERROR generated is EGL_CONTEXT_LOST.
37 * <p/>
38 * On detection of this error, the application must destroy all contexts.
39 * To continue rendering the application must recreate any contexts it
40 * requires, and subsequently restore any client API state and objects
41 * it wishes to use.
42 * <p/>
43 * Note that not all implementations can be made to generate power management
44 * events, and developers should continue to refer to platform-specific
45 * documentation in this area.
46 */
47 public class PowerManagementEventException extends RuntimeException {
48
49 static final long serialVersionUID = -1L;
50
51 public PowerManagementEventException() {
52 super();
53 }
54
55 public PowerManagementEventException(final String message) {
56 super(message);
57 }
58
59 public PowerManagementEventException(final String message, final Throwable cause) {
60 super(message, cause);
61 }
62
63 public PowerManagementEventException(final Throwable cause) {
64 super(cause);
65 }
66
67 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import java.nio.Buffer;
34 import java.nio.IntBuffer;
35
36 import static org.lwjgl.opengles.GLES20.*;
37 import static org.lwjgl.opengles.GLES30.*;
38
39 final class StateTracker {
40
41 private static StateTracker tracker = new StateTracker();
42
43 int elementArrayBuffer;
44 int arrayBuffer;
45 int pixelPackBuffer;
46 int pixelUnpackBuffer;
47
48 Buffer[] glVertexAttribPointer_buffer;
49
50 private final FastIntMap<VAOState> vaoMap = new FastIntMap<VAOState>();
51
52 int vertexArrayObject;
53
54 StateTracker() {
55 }
56
57 void init() {
58 glVertexAttribPointer_buffer = new Buffer[glGetInteger(GL_MAX_VERTEX_ATTRIBS)];
59 }
60
61 static StateTracker getTracker() {
62 return tracker;
63 }
64
65 static void bindBuffer(int target, int buffer) {
66 final StateTracker tracker = getTracker();
67
68 switch ( target ) {
69 case GL_ARRAY_BUFFER:
70 tracker.arrayBuffer = buffer;
71 break;
72 case GL_ELEMENT_ARRAY_BUFFER:
73 tracker.elementArrayBuffer = buffer;
74 break;
75 case GL_PIXEL_PACK_BUFFER:
76 tracker.pixelPackBuffer = buffer;
77 break;
78 case GL_PIXEL_UNPACK_BUFFER:
79 tracker.pixelUnpackBuffer = buffer;
80 break;
81 }
82 }
83
84 static void bindVAO(final int array) {
85 final FastIntMap<VAOState> vaoMap = tracker.vaoMap;
86 if ( !vaoMap.containsKey(array) )
87 vaoMap.put(array, new VAOState());
88
89 tracker.vertexArrayObject = array;
90 }
91
92 static void deleteVAO(final IntBuffer arrays) {
93 for ( int i = arrays.position(); i < arrays.limit(); i++ )
94 deleteVAO(arrays.get(i));
95 }
96
97 static void deleteVAO(final int array) {
98 tracker.vaoMap.remove(array);
99
100 if ( tracker.vertexArrayObject == array )
101 tracker.vertexArrayObject = 0;
102 }
103
104 /**
105 * Simple class to help us track VAO state. Currently
106 * only ELEMENT_ARRAY_BUFFER_BINDING is tracked, since
107 * that's the only state we check from tables 6.6-6.9.
108 */
109 private static class VAOState {
110
111 int elementArrayBuffer;
112
113 }
114
115 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opengl.OpenGLException;
35
36 import static org.lwjgl.opengles.EGL.*;
37 import static org.lwjgl.opengles.GLES20.*;
38
39 /**
40 * Simple utility class.
41 *
42 * @author Spasi
43 */
44 public final class Util {
45
46 private Util() {
47 }
48
49 /**
50 * Checks for OpenGL ES errors.
51 *
52 * @throws org.lwjgl.opengl.OpenGLException
53 * if GLES20.glGetError() returns anything else than GLES20.GL_NO_ERROR
54 */
55 public static void checkGLError() throws OpenGLException {
56 int err = glGetError();
57 if ( err != GL_NO_ERROR )
58 throw new OpenGLException(err);
59 }
60
61 /**
62 * Translates a GL error code to a String describing the error.
63 *
64 * @param error_code the OpenGL ES error code
65 *
66 * @return the error description
67 */
68 public static String translateGLErrorString(int error_code) {
69 switch ( error_code ) {
70 case GL_NO_ERROR:
71 return "No error";
72 case GL_INVALID_ENUM:
73 return "Invalid enum";
74 case GL_INVALID_VALUE:
75 return "Invalid value";
76 case GL_INVALID_OPERATION:
77 return "Invalid operation";
78 case GL_OUT_OF_MEMORY:
79 return "Out of memory";
80 default:
81 return null;
82 }
83 }
84
85 /**
86 * Checks for EGL errors.
87 *
88 * @throws org.lwjgl.LWJGLException if EGL.eglGetError() returns anything else than EGL.EGL_SUCCESS
89 */
90 static void checkEGLError() throws LWJGLException {
91 int err = eglGetError();
92 if ( err != EGL_SUCCESS )
93 throw new LWJGLException(translateEGLErrorString(err));
94 }
95
96 /**
97 * Translates an EGL error code to a String describing the error.
98 *
99 * @param error_code the EGL error code
100 *
101 * @return the error description
102 */
103 static String translateEGLErrorString(int error_code) {
104 switch ( error_code ) {
105 case EGL_NOT_INITIALIZED:
106 return "EGL not initialized";
107 case EGL_BAD_ACCESS:
108 return "Bad access";
109 case EGL_BAD_ALLOC:
110 return "Bad allocation";
111 case EGL_BAD_ATTRIBUTE:
112 return "Bad attribute";
113 case EGL_BAD_CONFIG:
114 return "Bad config";
115 case EGL_BAD_CONTEXT:
116 return "Bad EGL context";
117 case EGL_BAD_CURRENT_SURFACE:
118 return "Bad current EGL surface";
119 case EGL_BAD_DISPLAY:
120 return "Bad EGL display";
121 case EGL_BAD_MATCH:
122 return "Bad match";
123 case EGL_BAD_NATIVE_PIXMAP:
124 return "Bad native pixmap";
125 case EGL_BAD_NATIVE_WINDOW:
126 return "Bad native window";
127 case EGL_BAD_PARAMETER:
128 return "Bad parameter";
129 case EGL_BAD_SURFACE:
130 return "Bad EGL surface";
131 case EGL_CONTEXT_LOST:
132 return "EGL context lost";
133 default:
134 return null;
135 }
136 }
137
138 }
3939 * Test class for Display & DisplayMode
4040 *
4141 * @author Brian Matzon <brian@matzon.dk>
42 * @version $Revision: 3418 $
43 * $Id: DisplayTest.java 3418 2010-09-28 21:11:35Z spasi $
42 * @version $Revision$
43 * $Id$
4444 */
4545 public class DisplayTest {
4646
0 package org.lwjgl.test;
1
2 import java.io.File;
3 import java.io.FileFilter;
4 import java.lang.reflect.Field;
5 import java.lang.reflect.Modifier;
6 import java.util.Arrays;
7 import java.util.Comparator;
8 import java.util.HashMap;
9 import java.util.Map;
10 import java.util.regex.Pattern;
11
12 public class DuplicateTokens {
13
14 private static Pattern CORE;
15
16 private DuplicateTokens() {
17 }
18
19 public static void main(String[] args) {
20 File path = new File("bin/" + args[0].replace('.', '/'));
21
22 Map<String, Class> tokens = new HashMap<String, Class>(256);
23
24 CORE = Pattern.compile(args[1] + "[0-9]*");
25
26 checkFiles(tokens, filterPath(path, Pattern.compile(CORE.pattern() + "\\.class")), args[0]);
27 checkFiles(tokens, filterPath(path, Pattern.compile("((?!" + CORE.pattern() + ")[^.])+\\.class")), args[0]);
28 }
29
30 private static File[] filterPath(File path, final Pattern pattern) {
31 File[] files = path.listFiles(new FileFilter() {
32 public boolean accept(File pathname) {
33 return pattern.matcher(pathname.getName()).matches();
34 }
35 });
36
37 Arrays.sort(files, new Comparator<File>() {
38 public int compare(final File o1, final File o2) {
39 return o1.getName().compareTo(o2.getName());
40 }
41 });
42
43 return files;
44 }
45
46 private static void checkFiles(Map<String, Class> tokens, File[] files, String root) {
47 try {
48 for ( File file : files ) {
49 Class c = Class.forName(root + '.' + file.getName().substring(0, file.getName().length() - ".class".length()));
50 for ( Field f : c.getFields() ) {
51 int mod = f.getModifiers();
52 if ( !Modifier.isStatic(mod) )
53 continue;
54
55 if ( tokens.containsKey(f.getName()) ) {
56 Class src = tokens.get(f.getName());
57 if ( CORE.matcher(src.getSimpleName()).matches() || CORE.matcher(c.getSimpleName()).matches() )
58 System.out.println("DUPLICATE: " + f.getName() + " at " + c.getSimpleName() + " [" + src.getSimpleName() + ']');
59 } else
60 tokens.put(f.getName(), c);
61 }
62 }
63 } catch (Exception e) {
64 throw new RuntimeException(e);
65 }
66 }
67
68 }
0 package org.lwjgl.test;
1
2 import org.lwjgl.input.Keyboard;
3 import org.lwjgl.input.Mouse;
4 import org.lwjgl.opengl.Display;
5 import org.lwjgl.opengl.DisplayMode;
6 import org.lwjgl.opengl.GL11;
7 import org.lwjgl.opengl.PixelFormat;
8
9 public class LwjglShiftTest {
10
11 public static final int SCREEN_WIDTH = 640;
12 public static final int SCREEN_HEIGHT = 480;
13
14 public static void main(String[] args) throws Exception {
15 setDisplayMode();
16 Display.setTitle("Shift Test");
17 Display.setFullscreen(false);
18 Display.setVSyncEnabled(true);
19 Display.create(new PixelFormat(32, 0, 24, 8, 0));
20 Mouse.setGrabbed(false);
21
22 GL11.glMatrixMode(GL11.GL_PROJECTION);
23 GL11.glLoadIdentity();
24 GL11.glOrtho(0, 800, 0, 600, 1, -1);
25 GL11.glMatrixMode(GL11.GL_MODELVIEW);
26
27 boolean lcurr = false;
28 boolean rcurr = false;
29 while ( true ) {
30
31 if ( Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) ) {
32 break;
33 }
34
35 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
36
37 //Text.drawString("left shift", 10, 10);
38 //Text.drawString("right shift", 300, 10);
39
40 System.out.println(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) + " - " + Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
41
42 Display.update();
43 //Display.sync(15);
44
45 /*while ( Keyboard.next() ) {
46 System.out.println(Keyboard.getEventKey() + " - " + Keyboard.getEventKeyState());
47 }*/
48 }
49 }
50
51 private static void setDisplayMode() throws Exception {
52 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(SCREEN_WIDTH, SCREEN_HEIGHT, -1, -1, -1, -1, 60, 60);
53 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
54 "width=" + SCREEN_WIDTH,
55 "height=" + SCREEN_HEIGHT,
56 "freq=" + 60,
57 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
58 });
59 }
60 }
0 package org.lwjgl.test;
1
2 import org.lwjgl.LWJGLException;
3 import org.lwjgl.input.Keyboard;
4 import org.lwjgl.input.Mouse;
5 import org.lwjgl.opengl.Display;
6 import org.lwjgl.opengl.DisplayMode;
7 import org.lwjgl.opengl.GL11;
8
9 import static org.lwjgl.opengl.GL11.*;
10
11 public class QuadExample {
12
13 public void start() {
14 try {
15 Display.setDisplayMode(new DisplayMode(800,600));
16 Display.setResizable(true);
17 Display.setVSyncEnabled(true);
18 Display.create();
19 } catch (LWJGLException e) {
20 e.printStackTrace();
21 System.exit(0);
22 }
23
24 // init OpenGL
25 glMatrixMode(GL_PROJECTION);
26 glLoadIdentity();
27 glOrtho(0, 800, 0, 600, 1, -1);
28 glMatrixMode(GL_MODELVIEW);
29
30 Mouse.setGrabbed(true);
31
32 while (!Display.isCloseRequested()) {
33
34 Display.sync(30);
35
36 this.updateMouseVars();
37
38 while ( Keyboard.next() ) {
39 if ( Keyboard.getEventKeyState() == false && Keyboard.getEventKey() == Keyboard.KEY_G )
40 Mouse.setGrabbed(!Mouse.isGrabbed());
41 }
42
43 // Clear the screen and depth buffer
44 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
45
46 // set the color of the quad (R,G,B,A)
47 glColor3f(0.5f, 0.5f, 1.0f);
48
49 // draw quad
50 glBegin(GL_QUADS);
51 glVertex2f(mouseDx, mouseDy);
52 glVertex2f(200 + mouseDx, mouseDy);
53 glVertex2f(200 + mouseDx, 200 + mouseDy);
54 glVertex2f(mouseDx, 200 + mouseDy);
55 glEnd();
56
57 Display.update();
58 }
59
60 Display.destroy();
61 }
62
63 int mouseDx = 0;
64 int mouseDy = 0;
65
66 public void updateMouseVars(){
67
68 int localMouseDx = 0;
69 int localMouseDy = 0;
70
71 int c= 0;
72 while(Mouse.next()){
73
74 localMouseDx += Mouse.getEventDX();
75 localMouseDy += Mouse.getEventDY();
76 c++;
77
78 }
79
80 mouseDx += localMouseDx;
81 mouseDy += localMouseDy;
82
83 }
84
85 public static void main(String[] argv) {
86 QuadExample quadExample = new QuadExample();
87 quadExample.start();
88 }
89 }
0 package org.lwjgl.test;
1
2 import org.lwjgl.input.Keyboard;
3 import org.lwjgl.input.Mouse;
4 import org.lwjgl.opengl.Display;
5 import org.lwjgl.opengl.DisplayMode;
6 import org.lwjgl.opengl.PixelFormat;
7
8 public class ShiftTest {
9
10 public static final int SCREEN_WIDTH = 640;
11 public static final int SCREEN_HEIGHT = 480;
12
13 public static void main(String[] args) throws Exception {
14 setDisplayMode();
15 Display.setTitle("Shift Test");
16 Display.setFullscreen(false);
17 Display.setVSyncEnabled(true);
18 Display.create(new PixelFormat(32, 0, 24, 8, 0));
19 Mouse.setGrabbed(false);
20
21 boolean lcurr = false;
22 boolean rcurr = false;
23 while ( true ) {
24
25 boolean lShiftDown = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
26 boolean rShiftDown = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
27
28 if ( lcurr != lShiftDown || rcurr != rShiftDown ) {
29 System.out.println(String.format("LShift: %b\tRShift: %b", lShiftDown, rShiftDown));
30 lcurr = lShiftDown;
31 rcurr = rShiftDown;
32 }
33
34 if ( Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) ) {
35 break;
36 }
37 Display.processMessages();
38 Display.sync(60);
39 }
40 }
41
42 private static void setDisplayMode() throws Exception {
43 DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(SCREEN_WIDTH, SCREEN_HEIGHT, -1, -1, -1, -1, 60, 60);
44 org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
45 "width=" + SCREEN_WIDTH,
46 "height=" + SCREEN_HEIGHT,
47 "freq=" + 60,
48 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
49 });
50 }
51 }
0 package org.lwjgl.test;
1
2 import org.lwjgl.opengl.GL11;
3
4 import java.lang.reflect.Method;
5 import java.util.ArrayList;
6 import java.util.Collections;
7 import java.util.Comparator;
8 import java.util.List;
9
10 public class SignatureList {
11
12 public SignatureList() {
13 }
14
15 public static void main(String[] args) {
16 Class<?> clazz = GL11.class;
17
18 final Method[] methods = clazz.getMethods();
19
20 List<Method> sortedMethods = new ArrayList<Method>(methods.length);
21 for ( final Method m : methods ) {
22 sortedMethods.add(m);
23 }
24
25 Collections.sort(sortedMethods, new Comparator<Method>() {
26 public int compare(final Method o1, final Method o2) {
27 int cmp = o1.getName().compareTo(o2.getName());
28 if ( cmp != 0 )
29 return cmp;
30
31 final Class<?>[] params1 = o1.getParameterTypes();
32 final Class<?>[] params2 = o2.getParameterTypes();
33
34 cmp = Integer.compare(params1.length, params2.length);
35 if ( cmp != 0 ) return cmp;
36
37 for ( int i = 0; i < params1.length; i++ ) {
38 if ( params1[i] != params2[i] )
39 return params1[i].getSimpleName().compareTo(params2[i].getSimpleName());
40 }
41
42 return 0;
43 }
44 });
45
46 for ( final Method m : sortedMethods ) {
47 if ( !m.getName().startsWith("gl") )
48 continue;
49
50 Class<?>[] params = m.getParameterTypes();
51
52 System.out.print(m.getName() + "(");
53
54 boolean first = true;
55 for ( final Class<?> p : params ) {
56 if ( first )
57 first = false;
58 else
59 System.out.print(", ");
60 System.out.print(p.getSimpleName());
61 }
62 System.out.println(")");
63 }
64 }
65
66 }
4040 * Test class for Sys
4141 *
4242 * @author Brian Matzon <brian@matzon.dk>
43 * @version $Revision: 2983 $
44 * $Id: SysTest.java 2983 2008-04-07 18:36:09Z matzon $
43 * @version $Revision$
44 * $Id$
4545 */
4646 public class SysTest {
4747
0 package org.lwjgl.test;
1
2 import java.awt.Canvas;
3 import java.awt.Dimension;
4
5 import javax.swing.JFrame;
6
7 import org.lwjgl.input.Keyboard;
8 import org.lwjgl.input.Mouse;
9 import org.lwjgl.opengl.Display;
10 import org.lwjgl.opengl.GL11;
11
12 public class Test {
13 public static void main(String[] args) throws Exception {
14 Canvas canvas = new Canvas();
15 JFrame frame = new JFrame("Test");
16 frame.add(canvas);
17 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
18 frame.setSize(new Dimension(640, 480));
19 frame.setLocationRelativeTo(null);
20 frame.setVisible(true);
21
22 Display.setParent(canvas);
23 Display.setVSyncEnabled(true);
24 Display.create();
25 while ( !Display.isCloseRequested() ) {
26 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
27 Display.update();
28 // Press and release ALT on Windows, the printing stops until you press a key or click.
29 //System.out.println(Mouse.getX() + ", " + Mouse.getY() + " - " +System.currentTimeMillis());
30 while ( Keyboard.next() ) {
31 System.out.println(Keyboard.getKeyName(Keyboard.getEventKey()) + " - " +Keyboard.getEventKeyState());
32 }
33 }
34 }
35 }
0 package org.lwjgl.test;
1
2 import org.lwjgl.BufferUtils;
3 import org.lwjgl.LWJGLException;
4 import org.lwjgl.PointerBuffer;
5 import org.lwjgl.opengl.Display;
6 import org.lwjgl.opengl.GL11;
7 import org.lwjgl.opengl.GL15;
8 import org.lwjgl.opengl.GL20;
9
10 import static org.lwjgl.opengl.GL11.*;
11 import static org.lwjgl.opengl.GL43.*;
12
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15 import java.nio.Buffer;
16 import java.nio.ByteBuffer;
17 import java.security.PrivilegedActionException;
18
19 /**
20 * glGetVertexAttribPointer() is coded incorrectly. Any use of the buffer
21 * returned by glGetVertexAttribPointer() results in a JVM crash (SIGSEGV),
22 * because LWJGL is returning an offset as a DirectByteBuffer whose address is
23 * typically in the first page of memory. glGetVertexAttribPointer() should
24 * return a long, not a ByteBuffer.
25 * <p/>
26 * <p/>
27 * The spec for <a href=
28 * "http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml"
29 * >glVertexAttribPointer</a> says:
30 * <p/>
31 * pointer
32 * <ul>
33 * <li>
34 * Specifies a <b>offset of the first component</b> of the first generic vertex
35 * attribute in the array in the data store of the buffer currently bound to the
36 * GL_ARRAY_BUFFER target. The initial value is 0.</li>
37 * </ul>
38 * Emphasis mine. This is an offset into the VBO, not a native pointer.
39 * <p/>
40 * <p/>
41 * Now look at <a href=
42 * "http://www.opengl.org/sdk/docs/man3/xhtml/glGetVertexAttribPointerv.xml"
43 * >glGetVertexAttribPointerv</a>, which says:
44 * <ul>
45 * <li>The pointer returned is a <b>byte offset into the data store</b> of the
46 * buffer object that was bound to the GL_ARRAY_BUFFER target (see glBindBuffer)
47 * when the desired pointer was previously specified.</li>
48 * </ul>
49 * Emphasis mine again. The spec clearly intends this to be an offset, not a
50 * pointer.
51 */
52 public class Test_glGetVertexAttribPointer_API_bug {
53
54 static boolean crashJvm = "true".equals(System.getProperty("crashJvm",
55 "false"));
56
57 static final int FLOAT_BYTES = 4;
58
59 static class Attr {
60
61 final String name;
62 final int index;
63 final int size;
64 final int offset;
65
66 Attr(String name, int index, int size,
67 int offset) {
68 this.name = name;
69 this.index = index;
70 this.size = size;
71 this.offset = offset;
72 }
73
74 long getByteOffset() {
75 return offset * FLOAT_BYTES;
76 }
77 }
78
79 static class AttrGen {
80
81 int offset = 0;
82
83 Attr allocAttr(String name, int index, int size) {
84 Attr result = new Attr(name, index, size, offset);
85 offset += size;
86 return result;
87 }
88 }
89
90 static AttrGen gen = new AttrGen();
91 static final Attr position = gen.allocAttr("position", 1, 3);
92 static final Attr normal = gen.allocAttr("normal", 2, 3);
93 static final Attr textureCoordinates = gen.allocAttr("textureCoordinates",
94 3, 2);
95 static final int stride = gen.offset;
96 static final int strideBytes = stride * FLOAT_BYTES;
97
98 static final Attr[] attributes = { position, normal, textureCoordinates };
99
100 /** Hack to call BufferUtils.getBufferAddress() */
101 static long getBufferAddress(ByteBuffer buf)
102 throws SecurityException, NoSuchMethodException,
103 IllegalArgumentException, IllegalAccessException,
104 InvocationTargetException {
105 Method m = BufferUtils.class.getDeclaredMethod(
106 "getBufferAddress", Buffer.class);
107 if ( !m.isAccessible() )
108 m.setAccessible(true);
109 return (Long)m.invoke(null, buf);
110 }
111
112 static long glGetVertexAttribPointer(int index)
113 throws NoSuchMethodException, IllegalAccessException,
114 InvocationTargetException {
115 int result_size = PointerBuffer.getPointerSize();
116 //ByteBuffer buf = GL20.glGetVertexAttribPointer(index, GL20.GL_VERTEX_ATTRIB_ARRAY_POINTER, result_size);
117
118 ByteBuffer buf = BufferUtils.createByteBuffer(PointerBuffer.getPointerSize());
119
120 GL20.glGetVertexAttribPointer(index, GL20.GL_VERTEX_ATTRIB_ARRAY_POINTER, buf);
121
122 /*if ( buf == null )
123 return 0;
124
125 long bufferAddress = getBufferAddress(buf);
126 if ( crashJvm ) {
127 *//*
128 * This crashes the JVM with a SIGSEGV because it tries to
129 * dereference something that was never intended to be a pointer.
130 * It's an offset (e.g. 12).
131 *//*
132 System.out
133 .println("Dereferencing "
134 + bufferAddress
135 + " (this will probably crash the JVM with a SIGSEGV) ... ");
136 buf.get(0);
137 }
138 */
139
140 long bufferAddress = buf.getLong(0);
141 System.out.println(index + " bufferAddress = " + bufferAddress);
142
143 return bufferAddress;
144 }
145
146 public static void main(String[] args) throws LWJGLException,
147 SecurityException, NoSuchMethodException, IllegalArgumentException,
148 IllegalAccessException, InvocationTargetException,
149 PrivilegedActionException {
150 Display.create();
151
152 /*
153 * Note: it's not necessary to call glBufferData(); the functions
154 * involved are only concerned with data layout.
155 */
156
157 int vbo = GL15.glGenBuffers();
158 GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
159
160 for ( Attr attr : attributes ) {
161 GL20.glEnableVertexAttribArray(attr.index);
162 long posPointer = glGetVertexAttribPointer(attr.index);
163 if ( posPointer != 0 )
164 throw new AssertionError();
165 GL20.glVertexAttribPointer(attr.index, attr.size, GL11.GL_FLOAT,
166 false, strideBytes, attr.getByteOffset());
167 }
168
169 for ( Attr attr : attributes ) {
170 long posPointer = glGetVertexAttribPointer(attr.index);
171 /* this proves that value returned is the offset */
172 if ( posPointer != attr.getByteOffset() )
173 throw new AssertionError("this will never happen");
174 System.out.println(attr.name + ": offset = " + posPointer);
175 }
176
177 if ( !crashJvm ) {
178 System.out
179 .println("Test passed, but try running again with -DcrashJvm=true.");
180 } else {
181 System.out
182 .println("You won't ever get this far with LWJGL 2.8.5 or 2.9.0");
183 }
184 }
185 }
0 package org.lwjgl.test.input;
1
2 import org.lwjgl.LWJGLException;
3 import org.lwjgl.Sys;
4 import org.lwjgl.input.Keyboard;
5 import org.lwjgl.input.Mouse;
6 import org.lwjgl.opengl.Display;
7 import org.lwjgl.opengl.GL11;
8
9 import java.awt.*;
10 import java.awt.event.*;
11 import java.util.Random;
12 import javax.swing.*;
13
14 /** @author Spasi */
15 public class ControlFail {
16
17 public ControlFail() {
18
19 }
20
21 public static void main(String[] args) {
22 Canvas canvas = new Canvas();
23 JFrame frame = new JFrame("Test");
24
25 MenuBar menu = new MenuBar();
26 Menu file = new Menu("File");
27 file.add(new MenuItem("New"));
28 file.add(new MenuItem("Open"));
29 file.add(new MenuItem("Save"));
30 menu.add(file);
31
32 frame.setMenuBar(menu);
33
34 JComboBox combo = new JComboBox<String>(new String[] { "foo", "bar", "yo", "sakis" });
35 combo.setLightWeightPopupEnabled(false);
36
37 frame.getContentPane().setLayout(new BorderLayout());
38 frame.getContentPane().add(combo, BorderLayout.NORTH);
39 frame.getContentPane().add(canvas, BorderLayout.CENTER);
40 frame.getContentPane().add(new JTextField(32), BorderLayout.SOUTH);
41
42 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
43 frame.setSize(new Dimension(640, 480));
44 frame.setLocationRelativeTo(null);
45 frame.setVisible(true);
46 canvas.setBackground(Color.RED);
47 canvas.addMouseListener(new MouseAdapter() {
48 public void mousePressed(final MouseEvent e) {
49 System.out.println("e = " + e);
50 }
51 });
52
53 try {
54 Display.setParent(canvas);
55 Display.setVSyncEnabled(true);
56 Display.create();
57 //Mouse.setGrabbed(true);
58 OUTER:
59 while ( !Display.isCloseRequested() ) {
60 float color = new Random().nextFloat();
61 GL11.glClearColor(color, color, color, 0.0f);
62 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
63 Display.update();
64
65 /*if ( Display.isActive() && !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) )
66 System.out.println("control is up " + System.currentTimeMillis());*/
67
68 while ( Keyboard.next() ) {
69 int character_code = ((int)Keyboard.getEventCharacter()) & 0xffff;
70 System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.getEventKey()));
71 System.out.println("Pressed:" + Keyboard.getEventKeyState());
72 System.out.println("Key character code: 0x" + Integer.toHexString(character_code));
73 System.out.println("Key character: " + Keyboard.getEventCharacter());
74 System.out.println("Repeat event: " + Keyboard.isRepeatEvent());
75
76 if ( Keyboard.getEventKey() == Keyboard.KEY_G && Keyboard.getEventKeyState() ) {
77 Mouse.setGrabbed(!Mouse.isGrabbed());
78 }
79 if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE ) {
80 break OUTER;
81 }
82 }
83
84 //Display.sync(10);
85 }
86
87 Display.destroy();
88 frame.dispose();
89 } catch (LWJGLException e) {
90 e.printStackTrace();
91 }
92 }
93
94 }
4848 * Tests switching between windowed and fullscreen - including hardware cursor test
4949 *
5050 * @author Brian Matzon <brian@matzon.dk>
51 * @version $Revision: 3418 $
52 * $Id: HWCursorTest.java 3418 2010-09-28 21:11:35Z spasi $
51 * @version $Revision$
52 * $Id$
5353 */
5454 public class HWCursorTest {
5555
4343 * Keyboard test
4444 *
4545 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3418 $
47 * $Id: KeyboardTest.java 3418 2010-09-28 21:11:35Z spasi $
46 * @version $Revision$
47 * $Id$
4848 */
4949 public class KeyboardTest {
5050
201201
202202 render();
203203
204 try {
205 Thread.sleep(0);
206 } catch (Exception e) {
207 }
204 Display.sync(60);
208205 }
209206 }
210207
4343 * Mouse test
4444 *
4545 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3418 $
47 * $Id: MouseCreationTest.java 3418 2010-09-28 21:11:35Z spasi $
46 * @version $Revision$
47 * $Id$
4848 */
4949 public class MouseCreationTest {
5050 /** position of quad to draw */
4545 * Mouse test
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 3418 $
49 * $Id: MouseTest.java 3418 2010-09-28 21:11:35Z spasi $
48 * @version $Revision$
49 * $Id$
5050 */
5151 public class MouseTest {
5252 /** Direction mouse has moved */
353353 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
354354 Mouse.setGrabbed(!Mouse.isGrabbed());
355355 }
356
357 if(Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) {
358 Display.setResizable(!Display.isResizable());
359 }
356360 }
357361 }
358362
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.util.mapped.MappedObject;
34
35 /** @author Riven */
36 public class MappedFloat extends MappedObject {
37
38 public MappedFloat() {
39 this.test();
40 }
41
42 public float value;
43
44 public void test() {
45 this.value = 4;
46 }
47
48 @Override
49 public String toString() {
50 return "MappedFloat[" + value + "]";
51 }
52
53 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.MemoryUtil;
34
35 import java.nio.ByteBuffer;
36 import java.util.Arrays;
37
38 import static org.lwjgl.util.mapped.MappedHelper.*;
39
40 /** @author Riven */
41 @SuppressWarnings("static-access")
42 public class MappedObjectBench {
43
44 static class InstanceVec3 {
45
46 float x, y, z;
47
48 @Override
49 public String toString() {
50 return "InstanceVec3[" + x + ", " + y + ", " + z + "]";
51 }
52 }
53
54 static class ArrayVec3 {
55
56 float[] a;
57 int i;
58
59 @Override
60 public String toString() {
61 return "ArrayVec3[" + a[i * 3 + 0] + ", " + a[i * 3 + 1] + ", " + a[i * 3 + 2] + "]";
62 }
63 }
64
65 static void benchmarkInstances() {
66 final int runs = 64;
67 final int iterations = 64 * 1024;
68
69 InstanceVec3 vec1 = new InstanceVec3();
70 InstanceVec3 vec2 = new InstanceVec3();
71 InstanceVec3 vec3 = new InstanceVec3();
72
73 long[] took = new long[runs];
74 for ( int run = 0; run < runs; run++ ) {
75 long t0 = System.nanoTime();
76 for ( int iteration = 0; iteration < iterations; iteration++ ) {
77 vec1.x = 13;
78 vec1.y += vec1.y * vec1.x + 0.3f;
79 vec1.z += vec2.y + vec1.x + 0.3f;
80 vec2.z += vec2.y + vec1.x;
81 vec3.z += vec2.z + vec1.y;
82 }
83 long t1 = System.nanoTime();
84 took[run] = t1 - t0;
85 }
86
87 Arrays.sort(took);
88 System.out.println("instance took: " + took[took.length / 2] / 1024 + "us");
89
90 System.out.println(vec1);
91 System.out.println(vec2);
92 System.out.println(vec3);
93 }
94
95 static void benchmarkMapped() {
96 final int runs = 64;
97 final int iterations = 64 * 1024;
98
99 ByteBuffer bb = ByteBuffer.allocateDirect(200);
100
101 MappedVec3 vecs = MappedVec3.map(bb);
102
103 MappedVec3 vec1 = vecs.dup();
104 MappedVec3 vec2 = vecs.dup();
105 MappedVec3 vec3 = vecs.dup();
106
107 vec1.view = 0;
108 vec2.view = 1;
109 vec3.view = 2;
110
111 long[] took = new long[runs];
112 for ( int run = 0; run < runs; run++ ) {
113 long t0 = System.nanoTime();
114 for ( int iteration = 0; iteration < iterations; iteration += 2 ) {
115 vec1.x = 13;
116 vec1.y += vec1.y * vec1.x + 0.3f;
117 vec1.z += vec2.y + vec1.x + 0.3f;
118 vec2.z += vec2.y + vec1.x;
119 vec3.z += vec2.z + vec1.y;
120
121 vec1.x = 13;
122 vec1.y += vec1.y * vec1.x + 0.3f;
123 vec1.z += vec2.y + vec1.x + 0.3f;
124 vec2.z += vec2.y + vec1.x;
125 vec3.z += vec2.z + vec1.y;
126 }
127 long t1 = System.nanoTime();
128 took[run] = t1 - t0;
129 }
130
131 Arrays.sort(took);
132 System.out.println("mapped took: " + took[took.length / 2] / 1024 + "us");
133
134 System.out.println(vec1);
135 System.out.println(vec2);
136 System.out.println(vec3);
137
138 System.out.println(bb);
139 }
140
141 static void benchmarkIndirectArray() {
142 final int runs = 64;
143 final int iterations = 64 * 1024;
144
145 float[] bb = new float[200];
146
147 ArrayVec3 vec1 = new ArrayVec3();
148 ArrayVec3 vec2 = new ArrayVec3();
149 ArrayVec3 vec3 = new ArrayVec3();
150
151 vec1.a = bb;
152 vec2.a = bb;
153 vec3.a = bb;
154
155 vec1.i = 0;
156 vec2.i = 1;
157 vec3.i = 2;
158
159 long[] took = new long[runs];
160 for ( int run = 0; run < runs; run++ ) {
161 long t0 = System.nanoTime();
162 for ( int iteration = 0; iteration < iterations; iteration++ ) {
163 vec1.a[vec1.i * 3 + 0] = 13;
164 vec1.a[vec1.i * 3 + 1] += vec1.a[vec1.i * 3 + 1] * vec1.a[vec1.i * 3 + 0] + 0.3f;
165 vec1.a[vec1.i * 3 + 2] += vec2.a[vec2.i * 3 + 1] + vec1.a[vec1.i * 3 + 0] + 0.3f;
166 vec2.a[vec2.i * 3 + 2] += vec2.a[vec2.i * 3 + 1] + vec1.a[vec1.i * 3 + 0];
167 vec3.a[vec3.i * 3 + 2] += vec2.a[vec2.i * 3 + 2] + vec2.a[vec2.i * 3 + 1];
168 }
169 long t1 = System.nanoTime();
170 took[run] = t1 - t0;
171 }
172
173 Arrays.sort(took);
174 System.out.println("array took: " + took[took.length / 2] / 1024 + "us");
175
176 System.out.println(vec1);
177 System.out.println(vec2);
178 System.out.println(vec3);
179
180 System.out.println(bb);
181 }
182
183 static void benchmarkDirectArray() {
184 final int runs = 64;
185 final int iterations = 64 * 1024;
186
187 float[] bb = new float[200];
188
189 long[] took = new long[runs];
190 for ( int run = 0; run < runs; run++ ) {
191 long t0 = System.nanoTime();
192 for ( int iteration = 0; iteration < iterations; iteration++ ) {
193 bb[1 * 3 + 0] = 13;
194 bb[1 * 3 + 1] += bb[1 * 3 + 1] * bb[1 * 3 + 0] + 0.3f;
195 bb[1 * 3 + 2] += bb[2 * 3 + 1] + bb[1 * 3 + 0] + 0.3f;
196 bb[2 * 3 + 2] += bb[2 * 3 + 1] + bb[1 * 3 + 0];
197 bb[3 * 3 + 2] += bb[2 * 3 + 2] + bb[2 * 3 + 1];
198 }
199 long t1 = System.nanoTime();
200 took[run] = t1 - t0;
201 }
202
203 Arrays.sort(took);
204 System.out.println("array2 took: " + took[took.length / 2] / 1024 + "us");
205
206 System.out.println(bb);
207 }
208
209 static void benchmarkUnsafe() {
210 final int runs = 64;
211 final int iterations = 64 * 1024;
212
213 ByteBuffer bb = ByteBuffer.allocateDirect(200);
214 long addr = MemoryUtil.getAddress(bb);
215
216 long[] took = new long[runs];
217 for ( int run = 0; run < runs; run++ ) {
218 long t0 = System.nanoTime();
219 for ( int iteration = 0; iteration < iterations; iteration++ ) {
220 fput(13, addr + (1 * 3 + 0) * 4);
221 fput(fget(addr + (1 * 3 + 1) * 4) + fget(addr + (1 * 3 + 1) * 4) * fget(addr + (1 * 3 + 0) * 4) + 0.3f, addr + (1 * 3 + 1) * 4);
222 fput(fget(addr + (1 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4) + fget(addr + (1 * 3 + 0) * 4) + 0.3f, addr + (1 * 3 + 2) * 4);
223 fput(fget(addr + (2 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4) + fget(addr + (1 * 3 + 0) * 4), addr + (2 * 3 + 2) * 4);
224 fput(fget(addr + (3 * 3 + 2) * 4) + fget(addr + (2 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4), addr + (3 * 3 + 2) * 4);
225 }
226 long t1 = System.nanoTime();
227 took[run] = t1 - t0;
228 }
229
230 Arrays.sort(took);
231 System.out.println("unsafe took: " + took[took.length / 2] / 1024 + "us");
232
233 System.out.println(bb);
234 }
235
236 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.MemoryUtil;
34 import org.lwjgl.util.mapped.MappedHelper;
35
36 import java.nio.ByteBuffer;
37
38 /** @author Riven */
39 @SuppressWarnings("static-access")
40 public class MappedObjectTests1 {
41
42 static class Test {
43
44 int value;
45 }
46
47 static void testViewField() {
48 Test test = new Test();
49 test.value = 13;
50 test.value += 1;
51 test.value++;
52 System.out.println(test);
53
54 ByteBuffer bb = ByteBuffer.allocateDirect(200);
55 MappedFloat vecs = MappedFloat.map(bb);
56
57 // verify 'malloc', SIZEOF and capacity()
58 {
59 MappedFloat vecs1 = MappedFloat.malloc(1234);
60
61 assert (vecs1.getSizeof() == MappedFloat.SIZEOF);
62 assert (vecs1.getSizeof() * 1234 == vecs1.backingByteBuffer().capacity());
63 assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity());
64 assert(vecs1.capacity() == vecs1.backingByteBuffer().capacity() / MappedFloat.SIZEOF);
65
66 ByteBuffer buf = ByteBuffer.allocateDirect(200);
67 buf.position(10 * MappedFloat.SIZEOF);
68
69 MappedFloat vecs2 = MappedFloat.map(buf);
70 assert(vecs2.capacity() == (vecs2.backingByteBuffer().capacity() / MappedFloat.SIZEOF) - 10);
71 }
72
73 // manipulate 'mapped.value'
74 {
75 assert (vecs.value == 0.0f); // 4.0 is set in constructor, but runViewConstructor is not called
76 vecs.value = 1.1f;
77 assert (vecs.value == 1.1f);
78 }
79
80 // manipulate 'view' with assignment
81 {
82 assert (vecs.view == 0);
83 vecs.view = 1;
84 assert (vecs.view == 1);
85 assert (vecs.value != 1.1f); // old view
86 vecs.view = 0;
87 }
88
89 // manipulate 'view' with iinc
90 {
91 assert (vecs.view == 0);
92 vecs.view++;
93 assert (vecs.view == 1);
94 assert (vecs.value != 1.1f); // old view
95 vecs.view = 0;
96 }
97
98 // manipulate 'view' with next()
99 {
100 assert (vecs.view == 0);
101 vecs.next();
102 assert (vecs.view == 1);
103 assert (vecs.value != 1.1f); // old view
104 vecs.view = 0;
105 }
106
107 // test bounds checking
108 {
109 assert (vecs.view == 0);
110 try {
111 vecs.view = 49;
112 assert vecs.view == 49;
113 vecs.view = 0;
114 vecs.view = 50;
115 System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
116 vecs.view = 0;
117 } catch (IndexOutOfBoundsException e) {
118 // expected, ignore
119 }
120
121 assert (vecs.view == 0);
122
123 try {
124 vecs.view = 10;
125 MappedFloat vecs2 = vecs.slice();
126 vecs.view = 0;
127
128 vecs2.view = 39;
129 assert vecs2.view == 39;
130 vecs2.view = 40;
131 System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
132 } catch (IndexOutOfBoundsException e) {
133 // expected, ignore
134 }
135
136 try {
137 ByteBuffer posTest = ByteBuffer.allocateDirect(200);
138 posTest.position(10 * MappedFloat.SIZEOF); // position > 0
139
140 MappedFloat vecs2 = MappedFloat.map(posTest);
141 vecs2.view = 39;
142 assert vecs2.view == 39;
143 vecs2.view = 40;
144 System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
145 } catch (IndexOutOfBoundsException e) {
146 // expected, ignore
147 }
148 }
149
150 // test newBuffer
151 {
152 long addr1 = MemoryUtil.getAddress(bb);
153 ByteBuffer bb2 = MappedHelper.newBuffer(addr1, bb.capacity());
154 long addr2 = MemoryUtil.getAddress(bb);
155
156 System.out.println(bb);
157 System.out.println(bb2);
158 System.out.println(addr1);
159 System.out.println(addr2);
160 }
161
162 // test 'copy'
163 {
164 vecs.value = 13.37f;
165 MappedFloat dec2 = vecs.dup();
166 dec2.view = 1;
167 System.out.println(vecs);
168 System.out.println(dec2);
169 vecs.copyTo(dec2);
170 System.out.println(vecs);
171 System.out.println(dec2);
172 assert (dec2.value == 13.37f);
173
174 vecs.value = 73.31f;
175 vecs.copyRange(dec2, 1);
176 assert (dec2.value == 73.31f);
177 }
178 }
179 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.nio.ByteBuffer;
34
35 /** @author Riven */
36 @SuppressWarnings("static-access")
37 public class MappedObjectTests2 {
38
39 static void testWriteFieldAccess(MappedVec3 vecs) {
40 // write access results into a transform-time IllegalAccessException
41
42 System.out.println(vecs.baseAddress); // test read-access
43
44 System.out.println(vecs.viewAddress); // test read-access
45
46 System.out.println(vecs.getAlign()); // test read-access
47
48 System.out.println(MappedVec3.SIZEOF); // test read-access
49 }
50
51 static void testFields() {
52 ByteBuffer bb = ByteBuffer.allocateDirect(200);
53 MappedVec3 vecs = MappedVec3.map(bb);
54
55 testWriteFieldAccess(vecs);
56
57 vecs.x = 13.13f;
58 vecs.y = 14.14f;
59 vecs.z = 15.15f;
60
61 System.out.println(vecs.viewAddress);
62
63 assert (vecs.x == 13.13f);
64 assert (vecs.y == 14.14f);
65 assert (vecs.z == 15.15f);
66
67 vecs.view = 0;
68
69 assert (vecs.x == 13.13f);
70 assert (vecs.y == 14.14f);
71 assert (vecs.z == 15.15f);
72
73 System.out.println(vecs);
74 vecs.view = 1;
75 System.out.println(vecs);
76
77 assert (vecs.x == 0.0f);
78 assert (vecs.y == 0.0f);
79 assert (vecs.z == 0.0f);
80
81 // now it becomes weird: offsets and strides
82
83 vecs.view = 1;
84 vecs.x = 0.1234f;
85 vecs.view = 0;
86
87 // test stride & sizeof
88 {
89 long a1 = vecs.viewAddress;
90 vecs.view = 1;
91 long a2 = vecs.viewAddress;
92 assert (a2 - a1 == MappedVec3.SIZEOF);
93 assert (a2 - a1 == vecs.getSizeof());
94 vecs.view = 0;
95 }
96 }
97 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.MemoryUtil;
34 import org.lwjgl.util.mapped.MappedObject;
35 import org.lwjgl.util.mapped.MappedSet;
36 import org.lwjgl.util.mapped.MappedSet2;
37
38 import java.nio.ByteBuffer;
39 import java.nio.ByteOrder;
40
41 import static org.lwjgl.util.mapped.MappedObject.*;
42
43 /** @author Riven */
44 @SuppressWarnings("static-access")
45 public class MappedObjectTests3 {
46
47 static void testMappedBuffer() {
48 int elementCount = 4;
49
50 MappedSomething some = MappedSomething.malloc(elementCount);
51
52 assert (some.data != some.data);
53
54 long addr1 = MemoryUtil.getAddress(some.backingByteBuffer());
55
56 ByteBuffer mapped = some.data; // creates new ByteBuffer instance
57 long addr2 = MemoryUtil.getAddress(mapped);
58
59 assert (addr2 - addr1 == 4);
60 assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
61
62 {
63 assert (some.shared == 0);
64 assert (mapped.getInt(8) == 0);
65
66 some.shared = 1234;
67
68 assert (some.shared == 1234);
69 assert (mapped.getInt(8) == 1234);
70 }
71
72 some.view++;
73 mapped = some.data; // creates new ByteBuffer instance
74
75 long addr3 = MemoryUtil.getAddress(mapped);
76 assert (addr3 - addr1 == 4 + MappedSomething.SIZEOF);
77 assert (addr3 - addr2 == 0 + MappedSomething.SIZEOF);
78 assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
79 }
80
81 static void testForeach() {
82 int elementCount = 10;
83 MappedSomething some = MappedSomething.malloc(elementCount);
84
85 int i = 0;
86 for ( MappedSomething item : foreach(some, elementCount / 2) ) {
87 assert (item.view == i++);
88 }
89 assert (some.view == (elementCount / 2) - 1);
90 System.out.println("current.view=" + some.view + ", not " + (elementCount / 2) + ", as you might expect");
91
92 i = 0;
93 for ( MappedSomething item : foreach(some) ) {
94 assert (item.view == i++);
95 }
96 assert (some.view == elementCount - 1);
97 }
98
99 public static class Xyz extends MappedObject {
100
101 int x, y, z;
102 }
103
104 static void testConstructor() {
105 int capacity = 1024;
106 ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
107 long address = MemoryUtil.getAddress(bb);
108
109 MappedFloat mf = MappedFloat.map(address, capacity);
110
111 assert (address == mf.baseAddress);
112
113 assert (mf.value == 0.0f);
114 mf.view = 1;
115 assert (mf.value == 0.0f);
116 mf.runViewConstructor();
117 assert (mf.value == 4.0f);
118
119 Xyz.malloc(3);
120 }
121
122 static void testMappedSet() {
123 MappedVec2 vec2 = MappedVec2.malloc(3);
124 MappedVec3 vec3 = MappedVec3.malloc(3);
125
126 MappedSet2 set = MappedSet.create(vec2, vec3);
127
128 assert (vec2.view == 0);
129 assert (vec3.view == 0);
130
131 set.view = 2;
132 assert (vec2.view == 2);
133 assert (vec3.view == 2);
134
135 set.view = 0;
136 assert (vec2.view == 0);
137 assert (vec3.view == 0);
138
139 set.next();
140 assert (vec2.view == 1);
141 assert (vec3.view == 1);
142 }
143
144 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.MemoryUtil;
34 import org.lwjgl.PointerBuffer;
35 import org.lwjgl.opengl.Display;
36 import org.lwjgl.util.mapped.*;
37
38 import java.io.File;
39 import java.lang.reflect.Field;
40 import java.nio.ByteBuffer;
41
42 /** @author Riven */
43 @SuppressWarnings("static-access")
44 public class MappedObjectTests4 {
45
46 public static void testLWJGL() throws Exception {
47 System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath());
48 Display.create();
49 }
50
51 public static void testLocalView() {
52 MappedFloat mapped1 = MappedFloat.malloc(5);
53 MappedFloat mapped2 = MappedFloat.malloc(5);
54
55 testLocalView(mapped1);
56 testLocalView(mapped1, mapped2);
57
58 MappedSomething some = MappedSomething.malloc(5);
59 testLocalView(some);
60 }
61
62 private static void testLocalView(MappedFloat mapped1) {
63 final MappedFloat[] array = mapped1.asArray();
64
65 assert (array.length == 5);
66
67 int l = 10 * array.length;
68 for ( int localView1 = 0; localView1 < 5; localView1++ ) {
69 array[localView1].value = localView1 * 5;
70 array[localView1].value *= 2.0f;
71 }
72 System.out.println();
73 float x = 0.0f;
74 for ( int localView1 = 0; localView1 < 5; localView1++ ) {
75 System.out.println("[" + localView1 + "] =>" + array[localView1].value);
76 x += array[localView1].value;
77 }
78 System.out.println("x = " + x);
79 }
80
81 private static void testLocalView(MappedFloat mo1, MappedFloat mo2) {
82 final MappedFloat[] array1 = mo1.<MappedFloat>asArray();
83 for ( int v1 = 0; v1 < 5; v1++ ) {
84 array1[v1].value = (float)Math.random();
85 array1[v1].value *= 2.0f;
86 }
87 final MappedFloat[] array2 = mo2.<MappedFloat>asArray();
88 for ( int v2 = 0; v2 < 5; v2++ ) {
89 array2[v2].value = (float)Math.random();
90 array2[v2].value *= 2.0f;
91 }
92
93 System.out.println();
94
95 for ( int v1 = 0; v1 < 5; v1++ ) {
96 System.out.println("[" + v1 + "] =>" + array1[v1].value);
97 }
98 for ( int v2 = 0; v2 < 5; v2++ ) {
99 System.out.println("[" + v2 + "] =>" + array2[v2].value);
100 }
101 }
102
103 private static void testLocalView(MappedSomething some) {
104 final MappedSomething[] array = some.asArray();
105
106 assert (array.length == 5);
107
108 final long baseAddress = MemoryUtil.getAddress(some.backingByteBuffer());
109 for ( int i = 0; i < array.length; i++ ) {
110 ByteBuffer data = array[i].data;
111
112 assert (data.capacity() == (64 - 4));
113 assert (MemoryUtil.getAddress(data) == baseAddress + i * MappedSomething.SIZEOF + 4);
114 }
115 }
116
117 public static class MappedPointer extends MappedObject {
118
119 int foo;
120 @Pointer long pointer;
121 int bar;
122
123 }
124
125 public static void testPointer() {
126 MappedPointer data = MappedPointer.malloc(100);
127
128 assert (data.backingByteBuffer().capacity() == 100 * (4 + 4 + PointerBuffer.getPointerSize()));
129
130 for ( int i = 0; i < 100; i++ ) {
131 data.view = i;
132
133 data.foo = i;
134 data.pointer = i * 1000;
135 data.bar = i * 2;
136 }
137
138 for ( int i = 0; i < 100; i++ ) {
139 data.view = i;
140
141 assert (data.foo == i);
142 assert (data.pointer == i * 1000);
143 assert (data.bar == i * 2);
144 }
145 }
146
147 @MappedType(cacheLinePadding = true)
148 public static class MappedCacheLinePadded extends MappedObject {
149
150 int foo;
151 int bar;
152
153 }
154
155 public static void testCacheLineAlignment() {
156 MappedCacheLinePadded data = MappedCacheLinePadded.malloc(10);
157
158 assert (data.backingByteBuffer().capacity() == 10 * CacheUtil.getCacheLineSize());
159 assert (MemoryUtil.getAddress(data.backingByteBuffer()) % CacheUtil.getCacheLineSize() == 0);
160
161 for ( int i = 0; i < 10; i++ ) {
162 data.view = i;
163
164 data.foo = i;
165 data.bar = i * 2;
166 }
167
168 for ( int i = 0; i < 10; i++ ) {
169 data.view = i;
170
171 assert (data.foo == i);
172 assert (data.bar == i * 2);
173 }
174 }
175
176 public static class MappedFieldCacheLinePadded extends MappedObject {
177
178 // If we assume CacheUtil.getCacheLineSize() == 64
179 // 0 - 63
180 @CacheLinePad long longBar;
181 // 64 - 71
182 long longFoo;
183 // 72 - 75
184 int intFoo;
185 // 128 - 131
186 @CacheLinePad(before = true) int intBar;
187 // 192 - 195
188 int foo;
189 // 256 - 267
190 @CacheLinePad(before = true, after = false)
191 @MappedField(byteLength = 12)
192 ByteBuffer buffer;
193 // 268 - 271
194 int bar;
195
196 }
197
198 public static void testCacheLinePadding() {
199 MappedFieldCacheLinePadded data = MappedFieldCacheLinePadded.map(CacheUtil.createByteBuffer(10 * MappedFieldCacheLinePadded.SIZEOF));
200
201 final int sizeof =
202 CacheUtil.getCacheLineSize()
203 + 8
204 + (CacheUtil.getCacheLineSize() - 8)
205 + CacheUtil.getCacheLineSize()
206 + 4
207 + (CacheUtil.getCacheLineSize() - 4)
208 + 12
209 + 4;
210
211 assert (MappedFieldCacheLinePadded.SIZEOF == sizeof);
212 assert (data.backingByteBuffer().capacity() == sizeof * 10);
213
214 for ( int i = 0; i < 10; i++ ) {
215 data.view = i;
216
217 data.longFoo = i * 1000000000L;
218 data.longBar = i * 2000000000L;
219 data.intFoo = i * 1000;
220 data.intBar = i * 2000;
221 data.foo = i;
222 }
223
224 for ( int i = 0; i < 10; i++ ) {
225 data.view = i;
226
227 assert (data.longFoo == i * 1000000000L);
228 assert (data.longBar == i * 2000000000L);
229 assert (data.intFoo == i * 1000);
230 assert (data.intBar == i * 2000);
231 assert (data.foo == i);
232 }
233 }
234
235 public static class POJOFieldCacheLinePadded {
236
237 @CacheLinePad long longBar;
238 long longFoo;
239 int intFoo;
240 @CacheLinePad(before = true) int intBar;
241 int foo;
242 @CacheLinePad boolean bool;
243 int bar;
244
245 }
246
247 public static void testCacheLinePaddingPOJO() {
248 Field[] fields = new POJOFieldCacheLinePadded().getClass().getDeclaredFields();
249 assert (fields.length == (1 + 7) + 1 + 1 + (15 + 1 + 15) + 1 + (1 + 63) + 1);
250 }
251
252 }
0 /*
1 * Created on Jul 12, 2011
2 */
3
4 package org.lwjgl.test.mapped;
5
6 import org.lwjgl.opengl.Display;
7
8 import java.io.File;
9
10 public class MappedObjectWithLibrary {
11
12 public static void testLWJGL() throws Exception {
13 System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath());
14 Display.create();
15 }
16 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.util.mapped.MappedField;
34 import org.lwjgl.util.mapped.MappedObject;
35
36 import java.nio.ByteBuffer;
37
38 /** @author Riven */
39 public class MappedSomething extends MappedObject {
40
41 @MappedField(byteOffset = 0)
42 public int used;
43
44 @MappedField(byteLength = 64 - 4) // optional byteOffset
45 public ByteBuffer data;
46
47 @MappedField(byteOffset = 12) // inside data
48 public int shared;
49
50 @Override
51 public String toString() {
52 return "MappedSomething[" + used + "]";
53 }
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.util.mapped.MappedObject;
34
35 /** @author Riven */
36 public class MappedVec2 extends MappedObject {
37
38 public float x;
39
40 public float y;
41
42 @Override
43 public String toString() {
44 return "MappedVec2[" + x + "," + y + "]";
45 }
46
47 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.util.mapped.MappedObject;
34
35 /** @author Riven */
36 public class MappedVec3 extends MappedObject {
37
38 public float x;
39
40 public float y;
41
42 public float z;
43
44 @Override
45 public String toString() {
46 return "[" + x + "," + y + "," + z + "]";
47 }
48
49 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.util.mapped.MappedObjectClassLoader;
34 import org.lwjgl.util.mapped.MappedObjectTransformer;
35
36 /** @author Riven */
37 @SuppressWarnings("static-access")
38 public class TestMappedObject {
39
40 static {
41 boolean assertsEnabled = false;
42 assert assertsEnabled = true; // Intentional side effect!!!
43 if ( !assertsEnabled )
44 throw new RuntimeException("Asserts must be enabled for this test.");
45 }
46
47 public static void main(String[] args) throws Exception {
48 MappedObjectTransformer.register(MappedFloat.class);
49 MappedObjectTransformer.register(MappedVec2.class);
50 MappedObjectTransformer.register(MappedVec3.class);
51 MappedObjectTransformer.register(MappedSomething.class);
52 MappedObjectTransformer.register(MappedObjectTests3.Xyz.class);
53 MappedObjectTransformer.register(MappedObjectTests4.MappedPointer.class);
54 MappedObjectTransformer.register(MappedObjectTests4.MappedCacheLinePadded.class);
55 MappedObjectTransformer.register(MappedObjectTests4.MappedFieldCacheLinePadded.class);
56
57 if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) {
58 return;
59 }
60
61 MappedObjectTests1.testViewField();
62
63 MappedObjectTests2.testFields();
64
65 // MappedObjectBench.benchmarkMapped();
66 // MappedObjectBench.benchmarkInstances();
67 // MappedObjectBench.benchmarkIndirectArray();
68 // MappedObjectBench.benchmarkDirectArray();
69 // MappedObjectBench.benchmarkUnsafe();
70
71 MappedObjectTests3.testMappedBuffer();
72 MappedObjectTests3.testForeach();
73 MappedObjectTests3.testConstructor();
74 MappedObjectTests3.testMappedSet();
75
76 MappedObjectTests4.testLocalView();
77 //MappedObjectTests4.testLWJGL();
78 MappedObjectTests4.testPointer();
79 MappedObjectTests4.testCacheLineAlignment();
80 MappedObjectTests4.testCacheLinePadding();
81 MappedObjectTests4.testCacheLinePaddingPOJO();
82
83 System.out.println("done");
84 }
85
86 }
4141 * This is a test for the ALC part of OpenAL
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: ALCTest.java 2983 2008-04-07 18:36:09Z matzon $
44 * @version $Revision$
45 * $Id$
4646 */
4747 public class ALCTest extends BasicTest {
4848
4343 * This is a basic test, which contains the most used stuff
4444 *
4545 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3418 $
47 * $Id: BasicTest.java 3418 2010-09-28 21:11:35Z spasi $
46 * @version $Revision$
47 * $Id$
4848 */
4949 public abstract class BasicTest {
5050
4545 * a source moving around the listener using the keyboard
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2983 $
49 * $Id: MovingSoundTest.java 2983 2008-04-07 18:36:09Z matzon $
48 * @version $Revision$
49 * $Id$
5050 */
5151 public class MovingSoundTest extends BasicTest {
5252
4444 * We cannot inherit from BasicTest since it follows another structure.
4545 *
4646 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 2983 $
48 * $Id: OpenALCreationTest.java 2983 2008-04-07 18:36:09Z matzon $
47 * @version $Revision$
48 * $Id$
4949 */
5050 public class OpenALCreationTest {
5151
4646 * Yes, over zealous use of getError ;)
4747 *
4848 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: PlayTest.java 2983 2008-04-07 18:36:09Z matzon $
49 * @version $Revision$
50 * $Id$
5151 */
5252 public class PlayTest extends BasicTest {
5353
4646 * Yes, over zealous use of getError ;)
4747 *
4848 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: PlayTestMemory.java 2983 2008-04-07 18:36:09Z matzon $
49 * @version $Revision$
50 * $Id$
5151 */
5252 public class PlayTestMemory extends BasicTest {
5353
5151 * (http://www.edenwaith.com/products/pige/tutorials/openal.php)
5252 *
5353 * @author Brian Matzon <brian@matzon.dk>
54 * @version $Revision: 3418 $
55 * $Id: PositionTest.java 3418 2010-09-28 21:11:35Z spasi $
54 * @version $Revision$
55 * $Id$
5656 */
5757 public class PositionTest extends BasicTest {
5858
4141 * Simple test for testing the number of available sources
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: SourceLimitTest.java 2983 2008-04-07 18:36:09Z matzon $
44 * @version $Revision$
45 * $Id$
4646 */
4747 public class SourceLimitTest extends BasicTest {
4848
4141 * Simple test for stresstesting OpenAL playing random samples ad nausea
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2983 $
45 * $Id: StressTest.java 2983 2008-04-07 18:36:09Z matzon $
44 * @version $Revision$
45 * $Id$
4646 */
4747 public class StressTest extends BasicTest {
4848
8080 System.out.println(caps);
8181 System.out.println("\t-------------------------");
8282
83 System.out.println("\tCL_DEVICE_TYPE = " + device.getInfoInt(CL_DEVICE_TYPE));
83 System.out.println("\tCL_DEVICE_TYPE = " + device.getInfoLong(CL_DEVICE_TYPE));
8484 System.out.println("\tCL_DEVICE_VENDOR_ID = " + device.getInfoInt(CL_DEVICE_VENDOR_ID));
8585 System.out.println("\tCL_DEVICE_MAX_COMPUTE_UNITS = " + device.getInfoInt(CL_DEVICE_MAX_COMPUTE_UNITS));
8686 System.out.println("\tCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = " + device.getInfoInt(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS));
142142 System.out.println("-TRYING TO EXEC NATIVE KERNEL-");
143143 final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null);
144144
145 final PointerBuffer ev = BufferUtils.createPointerBuffer(1);
146
145147 clEnqueueNativeKernel(queue, new CLNativeKernel() {
146148 protected void execute(final ByteBuffer[] memobjs) {
147 if ( memobjs == null )
148 System.out.println("OK, it's null");
149 else {
150 System.out.println("memobjs = " + memobjs.length);
151 for ( int k = 0; k < memobjs.length; k++ ) {
152 System.out.println("memobjs[" + k + "].remaining() = " + memobjs[k].remaining());
153 for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) {
154 memobjs[k].put(l, (byte)l);
155 }
149 System.out.println("\tmemobjs.length = " + memobjs.length);
150 for ( int k = 0; k < memobjs.length; k++ ) {
151 System.out.println("\tmemobjs[" + k + "].remaining() = " + memobjs[k].remaining());
152 for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) {
153 memobjs[k].put(l, (byte)l);
156154 }
157155 }
156 System.out.println("\tNative kernel done.");
158157 }
159 }, new CLMem[] { buffer }, new long[] { 128 }, null, null);
160
161 clFinish(queue);
158 }, new CLMem[] { buffer }, new long[] { 128 }, null, ev);
159
160 final CLEvent e = queue.getCLEvent(ev.get(0));
161
162 clSetEventCallback(e, CL_COMPLETE, new CLEventCallback() {
163 protected void handleMessage(final CLEvent event, final int event_command_exec_status) {
164 System.out.println("\t\tEvent callback status: " + getEventStatusName(event_command_exec_status));
165 }
166 });
167
168 int status = e.getInfoInt(CL_EVENT_COMMAND_EXECUTION_STATUS);
169 System.out.println("NATIVE KERNEL STATUS: " + getEventStatusName(status));
170 clFlush(queue);
171 do {
172 int newStatus = e.getInfoInt(CL_EVENT_COMMAND_EXECUTION_STATUS);
173 if ( newStatus != status ) {
174 status = newStatus;
175 System.out.println("NATIVE KERNEL STATUS: " + getEventStatusName(status));
176 }
177 } while ( status != CL_SUCCESS ); // Busy-spin until we're done
178
179 clReleaseEvent(e);
162180 }
163181 }
164182
181199 System.out.println("\t" + param_name + " = " + device.getInfoString(param));
182200 }
183201
202 private static String getEventStatusName(final int status) {
203 switch ( status ) {
204 case CL_QUEUED:
205 return "CL_QUEUED";
206 case CL_SUBMITTED:
207 return "CL_SUBMITTED";
208 case CL_RUNNING:
209 return "CL_RUNNING";
210 default:
211 return "CL_COMPLETE";
212 }
213 }
214
184215 private static void die(String kind, String description) {
185216 System.out.println(kind + " error " + description + " occured");
186217 }
517517 glDeleteBuffers(glIDs);
518518 }
519519
520 if ( useTextures )
520 if ( useTextures ) {
521521 glGenTextures(glIDs);
522 else
523 glGenBuffers(glIDs);
524
525 if ( useTextures ) {
522
526523 // Init textures
527524 for ( int i = 0; i < slices; i++ ) {
528525 glBindTexture(GL_TEXTURE_2D, glIDs.get(i));
534531 }
535532 glBindTexture(GL_TEXTURE_2D, 0);
536533 } else {
534 glGenBuffers(glIDs);
535
537536 // setup one empty PBO per slice
538537 for ( int i = 0; i < slices; i++ ) {
539538 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glIDs.get(i));
11 #ifdef AMD_FP
22 #pragma OPENCL EXTENSION cl_amd_fp64 : enable
33 #else
4 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
4 #ifndef CL_VERSION_1_2
5 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
6 #endif
57 #endif
68 #define varfloat double
79 #define _255 255.0
5658 output[iy * width + ix] = 0;
5759 #endif
5860 } else {
59 varfloat alpha = (varfloat)iteration / maxIterations;
61 float alpha = (float)iteration / maxIterations;
6062 int colorIndex = (int)(alpha * colorMapSize);
6163 #ifdef USE_TEXTURE
6264 // We could have changed colorMap to a texture + sampler, but the
6870 (c & 0xFF) >> 0,
6971 (c & 0xFF00) >> 8,
7072 (c & 0xFF0000) >> 16,
71 _255
73 255.0f
7274 );
73 write_imagef(output, (int2)(ix, iy), oc / _255);
75 write_imagef(output, (int2)(ix, iy), oc / 255.0f);
7476 #else
7577 output[iy * width + ix] = colorMap[colorIndex];
7678 #endif
0 package org.lwjgl.test.opengl;
1
2 import org.lwjgl.LWJGLException;
3 import org.lwjgl.input.Mouse;
4 import org.lwjgl.opengl.Display;
5 import org.lwjgl.opengl.GL11;
6
7 import java.awt.*;
8 import java.awt.event.*;
9 import javax.swing.*;
10 import javax.swing.event.InternalFrameEvent;
11 import javax.swing.event.InternalFrameListener;
12 import javax.swing.plaf.metal.MetalLookAndFeel;
13
14 import static org.lwjgl.opengl.GL11.*;
15
16 public class CanvasFocusTest extends JFrame {
17
18 private static final long serialVersionUID = 2853176700479564421L;
19 private JMenuBar menuBar;
20 private Canvas canvas;
21 private Thread gameThread;
22
23 private boolean running;
24
25 private JInternalFrame createDebugFrame() {
26
27 JInternalFrame internalFrame = new JInternalFrame("Debug Frame");
28 internalFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
29 internalFrame.setSize(400, 100);
30 internalFrame.setVisible(true);
31
32 JButton focus = new JButton("Focus");
33 focus.addActionListener(new ActionListener() {
34 public void actionPerformed(ActionEvent e) {
35 canvas.setFocusable(true);
36 }
37 });
38 internalFrame.add(focus);
39
40 JButton unfocus = new JButton("Unfocus");
41 unfocus.addActionListener(new ActionListener() {
42 public void actionPerformed(ActionEvent e) {
43 canvas.setFocusable(false);
44 }
45 });
46
47 internalFrame.add(unfocus);
48
49 JButton metal = new JButton("Metal");
50 metal.addActionListener(new ActionListener() {
51 public void actionPerformed(ActionEvent e) {
52 switchMetal();
53 }
54 });
55
56 internalFrame.add(metal);
57
58 JButton substance = new JButton("Substance");
59 substance.addActionListener(new ActionListener() {
60 public void actionPerformed(ActionEvent e) {
61 switchSubstance();
62 }
63 });
64
65 internalFrame.add(substance);
66 return internalFrame;
67 }
68
69 private JInternalFrame createGameFrame() {
70 final JInternalFrame canvasFrame = new JInternalFrame("Game Frame");
71 canvasFrame.setSize(800, 600);
72 canvasFrame.setLocation(80, 80);
73 canvasFrame.setVisible(true);
74
75 canvas = new Canvas() {
76 @Override
77 public void addNotify() {
78 super.addNotify();
79 startLWJGL();
80 }
81
82 @Override
83 public void removeNotify() {
84 stopLWJGL();
85 super.removeNotify();
86 }
87 };
88
89 canvasFrame.add(canvas);
90 canvas.setSize(canvasFrame.getContentPane().getSize());
91 canvas.setFocusable(true);
92 canvas.requestFocus();
93 canvas.setIgnoreRepaint(true);
94
95 canvasFrame.addInternalFrameListener(new InternalFrameListener() {
96 public void internalFrameOpened(InternalFrameEvent e) {
97 SwingUtilities.getWindowAncestor(canvasFrame).validate();
98 }
99
100 public void internalFrameClosing(InternalFrameEvent e) {
101 SwingUtilities.getWindowAncestor(canvasFrame).validate();
102 }
103
104 public void internalFrameClosed(InternalFrameEvent e) {
105 SwingUtilities.getWindowAncestor(canvasFrame).validate();
106 }
107
108 public void internalFrameIconified(InternalFrameEvent e) {
109 SwingUtilities.getWindowAncestor(canvasFrame).validate();
110 }
111
112 public void internalFrameDeiconified(InternalFrameEvent e) {
113 SwingUtilities.getWindowAncestor(canvasFrame).validate();
114 }
115
116 public void internalFrameActivated(InternalFrameEvent e) {
117 SwingUtilities.getWindowAncestor(canvasFrame).validate();
118 }
119
120 public void internalFrameDeactivated(InternalFrameEvent e) {
121 SwingUtilities.getWindowAncestor(canvasFrame).validate();
122 }
123 });
124 canvasFrame.addComponentListener(new ComponentAdapter() {
125 public void componentResized(ComponentEvent e) {
126 SwingUtilities.getWindowAncestor(canvasFrame).validate();
127 }
128
129 public void componentMoved(ComponentEvent e) {
130 SwingUtilities.getWindowAncestor(canvasFrame).validate();
131
132 }
133 });
134
135 Thread thread = new Thread() {
136 @Override
137 public void run() {
138 while ( true ) {
139 while ( !Mouse.isCreated() ) {
140 try {
141 Thread.sleep(10);
142 } catch (InterruptedException e) {
143 e.printStackTrace();
144 }
145 }
146
147 while ( Mouse.next() ) {
148 int wheelD = Mouse.getDWheel();
149 if ( wheelD != 0 ) {
150 System.out.println("" + wheelD);
151 }
152 }
153 }
154 }
155 };
156 thread.start();
157
158 return canvasFrame;
159 }
160
161 protected void gameLoop() {
162 glClearColor(1f, 0f, 1f, 0f);
163
164 Boolean active = null;
165 while ( running ) {
166 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
167
168 Display.update();
169 Display.sync(60);
170
171 boolean a = Display.isActive();
172 if ( active == null || active != a ) {
173 System.out.println("Diplay.isActive() = " + a + " - " +canvas.isFocusOwner());
174 active = a;
175 }
176 }
177
178 Display.destroy();
179 }
180
181 public void init() {
182
183 }
184
185 protected void initGL() {
186 }
187
188 private void loadSwing() {
189
190 switchSubstance();
191
192 menuBar = new JMenuBar();
193 JMenu file = new JMenu("File");
194 file.add(new JMenuItem("Item 1"));
195 file.add(new JMenuItem("Item 2"));
196 file.add(new JMenuItem("Item 3"));
197 menuBar.add(file);
198
199 setJMenuBar(menuBar);
200
201 JDesktopPane desktop = new JDesktopPane();
202 this.add(desktop);
203
204 JInternalFrame canvasFrame = createGameFrame();
205 desktop.add(canvasFrame);
206
207 JInternalFrame debugFrame = createDebugFrame();
208 desktop.add(debugFrame);
209
210 this.setSize(1024, 768);
211
212 setVisible(true);
213 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
214 }
215
216 public void start() {
217
218 EventQueue.invokeLater(new Runnable() {
219 public void run() {
220 loadSwing();
221 }
222 });
223
224 }
225
226 public void startLWJGL() {
227 gameThread = new Thread() {
228
229 @Override
230 public void run() {
231 running = true;
232 try {
233 Display.setParent(canvas);
234 Display.create();
235 initGL();
236 } catch (LWJGLException e) {
237 e.printStackTrace();
238 return;
239 }
240 gameLoop();
241 }
242 };
243 gameThread.start();
244 }
245
246 private void stopLWJGL() {
247 Display.destroy();
248 }
249
250 protected void switchMetal() {
251 try {
252 UIManager.setLookAndFeel(new MetalLookAndFeel());
253 UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());
254 SwingUtilities.updateComponentTreeUI(this);
255 } catch (UnsupportedLookAndFeelException e) {
256 e.printStackTrace();
257 }
258 }
259
260 protected void switchSubstance() {
261 UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());
262 SwingUtilities.updateComponentTreeUI(this);
263 }
264
265 public static void main(String[] args) {
266 new CanvasFocusTest().start();
267 }
268
269 }
0 package org.lwjgl.test.opengl;
1
2 import org.lwjgl.input.Keyboard;
3 import org.lwjgl.input.Mouse;
4 import org.lwjgl.opengl.*;
5
6 import java.lang.reflect.Field;
7 import java.nio.ByteBuffer;
8 import java.nio.ByteOrder;
9 import java.nio.IntBuffer;
10
11 import static org.lwjgl.opengl.GL11.*;
12 import static org.lwjgl.opengl.GL15.*;
13
14 /**
15 *
16 */
17 public class CrashTest {
18
19 /**
20 * The main method.
21 *
22 * @param args command-line arguments (ignored)
23 */
24 public static void main(String[] args) {
25 try {
26
27 // native library loading
28 /*System.setProperty("java.library.path", "lib/native/macosx");
29 Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
30 fieldSysPath.setAccessible(true);
31 fieldSysPath.set(null, null);*/
32
33 // initialize LWJGL
34 Display.setDisplayMode(new DisplayMode(640, 480));
35 Display.create(new PixelFormat(), new ContextAttribs(4, 2).withProfileCompatibility(true).withDebug(true));
36 Mouse.create();
37 Mouse.setGrabbed(true);
38 Mouse.poll();
39 Keyboard.create();
40
41 AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
42
43 // initialize OpenGL
44 glMatrixMode(GL_PROJECTION);
45 glLoadIdentity();
46 glMatrixMode(GL_MODELVIEW);
47 glLoadIdentity();
48
49 // clear screen
50 glDepthMask(true);
51 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
52 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
53
54 // prepare data (24 quads, 4 vertices each, 2 floats each, 4 bytes each)
55 IntBuffer buffer = ByteBuffer.allocateDirect(24 * 4 * 2 * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
56 for ( int i = 0; i < 6; i++ ) {
57 for ( int j = 0; j < 4; j++ ) {
58 buffer.put(2 * i);
59 buffer.put(2 * j);
60 buffer.put(2 * i + 1);
61 buffer.put(2 * j);
62 buffer.put(2 * i + 1);
63 buffer.put(2 * j + 1);
64 buffer.put(2 * i);
65 buffer.put(2 * j + 1);
66 }
67 }
68
69 // prepare OpenGL buffer
70 int arrayBufferName = glGenBuffers();
71 glBindBuffer(GL_ARRAY_BUFFER, arrayBufferName);
72 //buffer.rewind(); // <-- forget this and it crashes!
73 glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
74
75 // set up OpenGL state
76 glScalef(0.25f, 1.0f / 3.0f, 1.0f);
77 glVertexPointer(2, GL_INT, 0, 0);
78 glEnableClientState(GL_VERTEX_ARRAY);
79
80 // draw the frame
81 glDrawArrays(GL_TRIANGLES, 0, 24 * 4);
82 glFlush();
83 Display.swapBuffers();
84
85 // wait for keypress
86 while ( !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) ) {
87 Keyboard.poll();
88 }
89
90 // clean up
91 Keyboard.destroy();
92 Mouse.destroy();
93 Display.destroy();
94
95 } catch (Throwable e) {
96 System.err.println("got an exception");
97 throw new RuntimeException(e);
98 }
99 }
100
101 }
4545 * Tests switching between windowed and fullscreen
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 3418 $
49 * $Id: FullScreenWindowedTest.java 3418 2010-09-28 21:11:35Z spasi $
48 * @version $Revision$
49 * $Id$
5050 */
5151 public class FullScreenWindowedTest {
5252 /** Intended deiplay mode */
5252 * This is the OpenGL "standard" Gears demo, originally by Brian Paul
5353 * </p>
5454 * @author Brian Matzon <brian@matzon.dk>
55 * @version $Revision: 3418 $
56 * $Id: Gears.java 3418 2010-09-28 21:11:35Z spasi $
55 * @version $Revision$
56 * $Id$
5757 */
5858 public class Gears {
5959
0 package org.lwjgl.test.opengl;
1
2 import org.lwjgl.BufferUtils;
3 import org.lwjgl.LWJGLException;
4 import org.lwjgl.opengl.Display;
5
6 import java.nio.IntBuffer;
7
8 import static org.lwjgl.opengl.GL11.*;
9
10 public class JNIPerfTestLWJGL {
11
12 private JNIPerfTestLWJGL() {
13 }
14
15 public static void main(String[] args) {
16 try {
17 Display.setFullscreen(false);
18 Display.create();
19 } catch (LWJGLException e) {
20 e.printStackTrace();
21 }
22
23 int DURATION = 1024 * 1024;
24 int WARMUP = 5 * DURATION;
25 int BENCH = 10 * DURATION;
26
27 benchmark(WARMUP, BENCH);
28
29 //BufferUtils.noop4(0.0f, 0.0f, 0.0f, 0.0f);
30 }
31
32 private static void benchmark(int WARMUP, int BENCH) {
33 IntBuffer buffer = BufferUtils.createIntBuffer(16);
34
35 int sum = 0;
36 sum += benchLoop(buffer, WARMUP);
37
38 System.out.println("WARMUP DONE");
39
40 long time = System.nanoTime();
41 sum += benchLoop(buffer, BENCH);
42 time = (System.nanoTime() - time) / BENCH;
43
44 System.out.println(time);
45 if ( sum == Integer.MIN_VALUE )
46 throw new RuntimeException();
47 }
48
49 private static int benchLoop(IntBuffer buffer, int duration) {
50 int sum = 0;
51 for ( int i = 0; i < duration; i++ ) {
52 //glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS, buffer); // 18
53 //sum += buffer.get(0);
54 //glDepthMask(true); // 12
55 //glColor4f(1.0f, 1.0f, 1.0f, 0.0f); // 13
56
57 //glColor3f(1.0f, 1.0f, 1.0f); // 16
58 //BufferUtils.noop0(); // 7
59 //BufferUtils.noop0f(0L); // 8
60 //BufferUtils.noop3(1, 2, 3); // 8
61 //BufferUtils.noop4f(1.0f, 1.0f, 1.0f, 0.0f, 0L); // 8
62 }
63 return sum;
64 }
65
66 }
5050 * Tests Pbuffers
5151 *
5252 * @author elias_naur <elias_naur@users.sourceforge.net>
53 * @version $Revision: 3418 $
54 * $Id: PbufferTest.java 3418 2010-09-28 21:11:35Z spasi $
53 * @version $Revision$
54 * $Id$
5555 */
5656 public class PbufferTest {
5757
0 package org.lwjgl.test.opengl;
1
2 import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
3 import static org.lwjgl.opengl.GL11.glClear;
4 import static org.lwjgl.opengl.GL11.glClearColor;
5
6 import java.awt.*;
7 import java.awt.event.WindowAdapter;
8 import java.awt.event.WindowEvent;
9
10 import javax.swing.*;
11
12 import org.lwjgl.LWJGLException;
13 import org.lwjgl.input.Keyboard;
14 import org.lwjgl.opengl.Display;
15
16 /**
17 * <p>
18 * </p>
19 *
20 * @author Brian Matzon <brian@matzon.dk>
21 */
22 public class SwingFocusTest {
23
24 private JFrame frame;
25 private final JPanel panel1 = new JPanel();
26 private final JPanel panel2 = new JPanel();
27 private final JTextPane textPane = new JTextPane();
28
29 /** The Canvas where the LWJGL Display is added */
30 Canvas display_parent;
31
32 /** Thread which runs the main game loop */
33 Thread gameThread;
34
35 /** is the game loop running */
36 boolean running;
37
38 public SwingFocusTest() {
39 }
40
41 /**
42 * Once the Canvas is created its add notify method will call this method to
43 * start the LWJGL Display and game loop in another thread.
44 */
45 public void startLWJGL() {
46 gameThread = new Thread() {
47 public void run() {
48 running = true;
49 try {
50 Display.setParent(display_parent);
51 Display.setVSyncEnabled(true);
52 Display.create();
53 initGL();
54 } catch (LWJGLException e) {
55 e.printStackTrace();
56 }
57 gameLoop();
58 }
59 };
60 gameThread.start();
61 }
62
63 protected void gameLoop() {
64 while ( running ) {
65 //System.out.println("--GAMELOOP--");
66
67 Display.processMessages();
68
69 if ( Display.isDirty() ) {
70 if ( Keyboard.isKeyDown(Keyboard.KEY_SPACE) ) {
71 glClearColor(1f, 0, 0, 0);
72 System.out.println("Pigs in space!");
73 } else {
74 glClearColor(0f, 0f, 1f, 0f);
75 }
76 glClear(GL_COLOR_BUFFER_BIT);
77
78 Display.update(false);
79 }
80 }
81 Display.destroy();
82 }
83
84 protected void initGL() {
85 }
86
87 /**
88 * Tell game loop to stop running, after which the LWJGL Display will be destoryed.
89 * The main thread will wait for the Display.destroy() to complete
90 */
91 private void stopLWJGL() {
92 running = false;
93 try {
94 gameThread.join();
95 } catch (InterruptedException e) {
96 e.printStackTrace();
97 }
98 }
99
100 private void execute() {
101 frame.setVisible(true);
102
103 try {
104 Display.setParent(display_parent);
105 Display.setVSyncEnabled(true);
106 Display.create();
107 } catch (LWJGLException e) {
108 e.printStackTrace();
109 }
110 initGL();
111
112 running = true;
113
114 while ( running ) {
115 //System.out.println("--GAMELOOP--");
116
117 Display.processMessages();
118
119 if ( true ) {
120 if ( Keyboard.isKeyDown(Keyboard.KEY_SPACE) ) {
121 glClearColor(1f, 0, 0, 0);
122 System.out.println("Pigs in space!");
123 } else {
124 glClearColor(0f, 0f, 1f, 0f);
125 }
126 glClear(GL_COLOR_BUFFER_BIT);
127
128 Display.update(false);
129 }
130 }
131 Display.destroy();
132 }
133
134 private void initialize() {
135 frame = new JFrame();
136 frame.addWindowListener(new WindowAdapter() {
137 public void windowClosing(WindowEvent e) {
138 frame.remove(display_parent);
139 frame.dispose();
140 }
141 });
142 frame.setBounds(100, 100, 450, 300);
143 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
144
145 JMenuBar menuBar = new JMenuBar();
146
147 for ( int i = 0; i < 10; i++ ) {
148 JMenu menu = new JMenu("Menu " + i);
149 for ( int j = 0; j < 10; j++ ) {
150 menu.add(new JMenuItem("Item " + j));
151 }
152 menuBar.add(menu);
153 }
154 frame.setJMenuBar(menuBar);
155
156 frame.getContentPane().setLayout(new GridLayout(0, 2, 0, 0));
157 frame.getContentPane().add(panel1);
158 panel1.setLayout(null);
159 textPane.setBounds(10, 5, 124, 20);
160
161 JPopupMenu contextMenu = new JPopupMenu("Edit");
162 contextMenu.add(new JMenuItem("Save"));
163 contextMenu.add(new JMenuItem("Save As"));
164 contextMenu.add(new JMenuItem("Close"));
165
166 textPane.setComponentPopupMenu(contextMenu);
167
168 panel1.add(textPane);
169 frame.getContentPane().add(panel2);
170 panel2.setLayout(new BorderLayout(0, 0));
171
172 display_parent = new Canvas() {
173 /*public void addNotify() {
174 super.addNotify();
175 startLWJGL();
176 }
177
178 public void removeNotify() {
179 stopLWJGL();
180 super.removeNotify();
181 }*/
182 };
183 display_parent.setFocusable(true);
184 display_parent.requestFocus();
185 display_parent.setIgnoreRepaint(true);
186 panel2.add(display_parent);
187 }
188
189 public static void main(String[] args) {
190 SwingFocusTest sit = new SwingFocusTest();
191 sit.initialize();
192 sit.execute();
193 }
194 }
129129 System.out.println("Unexpected wait status: 0x" + Integer.toHexString(status));
130130 }
131131
132 System.out.println("Sync Status: " + (glGetSync(sync, GL_SYNC_STATUS) == GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
132 System.out.println("Sync Status: " + (glGetSynci(sync, GL_SYNC_STATUS) == GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
133133
134134 glDeleteSync(sync);
135135
3030 */
3131
3232 /**
33 * $Id: VBOIndexTest.java 3418 2010-09-28 21:11:35Z spasi $
33 * $Id$
3434 *
3535 * Simple java test program.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3418 $
38 * @version $Revision$
3939 */
4040
4141 package org.lwjgl.test.opengl;
3030 */
3131
3232 /**
33 * $Id: VBOTest.java 3418 2010-09-28 21:11:35Z spasi $
33 * $Id$
3434 *
3535 * Simple java test program.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3418 $
38 * @version $Revision$
3939 */
4040
4141 package org.lwjgl.test.opengl;
7373
7474 if ( 2 < args.length ) {
7575 for ( int i = 2; i < args.length; i++ ) {
76 if ( Pattern.matches("[0-9]+", args[i]) )
77 ca = ca.withLayer(Integer.parseInt(args[i]));
78 else if ( "debug".equalsIgnoreCase(args[i]) )
79 ca = ca.withDebug(true);
80 else if ( "fc".equalsIgnoreCase(args[i]) )
81 ca = ca.withForwardCompatible(true);
82 else if ( "core".equalsIgnoreCase(args[i]) )
76 if ( "core".equalsIgnoreCase(args[i]) )
8377 ca = ca.withProfileCore(true);
8478 else if ( "compatibility".equalsIgnoreCase(args[i]) )
8579 ca = ca.withProfileCompatibility(true);
8680 else if ( "es".equalsIgnoreCase(args[i]) )
8781 ca = ca.withProfileES(true);
82 else if ( "debug".equalsIgnoreCase(args[i]) )
83 ca = ca.withDebug(true);
84 else if ( "fc".equalsIgnoreCase(args[i]) )
85 ca = ca.withForwardCompatible(true);
86 else if ( "robust".equalsIgnoreCase(args[i]) )
87 ca = ca.withRobustAccess(true);
88 else if ( "reset_isolation".equalsIgnoreCase(args[i]) )
89 ca = ca.withContextResetIsolation(true);
90 else if ( "reset_lose".equalsIgnoreCase(args[i]) )
91 ca = ca.withResetNotificationStrategy(ContextAttribs.LOSE_CONTEXT_ON_RESET_ARB);
92 else if ( "release_none".equalsIgnoreCase(args[i]) )
93 ca = ca.withContextReleaseBehavior(ContextAttribs.CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
94 else if ( Pattern.matches("[0-9]+", args[i]) )
95 ca = ca.withLayer(Integer.parseInt(args[i]));
8896 else
8997 argsError("Unknown argument: \'" + args[i] + "\'");
9098 }
119127 boolean deprecated = false;
120128 try {
121129 glVertex3f(0.0f, 0.0f, 0.0f);
130 Util.checkGLError();
122131 deprecated = true;
123132 } catch (Throwable t) {}
124133
234243
235244 private static void argsError(final String msg) {
236245 System.out.println("\nInvalid arguments error: " + msg);
237 System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {'core'|'compatibility', <layer>, 'debug', 'fc'}:\n");
238 System.out.println("majorVersion\t- Major OpenGL version.");
239 System.out.println("majorVersion\t- Minor OpenGL version.");
246 System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {'core'|'compatibility'|'es', 'debug', 'fc', 'robust', 'reset_isolation', 'reset_lose', 'release_none', <layer>}:\n");
247 System.out.println("<majorVersion>\t- Major OpenGL version.");
248 System.out.println("<majorVersion>\t- Minor OpenGL version.");
240249 System.out.println("core\t- Sets the Core Profile bit (optional, requires 3.2+).");
241250 System.out.println("compatibility\t- Sets the Compatibility Profile bit (optional, requires 3.2+).");
242 System.out.println("ws\t- Sets the OpenGL ES Profile bit (optional, requires 2.0).");
243 System.out.println("layer\t- Layer plane (optional).");
251 System.out.println("es\t- Sets the OpenGL ES Profile bit (optional, requires 2.0).");
244252 System.out.println("debug\t- Enables debug mode (optional).");
245253 System.out.println("fc\t- Enables forward compatibility mode (optional, requires 3.0+).");
254 System.out.println("robust\t- Enables robust access (optional).");
255 System.out.println("reset_isolation\t- Enables reset isolation (optional).");
256 System.out.println("reset_lose\t- Enables lose context on reset (optional).");
257 System.out.println("release_none\t- Enables release behavior = none (optional).");
258 System.out.println("<layer>\t- Layer plane (optional).");
246259
247260 cleanup();
248261 System.exit(-1);
0 package org.lwjgl.test.opengl;
1
2 import org.lwjgl.opengl.*;
3
4 public class WindowLocationTest {
5 public static void main(String[] args) {
6 try {
7 Display.setDisplayMode(new DisplayMode(640, 480));
8 Display.setLocation(0, 0);
9 Display.create();
10 Display.setLocation(0, 0);
11
12 for ( int i = 0; i < 5; i++ ) {
13 int x = Display.getX();
14 int y = Display.getY();
15
16 System.out.println("x=" + x + ", y=" + y);
17
18 Display.setLocation(x, y);
19 }
20
21 try {
22 Thread.sleep(2000);
23 } catch (InterruptedException e) {
24 e.printStackTrace();
25 }
26
27 Display.destroy();
28 } catch (Exception ex) {
29 ex.printStackTrace();
30 }
31 }
32 }
3434 import java.awt.Color;
3535 import java.awt.event.WindowAdapter;
3636 import java.awt.event.WindowEvent;
37 import java.nio.FloatBuffer;
3837
39 import org.lwjgl.BufferUtils;
4038 import org.lwjgl.LWJGLException;
41 import org.lwjgl.LWJGLUtil;
42 import org.lwjgl.Sys;
43 import org.lwjgl.opengl.AWTGLCanvas;
44 import org.lwjgl.opengl.GLContext;
45
46 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
47 import static org.lwjgl.opengl.GL11.*;
4839
4940 /**
5041 * <p>
5546 * $Id$
5647 */
5748 public class AWTGears extends Frame {
58
59 /** AWT GL canvas */
60 private AWTGLCanvas canvas0;
61
62 private float view_rotx = 20.0f;
63
64 private float view_roty = 30.0f;
65
66 private float view_rotz;
67
68 private int gear1;
69
70 private int gear2;
71
72 private int gear3;
73
74 private float angle;
7549
7650 /**
7751 * C'tor
9367 setVisible(true);
9468 }
9569
96 private void setup() {
97 // setup ogl
98 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
99 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
100 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
101 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
102 pos.flip();
103 red.flip();
104 green.flip();
105 blue.flip();
106
107 glLight(GL_LIGHT0, GL_POSITION, pos);
108 glEnable(GL_CULL_FACE);
109 glEnable(GL_LIGHTING);
110 glEnable(GL_LIGHT0);
111 glEnable(GL_DEPTH_TEST);
112
113 /* make the gears */
114 gear1 = glGenLists(1);
115 glNewList(gear1, GL_COMPILE);
116 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
117 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
118 glEndList();
119
120 gear2 = glGenLists(1);
121 glNewList(gear2, GL_COMPILE);
122 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
123 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
124 glEndList();
125
126 gear3 = glGenLists(1);
127 glNewList(gear3, GL_COMPILE);
128 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
129 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
130 glEndList();
131
132 glEnable(GL_NORMALIZE);
133
134 glMatrixMode(GL_PROJECTION);
135
136 System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName());
137 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
138 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
139 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
140 System.err.println();
141 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
142 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
143 // --- not using extensions
144 glLoadIdentity();
145 } else {
146 // --- using extensions
147 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
148 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
149 0, 0, 1, 0, 0, 0, 0, 1});
150 identityTranspose.flip();
151 glLoadTransposeMatrixARB(identityTranspose);
152 }
153
154 float h = (float) 300 / (float) 300;
155 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
156 glMatrixMode(GL_MODELVIEW);
157 glLoadIdentity();
158 glTranslatef(0.0f, 0.0f, -40.0f);
159 }
160
161 /**
162 * Draw a gear wheel. You'll probably want to call this function when
163 * building a display list since we do a lot of trig here.
164 *
165 * @param inner_radius radius of hole at center
166 * @param outer_radius radius at center of teeth
167 * @param width width of gear
168 * @param teeth number of teeth
169 * @param tooth_depth depth of tooth
170 */
171 private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
172 int i;
173 float r0, r1, r2;
174 float angle, da;
175 float u, v, len;
176
177 r0 = inner_radius;
178 r1 = outer_radius - tooth_depth / 2.0f;
179 r2 = outer_radius + tooth_depth / 2.0f;
180
181 da = 2.0f * (float) Math.PI / teeth / 4.0f;
182
183 glShadeModel(GL_FLAT);
184
185 glNormal3f(0.0f, 0.0f, 1.0f);
186
187 /* draw front face */
188 glBegin(GL_QUAD_STRIP);
189 for (i = 0; i <= teeth; i++) {
190 angle = i * 2.0f * (float) Math.PI / teeth;
191 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
192 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
193 if (i < teeth) {
194 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
195 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
196 width * 0.5f);
197 }
198 }
199 glEnd();
200
201 /* draw front sides of teeth */
202 glBegin(GL_QUADS);
203 for (i = 0; i < teeth; i++) {
204 angle = i * 2.0f * (float) Math.PI / teeth;
205 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
206 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
207 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
208 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
209 }
210 glEnd();
211
212 /* draw back face */
213 glBegin(GL_QUAD_STRIP);
214 for (i = 0; i <= teeth; i++) {
215 angle = i * 2.0f * (float) Math.PI / teeth;
216 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
217 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
218 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
219 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
220 }
221 glEnd();
222
223 /* draw back sides of teeth */
224 glBegin(GL_QUADS);
225 for (i = 0; i < teeth; i++) {
226 angle = i * 2.0f * (float) Math.PI / teeth;
227 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
228 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
229 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
230 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
231 }
232 glEnd();
233
234 /* draw outward faces of teeth */
235 glBegin(GL_QUAD_STRIP);
236 for (i = 0; i < teeth; i++) {
237 angle = i * 2.0f * (float) Math.PI / teeth;
238 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
239 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
240 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
241 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
242 len = (float) Math.sqrt(u * u + v * v);
243 u /= len;
244 v /= len;
245 glNormal3f(v, -u, 0.0f);
246 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
247 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
248 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
249 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
250 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
251 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
252 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
253 glNormal3f(v, -u, 0.0f);
254 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
255 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
256 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
257 }
258 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
259 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
260 glEnd();
261
262 glShadeModel(GL_SMOOTH);
263
264 /* draw inside radius cylinder */
265 glBegin(GL_QUAD_STRIP);
266 for (i = 0; i <= teeth; i++) {
267 angle = i * 2.0f * (float) Math.PI / teeth;
268 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
269 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
270 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
271 }
272 glEnd();
273 }
274
27570 public static void main(String[] args) throws LWJGLException {
27671 new AWTGears();
27772 }
4545 * <p>
4646 * Tests AWTGLCanvas functionality
4747 * <p>
48 * @version $Revision: 3418 $
49 * @author $Author: spasi $
50 * $Id: AWTTest.java 3418 2010-09-28 21:11:35Z spasi $
48 * @version $Revision$
49 * @author $Author$
50 * $Id$
5151 */
5252 public class AWTTest extends Frame {
5353
4848 * <p>
4949 * Tests Display.setParent()
5050 * <p>
51 * @version $Revision: 3418 $
52 * @author $Author: spasi $
53 * $Id: DisplayParentTest.java 3418 2010-09-28 21:11:35Z spasi $
51 * @version $Revision$
52 * @author $Author$
53 * $Id$
5454 */
5555 public class DisplayParentTest extends Frame {
5656 boolean killswitch;
3939 import org.lwjgl.BufferUtils;
4040 import org.lwjgl.LWJGLException;
4141 import org.lwjgl.opengl.Drawable;
42 import org.lwjgl.opengl.GLContext;
43 import org.lwjgl.opengl.GLSync;
4244 import org.lwjgl.util.Color;
4345 import org.lwjgl.util.ReadableColor;
4446
4547 import java.nio.ByteBuffer;
48 import java.util.concurrent.locks.ReentrantLock;
4649
4750 import static org.lwjgl.opengl.GL11.*;
51 import static org.lwjgl.opengl.GL32.*;
4852
4953 abstract class BackgroundLoader {
5054
51 private static final int WIDTH = 32;
55 private static final int WIDTH = 32;
5256 private static final int HEIGHT = 32;
5357
54 private static final Object lock = new Object();
58 // CPU synchronization
59 private final ReentrantLock lock = new ReentrantLock();
60 // GPU synchronization
61 private GLSync fence;
5562
5663 private Drawable drawable;
5764
5865 private boolean running;
5966
6067 private ByteBuffer texture;
61 private int texID;
68 private int texID;
6269
6370 protected BackgroundLoader() {
6471 running = true;
7279 }
7380
7481 void start() throws LWJGLException {
82 // The shared context must be created on the main thread.
83 drawable = getDrawable();
84
7585 new Thread(new Runnable() {
7686 public void run() {
7787 System.out.println("-- Background Thread started --");
8595 }
8696
8797 try {
88 drawable = getDrawable();
98 // Make the shared context current in the worker thread
8999 drawable.makeCurrent();
90100 } catch (LWJGLException e) {
91101 throw new RuntimeException(e);
93103
94104 System.out.println("** Drawable created **");
95105
96 synchronized ( lock ) {
97 // Create a "dummy" texture while we wait for texture IO
98 createCheckerTexture(Color.RED, Color.WHITE, 2);
99
100 texID = glGenTextures();
101 glBindTexture(GL_TEXTURE_2D, texID);
102 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
103
104 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
105 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
106
107 glBindTexture(GL_TEXTURE_2D, 0);
108 }
106 // Create a "dummy" texture while we wait for texture IO
107 createCheckerTexture(Color.RED, Color.WHITE, 2);
108
109 lock.lock();
110
111 texID = glGenTextures();
112 glBindTexture(GL_TEXTURE_2D, texID);
113 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
114
115 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
116 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
117
118 glBindTexture(GL_TEXTURE_2D, 0);
119
120 // OpenGL commands from different contexts may be executed in any order. So we need a way to synchronize
121 final boolean useFences = GLContext.getCapabilities().OpenGL32;
122
123 if ( useFences )
124 fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
125 else
126 glFlush(); // Best we can do without fences. This will force rendering on the main thread to happen after we upload the texture.
127
128 lock.unlock();
109129
110130 System.out.println("** Dummy texture created **");
111131
128148 else
129149 createGradientTexture(Color.GREEN, Color.YELLOW);
130150
151 lock.lock();
152
131153 glBindTexture(GL_TEXTURE_2D, texID);
132154 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
133155
134 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
135 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
156 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
157 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
136158
137159 glBindTexture(GL_TEXTURE_2D, 0);
160
161 if ( useFences )
162 fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
163 else
164 glFlush();
165
166 lock.unlock();
138167
139168 System.out.println("** Created new gradient texture **");
140169
150179 }
151180
152181 int getTexID() {
153 synchronized ( lock ) {
182 lock.lock();
183 try {
184 if ( fence != null ) {
185 glWaitSync(fence, 0, GL_TIMEOUT_IGNORED);
186 fence = null;
187 }
154188 return texID;
189 } finally {
190 lock.unlock();
155191 }
156192 }
157193
0 package org.lwjgl.test.opengl.pbuffers;
1
2 import org.lwjgl.LWJGLException;
3 import org.lwjgl.opengl.Pbuffer;
4 import org.lwjgl.opengl.PixelFormat;
5
6 public class MSAATest {
7
8 public MSAATest() {
9
10 }
11
12 public static void main(String[] args) {
13 try {
14 new Pbuffer(64, 64, new PixelFormat(32, 8, 24, 8, 4), null);
15 } catch (LWJGLException e) {
16 throw new RuntimeException(e);
17 }
18 System.out.println("done");
19 }
20
21 }
4949 * Tests Pbuffers
5050 *
5151 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 3418 $
53 * $Id: PbufferTest.java 3418 2010-09-28 21:11:35Z spasi $
52 * @version $Revision$
53 * $Id$
5454 */
5555 public final class PbufferTest {
5656
7474
7575 printShaderObjectInfoLog(file, shaderID);
7676
77 if ( glGetShader(shaderID, GL_COMPILE_STATUS) == GL_FALSE )
77 if ( glGetShaderi(shaderID, GL_COMPILE_STATUS) == GL_FALSE )
7878 ShadersTest.kill("A compilation error occured in a vertex shader.");
7979
8080 programID = glCreateProgram();
8484
8585 printShaderProgramInfoLog(programID);
8686
87 if ( glGetProgram(programID, GL_LINK_STATUS) == GL_FALSE )
87 if ( glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE )
8888 ShadersTest.kill("A linking error occured in a shader program.");
8989
9090 final String[] uniformNames = { "uniformA", "uniformB" };
9191
9292 // Get uniform block index and data size
9393 final int blockIndex = glGetUniformBlockIndex(programID, "test");
94 final int blockSize = glGetActiveUniformBlock(programID, blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE);
94 final int blockSize = glGetActiveUniformBlocki(programID, blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE);
9595
9696 System.out.println("blockSize = " + blockSize);
9797
136136
137137 System.out.println("Setting display mode to: " + displayMode);
138138 Display.setDisplayMode(displayMode);
139 Display.create(new PixelFormat(8, 24, 0), "UNI".equalsIgnoreCase(args[0]) ? new ContextAttribs(3, 1) : null);
139 Display.create(new PixelFormat(8, 24, 0));
140140 ShadersTest.displayMode = displayMode;
141141 } catch (LWJGLException e) {
142142 kill(e.getMessage());
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.sprites;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.Sys;
36 import org.lwjgl.input.Keyboard;
37 import org.lwjgl.input.Mouse;
38 import org.lwjgl.opengl.*;
39
40 import java.awt.image.BufferedImage;
41 import java.awt.image.Raster;
42 import java.io.IOException;
43 import java.nio.ByteBuffer;
44 import java.nio.FloatBuffer;
45 import java.util.Random;
46 import javax.imageio.ImageIO;
47
48 import static org.lwjgl.opengl.EXTTransformFeedback.*;
49 import static org.lwjgl.opengl.GL11.*;
50 import static org.lwjgl.opengl.GL12.*;
51 import static org.lwjgl.opengl.GL15.*;
52 import static org.lwjgl.opengl.GL20.*;
53 import static org.lwjgl.opengl.GL30.*;
54
55 /**
56 * Sprite rendering demo. Three implementations are supported:
57 * a) CPU animation + BufferData VBO update.
58 * b) CPU animation + MapBufferRange VBO update.
59 * c) GPU animation using transform feedback with a vertex shader.
60 *
61 * @author Spasi
62 * @since 18/3/2011
63 */
64 public final class SpriteShootout {
65
66 static final int SCREEN_WIDTH = 800;
67 static final int SCREEN_HEIGHT = 600;
68
69 private static final int ANIMATION_TICKS = 60;
70
71 private boolean run = true;
72 private boolean render = true;
73 private boolean colorMask = true;
74 private boolean animate = true;
75 private boolean smooth;
76 private boolean vsync;
77
78 int ballSize = 42;
79 int ballCount = 100 * 1000;
80
81 private SpriteRenderer renderer;
82
83 // OpenGL stuff
84 private int texID;
85 private int texBigID;
86 private int texSmallID;
87
88 long animateTime;
89
90 private SpriteShootout() {
91 }
92
93 public static void main(String[] args) {
94 try {
95 new SpriteShootout().start();
96 } catch (LWJGLException e) {
97 e.printStackTrace();
98 }
99 }
100
101 private void start() throws LWJGLException {
102 try {
103 initGL();
104
105 final ContextCapabilities caps = GLContext.getCapabilities();
106 if ( caps.OpenGL30 || caps.GL_EXT_transform_feedback )
107 renderer = new SpriteRendererTF();
108 else if ( caps.GL_ARB_map_buffer_range )
109 renderer = new SpriteRendererMapped();
110 else
111 renderer = new SpriteRendererPlain();
112
113 updateBalls(ballCount);
114 run();
115 } catch (Throwable t) {
116 t.printStackTrace();
117 } finally {
118 destroy();
119 }
120 }
121
122 private void initGL() throws LWJGLException {
123 Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2,
124 (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2);
125 Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
126 Display.setTitle("Sprite Shootout");
127 Display.create();
128 //Display.create(new PixelFormat(), new ContextAttribs(4, 1).withProfileCompatibility(true).withDebug(true));
129 //AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
130
131 final ContextCapabilities caps = GLContext.getCapabilities();
132 if ( !GLContext.getCapabilities().OpenGL20 )
133 throw new RuntimeException("OpenGL 2.0 is required for this demo.");
134
135 // Setup viewport
136
137 glMatrixMode(GL_PROJECTION);
138 glLoadIdentity();
139 glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);
140
141 glMatrixMode(GL_MODELVIEW);
142 glLoadIdentity();
143 glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
144
145 glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
146
147 // Create textures
148
149 try {
150 texSmallID = createTexture("res/ball_sm.png");
151 texBigID = createTexture("res/ball.png");
152 } catch (IOException e) {
153 e.printStackTrace();
154 System.exit(-1);
155 }
156 texID = texBigID;
157
158 // Setup rendering state
159
160 glEnable(GL_BLEND);
161 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
162
163 glEnable(GL_ALPHA_TEST);
164 glAlphaFunc(GL_GREATER, 0.0f);
165
166 glColorMask(colorMask, colorMask, colorMask, false);
167 glDepthMask(false);
168 glDisable(GL_DEPTH_TEST);
169
170 if ( caps.GL_ARB_compatibility || !caps.OpenGL31 )
171 glEnable(GL_POINT_SPRITE);
172
173 // Setup geometry
174
175 glEnableClientState(GL_VERTEX_ARRAY);
176
177 Util.checkGLError();
178 }
179
180 private static int createTexture(final String path) throws IOException {
181 final BufferedImage img = ImageIO.read(SpriteShootout.class.getClassLoader().getResource(path));
182
183 final int w = img.getWidth();
184 final int h = img.getHeight();
185
186 final ByteBuffer buffer = readImage(img);
187
188 final int texID = glGenTextures();
189
190 glBindTexture(GL_TEXTURE_2D, texID);
191 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
192 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
193 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
195 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
196
197 return texID;
198 }
199
200 private static ByteBuffer readImage(final BufferedImage img) throws IOException {
201 final Raster raster = img.getRaster();
202
203 final int bands = raster.getNumBands();
204
205 final int w = img.getWidth();
206 final int h = img.getHeight();
207
208 final int size = w * h * bands;
209
210 final byte[] pixels = new byte[size];
211 raster.getDataElements(0, 0, w, h, pixels);
212
213 final ByteBuffer pbuffer = BufferUtils.createByteBuffer(size);
214
215 if ( bands == 4 ) {
216 for ( int i = 0; i < (w * h * 4); i += 4 ) {
217 // Pre-multiply alpha
218 final float a = unpackUByte01(pixels[i + 3]);
219 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 2]) * a));
220 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 1]) * a));
221 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 0]) * a));
222 pbuffer.put(pixels[i + 3]);
223 }
224 } else if ( bands == 3 ) {
225 for ( int i = 0; i < (w * h * 3); i += 3 ) {
226 pbuffer.put(pixels[i + 2]);
227 pbuffer.put(pixels[i + 1]);
228 pbuffer.put(pixels[i + 0]);
229 }
230 } else
231 pbuffer.put(pixels, 0, size);
232
233 pbuffer.flip();
234
235 return pbuffer;
236 }
237
238 private static float unpackUByte01(final byte x) {
239 return (x & 0xFF) / 255.0f;
240 }
241
242 private static byte packUByte01(final float x) {
243 return (byte)(x * 255.0f);
244 }
245
246 private void updateBalls(final int count) {
247 System.out.println("NUMBER OF BALLS: " + count);
248 renderer.updateBalls(ballCount);
249 }
250
251 private void run() {
252 long startTime = System.currentTimeMillis() + 5000;
253 long fps = 0;
254
255 long time = Sys.getTime();
256 final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
257
258 renderer.render(false, true, 0);
259
260 while ( run ) {
261 Display.processMessages();
262 handleInput();
263
264 glClear(GL_COLOR_BUFFER_BIT);
265
266 final long currTime = Sys.getTime();
267 final int delta = (int)(currTime - time);
268 if ( smooth || delta >= ticksPerUpdate ) {
269 renderer.render(render, animate, delta);
270 time = currTime;
271 } else
272 renderer.render(render, false, 0);
273
274 Display.update(false);
275 //Display.sync(60);
276
277 if ( startTime > System.currentTimeMillis() ) {
278 fps++;
279 } else {
280 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
281 startTime = System.currentTimeMillis() + 5000;
282 System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
283 System.out.println("\tAnimation: " + (animateTime / fps / 1000) + "us");
284 animateTime = 0;
285 fps = 0;
286 }
287 }
288 }
289
290 private void handleInput() {
291 if ( Display.isCloseRequested() )
292 run = false;
293
294 while ( Keyboard.next() ) {
295 if ( Keyboard.getEventKeyState() )
296 continue;
297
298 switch ( Keyboard.getEventKey() ) {
299 case Keyboard.KEY_1:
300 case Keyboard.KEY_2:
301 case Keyboard.KEY_3:
302 case Keyboard.KEY_4:
303 case Keyboard.KEY_5:
304 case Keyboard.KEY_6:
305 case Keyboard.KEY_7:
306 case Keyboard.KEY_8:
307 case Keyboard.KEY_9:
308 case Keyboard.KEY_0:
309 ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1);
310 updateBalls(ballCount);
311 break;
312 case Keyboard.KEY_ADD:
313 case Keyboard.KEY_SUBTRACT:
314 int mult;
315 if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) )
316 mult = 1000;
317 else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) )
318 mult = 100;
319 else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
320 mult = 10;
321 else
322 mult = 1;
323 if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT )
324 mult = -mult;
325 ballCount += mult * 100;
326 if ( ballCount <= 0 )
327 ballCount = 1;
328 updateBalls(ballCount);
329 break;
330 case Keyboard.KEY_ESCAPE:
331 run = false;
332 break;
333 case Keyboard.KEY_A:
334 animate = !animate;
335 System.out.println("Animation is now " + (animate ? "on" : "off") + ".");
336 break;
337 case Keyboard.KEY_C:
338 colorMask = !colorMask;
339 glColorMask(colorMask, colorMask, colorMask, false);
340 System.out.println("Color mask is now " + (colorMask ? "on" : "off") + ".");
341 // Disable alpha test when color mask is off, else we get no benefit.
342 if ( colorMask ) {
343 glEnable(GL_BLEND);
344 glEnable(GL_ALPHA_TEST);
345 } else {
346 glDisable(GL_BLEND);
347 glDisable(GL_ALPHA_TEST);
348 }
349 break;
350 case Keyboard.KEY_R:
351 render = !render;
352 System.out.println("Rendering is now " + (render ? "on" : "off") + ".");
353 break;
354 case Keyboard.KEY_S:
355 smooth = !smooth;
356 System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + ".");
357 break;
358 case Keyboard.KEY_T:
359 if ( texID == texBigID ) {
360 texID = texSmallID;
361 ballSize = 16;
362 } else {
363 texID = texBigID;
364 ballSize = 42;
365 }
366 renderer.updateBallSize();
367 glBindTexture(GL_TEXTURE_2D, texID);
368 System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture.");
369 break;
370 case Keyboard.KEY_V:
371 vsync = !vsync;
372 Display.setVSyncEnabled(vsync);
373 System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + ".");
374 break;
375 }
376 }
377
378 while ( Mouse.next() ) ;
379 }
380
381 private void destroy() {
382 Display.destroy();
383 }
384
385 private abstract class SpriteRenderer {
386
387 protected float[] transform = { };
388
389 protected int vshID;
390 protected int progID;
391
392 protected void createProgram() {
393 final int fshID = glCreateShader(GL_FRAGMENT_SHADER);
394 glShaderSource(fshID, "uniform sampler2D COLOR_MAP;\n" +
395 "void main(void) {\n" +
396 " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" +
397 "}");
398 glCompileShader(fshID);
399 if ( glGetShaderi(fshID, GL_COMPILE_STATUS) == GL_FALSE ) {
400 System.out.println(glGetShaderInfoLog(fshID, glGetShaderi(fshID, GL_INFO_LOG_LENGTH)));
401 throw new RuntimeException("Failed to compile fragment shader.");
402 }
403
404 progID = glCreateProgram();
405 glAttachShader(progID, vshID);
406 glAttachShader(progID, fshID);
407 glLinkProgram(progID);
408 if ( glGetProgrami(progID, GL_LINK_STATUS) == GL_FALSE ) {
409 System.out.println(glGetProgramInfoLog(progID, glGetProgrami(progID, GL_INFO_LOG_LENGTH)));
410 throw new RuntimeException("Failed to link shader program.");
411 }
412
413 glUseProgram(progID);
414 glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0);
415
416 updateBallSize();
417 }
418
419 public void updateBallSize() {
420 glPointSize(ballSize);
421 }
422
423 public void updateBalls(final int count) {
424 final Random random = new Random();
425
426 final float[] newTransform = new float[count * 4];
427 System.arraycopy(transform, 0, newTransform, 0, Math.min(transform.length, newTransform.length));
428 if ( newTransform.length > transform.length ) {
429 for ( int i = transform.length; i < newTransform.length; ) {
430 newTransform[i++] = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f);
431 newTransform[i++] = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f);
432 newTransform[i++] = random.nextFloat() * 0.4f - 0.2f;
433 newTransform[i++] = random.nextFloat() * 0.4f - 0.2f;
434 }
435 }
436 transform = newTransform;
437 }
438
439 protected void animate(
440 final float[] sprites,
441 final FloatBuffer spritesRender,
442 final int ballSize, final int ballIndex, final int batchSize, final int delta
443 ) {
444 final float ballRadius = ballSize * 0.5f;
445 final float boundW = SCREEN_WIDTH - ballRadius;
446 final float boundH = SCREEN_HEIGHT - ballRadius;
447
448 for ( int b = ballIndex * 4, len = (ballIndex + batchSize) * 4; b < len; b += 4 ) {
449 float x = sprites[b + 0];
450 float dx = sprites[b + 2];
451
452 x += dx * delta;
453 if ( x < ballRadius ) {
454 x = ballRadius;
455 sprites[b + 2] = -dx;
456 } else if ( x > boundW ) {
457 x = boundW;
458 sprites[b + 2] = -dx;
459 }
460 sprites[b + 0] = x;
461
462 float y = sprites[b + 1];
463 float dy = sprites[b + 3];
464
465 y += dy * delta;
466 if ( y < ballRadius ) {
467 y = ballRadius;
468 sprites[b + 3] = -dy;
469 } else if ( y > boundH ) {
470 y = boundH;
471 sprites[b + 3] = -dy;
472 }
473 sprites[b + 1] = y;
474
475 spritesRender.put(x).put(y);
476 }
477 spritesRender.clear();
478 }
479
480 protected abstract void render(boolean render, boolean animate, int delta);
481
482 }
483
484 private abstract class SpriteRendererBatched extends SpriteRenderer {
485
486 protected static final int BALLS_PER_BATCH = 10 * 1000;
487
488 SpriteRendererBatched() {
489 vshID = glCreateShader(GL_VERTEX_SHADER);
490 glShaderSource(vshID, "void main(void) {\n" +
491 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
492 "}");
493 glCompileShader(vshID);
494 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
495 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
496 throw new RuntimeException("Failed to compile vertex shader.");
497 }
498
499 createProgram();
500 }
501
502 }
503
504 private class SpriteRendererPlain extends SpriteRendererBatched {
505
506 private final FloatBuffer geom;
507
508 protected int[] animVBO;
509
510 SpriteRendererPlain() {
511 System.out.println("Shootout Implementation: CPU animation & BufferData");
512 geom = BufferUtils.createFloatBuffer(BALLS_PER_BATCH * 4 * 2);
513 }
514
515 public void updateBalls(final int count) {
516 super.updateBalls(count);
517
518 final int batchCount = count / BALLS_PER_BATCH + (count % BALLS_PER_BATCH == 0 ? 0 : 1);
519 if ( animVBO != null && batchCount == animVBO.length )
520 return;
521
522 final int[] newAnimVBO = new int[batchCount];
523 if ( animVBO != null ) {
524 System.arraycopy(animVBO, 0, newAnimVBO, 0, Math.min(animVBO.length, newAnimVBO.length));
525 for ( int i = newAnimVBO.length; i < animVBO.length; i++ )
526 glDeleteBuffers(animVBO[i]);
527 }
528 for ( int i = animVBO == null ? 0 : animVBO.length; i < newAnimVBO.length; i++ ) {
529 newAnimVBO[i] = glGenBuffers();
530 glBindBuffer(GL_ARRAY_BUFFER, newAnimVBO[i]);
531 }
532
533 animVBO = newAnimVBO;
534 }
535
536 public void render(final boolean render, final boolean animate, final int delta) {
537 int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
538 int ballIndex = 0;
539 int vboIndex = 0;
540 while ( ballIndex < ballCount ) {
541 glBindBuffer(GL_ARRAY_BUFFER, animVBO[vboIndex++]);
542
543 if ( animate )
544 animate(ballIndex, batchSize, delta);
545
546 if ( render ) {
547 glVertexPointer(2, GL_FLOAT, 0, 0);
548 glDrawArrays(GL_POINTS, 0, batchSize);
549 }
550
551 ballIndex += batchSize;
552 batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
553 }
554 }
555
556 private void animate(final int ballIndex, final int batchSize, final int delta) {
557 animate(transform, geom, ballSize, ballIndex, batchSize, delta);
558
559 // Orphan current buffer and allocate a new one
560 glBufferData(GL_ARRAY_BUFFER, geom.capacity() * 4, GL_STREAM_DRAW);
561 glBufferSubData(GL_ARRAY_BUFFER, 0, geom);
562 }
563 }
564
565 private class SpriteRendererMapped extends SpriteRendererBatched {
566
567 private StreamVBO animVBO;
568
569 SpriteRendererMapped() {
570 System.out.println("Shootout Implementation: CPU animation & MapBufferRange");
571 }
572
573 public void updateBalls(final int count) {
574 super.updateBalls(count);
575
576 if ( animVBO != null )
577 animVBO.destroy();
578
579 animVBO = new StreamVBO(GL_ARRAY_BUFFER, ballCount * (2 * 4));
580 }
581
582 public void render(final boolean render, final boolean animate, final int delta) {
583 int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
584 int ballIndex = 0;
585 while ( ballIndex < ballCount ) {
586 if ( animate ) {
587 final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4));
588
589 long t0 = System.nanoTime();
590 animate(transform, buffer.asFloatBuffer(), ballSize, ballIndex, batchSize, delta);
591 long t1 = System.nanoTime();
592
593 animateTime += t1 - t0;
594
595 animVBO.unmap();
596 }
597
598 if ( render ) {
599 glVertexPointer(2, GL_FLOAT, 0, ballIndex * (2 * 4));
600 glDrawArrays(GL_POINTS, 0, batchSize);
601 }
602
603 ballIndex += batchSize;
604 batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
605 }
606 }
607 }
608
609 private class SpriteRendererTF extends SpriteRenderer {
610
611 private int progIDTF;
612 private int ballSizeLoc;
613 private int deltaLoc;
614
615 private int[] tfVBO = new int[2];
616 private int currVBO;
617
618 SpriteRendererTF() {
619 System.out.println("Shootout Implementation: TF GPU animation");
620
621 // Transform-feedback program
622
623 final int vshID = glCreateShader(GL_VERTEX_SHADER);
624 glShaderSource(vshID, "#version 130\n" +
625 "const float WIDTH = " + SCREEN_WIDTH + ";\n" +
626 "const float HEIGHT = " + SCREEN_HEIGHT + ";\n" +
627 "uniform float ballSize;\n" + // ballSize / 2
628 "uniform float delta;\n" +
629 "void main(void) {\n" +
630 " vec4 anim = gl_Vertex;\n" +
631 " anim.xy = anim.xy + anim.zw * delta;\n" +
632 " vec2 animC = clamp(anim.xy, vec2(ballSize), vec2(WIDTH - ballSize, HEIGHT - ballSize));\n" +
633 " if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
634 " if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
635 " gl_Position = vec4(animC, anim.zw);\n" +
636 "}");
637 glCompileShader(vshID);
638 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
639 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
640 throw new RuntimeException("Failed to compile vertex shader.");
641 }
642
643 progIDTF = glCreateProgram();
644 glAttachShader(progIDTF, vshID);
645 glTransformFeedbackVaryings(progIDTF, new CharSequence[] { "gl_Position" }, GL_SEPARATE_ATTRIBS);
646 glLinkProgram(progIDTF);
647 if ( glGetProgrami(progIDTF, GL_LINK_STATUS) == GL_FALSE ) {
648 System.out.println(glGetProgramInfoLog(progIDTF, glGetProgrami(progIDTF, GL_INFO_LOG_LENGTH)));
649 throw new RuntimeException("Failed to link shader program.");
650 }
651
652 glUseProgram(progIDTF);
653
654 ballSizeLoc = glGetUniformLocation(progIDTF, "ballSize");
655 deltaLoc = glGetUniformLocation(progIDTF, "delta");
656
657 glUniform1f(ballSizeLoc, ballSize * 0.5f);
658
659 // -----------------
660
661 this.vshID = glCreateShader(GL_VERTEX_SHADER);
662 glShaderSource(this.vshID, "void main(void) {\n" +
663 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
664 "}");
665 glCompileShader(this.vshID);
666 if ( glGetShaderi(this.vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
667 System.out.println(glGetShaderInfoLog(this.vshID, glGetShaderi(this.vshID, GL_INFO_LOG_LENGTH)));
668 throw new RuntimeException("Failed to compile vertex shader.");
669 }
670
671 createProgram();
672 }
673
674 public void updateBallSize() {
675 glUseProgram(progIDTF);
676 glUniform1f(ballSizeLoc, ballSize * 0.5f);
677
678 glUseProgram(progID);
679 super.updateBallSize();
680 }
681
682 public void updateBalls(final int count) {
683 if ( tfVBO[0] != 0 ) {
684 // Fetch current animation state
685 final FloatBuffer state = BufferUtils.createFloatBuffer(transform.length);
686 glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, state);
687 state.get(transform);
688 }
689
690 super.updateBalls(count);
691
692 if ( tfVBO[0] != 0 ) {
693 for ( int i = 0; i < tfVBO.length; i++ )
694 glDeleteBuffers(tfVBO[i]);
695 }
696
697 final FloatBuffer state = BufferUtils.createFloatBuffer(count * 4);
698 state.put(transform);
699 state.flip();
700
701 for ( int i = 0; i < tfVBO.length; i++ ) {
702 tfVBO[i] = glGenBuffers();
703 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]);
704 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, state, GL_STATIC_DRAW);
705 }
706
707 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]);
708 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
709 }
710
711 public void render(final boolean render, final boolean animate, final int delta) {
712 if ( animate ) {
713 glUseProgram(progIDTF);
714 glUniform1f(deltaLoc, delta);
715
716 final int vbo = currVBO;
717 currVBO = 1 - currVBO;
718
719 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[vbo]);
720 glVertexPointer(4, GL_FLOAT, 0, 0);
721
722 glEnable(GL_RASTERIZER_DISCARD);
723 if ( GLContext.getCapabilities().OpenGL30 ) {
724 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfVBO[1 - vbo]);
725
726 glBeginTransformFeedback(GL_POINTS);
727 glDrawArrays(GL_POINTS, 0, ballCount);
728 glEndTransformFeedback();
729 } else {
730 glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, tfVBO[1 - vbo]);
731
732 glBeginTransformFeedbackEXT(GL_POINTS);
733 glDrawArrays(GL_POINTS, 0, ballCount);
734 glEndTransformFeedbackEXT();
735 }
736 glDisable(GL_RASTERIZER_DISCARD);
737
738 glUseProgram(progID);
739 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
740 }
741
742 if ( render )
743 glDrawArrays(GL_POINTS, 0, ballCount);
744 }
745
746 }
747
748 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.sprites;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.Sys;
36 import org.lwjgl.input.Keyboard;
37 import org.lwjgl.input.Mouse;
38 import org.lwjgl.opengl.*;
39
40 import java.awt.image.BufferedImage;
41 import java.awt.image.Raster;
42 import java.io.IOException;
43 import java.nio.ByteBuffer;
44 import java.nio.FloatBuffer;
45 import java.util.Random;
46 import javax.imageio.ImageIO;
47
48 import static org.lwjgl.opengl.EXTTransformFeedback.*;
49 import static org.lwjgl.opengl.GL11.*;
50 import static org.lwjgl.opengl.GL12.*;
51 import static org.lwjgl.opengl.GL15.*;
52 import static org.lwjgl.opengl.GL20.*;
53 import static org.lwjgl.opengl.GL30.*;
54
55 /**
56 * Sprite rendering demo. In this version we're doing the animation
57 * computations on the GPU, using transform feedback and a vertex
58 * shader, then rendering is performed in 2 passes, with depth testing
59 * enabled:
60 * 1) Sprites are rendered front-to-back, opaque fragments only, blending is disabled.
61 * 2) Sprites are rendered back-to-front, transparent fragments only, blending is enabled.
62 * Sorting is free, because we're animating double the amount of sprites rendered, the
63 * first batch is sorted f2b, the second is sorted b2f. Ordering is achieved by modifying
64 * the z-axis position of the sprites in the vertex shader.
65 *
66 * @author Spasi
67 * @since 18/3/2011
68 */
69 public final class SpriteShootout2P {
70
71 private static final int SCREEN_WIDTH = 800;
72 private static final int SCREEN_HEIGHT = 600;
73
74 private static final int ANIMATION_TICKS = 60;
75
76 private boolean run = true;
77 private boolean render = true;
78 private boolean colorMask = true;
79 private boolean animate = true;
80 private boolean smooth;
81 private boolean vsync;
82
83 private int ballSize = 42;
84 private int ballCount = 100 * 1000;
85
86 private SpriteRenderer renderer;
87
88 // OpenGL stuff
89 private int texID;
90 private int texBigID;
91 private int texSmallID;
92
93 private SpriteShootout2P() {
94 }
95
96 public static void main(String[] args) {
97 try {
98 new SpriteShootout2P().start();
99 } catch (LWJGLException e) {
100 e.printStackTrace();
101 }
102 }
103
104 private void start() throws LWJGLException {
105 try {
106 initGL();
107
108 renderer = new SpriteRendererTF();
109
110 updateBalls(ballCount);
111 run();
112 } catch (Throwable t) {
113 t.printStackTrace();
114 } finally {
115 destroy();
116 }
117 }
118
119 private void initGL() throws LWJGLException {
120 Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2,
121 (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2);
122 Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
123 Display.setTitle("Sprite Shootout 2-pass");
124 Display.create(new PixelFormat(0, 24, 0));
125 //Display.create(new PixelFormat(), new ContextAttribs(4, 1).withProfileCompatibility(true).withDebug(true));
126 //AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
127
128 final ContextCapabilities caps = GLContext.getCapabilities();
129 if ( !(caps.OpenGL30 || (caps.OpenGL20 && caps.GL_EXT_transform_feedback)) )
130 throw new RuntimeException("OpenGL 3.0 or 2.0 + EXT_transform_feedback is required for this demo.");
131
132 // Setup viewport
133
134 glMatrixMode(GL_PROJECTION);
135 glLoadIdentity();
136 glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);
137
138 glMatrixMode(GL_MODELVIEW);
139 glLoadIdentity();
140 glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
141
142 glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
143
144 // Create textures
145
146 try {
147 texSmallID = createTexture("res/ball_sm.png");
148 texBigID = createTexture("res/ball.png");
149 } catch (IOException e) {
150 e.printStackTrace();
151 System.exit(-1);
152 }
153 texID = texBigID;
154
155 // Setup rendering state
156
157 glEnable(GL_BLEND);
158 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
159
160 glEnable(GL_ALPHA_TEST);
161
162 glColorMask(colorMask, colorMask, colorMask, false);
163 glDepthMask(true);
164 glEnable(GL_DEPTH_TEST);
165 glDepthFunc(GL_LESS);
166 glClearDepth(1.0f);
167
168 if ( caps.GL_ARB_compatibility || !caps.OpenGL31 )
169 glEnable(GL_POINT_SPRITE);
170
171 // Setup geometry
172
173 glEnableClientState(GL_VERTEX_ARRAY);
174
175 Util.checkGLError();
176 }
177
178 private static int createTexture(final String path) throws IOException {
179 final BufferedImage img = ImageIO.read(SpriteShootout2P.class.getClassLoader().getResource(path));
180
181 final int w = img.getWidth();
182 final int h = img.getHeight();
183
184 final ByteBuffer buffer = readImage(img);
185
186 final int texID = glGenTextures();
187
188 glBindTexture(GL_TEXTURE_2D, texID);
189 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
190 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
191 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
192 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
193 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
194
195 return texID;
196 }
197
198 private static ByteBuffer readImage(final BufferedImage img) throws IOException {
199 final Raster raster = img.getRaster();
200
201 final int bands = raster.getNumBands();
202
203 final int w = img.getWidth();
204 final int h = img.getHeight();
205
206 final int size = w * h * bands;
207
208 final byte[] pixels = new byte[size];
209 raster.getDataElements(0, 0, w, h, pixels);
210
211 final ByteBuffer pbuffer = BufferUtils.createByteBuffer(size);
212
213 if ( bands == 4 ) {
214 for ( int i = 0; i < (w * h * 4); i += 4 ) {
215 // Pre-multiply alpha
216 final float a = unpackUByte01(pixels[i + 3]);
217 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 2]) * a));
218 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 1]) * a));
219 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 0]) * a));
220 pbuffer.put(pixels[i + 3]);
221 }
222 } else if ( bands == 3 ) {
223 for ( int i = 0; i < (w * h * 3); i += 3 ) {
224 pbuffer.put(pixels[i + 2]);
225 pbuffer.put(pixels[i + 1]);
226 pbuffer.put(pixels[i + 0]);
227 }
228 } else
229 pbuffer.put(pixels, 0, size);
230
231 pbuffer.flip();
232
233 return pbuffer;
234 }
235
236 private static float unpackUByte01(final byte x) {
237 return (x & 0xFF) / 255.0f;
238 }
239
240 private static byte packUByte01(final float x) {
241 return (byte)(x * 255.0f);
242 }
243
244 private void updateBalls(final int count) {
245 System.out.println("NUMBER OF BALLS: " + count);
246 renderer.updateBalls(ballCount);
247 }
248
249 private void run() {
250 long startTime = System.currentTimeMillis() + 5000;
251 long fps = 0;
252
253 long time = Sys.getTime();
254 final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
255
256 renderer.render(false, true, 0);
257
258 while ( run ) {
259 Display.processMessages();
260 handleInput();
261
262 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
263
264 final long currTime = Sys.getTime();
265 final int delta = (int)(currTime - time);
266 if ( smooth || delta >= ticksPerUpdate ) {
267 renderer.render(render, animate, delta);
268 time = currTime;
269 } else
270 renderer.render(render, false, 0);
271
272 Display.update(false);
273 //Display.sync(60);
274
275 if ( startTime > System.currentTimeMillis() ) {
276 fps++;
277 } else {
278 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
279 startTime = System.currentTimeMillis() + 5000;
280 System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
281 fps = 0;
282 }
283 }
284 }
285
286 private void handleInput() {
287 if ( Display.isCloseRequested() )
288 run = false;
289
290 while ( Keyboard.next() ) {
291 if ( Keyboard.getEventKeyState() )
292 continue;
293
294 switch ( Keyboard.getEventKey() ) {
295 case Keyboard.KEY_1:
296 case Keyboard.KEY_2:
297 case Keyboard.KEY_3:
298 case Keyboard.KEY_4:
299 case Keyboard.KEY_5:
300 case Keyboard.KEY_6:
301 case Keyboard.KEY_7:
302 case Keyboard.KEY_8:
303 case Keyboard.KEY_9:
304 case Keyboard.KEY_0:
305 ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1);
306 updateBalls(ballCount);
307 break;
308 case Keyboard.KEY_ADD:
309 case Keyboard.KEY_SUBTRACT:
310 int mult;
311 if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ) {
312 mult = 1000;
313 if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
314 mult *= 5;
315 } else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) )
316 mult = 100;
317 else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
318 mult = 10;
319 else
320 mult = 1;
321 if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT )
322 mult = -mult;
323 ballCount += mult * 100;
324 if ( ballCount <= 0 )
325 ballCount = 1;
326 updateBalls(ballCount);
327 break;
328 case Keyboard.KEY_ESCAPE:
329 run = false;
330 break;
331 case Keyboard.KEY_A:
332 animate = !animate;
333 System.out.println("Animation is now " + (animate ? "on" : "off") + ".");
334 break;
335 case Keyboard.KEY_C:
336 colorMask = !colorMask;
337 glColorMask(colorMask, colorMask, colorMask, false);
338 System.out.println("Color mask is now " + (colorMask ? "on" : "off") + ".");
339 // Disable alpha test when color mask is off, else we get no benefit.
340 if ( colorMask ) {
341 glEnable(GL_BLEND);
342 glEnable(GL_ALPHA_TEST);
343 } else {
344 glDisable(GL_BLEND);
345 glDisable(GL_ALPHA_TEST);
346 }
347 break;
348 case Keyboard.KEY_R:
349 render = !render;
350 System.out.println("Rendering is now " + (render ? "on" : "off") + ".");
351 break;
352 case Keyboard.KEY_S:
353 smooth = !smooth;
354 System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + ".");
355 break;
356 case Keyboard.KEY_T:
357 if ( texID == texBigID ) {
358 texID = texSmallID;
359 ballSize = 16;
360 } else {
361 texID = texBigID;
362 ballSize = 42;
363 }
364 renderer.updateBallSize();
365 glBindTexture(GL_TEXTURE_2D, texID);
366 System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture.");
367 break;
368 case Keyboard.KEY_V:
369 vsync = !vsync;
370 Display.setVSyncEnabled(vsync);
371 System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + ".");
372 break;
373 }
374 }
375
376 while ( Mouse.next() ) ;
377 }
378
379 private void destroy() {
380 Display.destroy();
381 }
382
383 private abstract class SpriteRenderer {
384
385 protected int progID;
386
387 protected void createPrograms(final int vshID) {
388 // Opaque pass
389
390 final int fshID = glCreateShader(GL_FRAGMENT_SHADER);
391 glShaderSource(fshID, "uniform sampler2D COLOR_MAP;\n" +
392 "void main(void) {\n" +
393 " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" +
394 "}");
395 glCompileShader(fshID);
396 if ( glGetShaderi(fshID, GL_COMPILE_STATUS) == GL_FALSE ) {
397 System.out.println(glGetShaderInfoLog(fshID, glGetShaderi(fshID, GL_INFO_LOG_LENGTH)));
398 throw new RuntimeException("Failed to compile fragment shader.");
399 }
400
401 progID = glCreateProgram();
402 glAttachShader(progID, vshID);
403 glAttachShader(progID, fshID);
404 glLinkProgram(progID);
405 if ( glGetProgrami(progID, GL_LINK_STATUS) == GL_FALSE ) {
406 System.out.println(glGetProgramInfoLog(progID, glGetProgrami(progID, GL_INFO_LOG_LENGTH)));
407 throw new RuntimeException("Failed to link shader program.");
408 }
409
410 glUseProgram(progID);
411 glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0);
412
413 updateBallSize();
414
415 glEnableClientState(GL_VERTEX_ARRAY);
416 }
417
418 public void updateBallSize() {
419 glPointSize(ballSize);
420 }
421
422 protected abstract void updateBalls(final int count);
423
424 protected abstract void render(boolean render, boolean animate, int delta);
425
426 }
427
428 private class SpriteRendererTF extends SpriteRenderer {
429
430 private int progIDTF;
431 private int ballSizeLoc;
432 private int deltaLoc;
433
434 private int[] tfVBO = new int[2];
435 private int currVBO;
436
437 private int depthVBO;
438 private int depthLoc;
439
440 SpriteRendererTF() {
441 System.out.println("Shootout Implementation: TF GPU animation & 2-pass rendering");
442
443 // Transform-feedback program
444
445 int vshID = glCreateShader(GL_VERTEX_SHADER);
446 glShaderSource(vshID, "#version 130\n" +
447 "const float WIDTH = " + SCREEN_WIDTH + ";\n" +
448 "const float HEIGHT = " + SCREEN_HEIGHT + ";\n" +
449 "uniform float ballSize;\n" + // ballSize / 2
450 "uniform float delta;\n" +
451 "void main(void) {\n" +
452 " vec4 anim = gl_Vertex;\n" +
453 " anim.xy = anim.xy + anim.zw * delta;\n" +
454 " vec2 animC = clamp(anim.xy, vec2(ballSize), vec2(WIDTH - ballSize, HEIGHT - ballSize));\n" +
455 " if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
456 " if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
457 " gl_Position = vec4(animC, anim.zw);\n" +
458 "}");
459 glCompileShader(vshID);
460 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
461 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
462 throw new RuntimeException("Failed to compile vertex shader.");
463 }
464
465 progIDTF = glCreateProgram();
466 glAttachShader(progIDTF, vshID);
467 glTransformFeedbackVaryings(progIDTF, new CharSequence[] { "gl_Position" }, GL_SEPARATE_ATTRIBS);
468 glLinkProgram(progIDTF);
469 if ( glGetProgrami(progIDTF, GL_LINK_STATUS) == GL_FALSE ) {
470 System.out.println(glGetProgramInfoLog(progIDTF, glGetProgrami(progIDTF, GL_INFO_LOG_LENGTH)));
471 throw new RuntimeException("Failed to link shader program.");
472 }
473
474 glUseProgram(progIDTF);
475
476 ballSizeLoc = glGetUniformLocation(progIDTF, "ballSize");
477 deltaLoc = glGetUniformLocation(progIDTF, "delta");
478
479 glUniform1f(ballSizeLoc, ballSize * 0.5f);
480
481 // -----------------
482
483 vshID = glCreateShader(GL_VERTEX_SHADER);
484 glShaderSource(vshID, "#version 130\n" +
485 "in float depth;\n" +
486 "void main(void) {\n" +
487 " gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xy, depth, gl_Vertex.w);\n" +
488 "}");
489 glCompileShader(vshID);
490 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
491 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
492 throw new RuntimeException("Failed to compile vertex shader.");
493 }
494
495 createPrograms(vshID);
496
497 depthLoc = glGetAttribLocation(progID, "depth");
498
499 // -----------------
500 }
501
502 public void updateBallSize() {
503 glUseProgram(progIDTF);
504 glUniform1f(ballSizeLoc, ballSize * 0.5f);
505
506 super.updateBallSize();
507 }
508
509 public void updateBalls(final int count) {
510 // Depth data
511
512 final FloatBuffer depths = BufferUtils.createFloatBuffer(count * 2);
513 final float depthStep = 1.9f / count;
514 float depth = Float.parseFloat("0x1.fffffep-1");
515 // Front-to-back
516 for ( int i = 0; i < count; i++ ) {
517 depths.put(depth);
518 depth -= depthStep;
519 }
520 // Back-to-front
521 for ( int i = 0; i < count; i++ )
522 depths.put(depths.get(count - 1 - i));
523 depths.flip();
524
525 if ( depthVBO != 0 )
526 glDeleteBuffers(depthVBO);
527
528 depthVBO = glGenBuffers();
529 glBindBuffer(GL_ARRAY_BUFFER, depthVBO);
530 glBufferData(GL_ARRAY_BUFFER, depths, GL_STATIC_DRAW);
531
532 glEnableVertexAttribArray(depthLoc);
533 glVertexAttribPointer(depthLoc, 1, GL_FLOAT, false, 0, 0);
534
535 // Animation data
536
537 final FloatBuffer transform = BufferUtils.createFloatBuffer(count * 2 * 4);
538 // Front-to-back
539 final Random random = new Random();
540 for ( int i = 0; i < count; i++ ) {
541 transform.put((int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f));
542 transform.put((int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f));
543 transform.put(random.nextFloat() * 0.4f - 0.2f);
544 transform.put(random.nextFloat() * 0.4f - 0.2f);
545 }
546 // Back-to-front
547 for ( int i = 0; i < count; i++ ) {
548 final int offset = (count - 1 - i) * 4;
549 transform.put(transform.get(offset + 0));
550 transform.put(transform.get(offset + 1));
551 transform.put(transform.get(offset + 2));
552 transform.put(transform.get(offset + 3));
553 }
554 transform.flip();
555
556 if ( tfVBO[0] != 0 ) {
557 for ( int i = 0; i < tfVBO.length; i++ )
558 glDeleteBuffers(tfVBO[i]);
559 }
560
561 for ( int i = 0; i < tfVBO.length; i++ ) {
562 tfVBO[i] = glGenBuffers();
563 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]);
564 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, transform, GL_STATIC_DRAW);
565 }
566
567 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]);
568 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
569 }
570
571 public void render(final boolean render, final boolean animate, final int delta) {
572 if ( animate ) {
573 glDisableVertexAttribArray(depthLoc);
574
575 final int vbo = currVBO;
576 currVBO = 1 - currVBO;
577
578 glUseProgram(progIDTF);
579 glUniform1f(deltaLoc, delta);
580
581 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[vbo]);
582 glVertexPointer(4, GL_FLOAT, 0, 0);
583
584 glEnable(GL_RASTERIZER_DISCARD);
585 if ( GLContext.getCapabilities().OpenGL30 ) {
586 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfVBO[1 - vbo]);
587
588 glBeginTransformFeedback(GL_POINTS);
589 glDrawArrays(GL_POINTS, 0, ballCount * 2);
590 glEndTransformFeedback();
591 } else {
592 glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, tfVBO[1 - vbo]);
593
594 glBeginTransformFeedbackEXT(GL_POINTS);
595 glDrawArrays(GL_POINTS, 0, ballCount * 2);
596 glEndTransformFeedbackEXT();
597 }
598 glDisable(GL_RASTERIZER_DISCARD);
599
600 glUseProgram(progID);
601 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
602
603 glEnableVertexAttribArray(depthLoc);
604 }
605
606 if ( render ) {
607 // Render front-to-back opaque pass
608 glAlphaFunc(GL_EQUAL, 1.0f);
609 glDisable(GL_BLEND);
610 glDrawArrays(GL_POINTS, 0, ballCount);
611 glEnable(GL_BLEND);
612
613 // Render back-to-front transparent pass
614 glAlphaFunc(GL_GREATER, 0.0f); // Fragments with alpha == 1.0 are early-depth-rejected.
615 glDepthMask(false);
616 glDrawArrays(GL_POINTS, ballCount, ballCount);
617 glDepthMask(true);
618 }
619 }
620
621 }
622
623 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.sprites;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.PointerBuffer;
36 import org.lwjgl.Sys;
37 import org.lwjgl.input.Keyboard;
38 import org.lwjgl.input.Mouse;
39 import org.lwjgl.opencl.*;
40 import org.lwjgl.opencl.api.Filter;
41 import org.lwjgl.opengl.ContextCapabilities;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.DisplayMode;
44 import org.lwjgl.opengl.GLContext;
45
46 import java.awt.image.BufferedImage;
47 import java.awt.image.Raster;
48 import java.io.IOException;
49 import java.nio.ByteBuffer;
50 import java.nio.FloatBuffer;
51 import java.nio.IntBuffer;
52 import java.util.List;
53 import java.util.Random;
54 import javax.imageio.ImageIO;
55
56 import static org.lwjgl.opencl.CL10.*;
57 import static org.lwjgl.opencl.CL10GL.*;
58 import static org.lwjgl.opengl.GL11.*;
59 import static org.lwjgl.opengl.GL12.*;
60 import static org.lwjgl.opengl.GL15.*;
61 import static org.lwjgl.opengl.GL20.*;
62
63 /**
64 * Sprite rendering demo. In this version OpenCL is used for the animation
65 * computations. CL_KHR_gl_sharing is required for sharing the animation
66 * data with OpenGL for rendering.
67 *
68 * @author Spasi
69 * @since 18/3/2011
70 */
71 public final class SpriteShootoutCL {
72
73 private static final int SCREEN_WIDTH = 800;
74 private static final int SCREEN_HEIGHT = 600;
75
76 private static final int ANIMATION_TICKS = 60;
77
78 private boolean run = true;
79 private boolean render = true;
80 private boolean colorMask = true;
81 private boolean animate = true;
82 private boolean smooth;
83 private boolean vsync;
84
85 private int ballSize = 42;
86 private int ballCount = 100 * 1000;
87
88 private SpriteRenderer renderer;
89
90 // OpenGL stuff
91 private int texID;
92 private int texBigID;
93 private int texSmallID;
94
95 // OpenCL stuff
96
97 private IntBuffer errorCode = BufferUtils.createIntBuffer(1);
98
99 private CLDevice clDevice;
100 private CLContext clContext;
101 private CLCommandQueue queue;
102 private CLProgram program;
103 private CLKernel kernel;
104 private CLMem clTransform;
105
106 private PointerBuffer kernelGlobalWorkSize;
107
108 private SpriteShootoutCL() {
109 }
110
111 public static void main(String[] args) {
112 try {
113 new SpriteShootoutCL().start();
114 } catch (LWJGLException e) {
115 e.printStackTrace();
116 }
117 }
118
119 private void start() throws LWJGLException {
120 try {
121 initGL();
122 initCL();
123
124 renderer = new SpriteRendererDefault();
125
126 updateBalls(ballCount);
127 run();
128 } catch (Throwable t) {
129 t.printStackTrace();
130 } finally {
131 destroy();
132 }
133 }
134
135 private void initCL() throws LWJGLException {
136 CL.create();
137
138 final List<CLPlatform> platforms = CLPlatform.getPlatforms();
139 if ( platforms == null )
140 throw new RuntimeException("No OpenCL platforms found.");
141
142 final Filter<CLDevice> glSharingFilter = new Filter<CLDevice>() {
143 public boolean accept(final CLDevice device) {
144 final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device);
145 return caps.CL_KHR_gl_sharing;
146 }
147 };
148
149 CLPlatform platform = null;
150 List<CLDevice> devices = null;
151 for ( CLPlatform p : platforms ) {
152 // Find devices with GL sharing support
153 devices = p.getDevices(CL_DEVICE_TYPE_GPU, glSharingFilter);
154 if ( devices != null ) {
155 platform = p;
156 break;
157 }
158 }
159
160 if ( devices == null )
161 throw new RuntimeException("No OpenCL GPU device found.");
162
163 clDevice = devices.get(0);
164 // Make sure we use only 1 device
165 devices.clear();
166 devices.add(clDevice);
167
168 clContext = CLContext.create(platform, devices, new CLContextCallback() {
169 protected void handleMessage(final String errinfo, final ByteBuffer private_info) {
170 System.out.println("[CONTEXT MESSAGE] " + errinfo);
171 }
172 }, Display.getDrawable(), errorCode);
173 checkCLError(errorCode);
174
175 queue = clCreateCommandQueue(clContext, clDevice, 0, errorCode);
176 checkCLError(errorCode);
177 }
178
179 private void initGL() throws LWJGLException {
180 Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2,
181 (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2);
182 Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
183 Display.setTitle("Sprite Shootout - CL");
184 Display.create();
185
186 final ContextCapabilities caps = GLContext.getCapabilities();
187 if ( !caps.OpenGL20 )
188 throw new RuntimeException("OpenGL 2.0 is required for this demo.");
189
190 // Setup viewport
191
192 glMatrixMode(GL_PROJECTION);
193 glLoadIdentity();
194 glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);
195
196 glMatrixMode(GL_MODELVIEW);
197 glLoadIdentity();
198 glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
199
200 glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
201
202 // Create textures
203
204 try {
205 texSmallID = createTexture("res/ball_sm.png");
206 texBigID = createTexture("res/ball.png");
207 } catch (IOException e) {
208 e.printStackTrace();
209 System.exit(-1);
210 }
211 texID = texBigID;
212
213 // Setup rendering state
214
215 glEnable(GL_BLEND);
216 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
217
218 glEnable(GL_ALPHA_TEST);
219 glAlphaFunc(GL_GREATER, 0.0f);
220
221 glColorMask(colorMask, colorMask, colorMask, false);
222 glDepthMask(false);
223 glDisable(GL_DEPTH_TEST);
224
225 if ( caps.GL_ARB_compatibility || !caps.OpenGL31 )
226 glEnable(GL_POINT_SPRITE);
227
228 // Setup geometry
229
230 org.lwjgl.opengl.Util.checkGLError();
231 }
232
233 private static int createTexture(final String path) throws IOException {
234 final BufferedImage img = ImageIO.read(SpriteShootoutCL.class.getClassLoader().getResource(path));
235
236 final int w = img.getWidth();
237 final int h = img.getHeight();
238
239 final ByteBuffer buffer = readImage(img);
240
241 final int texID = glGenTextures();
242
243 glBindTexture(GL_TEXTURE_2D, texID);
244 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
245 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
246 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
247 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
248 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
249
250 return texID;
251 }
252
253 private static ByteBuffer readImage(final BufferedImage img) throws IOException {
254 final Raster raster = img.getRaster();
255
256 final int bands = raster.getNumBands();
257
258 final int w = img.getWidth();
259 final int h = img.getHeight();
260
261 final int size = w * h * bands;
262
263 final byte[] pixels = new byte[size];
264 raster.getDataElements(0, 0, w, h, pixels);
265
266 final ByteBuffer pbuffer = BufferUtils.createByteBuffer(size);
267
268 if ( bands == 4 ) {
269 for ( int i = 0; i < (w * h * 4); i += 4 ) {
270 // Pre-multiply alpha
271 final float a = unpackUByte01(pixels[i + 3]);
272 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 2]) * a));
273 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 1]) * a));
274 pbuffer.put(packUByte01(unpackUByte01(pixels[i + 0]) * a));
275 pbuffer.put(pixels[i + 3]);
276 }
277 } else if ( bands == 3 ) {
278 for ( int i = 0; i < (w * h * 3); i += 3 ) {
279 pbuffer.put(pixels[i + 2]);
280 pbuffer.put(pixels[i + 1]);
281 pbuffer.put(pixels[i + 0]);
282 }
283 } else
284 pbuffer.put(pixels, 0, size);
285
286 pbuffer.flip();
287
288 return pbuffer;
289 }
290
291 private static float unpackUByte01(final byte x) {
292 return (x & 0xFF) / 255.0f;
293 }
294
295 private static byte packUByte01(final float x) {
296 return (byte)(x * 255.0f);
297 }
298
299 private void updateBalls(final int count) {
300 System.out.println("NUMBER OF BALLS: " + count);
301 renderer.updateBalls(ballCount);
302 }
303
304 private void run() {
305 long startTime = System.currentTimeMillis() + 5000;
306 long fps = 0;
307
308 long time = Sys.getTime();
309 final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
310
311 renderer.render(false, true, 0);
312
313 while ( run ) {
314 Display.processMessages();
315 handleInput();
316
317 glClear(GL_COLOR_BUFFER_BIT);
318
319 final long currTime = Sys.getTime();
320 final int delta = (int)(currTime - time);
321 if ( smooth || delta >= ticksPerUpdate ) {
322 renderer.render(render, animate, delta);
323 time = currTime;
324 } else
325 renderer.render(render, false, 0);
326
327 Display.update(false);
328
329 if ( startTime > System.currentTimeMillis() ) {
330 fps++;
331 } else {
332 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
333 startTime = System.currentTimeMillis() + 5000;
334 System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
335 fps = 0;
336 }
337 }
338 }
339
340 private void handleInput() {
341 if ( Display.isCloseRequested() )
342 run = false;
343
344 while ( Keyboard.next() ) {
345 if ( Keyboard.getEventKeyState() )
346 continue;
347
348 switch ( Keyboard.getEventKey() ) {
349 case Keyboard.KEY_1:
350 case Keyboard.KEY_2:
351 case Keyboard.KEY_3:
352 case Keyboard.KEY_4:
353 case Keyboard.KEY_5:
354 case Keyboard.KEY_6:
355 case Keyboard.KEY_7:
356 case Keyboard.KEY_8:
357 case Keyboard.KEY_9:
358 case Keyboard.KEY_0:
359 ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1);
360 updateBalls(ballCount);
361 break;
362 case Keyboard.KEY_ADD:
363 case Keyboard.KEY_SUBTRACT:
364 int mult;
365 if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) )
366 mult = 1000;
367 else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) )
368 mult = 100;
369 else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
370 mult = 10;
371 else
372 mult = 1;
373 if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT )
374 mult = -mult;
375 ballCount += mult * 100;
376 if ( ballCount <= 0 )
377 ballCount = 1;
378 updateBalls(ballCount);
379 break;
380 case Keyboard.KEY_ESCAPE:
381 run = false;
382 break;
383 case Keyboard.KEY_A:
384 animate = !animate;
385 System.out.println("Animation is now " + (animate ? "on" : "off") + ".");
386 break;
387 case Keyboard.KEY_C:
388 colorMask = !colorMask;
389 glColorMask(colorMask, colorMask, colorMask, false);
390 System.out.println("Color mask is now " + (colorMask ? "on" : "off") + ".");
391 // Disable alpha test when color mask is off, else we get no benefit.
392 if ( colorMask ) {
393 glEnable(GL_BLEND);
394 glEnable(GL_ALPHA_TEST);
395 } else {
396 glDisable(GL_BLEND);
397 glDisable(GL_ALPHA_TEST);
398 }
399 break;
400 case Keyboard.KEY_R:
401 render = !render;
402 System.out.println("Rendering is now " + (render ? "on" : "off") + ".");
403 break;
404 case Keyboard.KEY_S:
405 smooth = !smooth;
406 System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + ".");
407 break;
408 case Keyboard.KEY_T:
409 if ( texID == texBigID ) {
410 texID = texSmallID;
411 ballSize = 16;
412 } else {
413 texID = texBigID;
414 ballSize = 42;
415 }
416 renderer.updateBallSize();
417 glBindTexture(GL_TEXTURE_2D, texID);
418 System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture.");
419 break;
420 case Keyboard.KEY_V:
421 vsync = !vsync;
422 Display.setVSyncEnabled(vsync);
423 System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + ".");
424 break;
425 }
426 }
427
428 while ( Mouse.next() ) ;
429 }
430
431 private static void checkCLError(IntBuffer buffer) {
432 org.lwjgl.opencl.Util.checkCLError(buffer.get(0));
433 }
434
435 private void destroy() {
436 if ( clContext != null )
437 clReleaseContext(clContext);
438 Display.destroy();
439 System.exit(0);
440 }
441
442 private abstract class SpriteRenderer {
443
444 protected int progID;
445 protected int animVBO;
446
447 protected void createKernel(final String source) {
448 program = clCreateProgramWithSource(clContext, source, errorCode);
449 checkCLError(errorCode);
450 final int build = clBuildProgram(program, clDevice, "", null);
451 if ( build != CL_SUCCESS ) {
452 System.out.println("BUILD LOG: " + program.getBuildInfoString(clDevice, CL_PROGRAM_BUILD_LOG));
453 throw new RuntimeException("Failed to build CL program, status: " + build);
454 }
455
456 kernel = clCreateKernel(program, "animate", errorCode);
457 checkCLError(errorCode);
458
459 kernelGlobalWorkSize = BufferUtils.createPointerBuffer(1);
460 kernelGlobalWorkSize.put(0, ballCount);
461
462 kernel.setArg(0, SCREEN_WIDTH);
463 kernel.setArg(1, SCREEN_HEIGHT);
464 }
465
466 protected void createProgram(final int vshID) {
467 final int fshID = glCreateShader(GL_FRAGMENT_SHADER);
468 glShaderSource(fshID, "#version 110\n" +
469 "uniform sampler2D COLOR_MAP;" +
470 "void main(void) {\n" +
471 " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" +
472 "}");
473 glCompileShader(fshID);
474 if ( glGetShaderi(fshID, GL_COMPILE_STATUS) == GL_FALSE ) {
475 System.out.println(glGetShaderInfoLog(fshID, glGetShaderi(fshID, GL_INFO_LOG_LENGTH)));
476 throw new RuntimeException("Failed to compile fragment shader.");
477 }
478
479 progID = glCreateProgram();
480 glAttachShader(progID, vshID);
481 glAttachShader(progID, fshID);
482 glLinkProgram(progID);
483 if ( glGetProgrami(progID, GL_LINK_STATUS) == GL_FALSE ) {
484 System.out.println(glGetProgramInfoLog(progID, glGetProgrami(progID, GL_INFO_LOG_LENGTH)));
485 throw new RuntimeException("Failed to link shader program.");
486 }
487
488 glUseProgram(progID);
489 glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0);
490
491 glEnableClientState(GL_VERTEX_ARRAY);
492 }
493
494 public void updateBallSize() {
495 glPointSize(ballSize);
496 kernel.setArg(2, ballSize * 0.5f);
497 }
498
499 public void updateBalls(final int count) {
500 kernelGlobalWorkSize.put(0, ballCount);
501
502 final FloatBuffer transform = BufferUtils.createFloatBuffer(count * 4);
503
504 final Random random = new Random();
505 for ( int i = 0; i < count; i++ ) {
506 transform.put((int)(random.nextFloat() * (SCREEN_WIDTH - ballSize)) + ballSize * 0.5f);
507 transform.put((int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize)) + ballSize * 0.5f);
508 transform.put(random.nextFloat() * 0.4f - 0.2f);
509 transform.put(random.nextFloat() * 0.4f - 0.2f);
510 }
511 transform.flip();
512
513 if ( animVBO != 0 ) {
514 clReleaseMemObject(clTransform);
515 glDeleteBuffers(animVBO);
516 }
517
518 animVBO = glGenBuffers();
519
520 glBindBuffer(GL_ARRAY_BUFFER, animVBO);
521 glBufferData(GL_ARRAY_BUFFER, transform, GL_STATIC_DRAW);
522 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
523
524 clTransform = clCreateFromGLBuffer(clContext, CL_MEM_READ_WRITE, animVBO, errorCode);
525 checkCLError(errorCode);
526 kernel.setArg(4, clTransform);
527 }
528
529 protected abstract void render(boolean render, boolean animate, int delta);
530
531 }
532
533 private class SpriteRendererDefault extends SpriteRenderer {
534
535 SpriteRendererDefault() {
536 System.out.println("Shootout Implementation: OpenCL GPU animation");
537
538 final int vshID = glCreateShader(GL_VERTEX_SHADER);
539 glShaderSource(vshID, "#version 150\n" +
540 "void main(void) {\n" +
541 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
542 "}");
543 glCompileShader(vshID);
544 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
545 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
546 throw new RuntimeException("Failed to compile vertex shader.");
547 }
548
549 createProgram(vshID);
550
551 org.lwjgl.opengl.Util.checkGLError();
552
553 createKernel("kernel void animate(\n" +
554 " const int WIDTH,\n" +
555 " const int HEIGHT,\n" +
556 " const float radius,\n" +
557 " const int delta,\n" +
558 " global float4 *balls\n" +
559 ") {\n" +
560 " unsigned int b = get_global_id(0);\n" +
561 "\n" +
562 " float4 anim = balls[b];\n" +
563 " anim.xy = anim.xy + anim.zw * delta;\n" +
564 " float2 animC = clamp(anim.xy, (float2)radius, (float2)(WIDTH - radius, HEIGHT - radius));\n" +
565 " if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
566 " if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
567 "\n" +
568 " balls[b] = (float4)(animC, anim.zw);\n" +
569 "}");
570
571 updateBallSize();
572 }
573
574 public void updateBalls(final int count) {
575 super.updateBalls(count);
576 }
577
578 public void render(final boolean render, final boolean animate, final int delta) {
579 if ( animate ) {
580 //glFinish();
581
582 kernel.setArg(3, delta);
583
584 clEnqueueAcquireGLObjects(queue, clTransform, null, null);
585 clEnqueueNDRangeKernel(queue, kernel, 1, null, kernelGlobalWorkSize, null, null, null);
586 clEnqueueReleaseGLObjects(queue, clTransform, null, null);
587
588 clFinish(queue);
589 }
590
591 if ( render )
592 glDrawArrays(GL_POINTS, 0, ballCount);
593 }
594
595 }
596
597 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.sprites;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.Sys;
36 import org.lwjgl.input.Keyboard;
37 import org.lwjgl.input.Mouse;
38 import org.lwjgl.opengl.*;
39 import org.lwjgl.util.mapped.MappedObject;
40 import org.lwjgl.util.mapped.MappedObjectClassLoader;
41 import org.lwjgl.util.mapped.MappedObjectTransformer;
42 import org.lwjgl.util.mapped.MappedType;
43
44 import java.awt.image.BufferedImage;
45 import java.awt.image.Raster;
46 import java.io.IOException;
47 import java.nio.ByteBuffer;
48 import java.util.Random;
49 import javax.imageio.ImageIO;
50
51 import static org.lwjgl.opengl.EXTTransformFeedback.*;
52 import static org.lwjgl.opengl.GL11.*;
53 import static org.lwjgl.opengl.GL12.*;
54 import static org.lwjgl.opengl.GL15.*;
55 import static org.lwjgl.opengl.GL20.*;
56 import static org.lwjgl.opengl.GL30.*;
57
58 /**
59 * Sprite rendering demo. Three implementations are supported:
60 * a) CPU animation + BufferData VBO update.
61 * b) CPU animation + MapBufferRange VBO update.
62 * c) GPU animation using transform feedback with a vertex shader.
63 *
64 * @author Spasi
65 * @since 18/3/2011
66 */
67 public final class SpriteShootoutMapped {
68
69 static final int SCREEN_WIDTH = 800;
70 static final int SCREEN_HEIGHT = 600;
71
72 private static final int ANIMATION_TICKS = 60;
73
74 private boolean run = true;
75 private boolean render = true;
76 private boolean colorMask = true;
77 private boolean animate = true;
78 private boolean smooth;
79 private boolean vsync;
80
81 int ballSize = 42;
82 int ballCount = 100 * 1000;
83
84 private SpriteRenderer renderer;
85
86 // OpenGL stuff
87 private int texID;
88 private int texBigID;
89 private int texSmallID;
90
91 long animateTime;
92
93 private SpriteShootoutMapped() {
94 }
95
96 public static void main(String[] args) {
97 MappedObjectTransformer.register(Pixel4b.class);
98 MappedObjectTransformer.register(Pixel3b.class);
99 MappedObjectTransformer.register(Sprite.class);
100 MappedObjectTransformer.register(SpriteRender.class);
101
102 if ( MappedObjectClassLoader.fork(SpriteShootoutMapped.class, args) )
103 return;
104
105 try {
106 new SpriteShootoutMapped().start();
107 } catch (LWJGLException e) {
108 e.printStackTrace();
109 }
110 }
111
112 private void start() throws LWJGLException {
113 try {
114 initGL();
115
116 final ContextCapabilities caps = GLContext.getCapabilities();
117 if ( !true && (caps.OpenGL30 || caps.GL_EXT_transform_feedback) )
118 renderer = new SpriteRendererTF();
119 else if ( true && caps.GL_ARB_map_buffer_range )
120 renderer = new SpriteRendererMapped();
121 else
122 renderer = new SpriteRendererPlain();
123
124 updateBalls(ballCount);
125 run();
126 } catch (Throwable t) {
127 t.printStackTrace();
128 } finally {
129 destroy();
130 }
131 }
132
133 private void initGL() throws LWJGLException {
134 Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2,
135 (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2);
136 Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
137 Display.setTitle("Sprite Shootout");
138 Display.create();
139 //Display.create(new PixelFormat(), new ContextAttribs(4, 1).withProfileCompatibility(true).withDebug(true));
140 //AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
141
142 if ( !GLContext.getCapabilities().OpenGL20 )
143 throw new RuntimeException("OpenGL 2.0 is required for this demo.");
144
145 // Setup viewport
146
147 glMatrixMode(GL_PROJECTION);
148 glLoadIdentity();
149 glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);
150
151 glMatrixMode(GL_MODELVIEW);
152 glLoadIdentity();
153 glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
154
155 glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
156
157 // Create textures
158
159 try {
160 texSmallID = createTexture("res/ball_sm.png");
161 texBigID = createTexture("res/ball.png");
162 } catch (IOException e) {
163 e.printStackTrace();
164 System.exit(-1);
165 }
166 texID = texBigID;
167
168 // Setup rendering state
169
170 glEnable(GL_BLEND);
171 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
172
173 glEnable(GL_ALPHA_TEST);
174 glAlphaFunc(GL_GREATER, 0.0f);
175
176 glColorMask(colorMask, colorMask, colorMask, false);
177 glDepthMask(false);
178 glDisable(GL_DEPTH_TEST);
179
180 // Setup geometry
181
182 glEnableClientState(GL_VERTEX_ARRAY);
183
184 Util.checkGLError();
185 }
186
187 private static int createTexture(final String path) throws IOException {
188 final BufferedImage img = ImageIO.read(SpriteShootoutMapped.class.getClassLoader().getResource(path));
189
190 final int w = img.getWidth();
191 final int h = img.getHeight();
192
193 final ByteBuffer buffer = readImage(img);
194
195 final int texID = glGenTextures();
196
197 glBindTexture(GL_TEXTURE_2D, texID);
198 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
201 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
202 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
203
204 return texID;
205 }
206
207 public static class Pixel4b extends MappedObject {
208
209 public byte r, g, b, a;
210
211 }
212
213 @MappedType(align = 3)
214 public static class Pixel3b extends MappedObject {
215
216 public byte r, g, b;
217
218 }
219
220 private static ByteBuffer readImage(final BufferedImage img) throws IOException {
221 final Raster raster = img.getRaster();
222
223 final int bands = raster.getNumBands();
224
225 final int w = img.getWidth();
226 final int h = img.getHeight();
227
228 final int count = w * h;
229
230 final byte[] pixels = new byte[count * bands];
231 raster.getDataElements(0, 0, w, h, pixels);
232
233 if ( bands == 4 ) {
234 Pixel4b p = Pixel4b.malloc(count);
235
236 int b = 0;
237 for ( int i = 0; i < count; i++, b += 4 ) {
238 // Pre-multiply alpha
239 final float a = unpackUByte01(pixels[b + 3]);
240
241 p.view = i;
242 p.r = packUByte01(unpackUByte01(pixels[b + 2]) * a);
243 p.g = packUByte01(unpackUByte01(pixels[b + 1]) * a);
244 p.b = packUByte01(unpackUByte01(pixels[b + 0]) * a);
245 p.a = pixels[b + 3];
246 }
247
248 return p.backingByteBuffer();
249 } else if ( bands == 3 ) {
250 Pixel3b p = Pixel3b.malloc(count);
251
252 int b = 0;
253 for ( int i = 0; i < count; i++, b += 3 ) {
254 p.view = i;
255 p.r = pixels[b + 2];
256 p.g = pixels[b + 1];
257 p.b = pixels[b + 0];
258 }
259
260 return p.backingByteBuffer();
261 } else {
262 ByteBuffer p = BufferUtils.createByteBuffer(count * bands);
263 p.put(pixels, 0, p.capacity());
264 p.flip();
265 return p;
266 }
267
268 }
269
270 private static float unpackUByte01(final byte x) {
271 return (x & 0xFF) / 255.0f;
272 }
273
274 private static byte packUByte01(final float x) {
275 return (byte)(x * 255.0f);
276 }
277
278 private void updateBalls(final int count) {
279 System.out.println("NUMBER OF BALLS: " + count);
280 renderer.updateBalls(ballCount);
281 }
282
283 private void run() {
284 long startTime = System.currentTimeMillis() + 5000;
285 long fps = 0;
286
287 long time = Sys.getTime();
288 final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
289
290 renderer.render(false, true, 0);
291
292 while ( run ) {
293 Display.processMessages();
294 handleInput();
295
296 glClear(GL_COLOR_BUFFER_BIT);
297
298 final long currTime = Sys.getTime();
299 final int delta = (int)(currTime - time);
300 if ( smooth || delta >= ticksPerUpdate ) {
301 renderer.render(render, animate, delta);
302 time = currTime;
303 } else
304 renderer.render(render, false, 0);
305
306 Display.update(false);
307 //Display.sync(60);
308
309 if ( startTime > System.currentTimeMillis() ) {
310 fps++;
311 } else {
312 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
313 startTime = System.currentTimeMillis() + 5000;
314 System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
315 System.out.println("Animation: " + animateTime / fps);
316 animateTime = 0;
317 fps = 0;
318 }
319 }
320 }
321
322 private void handleInput() {
323 if ( Display.isCloseRequested() )
324 run = false;
325
326 while ( Keyboard.next() ) {
327 if ( Keyboard.getEventKeyState() )
328 continue;
329
330 switch ( Keyboard.getEventKey() ) {
331 case Keyboard.KEY_1:
332 case Keyboard.KEY_2:
333 case Keyboard.KEY_3:
334 case Keyboard.KEY_4:
335 case Keyboard.KEY_5:
336 case Keyboard.KEY_6:
337 case Keyboard.KEY_7:
338 case Keyboard.KEY_8:
339 case Keyboard.KEY_9:
340 case Keyboard.KEY_0:
341 ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1);
342 updateBalls(ballCount);
343 break;
344 case Keyboard.KEY_ADD:
345 case Keyboard.KEY_SUBTRACT:
346 int mult;
347 if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) )
348 mult = 1000;
349 else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) )
350 mult = 100;
351 else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
352 mult = 10;
353 else
354 mult = 1;
355 if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT )
356 mult = -mult;
357 ballCount += mult * 100;
358 if ( ballCount <= 0 )
359 ballCount = 1;
360 updateBalls(ballCount);
361 break;
362 case Keyboard.KEY_ESCAPE:
363 run = false;
364 break;
365 case Keyboard.KEY_A:
366 animate = !animate;
367 System.out.println("Animation is now " + (animate ? "on" : "off") + ".");
368 break;
369 case Keyboard.KEY_C:
370 colorMask = !colorMask;
371 glColorMask(colorMask, colorMask, colorMask, false);
372 System.out.println("Color mask is now " + (colorMask ? "on" : "off") + ".");
373 // Disable alpha test when color mask is off, else we get no benefit.
374 if ( colorMask ) {
375 glEnable(GL_BLEND);
376 glEnable(GL_ALPHA_TEST);
377 } else {
378 glDisable(GL_BLEND);
379 glDisable(GL_ALPHA_TEST);
380 }
381 break;
382 case Keyboard.KEY_R:
383 render = !render;
384 System.out.println("Rendering is now " + (render ? "on" : "off") + ".");
385 break;
386 case Keyboard.KEY_S:
387 smooth = !smooth;
388 System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + ".");
389 break;
390 case Keyboard.KEY_T:
391 if ( texID == texBigID ) {
392 texID = texSmallID;
393 ballSize = 16;
394 } else {
395 texID = texBigID;
396 ballSize = 42;
397 }
398 renderer.updateBallSize();
399 glBindTexture(GL_TEXTURE_2D, texID);
400 System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture.");
401 break;
402 case Keyboard.KEY_V:
403 vsync = !vsync;
404 Display.setVSyncEnabled(vsync);
405 System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + ".");
406 break;
407 }
408 }
409
410 while ( Mouse.next() ) ;
411 }
412
413 private void destroy() {
414 Display.destroy();
415 }
416
417 public static class Sprite extends MappedObject {
418
419 public float dx, x;
420 public float dy, y;
421
422 }
423
424 public static class SpriteRender extends MappedObject {
425
426 public float x, y;
427
428 }
429
430 private abstract class SpriteRenderer {
431
432 protected Sprite sprites;
433
434 protected int spriteCount;
435
436 protected int vshID;
437 protected int progID;
438
439 protected void createProgram() {
440 final int fshID = glCreateShader(GL_FRAGMENT_SHADER);
441 glShaderSource(fshID, "uniform sampler2D COLOR_MAP;\n" +
442 "void main(void) {\n" +
443 " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" +
444 "}");
445 glCompileShader(fshID);
446 if ( glGetShaderi(fshID, GL_COMPILE_STATUS) == GL_FALSE ) {
447 System.out.println(glGetShaderInfoLog(fshID, glGetShaderi(fshID, GL_INFO_LOG_LENGTH)));
448 throw new RuntimeException("Failed to compile fragment shader.");
449 }
450
451 progID = glCreateProgram();
452 glAttachShader(progID, vshID);
453 glAttachShader(progID, fshID);
454 glLinkProgram(progID);
455 if ( glGetProgrami(progID, GL_LINK_STATUS) == GL_FALSE ) {
456 System.out.println(glGetProgramInfoLog(progID, glGetProgrami(progID, GL_INFO_LOG_LENGTH)));
457 throw new RuntimeException("Failed to link shader program.");
458 }
459
460 glUseProgram(progID);
461 glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0);
462
463 updateBallSize();
464
465 glEnableClientState(GL_VERTEX_ARRAY);
466 }
467
468 public void updateBallSize() {
469 glPointSize(ballSize);
470 }
471
472 public abstract void updateBalls(int count);
473
474 protected abstract void render(boolean render, boolean animate, int delta);
475
476 }
477
478 private abstract class SpriteRendererBatched extends SpriteRenderer {
479
480 protected static final int BALLS_PER_BATCH = 10 * 1000;
481
482 SpriteRendererBatched() {
483 vshID = glCreateShader(GL_VERTEX_SHADER);
484 glShaderSource(vshID, "void main(void) {\n" +
485 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
486 "}");
487 glCompileShader(vshID);
488 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
489 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
490 throw new RuntimeException("Failed to compile vertex shader.");
491 }
492
493 createProgram();
494 }
495
496 public void updateBalls(final int count) {
497 final Random random = new Random();
498
499 final Sprite newSprites = Sprite.malloc(count);
500 if ( sprites != null ) {
501 sprites.view = 0;
502 sprites.copyRange(newSprites, Math.min(count, spriteCount));
503 }
504
505 if ( count > spriteCount ) {
506 for ( int i = spriteCount; i < count; i++ ) {
507 newSprites.view = i;
508
509 newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f);
510 newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f);
511 newSprites.dx = random.nextFloat() * 0.4f - 0.2f;
512 newSprites.dy = random.nextFloat() * 0.4f - 0.2f;
513 }
514 }
515
516 sprites = newSprites;
517 spriteCount = count;
518 }
519
520 protected void animate(
521 final Sprite sprite,
522 final SpriteRender spriteRender,
523 final int ballSize, final int ballIndex, final int batchSize, final int delta
524 ) {
525 final float ballRadius = ballSize * 0.5f;
526 final float boundW = SCREEN_WIDTH - ballRadius;
527 final float boundH = SCREEN_HEIGHT - ballRadius;
528
529 final Sprite[] sprites = sprite.asArray();
530 final SpriteRender[] spritesRender = spriteRender.asArray();
531 for ( int b = ballIndex, r = 0, len = (ballIndex + batchSize); b < len; b++, r++ ) {
532 float dx = sprites[b].dx;
533 float x = sprites[b].x;
534
535 x += dx * delta;
536 if ( x < ballRadius ) {
537 x = ballRadius;
538 dx = -dx;
539 } else if ( x > boundW ) {
540 x = boundW;
541 dx = -dx;
542 }
543
544 sprites[b].dx = dx;
545 sprites[b].x = x;
546 spritesRender[r].x = x;
547
548 float dy = sprites[b].dy;
549 float y = sprites[b].y;
550
551 y += dy * delta;
552 if ( y < ballRadius ) {
553 y = ballRadius;
554 dy = -dy;
555 } else if ( y > boundH ) {
556 y = boundH;
557 dy = -dy;
558 }
559
560 sprites[b].dy = dy;
561 sprites[b].y = y;
562 spritesRender[r].y = y;
563 }
564 }
565
566 }
567
568 private class SpriteRendererPlain extends SpriteRendererBatched {
569
570 private final int DATA_PER_BATCH = BALLS_PER_BATCH * 2 * 4; // balls * 2 floats * 4 bytes
571
572 protected int[] animVBO;
573
574 private SpriteRender spritesRender;
575
576 SpriteRendererPlain() {
577 System.out.println("Shootout Implementation: CPU animation & BufferData");
578 spritesRender = SpriteRender.malloc(BALLS_PER_BATCH);
579 }
580
581 public void updateBalls(final int count) {
582 super.updateBalls(count);
583
584 final int batchCount = count / BALLS_PER_BATCH + (count % BALLS_PER_BATCH == 0 ? 0 : 1);
585 if ( animVBO != null && batchCount == animVBO.length )
586 return;
587
588 final int[] newAnimVBO = new int[batchCount];
589 if ( animVBO != null ) {
590 System.arraycopy(animVBO, 0, newAnimVBO, 0, Math.min(animVBO.length, newAnimVBO.length));
591 for ( int i = newAnimVBO.length; i < animVBO.length; i++ )
592 glDeleteBuffers(animVBO[i]);
593 }
594 for ( int i = animVBO == null ? 0 : animVBO.length; i < newAnimVBO.length; i++ ) {
595 newAnimVBO[i] = glGenBuffers();
596 glBindBuffer(GL_ARRAY_BUFFER, newAnimVBO[i]);
597 }
598
599 animVBO = newAnimVBO;
600 }
601
602 public void render(final boolean render, final boolean animate, final int delta) {
603 int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
604 int ballIndex = 0;
605 int batchIndex = 0;
606 while ( ballIndex < ballCount ) {
607 glBindBuffer(GL_ARRAY_BUFFER, animVBO[batchIndex]);
608
609 if ( animate )
610 animate(ballIndex, batchSize, delta);
611
612 if ( render ) {
613 glVertexPointer(2, GL_FLOAT, 0, 0);
614 glDrawArrays(GL_POINTS, 0, batchSize);
615 }
616
617 ballIndex += batchSize;
618 batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
619 batchIndex++;
620 }
621 }
622
623 private void animate(final int ballIndex, final int batchSize, final int delta) {
624 animate(
625 sprites, spritesRender,
626 ballSize, ballIndex, batchSize, delta
627 );
628
629 glBufferData(GL_ARRAY_BUFFER, DATA_PER_BATCH, GL_STREAM_DRAW);
630 glBufferSubData(GL_ARRAY_BUFFER, 0, spritesRender.backingByteBuffer());
631 }
632
633 }
634
635 private class SpriteRendererMapped extends SpriteRendererBatched {
636
637 private StreamVBO animVBO;
638
639 SpriteRendererMapped() {
640 System.out.println("Shootout Implementation: CPU animation & MapBufferRange");
641 }
642
643 public void updateBalls(final int count) {
644 super.updateBalls(count);
645
646 if ( animVBO != null )
647 animVBO.destroy();
648
649 animVBO = new StreamVBO(GL_ARRAY_BUFFER, ballCount * (2 * 4));
650 }
651
652 public void render(final boolean render, final boolean animate, final int delta) {
653 int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
654 int ballIndex = 0;
655 while ( ballIndex < ballCount ) {
656 if ( animate ) {
657 final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4));
658
659 long t0 = System.nanoTime();
660 animate(sprites, SpriteRender.<SpriteRender>map(buffer), ballSize, ballIndex, batchSize, delta);
661 long t1 = System.nanoTime();
662
663 animateTime += t1 - t0;
664
665 animVBO.unmap();
666 }
667
668 if ( render ) {
669 glVertexPointer(2, GL_FLOAT, 0, ballIndex * (2 * 4));
670 glDrawArrays(GL_POINTS, 0, batchSize);
671 }
672
673 ballIndex += batchSize;
674 batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
675 }
676 }
677
678 }
679
680 private class SpriteRendererTF extends SpriteRenderer {
681
682 private int progIDTF;
683 private int ballSizeLoc;
684 private int deltaLoc;
685
686 private int[] tfVBO = new int[2];
687 private int currVBO;
688
689 SpriteRendererTF() {
690 System.out.println("Shootout Implementation: TF GPU animation");
691
692 // Transform-feedback program
693
694 final int vshID = glCreateShader(GL_VERTEX_SHADER);
695 glShaderSource(vshID, "#version 130\n" +
696 "const float WIDTH = " + SCREEN_WIDTH + ";\n" +
697 "const float HEIGHT = " + SCREEN_HEIGHT + ";\n" +
698 "uniform float ballSize;\n" + // ballSize / 2
699 "uniform float delta;\n" +
700 "void main(void) {\n" +
701 " vec4 anim = gl_Vertex;\n" +
702 " anim.xy = anim.xy + anim.zw * delta;\n" +
703 " vec2 animC = clamp(anim.xy, vec2(ballSize), vec2(WIDTH - ballSize, HEIGHT - ballSize));\n" +
704 " if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
705 " if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
706 " gl_Position = vec4(animC, anim.zw);\n" +
707 "}");
708 glCompileShader(vshID);
709 if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
710 System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
711 throw new RuntimeException("Failed to compile vertex shader.");
712 }
713
714 progIDTF = glCreateProgram();
715 glAttachShader(progIDTF, vshID);
716 glTransformFeedbackVaryings(progIDTF, new CharSequence[] { "gl_Position" }, GL_SEPARATE_ATTRIBS);
717 glLinkProgram(progIDTF);
718 if ( glGetProgrami(progIDTF, GL_LINK_STATUS) == GL_FALSE ) {
719 System.out.println(glGetProgramInfoLog(progIDTF, glGetProgrami(progIDTF, GL_INFO_LOG_LENGTH)));
720 throw new RuntimeException("Failed to link shader program.");
721 }
722
723 glUseProgram(progIDTF);
724
725 ballSizeLoc = glGetUniformLocation(progIDTF, "ballSize");
726 deltaLoc = glGetUniformLocation(progIDTF, "delta");
727
728 glUniform1f(ballSizeLoc, ballSize * 0.5f);
729
730 // -----------------
731
732 this.vshID = glCreateShader(GL_VERTEX_SHADER);
733 glShaderSource(this.vshID, "void main(void) {\n" +
734 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
735 "}");
736 glCompileShader(this.vshID);
737 if ( glGetShaderi(this.vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
738 System.out.println(glGetShaderInfoLog(this.vshID, glGetShaderi(this.vshID, GL_INFO_LOG_LENGTH)));
739 throw new RuntimeException("Failed to compile vertex shader.");
740 }
741
742 createProgram();
743 }
744
745 public void updateBallSize() {
746 glUseProgram(progIDTF);
747 glUniform1f(ballSizeLoc, ballSize * 0.5f);
748
749 glUseProgram(progID);
750 super.updateBallSize();
751 }
752
753 private void doUpdateBalls(final int count) {
754 final Random random = new Random();
755
756 final Sprite newSprites = Sprite.malloc(count);
757 if ( sprites != null ) {
758 sprites.view = 0;
759 sprites.copyRange(newSprites, Math.min(count, spriteCount));
760 }
761
762 if ( count > spriteCount ) {
763 for ( int i = spriteCount; i < count; i++ ) {
764 newSprites.view = i;
765
766 newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f);
767 newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f);
768 newSprites.dx = random.nextFloat() * 0.4f - 0.2f;
769 newSprites.dy = random.nextFloat() * 0.4f - 0.2f;
770 }
771 }
772
773 sprites = newSprites;
774 spriteCount = count;
775 }
776
777 public void updateBalls(final int count) {
778 if ( tfVBO[0] != 0 ) {
779 // Fetch current animation state
780 glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sprites.backingByteBuffer());
781 }
782
783 doUpdateBalls(count);
784
785 if ( tfVBO[0] != 0 ) {
786 for ( int i = 0; i < tfVBO.length; i++ )
787 glDeleteBuffers(tfVBO[i]);
788 }
789
790 for ( int i = 0; i < tfVBO.length; i++ ) {
791 tfVBO[i] = glGenBuffers();
792 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]);
793 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sprites.backingByteBuffer(), GL_STATIC_DRAW);
794 }
795
796 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]);
797 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
798 }
799
800 public void render(final boolean render, final boolean animate, final int delta) {
801 if ( animate ) {
802 glUseProgram(progIDTF);
803 glUniform1f(deltaLoc, delta);
804
805 final int vbo = currVBO;
806 currVBO = 1 - currVBO;
807
808 glBindBuffer(GL_ARRAY_BUFFER, tfVBO[vbo]);
809 glVertexPointer(4, GL_FLOAT, 0, 0);
810
811 glEnable(GL_RASTERIZER_DISCARD);
812 if ( GLContext.getCapabilities().OpenGL30 ) {
813 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfVBO[1 - vbo]);
814
815 glBeginTransformFeedback(GL_POINTS);
816 glDrawArrays(GL_POINTS, 0, ballCount);
817 glEndTransformFeedback();
818 } else {
819 glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, tfVBO[1 - vbo]);
820
821 glBeginTransformFeedbackEXT(GL_POINTS);
822 glDrawArrays(GL_POINTS, 0, ballCount);
823 glEndTransformFeedbackEXT();
824 }
825 glDisable(GL_RASTERIZER_DISCARD);
826
827 glUseProgram(progID);
828 glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
829 }
830
831 if ( render )
832 glDrawArrays(GL_POINTS, 0, ballCount);
833 }
834
835 }
836
837 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.sprites;
32
33 import org.lwjgl.LWJGLUtil;
34
35 import java.nio.ByteBuffer;
36
37 import static java.lang.Math.*;
38 import static org.lwjgl.opengl.GL15.*;
39 import static org.lwjgl.opengl.GL30.*;
40
41 /**
42 * This class implements VBO orphaning, useful for streaming
43 * dynamically generated geometry to the GPU. OpenGL 3.0 or
44 * higher is required. See
45 * {@url http://www.opengl.org/wiki/Buffer_Object_Streaming}
46 * under "Buffer update" for details.
47 *
48 * @author Spasi
49 */
50 public class StreamVBO {
51
52 private final int target;
53 private final long size;
54 private final int padding;
55
56 private int ID;
57
58 private long cursor;
59
60 public StreamVBO(final int target, final int size) {
61 this(target, size, 64);
62 }
63
64 public StreamVBO(final int target, final int size, final int padding) {
65 this.target = target;
66 this.padding = padding;
67 this.size = max(pad(size), padding);
68
69 ID = glGenBuffers();
70
71 glBindBuffer(target, ID);
72 glBufferData(target, this.size, GL_STREAM_DRAW);
73 }
74
75 public int getTarget() {
76 return target;
77 }
78
79 public int getID() {
80 return ID;
81 }
82
83 public long getSize() {
84 return size;
85 }
86
87 public int getPadding() {
88 return padding;
89 }
90
91 public void bind() {
92 glBindBuffer(target, ID);
93 }
94
95 public void init(final int offset, final ByteBuffer data) {
96 glBufferSubData(target, offset, data);
97 }
98
99 public void unmap() {
100 glUnmapBuffer(target);
101 }
102
103 public void destroy() {
104 glBindBuffer(target, 0);
105 glDeleteBuffers(ID);
106 }
107
108 public void reset() {
109 // Orphan current buffer and allocate a new one
110 glBufferData(target, size, GL_STREAM_DRAW);
111 // Flush
112 cursor = 0;
113 }
114
115 public ByteBuffer map(final int bytes) {
116 return map(bytes, null);
117 }
118
119 public ByteBuffer map(final int bytes, final ByteBuffer old_buffer) {
120 return doMap(pad(bytes), old_buffer);
121 }
122
123 private int pad(int size) {
124 final int mod = size % padding;
125 if ( mod == 0 )
126 return size;
127
128 return size + padding - mod;
129 }
130
131 private ByteBuffer doMap(final int bytes, final ByteBuffer old_buffer) {
132 if ( LWJGLUtil.CHECKS && size < bytes )
133 throw new IllegalArgumentException(Integer.toString(bytes));
134
135 if ( size < cursor + bytes )
136 reset();
137
138 final ByteBuffer map = glMapBufferRange(target, cursor, bytes, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT, old_buffer);
139 cursor += bytes;
140 return map;
141 }
142
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 package org.lwjgl.test.opengles;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.input.Keyboard;
36 import org.lwjgl.opengl.Display;
37 import org.lwjgl.opengl.DisplayMode;
38 import org.lwjgl.opengles.PixelFormat;
39 import org.lwjgl.opengles.PowerManagementEventException;
40 import org.lwjgl.util.vector.Vector2f;
41
42 import java.nio.FloatBuffer;
43 import java.nio.IntBuffer;
44
45 import static org.lwjgl.opengles.GLES20.*;
46 import static org.lwjgl.test.opengles.util.GLMatrix.*;
47
48 /**
49 * Tests switching between windowed and fullscreen
50 *
51 * @author Brian Matzon <brian@matzon.dk>
52 * @version $Revision: 3172 $
53 * $Id: FullScreenWindowedTest.java 3172 2008-12-28 19:30:43Z elias_naur $
54 */
55 public class FullScreenWindowedTest {
56
57 /** Intended deiplay mode */
58 private DisplayMode mode;
59 /** our quad moving around */
60 private Vector2f quadPosition;
61 /** our quadVelocity */
62 private Vector2f quadVelocity;
63 /** angle of quad */
64 private float angle;
65 /** degrees to rotate per frame */
66 private float angleRotation = 1.0f;
67 /** Max speed of all changable attributes */
68 private static final float MAX_SPEED = 20.0f;
69
70 private static int buffer_id;
71 private static int indices_buffer_id;
72
73 private QuadRenderer renderer;
74
75 /** Creates a FullScreenWindowedTest */
76 public FullScreenWindowedTest() {
77 }
78
79 /** Executes the test */
80 public void execute() {
81 initialize();
82 mainLoop();
83 cleanup();
84 }
85
86 private void switchMode() throws LWJGLException {
87 mode = findDisplayMode(1024, 600, Display.getDisplayMode().getBitsPerPixel());
88 try {
89 Display.setDisplayModeAndFullscreen(mode);
90 } catch (PowerManagementEventException e) {
91 e.printStackTrace();
92 }
93 }
94
95 /** Initializes the test */
96 private void initialize() {
97 try {
98 //find displaymode
99 switchMode();
100
101 quadPosition = new Vector2f(100f, 100f);
102 quadVelocity = new Vector2f(1.0f, 1.0f);
103
104 reinit();
105 } catch (Exception e) {
106 e.printStackTrace();
107 }
108 }
109
110 private void reinit() throws LWJGLException {
111 Display.create(new PixelFormat());
112 glInit();
113 renderer = new QuadRenderer();
114 }
115
116 /** Runs the main loop of the "test" */
117 private void mainLoop() {
118 while ( !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested() ) {
119 if ( Display.isVisible() ) {
120 // check keyboard input
121 processKeyboard();
122 // do "game" logic, and render it
123 logic();
124 render();
125 } else {
126 // no need to render/paint if nothing has changed (ie. window
127 // dragged over)
128 if ( Display.isDirty() ) {
129 render();
130 }
131 // don't waste cpu time, sleep more
132 try {
133 Thread.sleep(100);
134 } catch (InterruptedException inte) {
135 }
136 }
137 // Update window
138 try {
139 Display.update();
140 Display.sync(60);
141 } catch (PowerManagementEventException e) {
142 e.printStackTrace();
143 }
144 }
145 }
146
147 /** Performs the logic */
148 private void logic() {
149 angle += angleRotation;
150 if ( angle > 90.0f ) {
151 angle = 0.0f;
152 }
153 quadPosition.x += quadVelocity.x;
154 quadPosition.y += quadVelocity.y;
155 //check colision with vertical border border
156 if ( quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0 ) {
157 quadVelocity.x *= -1;
158 }
159 //check collision with horizontal border
160 if ( quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0 ) {
161 quadVelocity.y *= -1;
162 }
163 }
164
165 private void render() {
166 //clear background
167 glClear(GL_COLOR_BUFFER_BIT);
168 // draw white quad
169 glPushMatrix();
170 {
171 glTranslatef(quadPosition.x, quadPosition.y, 0);
172 glRotatef(angle, 0.0f, 0.0f, 1.0f);
173
174 renderer.setMVPUniform();
175
176 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
177 }
178 glPopMatrix();
179 }
180
181 /** Processes keyboard input */
182 private void processKeyboard() {
183 //check for fullscreen key
184 if ( Keyboard.isKeyDown(Keyboard.KEY_F) ) {
185 try {
186 cleanup();
187
188 switchMode();
189
190 reinit();
191 } catch (Exception e) {
192 e.printStackTrace();
193 }
194 }
195 //check for window key
196 if ( Keyboard.isKeyDown(Keyboard.KEY_W) ) {
197 try {
198 cleanup();
199
200 mode = new DisplayMode(800, 480);
201 Display.setDisplayModeAndFullscreen(mode);
202
203 reinit();
204 } catch (Exception e) {
205 e.printStackTrace();
206 }
207 }
208 //check for speed changes
209 if ( Keyboard.isKeyDown(Keyboard.KEY_UP) ) {
210 quadVelocity.y += 0.1f;
211 }
212 if ( Keyboard.isKeyDown(Keyboard.KEY_DOWN) ) {
213 quadVelocity.y -= 0.1f;
214 }
215 if ( Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ) {
216 quadVelocity.x += 0.1f;
217 }
218 if ( Keyboard.isKeyDown(Keyboard.KEY_LEFT) ) {
219 quadVelocity.x -= 0.1f;
220 }
221 if ( Keyboard.isKeyDown(Keyboard.KEY_ADD) ) {
222 angleRotation += 0.1f;
223 }
224 if ( Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT) ) {
225 angleRotation -= 0.1f;
226 }
227 //throttle
228 if ( quadVelocity.x < -MAX_SPEED ) {
229 quadVelocity.x = -MAX_SPEED;
230 }
231 if ( quadVelocity.x > MAX_SPEED ) {
232 quadVelocity.x = MAX_SPEED;
233 }
234 if ( quadVelocity.y < -MAX_SPEED ) {
235 quadVelocity.y = -MAX_SPEED;
236 }
237 if ( quadVelocity.y > MAX_SPEED ) {
238 quadVelocity.y = MAX_SPEED;
239 }
240 if ( angleRotation < 0.0f ) {
241 angleRotation = 0.0f;
242 }
243 if ( angleRotation > MAX_SPEED ) {
244 angleRotation = MAX_SPEED;
245 }
246 }
247
248 /** Cleans up the test */
249 private void cleanup() {
250 renderer.cleanup();
251
252 IntBuffer int_buffer = BufferUtils.createIntBuffer(2);
253 int_buffer.put(0, buffer_id);
254 int_buffer.put(1, indices_buffer_id);
255
256 glDeleteBuffers(int_buffer);
257
258 Display.destroy();
259 }
260
261 /**
262 * Retrieves a displaymode, if one such is available
263 *
264 * @param width Required width
265 * @param height Required height
266 * @param bpp Minimum required bits per pixel
267 *
268 * @return
269 */
270 private static DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
271 DisplayMode[] modes = Display.getAvailableDisplayModes();
272 for ( int i = 0; i < modes.length; i++ ) {
273 if ( modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60 ) {
274 return modes[i];
275 }
276 }
277 return Display.getDesktopDisplayMode();
278 }
279
280 /** Initializes OGL */
281 private void glInit() {
282 // Go into orthographic projection mode.
283 glMatrixMode(GL_PROJECTION);
284 glLoadIdentity();
285 glOrtho(0, mode.getWidth(), 0, mode.getHeight(), -1.0f, 1.0f);
286
287 glMatrixMode(GL_MODELVIEW);
288 glLoadIdentity();
289
290 glViewport(0, 0, mode.getWidth(), mode.getHeight());
291 //set clear color to black
292 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
293
294 //sync frame (only works on windows)
295 Display.setVSyncEnabled(true);
296
297 final IntBuffer int_buffer = BufferUtils.createIntBuffer(2);
298 glGenBuffers(int_buffer);
299 buffer_id = int_buffer.get(0);
300 indices_buffer_id = int_buffer.get(1);
301
302 glBindBuffer(GL_ARRAY_BUFFER, buffer_id);
303 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer_id);
304
305 final FloatBuffer vertices = BufferUtils.createFloatBuffer(2 * 4);
306 vertices
307 .put(-50).put(-50)
308 .put(50).put(-50)
309 .put(-50).put(50)
310 .put(50).put(50);
311 vertices.rewind();
312
313 final IntBuffer indices = BufferUtils.createIntBuffer(4);
314 indices.put(0).put(1).put(2).put(3);
315 indices.rewind();
316
317 glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
318 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices, GL_STATIC_DRAW);
319 }
320
321 /** Test entry point */
322 public static void main(String[] args) {
323 System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively");
324 System.out.println("Move quad using arrowkeys, and change rotation using +/-");
325 FullScreenWindowedTest fswTest = new FullScreenWindowedTest();
326 fswTest.execute();
327 System.exit(0);
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
32 /*
33 * 3-D gear wheels. Originally by Brian Paul
34 */
35 package org.lwjgl.test.opengles;
36
37 import org.lwjgl.BufferUtils;
38 import org.lwjgl.LWJGLException;
39 import org.lwjgl.Sys;
40 import org.lwjgl.input.Keyboard;
41 import org.lwjgl.input.Mouse;
42 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.DisplayMode;
44 import org.lwjgl.opengles.*;
45 import org.lwjgl.test.opengles.util.Geometry;
46 import org.lwjgl.test.opengles.util.ImmediateModeBuffer;
47 import org.lwjgl.test.opengles.util.Shader;
48 import org.lwjgl.test.opengles.util.ShaderProgram;
49 import org.lwjgl.util.vector.Matrix4f;
50 import org.lwjgl.util.vector.Vector3f;
51
52 import java.lang.reflect.Field;
53 import java.nio.FloatBuffer;
54 import java.util.StringTokenizer;
55
56 import static org.lwjgl.opengles.GLES20.*;
57 import static org.lwjgl.test.opengles.util.GLLight.*;
58 import static org.lwjgl.test.opengles.util.GLMatrix.*;
59 import static org.lwjgl.test.opengles.util.Geometry.*;
60
61 /**
62 * <p>
63 * This is the OpenGL "standard" Gears demo, originally by Brian Paul
64 * </p>
65 *
66 * @author Brian Matzon <brian@matzon.dk>
67 * @version $Revision: 3276 $
68 * $Id: Gears.java 3276 2010-02-21 21:18:17Z matzon $
69 */
70 public class Gears {
71
72 private boolean run = true;
73
74 private float view_rotx = 20.0f;
75
76 private float view_roty = 30.0f;
77
78 private float view_rotz = 0.0f;
79
80 private Gear gear1;
81
82 private Gear gear2;
83
84 private Gear gear3;
85
86 private float angle = 0.0f;
87
88 private Shader vsh;
89 private Shader fsh;
90
91 private ShaderProgram program;
92
93 private int LIGHT_POS;
94
95 private int MVP;
96 private int NM;
97
98 private int GEAR_COLOR;
99
100 private int vPosition;
101 private int vNormal;
102
103 private final Matrix4f p = new Matrix4f();
104 private final Matrix4f mv = new Matrix4f();
105 private final Matrix4f mvp = new Matrix4f();
106
107 private final FloatBuffer m4fBuffer = BufferUtils.createFloatBuffer(4 * 4);
108 private final FloatBuffer m3fBuffer = BufferUtils.createFloatBuffer(3 * 3);
109
110 public static void main(String[] args) {
111 new Gears().execute();
112 System.exit(0);
113 }
114
115 /**
116 *
117 */
118 private void execute() {
119 try {
120 init();
121 } catch (LWJGLException e) {
122 e.printStackTrace();
123 System.out.println("Failed to initialize Gears.");
124 return;
125 }
126
127 System.out.println("\nGL RENDERER: " + glGetString(GL_RENDERER));
128 System.out.println("GL VENDOR: " + glGetString(GL_VENDOR));
129 System.out.println("GL VERSION: " + glGetString(GL_VERSION));
130 System.out.println("GL_SHADING_LANGUAGE_VERSION: " + glGetString(GL_SHADING_LANGUAGE_VERSION));
131 System.out.println("GL_EXTENSIONS = " + glGetString(GL_EXTENSIONS));
132
133 ContextCapabilities caps = GLContext.getCapabilities();
134
135 System.out.println();
136
137 // Check extension support
138 Field[] field = ContextCapabilities.class.getFields();
139 for ( Field f : field ) {
140 if ( f.getName().startsWith("GL_") ) {
141 try {
142 System.out.println(f.getName() + " - " + f.getBoolean(caps));
143 } catch (IllegalAccessException e) {
144 e.printStackTrace();
145 }
146 }
147 }
148
149 System.out.println();
150
151 // Check for extensions that LWJGL does not support
152 final String extensions = glGetString(GL_EXTENSIONS);
153
154 final StringTokenizer tokenizer = new StringTokenizer(extensions);
155 while ( tokenizer.hasMoreTokens() ) {
156 final String ext = tokenizer.nextToken();
157 try {
158 if ( !caps.getClass().getField(ext).getBoolean(caps) )
159 System.out.println("-- Extension exposed but functions are missing: " + ext);
160 } catch (NoSuchFieldException e) {
161 System.out.println("-- No LWJGL support for extension: " + ext);
162 } catch (Exception e) {
163 e.printStackTrace();
164 }
165 }
166
167 loop();
168
169 destroy();
170 }
171
172 /**
173 *
174 */
175 private void destroy() {
176 program.destroy();
177
178 fsh.destroy();
179 vsh.destroy();
180
181 gear3.destroy();
182 gear2.destroy();
183 gear1.destroy();
184
185 Display.destroy();
186 }
187
188 /**
189 *
190 */
191 private void loop() {
192 long lastFrameTime = Sys.getTime();
193 long startTime = System.currentTimeMillis() + 5000;
194 long fps = 0;
195
196 while ( run ) {
197 if ( !Display.isVisible() )
198 Thread.yield();
199 else {
200 // This is the current frame time.
201 long frameStart = Sys.getTime();
202
203 // How many seconds passed since last frame.
204 final float frameTime = (float)((frameStart - lastFrameTime) / (double)Sys.getTimerResolution());
205 lastFrameTime = frameStart;
206
207 angle += frameTime * 120.0f;
208
209 handleInput();
210
211 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_COVERAGE_BUFFER_BIT_NV);
212 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
213
214 glPushMatrix();
215 glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
216 glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
217 glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
218
219 glPushMatrix();
220 glTranslatef(-3.0f, -2.0f, 0.0f);
221 glRotatef(angle, 0.0f, 0.0f, 1.0f);
222 gear1.render();
223 glPopMatrix();
224
225 glPushMatrix();
226 glTranslatef(3.1f, -2.0f, 0.0f);
227 glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
228 gear2.render();
229 glPopMatrix();
230
231 glPushMatrix();
232 glTranslatef(-3.1f, 4.2f, 0.0f);
233 glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
234 gear3.render();
235 glPopMatrix();
236
237 glPopMatrix();
238
239 try {
240 Display.update();
241 //Display.sync(60);
242 } catch (PowerManagementEventException e) {
243 e.printStackTrace();
244 }
245 if ( startTime > System.currentTimeMillis() ) {
246 fps++;
247 } else {
248 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
249 startTime = System.currentTimeMillis() + 5000;
250 System.out.println(fps + " frames in " + (timeUsed / 1000f) + " seconds = " + (fps / (timeUsed / 1000f)));
251 fps = 0;
252 }
253
254 if ( Display.isCloseRequested() )
255 break;
256 }
257 }
258 }
259
260 private void handleInput() {
261 if ( Keyboard.getNumKeyboardEvents() != 0 ) {
262 while ( Keyboard.next() ) {
263 if ( Keyboard.getEventKeyState() )
264 continue;
265
266 final int key = Keyboard.getEventKey();
267 switch ( key ) {
268 case Keyboard.KEY_ESCAPE:
269 run = false;
270 break;
271 }
272 }
273 }
274
275 while ( Mouse.next() ) ;
276 }
277
278 /**
279 *
280 */
281 private void init() throws LWJGLException {
282 final int WIDTH = 640;
283 final int HEIGHT = 480;
284
285 Display.setLocation((Display.getDisplayMode().getWidth() - WIDTH) / 2,
286 (Display.getDisplayMode().getHeight() - HEIGHT) / 2);
287 try {
288 Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
289 } catch (PowerManagementEventException e) {
290 e.printStackTrace();
291 }
292 Display.setTitle("Gears");
293 Display.create(new PixelFormat());
294
295 //glCoverageMaskNV(true);
296
297 // setup ogl
298 glViewport(0, 0, WIDTH, HEIGHT);
299 glFrontFace(GL_CCW);
300 glCullFace(GL_BACK);
301 glEnable(GL_CULL_FACE);
302 glEnable(GL_DEPTH_TEST);
303
304 final Vector3f lp = new Vector3f(5.0f, 5.0f, 10.0f);
305 lp.normalise();
306 glLight(GL_LIGHT0, GL_POSITION, lp.getX(), lp.getY(), lp.getZ(), 0.0f);
307
308 /* make the gears */
309 gear1 = new Gear(gear(1.0f, 4.0f, 1.0f, 20, 0.7f), new float[] { 0.8f, 0.1f, 0.0f, 1.0f });
310 gear2 = new Gear(gear(0.5f, 2.0f, 2.0f, 10, 0.7f), new float[] { 0.0f, 0.8f, 0.2f, 1.0f });
311 gear3 = new Gear(gear(1.3f, 2.0f, 0.5f, 10, 0.7f), new float[] { 0.2f, 0.2f, 1.0f, 1.0f });
312
313 glMatrixMode(GL_PROJECTION);
314 glLoadIdentity();
315
316 final float h = (float)300 / (float)300;
317 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
318
319 glMatrixMode(GL_MODELVIEW);
320 glLoadIdentity();
321 glTranslatef(0.0f, 0.0f, -40.0f);
322
323 vsh = new Shader(GL_VERTEX_SHADER, "uniform highp vec4 LIGHT_POS;\n" +
324 "uniform highp mat4 MODEL_VIEW_PROJECTION_MATRIX;\n" +
325 "uniform mediump mat3 NORMAL_MATRIX;\n" +
326 "uniform lowp vec3 GEAR_COLOR;\n" +
327 "attribute highp vec3 vPosition;\n" +
328 "attribute mediump vec3 vNormal;\n" +
329 "varying lowp vec3 color;\n" +
330 "void main(void) {\n" +
331 "\tgl_Position = MODEL_VIEW_PROJECTION_MATRIX * vec4(vPosition, 1.0);\n" +
332 "\tvec3 normal = NORMAL_MATRIX * vNormal;\n" +
333 "\tcolor = max(dot(normal, vec3(LIGHT_POS)), 0.0) * GEAR_COLOR + vec3(0.05);\n" +
334 "}");
335
336 fsh = new Shader(GL_FRAGMENT_SHADER, "varying lowp vec3 color;\n" +
337 "void main(void) {\n" +
338 "\tgl_FragColor = vec4(color, 1.0);\n" +
339 "}");
340
341 program = new ShaderProgram(vsh, fsh);
342 program.enable();
343
344 LIGHT_POS = program.getUniformLocation("LIGHT_POS");
345
346 MVP = program.getUniformLocation("MODEL_VIEW_PROJECTION_MATRIX");
347 NM = program.getUniformLocation("NORMAL_MATRIX");
348
349 GEAR_COLOR = program.getUniformLocation("GEAR_COLOR");
350
351 vPosition = program.getAttributeLocation("vPosition");
352 vNormal = program.getAttributeLocation("vNormal");
353
354 glEnableVertexAttribArray(vNormal);
355 glEnableVertexAttribArray(vPosition);
356 }
357
358 /**
359 * Draw a gear wheel. You'll probably want to call this function when
360 * building a display list since we do a lot of trig here.
361 *
362 * @param inner_radius radius of hole at center
363 * @param outer_radius radius at center of teeth
364 * @param width width of gear
365 * @param teeth number of teeth
366 * @param tooth_depth depth of tooth
367 */
368 private static Geometry gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {
369 int i;
370 float r0, r1, r2;
371 float angle, da;
372 float u, v, len;
373
374 r0 = inner_radius;
375 r1 = outer_radius - tooth_depth / 2.0f;
376 r2 = outer_radius + tooth_depth / 2.0f;
377
378 da = 2.0f * (float)Math.PI / teeth / 4.0f;
379
380 final Geometry gear = new Geometry();
381 final ImmediateModeBuffer imb = new ImmediateModeBuffer(1024);
382 int lastDrawIndex = 0;
383
384 //glShadeModel(GL_FLAT);
385
386 // draw front face
387 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, teeth * 4 + 2);
388 for ( i = 0; i <= teeth; i++ ) {
389 angle = i * 2.0f * (float)Math.PI / teeth;
390
391 imb.glNormal3f(0.0f, 0.0f, 1.0f);
392 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
393
394 imb.glNormal3f(0.0f, 0.0f, 1.0f);
395 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
396
397 if ( i < teeth ) {
398 imb.glNormal3f(0.0f, 0.0f, 1.0f);
399 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
400
401 imb.glNormal3f(0.0f, 0.0f, 1.0f);
402 imb.glVertex3f(r1 * cos(angle + 3.0f * da), r1 * sin(angle + 3.0f * da), width * 0.5f);
403 }
404 }
405
406 // draw front sides of teeth
407 for ( i = 0; i < teeth; i++ ) {
408 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, 4);
409
410 angle = i * 2.0f * (float)Math.PI / teeth;
411
412 imb.glNormal3f(0.0f, 0.0f, 1.0f);
413 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
414
415 imb.glNormal3f(0.0f, 0.0f, 1.0f);
416 imb.glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5f);
417
418 imb.glNormal3f(0.0f, 0.0f, 1.0f);
419 imb.glVertex3f(r1 * cos(angle + 3.0f * da), r1 * sin(angle + 3.0f * da), width * 0.5f);
420
421 imb.glNormal3f(0.0f, 0.0f, 1.0f);
422 imb.glVertex3f(r2 * cos(angle + 2.0f * da), r2 * sin(angle + 2.0f * da), width * 0.5f);
423 }
424
425 // draw back face
426 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, (teeth + 1) * 4);
427 for ( i = 0; i <= teeth; i++ ) {
428 angle = i * 2.0f * (float)Math.PI / teeth;
429
430 imb.glNormal3f(0.0f, 0.0f, 1.0f);
431 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
432
433 imb.glNormal3f(0.0f, 0.0f, 1.0f);
434 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
435
436 imb.glNormal3f(0.0f, 0.0f, 1.0f);
437 imb.glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5f);
438
439 imb.glNormal3f(0.0f, 0.0f, 1.0f);
440 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
441 }
442
443 // draw back sides of teeth
444 for ( i = 0; i < teeth; i++ ) {
445 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, 4);
446
447 angle = i * 2.0f * (float)Math.PI / teeth;
448
449 imb.glNormal3f(0.0f, 0.0f, 1.0f);
450 imb.glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5f);
451
452 imb.glNormal3f(0.0f, 0.0f, 1.0f);
453 imb.glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5f);
454
455 imb.glNormal3f(0.0f, 0.0f, 1.0f);
456 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
457
458 imb.glNormal3f(0.0f, 0.0f, 1.0f);
459 imb.glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5f);
460 }
461
462 // draw outward faces of teeth
463 // OpenGL ES 2.0 note: This needs to be converted to a triangle
464 // list with face normals to get the flat look of the original.
465 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, teeth * 8 + 2);
466 for ( i = 0; i < teeth; i++ ) {
467 angle = i * 2.0f * (float)Math.PI / teeth;
468
469 imb.glNormal3f(cos(angle), sin(angle), 0.0f);
470 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
471
472 imb.glNormal3f(cos(angle), sin(angle), 0.0f);
473 imb.glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
474
475 u = r2 * cos(angle + da) - r1 * cos(angle);
476 v = r2 * sin(angle + da) - r1 * sin(angle);
477 len = (float)Math.sqrt(u * u + v * v);
478 u /= len;
479 v /= len;
480
481 imb.glNormal3f(v, -u, 0.0f);
482 imb.glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5f);
483
484 imb.glNormal3f(v, -u, 0.0f);
485 imb.glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5f);
486
487 imb.glNormal3f(cos(angle), sin(angle), 0.0f);
488 imb.glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5f);
489
490 imb.glNormal3f(cos(angle), sin(angle), 0.0f);
491 imb.glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5f);
492
493 u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
494 v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
495
496 imb.glNormal3f(v, -u, 0.0f);
497 imb.glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5f);
498
499 imb.glNormal3f(v, -u, 0.0f);
500 imb.glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5f);
501 }
502 imb.glNormal3f(cos(0), sin(0), 0.0f);
503 imb.glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5f);
504
505 imb.glNormal3f(cos(0), sin(0), 0.0f);
506 imb.glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5f);
507
508 //glShadeModel(GL_SMOOTH);
509
510 // draw inside radius cylinder
511 lastDrawIndex += gear.addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, (teeth + 1) * 2);
512 for ( i = 0; i <= teeth; i++ ) {
513 angle = i * 2.0f * (float)Math.PI / teeth;
514
515 imb.glNormal3f(-cos(angle), -sin(angle), 0.0f);
516 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
517
518 imb.glNormal3f(-cos(angle), -sin(angle), 0.0f);
519 imb.glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
520 }
521
522 gear.update(imb.getBuffer());
523 return gear;
524 }
525
526 private class Gear {
527
528 private final Geometry geom;
529
530 private final float[] color;
531
532 Gear(final Geometry geom, final float[] color) {
533 this.geom = geom;
534 this.color = color;
535 }
536
537 void render() {
538 // Set gear color
539 glUniform3f(GEAR_COLOR, color[0], color[1], color[2]);
540
541 // Set Light position
542 setUniform4f(LIGHT_POS, GL_LIGHT0, GL_POSITION);
543
544 // Get Projection and Modelview matrices
545 glMatrixMode(GL_PROJECTION);
546 glGetMatrix(p);
547
548 glMatrixMode(GL_MODELVIEW);
549 glGetMatrix(mv);
550
551 // Set MVP uniform
552 Matrix4f.mul(p, mv, mvp);
553 mvp.store(m4fBuffer);
554 m4fBuffer.flip();
555 glUniformMatrix4(MVP, false, m4fBuffer);
556
557 // Set normal matrix (upper-left 3x3 of the inverse transpose MV matrix)
558 mv.invert();
559 mv.transpose();
560 mv.store3f(m3fBuffer);
561 m3fBuffer.flip();
562 glUniformMatrix3(NM, false, m3fBuffer);
563
564 geom.bind();
565
566 final int stride = (3 + 3) * 4;
567 glVertexAttribPointer(vNormal, 3, GL_FLOAT, false, stride, 0);
568 glVertexAttribPointer(vPosition, 3, GL_FLOAT, false, stride, 3 * 4);
569
570 geom.draw();
571 }
572
573 void destroy() {
574 geom.destroy();
575 }
576
577 }
578
579 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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.opengles;
42
43 import org.lwjgl.BufferUtils;
44 import org.lwjgl.Sys;
45 import org.lwjgl.input.Keyboard;
46 import org.lwjgl.input.Mouse;
47 import org.lwjgl.opengl.Display;
48 import org.lwjgl.opengl.DisplayMode;
49 import org.lwjgl.opengles.GLContext;
50 import org.lwjgl.opengles.PixelFormat;
51
52 import java.nio.ByteBuffer;
53 import java.nio.FloatBuffer;
54 import java.nio.IntBuffer;
55
56 import static org.lwjgl.opengles.GLES20.*;
57 import static org.lwjgl.opengles.OESMapbuffer.*;
58 import static org.lwjgl.test.opengles.util.GLMatrix.*;
59
60 public final class MappedIndexedVBOTest {
61
62 static {
63 try {
64 //find first display mode that allows us 640*480*16
65 int mode = -1;
66 DisplayMode[] modes = Display.getAvailableDisplayModes();
67 for ( int i = 0; i < modes.length; i++ ) {
68 if ( modes[i].getWidth() == 640
69 && modes[i].getHeight() == 480
70 && modes[i].getBitsPerPixel() >= 16 ) {
71 mode = i;
72 break;
73 }
74 }
75 if ( mode != -1 ) {
76 //select above found displaymode
77 System.out.println("Setting display mode to " + modes[mode]);
78 Display.setDisplayMode(modes[mode]);
79 System.out.println("Created display.");
80 }
81 } catch (Exception e) {
82 System.err.println("Failed to create display due to " + e);
83 }
84 }
85
86 static {
87 try {
88 Display.create(new PixelFormat());
89 System.out.println("Created OpenGL.");
90
91 if ( !GLContext.getCapabilities().GL_OES_mapbuffer ) {
92 System.out.println("GL_OES_mapbuffer is not supported, quitting!");
93 System.exit(0);
94 }
95 } catch (Exception e) {
96 System.err.println("Failed to create OpenGL due to " + e);
97 System.exit(1);
98 }
99 }
100
101 /** Is the game finished? */
102 private static boolean finished;
103
104 /** A rotating square! */
105 private static float angle;
106 private static int buffer_id;
107 private static int indices_buffer_id;
108 private static FloatBuffer vertices;
109 private static ByteBuffer mapped_buffer;
110 private static FloatBuffer mapped_float_buffer;
111 private static IntBuffer indices;
112 private static ByteBuffer mapped_indices_buffer;
113 private static IntBuffer mapped_indices_int_buffer;
114
115 private static QuadRenderer renderer;
116
117 public static void main(String[] arguments) {
118 try {
119 init();
120 while ( !finished ) {
121 Display.update();
122 Display.sync(30);
123
124 if ( !Display.isVisible() )
125 Thread.sleep(200);
126 else if ( Display.isCloseRequested() )
127 System.exit(0);
128
129 mainLoop();
130 render();
131 }
132 } catch (Throwable t) {
133 t.printStackTrace();
134 } finally {
135 cleanup();
136 }
137 System.exit(0);
138 }
139
140 /** All calculations are done in here */
141 private static void mainLoop() {
142 angle += 1f;
143 if ( angle > 360.0f )
144 angle = 0.0f;
145
146 if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
147 System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
148 for ( int i = 0; i < Mouse.getButtonCount(); i++ )
149 if ( Mouse.isButtonDown(i) )
150 System.out.println("Button " + i + " down");
151 if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
152 finished = true;
153 for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
154 Keyboard.next();
155 if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
156 finished = true;
157 if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
158 System.out.println("Current time: " + Sys.getTime());
159 }
160 }
161
162 /** All rendering is done in here */
163 private static void render() {
164 glClear(GL_COLOR_BUFFER_BIT);
165
166 glPushMatrix();
167 glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
168 glRotatef(angle, 0, 0, 1.0f);
169
170 renderer.setMVPUniform();
171
172 ByteBuffer new_mapped_buffer = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES, mapped_buffer);
173 if ( new_mapped_buffer != mapped_buffer ) {
174 mapped_buffer = new_mapped_buffer;
175 mapped_float_buffer = new_mapped_buffer.asFloatBuffer();
176 }
177
178 new_mapped_buffer = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES, mapped_indices_buffer);
179 if ( new_mapped_buffer != mapped_indices_buffer ) {
180 mapped_indices_buffer = new_mapped_buffer;
181 mapped_indices_int_buffer = new_mapped_buffer.asIntBuffer();
182 }
183
184 mapped_float_buffer.rewind();
185 vertices.rewind();
186 mapped_float_buffer.put(vertices);
187
188 mapped_indices_int_buffer.rewind();
189 indices.rewind();
190 mapped_indices_int_buffer.put(indices);
191 if ( glUnmapBufferOES(GL_ARRAY_BUFFER) &&
192 glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER) ) {
193 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
194 }
195
196 glPopMatrix();
197 }
198
199 /** Initialize */
200 private static void init() throws Exception {
201 System.out.println("Timer resolution: " + Sys.getTimerResolution());
202
203 // Go into orthographic projection mode.
204 glMatrixMode(GL_PROJECTION);
205 glLoadIdentity();
206 glOrtho(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight(), -1.0f, 1.0f);
207
208 glMatrixMode(GL_MODELVIEW);
209 glLoadIdentity();
210 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
211
212 final IntBuffer int_buffer = BufferUtils.createIntBuffer(2);
213 glGenBuffers(int_buffer);
214 buffer_id = int_buffer.get(0);
215 indices_buffer_id = int_buffer.get(1);
216
217 glBindBuffer(GL_ARRAY_BUFFER, buffer_id);
218 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer_id);
219
220 vertices = BufferUtils.createFloatBuffer(2 * 4);
221 vertices
222 .put(-50).put(-50)
223 .put(50).put(-50)
224 .put(-50).put(50)
225 .put(50).put(50);
226 vertices.rewind();
227
228 indices = BufferUtils.createIntBuffer(4);
229 indices.put(0).put(1).put(2).put(3);
230 indices.rewind();
231
232 glBufferData(GL_ARRAY_BUFFER, 2 * 4 * 4, GL_STREAM_DRAW);
233 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * 4, GL_STREAM_DRAW);
234
235 renderer = new QuadRenderer();
236 }
237
238 /** Cleanup */
239 private static void cleanup() {
240 renderer.cleanup();
241
242 IntBuffer int_buffer = BufferUtils.createIntBuffer(2);
243 int_buffer.put(0, buffer_id);
244 int_buffer.put(1, indices_buffer_id);
245
246 glDeleteBuffers(int_buffer);
247
248 Display.destroy();
249 }
250
251 }
0 package org.lwjgl.test.opengles;
1
2 import org.lwjgl.BufferUtils;
3 import org.lwjgl.test.opengles.util.Shader;
4 import org.lwjgl.test.opengles.util.ShaderProgram;
5 import org.lwjgl.util.vector.Matrix4f;
6
7 import java.nio.FloatBuffer;
8
9 import static org.lwjgl.opengles.GLES20.*;
10 import static org.lwjgl.test.opengles.util.GLMatrix.*;
11
12 final class QuadRenderer {
13
14 private final Shader vsh;
15 private final Shader fsh;
16 private final ShaderProgram program;
17
18 private final int uniMVP;
19
20 private final Matrix4f p = new Matrix4f();
21 private final Matrix4f mv = new Matrix4f();
22 private final Matrix4f mvp = new Matrix4f();
23
24 private final FloatBuffer m4fBuffer = BufferUtils.createFloatBuffer(4 * 4);
25
26 QuadRenderer() {
27 vsh = new Shader(GL_VERTEX_SHADER, "uniform highp mat4 MODEL_VIEW_PROJECTION_MATRIX;\n" +
28 "attribute highp vec2 vPosition;\n" +
29 "void main(void) {\n" +
30 "\tgl_Position = MODEL_VIEW_PROJECTION_MATRIX * vec4(vPosition, 0.0, 1.0);\n" +
31 "}");
32
33 fsh = new Shader(GL_FRAGMENT_SHADER, "void main(void) {\n" +
34 "\tgl_FragColor = vec4(1.0);\n" +
35 "}");
36
37 program = new ShaderProgram(vsh, fsh);
38 program.enable();
39
40 uniMVP = program.getUniformLocation("MODEL_VIEW_PROJECTION_MATRIX");
41
42 final int vPosition = program.getAttributeLocation("vPosition");
43 glVertexAttribPointer(vPosition, 2, GL_FLOAT, false, 0, 0);
44 glEnableVertexAttribArray(vPosition);
45 }
46
47 void setMVPUniform() {
48 // Get Projection and Modelview matrices
49 glMatrixMode(GL_PROJECTION);
50 glGetMatrix(p);
51
52 glMatrixMode(GL_MODELVIEW);
53 glGetMatrix(mv);
54
55 // Set MVP uniform
56 Matrix4f.mul(p, mv, mvp);
57 mvp.store(m4fBuffer);
58 m4fBuffer.flip();
59 glUniformMatrix4(uniMVP, false, m4fBuffer);
60 }
61
62 void cleanup() {
63 program.destroy();
64
65 fsh.destroy();
66 vsh.destroy();
67 }
68
69 }
0 package org.lwjgl.test.opengles.util;
1
2 import java.nio.*;
3
4 import static org.lwjgl.opengles.GLES20.*;
5 import static org.lwjgl.opengles.OESMapbuffer.*;
6
7 abstract class BufferObject implements GLObject {
8
9 protected final int ID;
10
11 protected int target;
12 protected int usage;
13
14 /** The BufferObject data size in bytes. */
15 private int size;
16
17 protected BufferObject(final int type, final int usage) {
18 this.ID = glGenBuffers();
19 this.target = type;
20 this.usage = usage;
21 }
22
23 protected BufferObject(final int type, final int usage, final Buffer buffer) {
24 this(type, usage);
25 setData(buffer);
26 }
27
28 protected BufferObject(final int type, final int usage, final int dataSize) {
29 this(type, usage);
30 setData(dataSize);
31 }
32
33 public final int getID() {
34 return ID;
35 }
36
37 public void destroy() {
38 glDeleteBuffers(ID);
39 }
40
41 public final int getTarget() {
42 return target;
43 }
44
45 public final int getUsage() {
46 return usage;
47 }
48
49 public final int getSize() {
50 return size;
51 }
52
53 public abstract void enable();
54
55 public abstract void disable();
56
57 public final void setData(final Buffer buffer) {
58 enable();
59
60 if ( buffer instanceof ByteBuffer ) {
61 glBufferData(target, (ByteBuffer)buffer, usage);
62 size = buffer.remaining();
63 } else if ( buffer instanceof ShortBuffer ) {
64 glBufferData(target, (ShortBuffer)buffer, usage);
65 size = buffer.remaining() << 1;
66 } else if ( buffer instanceof IntBuffer ) {
67 glBufferData(target, (IntBuffer)buffer, usage);
68 size = buffer.remaining() << 2;
69 } else if ( buffer instanceof FloatBuffer ) {
70 glBufferData(target, (FloatBuffer)buffer, usage);
71 size = buffer.remaining() << 2;
72 }
73
74 disable();
75 }
76
77 public final void setData(final int dataSize) {
78 enable();
79
80 glBufferData(target, dataSize, usage);
81 size = dataSize;
82
83 disable();
84 }
85
86 public final ByteBuffer map(final int access, final ByteBuffer oldBuffer) {
87 return glMapBufferOES(target, access, oldBuffer);
88 }
89
90 public final ByteBuffer map(final int access, final int length, final ByteBuffer oldBuffer) {
91 return glMapBufferOES(target, access, length, oldBuffer);
92 }
93
94 public final boolean unmap() {
95 return glUnmapBufferOES(target);
96 }
97
98 }
0 package org.lwjgl.test.opengles.util;
1
2 import java.nio.Buffer;
3
4 import static org.lwjgl.opengles.GLES20.*;
5
6 public final class BufferObjectArray extends BufferObject {
7
8 private static int boundBOArray;
9
10 public BufferObjectArray(final int usage) {
11 super(GL_ARRAY_BUFFER, usage);
12 }
13
14 public BufferObjectArray(final int usage, final Buffer buffer) {
15 super(GL_ARRAY_BUFFER, usage, buffer);
16 }
17
18 public BufferObjectArray(final int usage, final int dataSize) {
19 super(GL_ARRAY_BUFFER, usage, dataSize);
20 }
21
22 public void enable() {
23 if ( boundBOArray != ID ) {
24 glBindBuffer(GL_ARRAY_BUFFER, ID);
25 boundBOArray = ID;
26 }
27 }
28
29 public void disable() {
30 boArrayDisable();
31 }
32
33 public static void boArrayDisable() {
34 if ( boundBOArray != 0 ) {
35 glBindBuffer(GL_ARRAY_BUFFER, 0);
36 boundBOArray = 0;
37 }
38 }
39
40 }
0 package org.lwjgl.test.opengles.util;
1
2 import java.nio.Buffer;
3
4 import static org.lwjgl.opengles.GLES20.*;
5
6 public final class BufferObjectElement extends BufferObject {
7
8 private static int boundBOElementArray;
9
10 public BufferObjectElement(final int usage) {
11 super(GL_ELEMENT_ARRAY_BUFFER, usage);
12 }
13
14 public BufferObjectElement(final int usage, final Buffer buffer) {
15 super(GL_ELEMENT_ARRAY_BUFFER, usage, buffer);
16 }
17
18 public BufferObjectElement(final int usage, final int dataSize) {
19 super(GL_ELEMENT_ARRAY_BUFFER, usage, dataSize);
20 }
21
22 public void enable() {
23 if ( boundBOElementArray != ID ) {
24 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
25 boundBOElementArray = ID;
26 }
27 }
28
29 public void disable() {
30 boElementArrayDisable();
31 }
32
33 public static void boElementArrayDisable() {
34 if ( boundBOElementArray != 0 ) {
35 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
36 boundBOElementArray = 0;
37 }
38 }
39
40 }
0 package org.lwjgl.test.opengles.util;
1
2 import static org.lwjgl.opengles.GLES20.*;
3
4 /** Emulates the light state in fixed-function OpenGL. */
5 public class GLLight {
6
7 public static final int GL_LIGHT0 = 0x4000;
8 public static final int GL_LIGHT1 = 0x4001;
9 public static final int GL_LIGHT2 = 0x4002;
10 public static final int GL_LIGHT3 = 0x4003;
11 public static final int GL_LIGHT4 = 0x4004;
12 public static final int GL_LIGHT5 = 0x4005;
13 public static final int GL_LIGHT6 = 0x4006;
14 public static final int GL_LIGHT7 = 0x4007;
15
16 public static final int GL_AMBIENT = 0x1200;
17 public static final int GL_DIFFUSE = 0x1201;
18 public static final int GL_SPECULAR = 0x1202;
19 public static final int GL_POSITION = 0x1203;
20 public static final int GL_SPOT_DIRECTION = 0x1204;
21 public static final int GL_SPOT_EXPONENT = 0x1205;
22 public static final int GL_SPOT_CUTOFF = 0x1206;
23 public static final int GL_CONSTANT_ATTENUATION = 0x1207;
24 public static final int GL_LINEAR_ATTENUATION = 0x1208;
25 public static final int GL_QUADRATIC_ATTENUATION = 0x1209;
26
27 private static final Light[] lights = new Light[8];
28
29 static {
30 for ( int i = 0; i < lights.length; i++ )
31 lights[i] = new Light();
32
33 System.arraycopy(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }, 0, lights[0].diffuse, 0, 4);
34 System.arraycopy(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }, 0, lights[0].specular, 0, 4);
35 }
36
37 private GLLight() {
38 }
39
40 public static void glLight(final int light, final int pname, final float v) {
41 if ( light < GL_LIGHT0 || GL_LIGHT7 < light )
42 throw new IllegalArgumentException("Invalid light specified: " + light);
43
44 final Light l = lights[light - GL_LIGHT0];
45
46 switch ( pname ) {
47 case GL_SPOT_EXPONENT:
48 l.s = v;
49 break;
50 case GL_SPOT_CUTOFF:
51 l.c = v;
52 break;
53 case GL_CONSTANT_ATTENUATION:
54 l.k0 = v;
55 break;
56 case GL_LINEAR_ATTENUATION:
57 l.k1 = v;
58 break;
59 case GL_QUADRATIC_ATTENUATION:
60 l.k2 = v;
61 break;
62 default:
63 throw new IllegalArgumentException("Invalid light parameter specified: " + pname);
64 }
65 }
66
67 public static void glLight(final int light, final int pname,
68 final float x, final float y, final float z) {
69 if ( light < GL_LIGHT0 || GL_LIGHT7 < light )
70 throw new IllegalArgumentException("Invalid light specified: " + light);
71
72 if ( pname != GL_SPOT_DIRECTION )
73 throw new IllegalArgumentException("Invalid light parameter specified: " + pname);
74
75 final float[] param = lights[light - GL_LIGHT0].direction;
76
77 param[0] = x;
78 param[1] = y;
79 param[2] = z;
80 }
81
82 private static float[] getParam4f(final int light, final int pname) {
83 if ( light < GL_LIGHT0 || GL_LIGHT7 < light )
84 throw new IllegalArgumentException("Invalid light specified: " + light);
85
86 final Light l = lights[light - GL_LIGHT0];
87 switch ( pname ) {
88 case GL_AMBIENT:
89 return l.ambient;
90 case GL_DIFFUSE:
91 return l.diffuse;
92 case GL_SPECULAR:
93 return l.specular;
94 case GL_POSITION:
95 return l.position;
96 default:
97 throw new IllegalArgumentException("Invalid light parameter specified: " + pname);
98 }
99 }
100
101 public static void glLight(final int light, final int pname,
102 final float x, final float y, final float z, final float w) {
103 final float[] param = getParam4f(light, pname);
104 param[0] = x;
105 param[1] = y;
106 param[2] = z;
107 param[3] = w;
108 }
109
110 public static void setUniform1f(final int location, final int light, final int pname) {
111 if ( light < GL_LIGHT0 || GL_LIGHT7 < light )
112 throw new IllegalArgumentException("Invalid light specified: " + light);
113
114 final Light l = lights[light - GL_LIGHT0];
115
116 switch ( pname ) {
117 case GL_SPOT_EXPONENT:
118 glUniform1f(location, l.s);
119 break;
120 case GL_SPOT_CUTOFF:
121 glUniform1f(location, l.c);
122 break;
123 case GL_CONSTANT_ATTENUATION:
124 glUniform1f(location, l.k0);
125 break;
126 case GL_LINEAR_ATTENUATION:
127 glUniform1f(location, l.k1);
128 break;
129 case GL_QUADRATIC_ATTENUATION:
130 glUniform1f(location, l.k2);
131 break;
132 default:
133 throw new IllegalArgumentException("Invalid light parameter specified: " + pname);
134 }
135 }
136
137 public static void setUniform3f(final int location, final int light, final int pname) {
138 if ( pname != GL_SPOT_DIRECTION )
139 throw new IllegalArgumentException("Invalid light parameter specified: " + pname);
140
141 final float[] param = lights[light - GL_LIGHT0].direction;
142 glUniform3f(location, param[0], param[1], param[2]);
143 }
144
145 public static void setUniform4f(final int location, final int light, final int pname) {
146 final float[] param = getParam4f(light, pname);
147 glUniform4f(location, param[0], param[1], param[2], param[3]);
148 }
149
150 private static class Light {
151
152 float[] ambient = { 0.0f, 0.0f, 0.0f, 1.0f };
153 float[] diffuse = { 0.0f, 0.0f, 0.0f, 1.0f };
154 float[] specular = { 0.0f, 0.0f, 0.0f, 1.0f };
155
156 float[] position = { 0.0f, 0.0f, 1.0f, 0.0f };
157 float[] direction = { 0.0f, 0.0f, -1.0f };
158
159 float s, c = 180.0f;
160 float k0 = 1.0f, k1, k2;
161
162 }
163
164 }
0 package org.lwjgl.test.opengles.util;
1
2 import org.lwjgl.util.vector.Matrix4f;
3 import org.lwjgl.util.vector.Vector3f;
4
5 import java.util.Stack;
6
7 import static java.lang.Math.*;
8
9 /** Emulates the matrix stack in fixed-function OpenGL. */
10 public final class GLMatrix {
11
12 public static final int GL_MODELVIEW = 0x1700;
13 public static final int GL_PROJECTION = 0x1701;
14
15 private static final float PI = (float)Math.PI;
16
17 /** The model/view matrix stack. */
18 private static final Stack<Matrix4f> mvMatrixStack = new Stack<Matrix4f>();
19
20 /** The projection matrix stack. */
21 private static final Stack<Matrix4f> pMatrixStack = new Stack<Matrix4f>();
22
23 private static final Matrix4f m4f = new Matrix4f();
24 private static final Vector3f v3f = new Vector3f();
25
26 private static int mode = GL_MODELVIEW;
27
28 static {
29 mvMatrixStack.push(new Matrix4f());
30 pMatrixStack.push(new Matrix4f());
31 }
32
33 private GLMatrix() {
34 }
35
36 private static Stack<Matrix4f> getCurrentStack() {
37 switch ( mode ) {
38 case GL_MODELVIEW:
39 return mvMatrixStack;
40 case GL_PROJECTION:
41 return pMatrixStack;
42 default:
43 return null; // Cannot happen
44 }
45 }
46
47 private static Matrix4f getCurrentMatrix() {
48 return getCurrentStack().peek();
49 }
50
51 public static void glMatrixMode(final int mode) {
52 if ( mode != GL_MODELVIEW && mode != GL_PROJECTION )
53 throw new IllegalArgumentException("Invalid matrix mode specified: " + mode);
54
55 GLMatrix.mode = mode;
56 }
57
58 public static void glPushMatrix() {
59 final Stack<Matrix4f> stack = getCurrentStack();
60 stack.push(new Matrix4f(stack.peek()));
61 }
62
63 public static void glPopMatrix() {
64 final Stack<Matrix4f> stack = getCurrentStack();
65
66 if ( stack.size() == 1 )
67 throw new IllegalStateException("The last matrix in the stack cannot be popped.");
68
69 getCurrentStack().pop();
70 }
71
72 public static void glLoadIdentity() {
73 final Matrix4f m = getCurrentMatrix();
74 m.setIdentity();
75 }
76
77 public static void glLoadMatrix(final Matrix4f s) {
78 getCurrentMatrix().load(s);
79 }
80
81 public static void glMultMatrix(final Matrix4f m) {
82 final Matrix4f c = getCurrentMatrix();
83 Matrix4f.mul(c, m, c);
84 }
85
86 public static void glTranslatef(final float x, final float y, final float z) {
87 final Matrix4f m = getCurrentMatrix();
88 v3f.set(x, y, z);
89 m.translate(v3f);
90 }
91
92 public static void glRotatef(final float angle, final float x, final float y, final float z) {
93 final Matrix4f m = getCurrentMatrix();
94 v3f.set(x, y, z);
95 m.rotate((float)toRadians(angle), v3f);
96 }
97
98 public static void glOrtho(final float l, final float r, final float b, final float t, final float n, final float f) {
99 final Matrix4f m = m4f;
100 m.setIdentity();
101
102 m.m00 = 2.0f / (r - l);
103 m.m30 = -(r + l) / (r - l);
104
105 m.m11 = 2.0f / (t - b);
106 m.m31 = -(t + b) / (t - b);
107
108 m.m22 = -2.0f / (f - n);
109 m.m32 = -(f + n) / (f - n);
110
111 glMultMatrix(m);
112 }
113
114 public static void glFrustum(final float l, final float r, final float b, final float t, final float n, final float f) {
115 final Matrix4f m = m4f;
116 m.setIdentity();
117
118 m.m00 = 2.0f * n / (r - l);
119 m.m20 = (r + l) / (r - l);
120
121 m.m11 = 2.0f * n / (t - b);
122 m.m21 = (t + b) / (t - b);
123
124 m.m22 = -(f + n) / (f - n);
125 m.m32 = -(2.0f * f * n) / (f - n);
126
127 m.m23 = -1.0f;
128 m.m33 = 0.0f;
129
130 glMultMatrix(m);
131 }
132
133 public static void gluPerspective(final float fovy, final float aspect, final float zNear, final float zFar) {
134 final float radians = fovy / 2.0f * PI / 180.0f;
135
136 final float deltaZ = zFar - zNear;
137 final float sine = (float)sin(radians);
138
139 if ( (deltaZ == 0) || (sine == 0) || (aspect == 0) ) {
140 return;
141 }
142
143 final float cotangent = (float)cos(radians) / sine;
144
145 final Matrix4f m = m4f;
146 m.setIdentity();
147
148 m.m00 = cotangent / aspect;
149 m.m11 = cotangent;
150 m.m22 = -(zFar + zNear) / deltaZ;
151 m.m23 = -1.0f;
152 m.m32 = -2 * zNear * zFar / deltaZ;
153 m.m33 = 0.0f;
154
155 glMultMatrix(m);
156 }
157
158 public static void glGetMatrix(final Matrix4f d) {
159 d.load(getCurrentMatrix());
160 }
161
162 }
0 package org.lwjgl.test.opengles.util;
1
2 public interface GLObject {
3
4 int getID();
5
6 void destroy();
7
8 }
0 package org.lwjgl.test.opengles.util;
1
2 import org.lwjgl.test.opengles.util.BufferObjectArray;
3
4 import java.nio.FloatBuffer;
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import static org.lwjgl.opengles.GLES20.*;
9
10 public class Geometry {
11
12 protected BufferObjectArray bo;
13
14 protected final List<DrawCommand> drawCommands = new ArrayList<DrawCommand>(4);
15
16 public Geometry() {
17 }
18
19 public Geometry(final FloatBuffer buffer) {
20 update(buffer);
21 }
22
23 public void update(final FloatBuffer buffer) {
24 if ( bo != null )
25 destroy();
26
27 bo = new BufferObjectArray(GL_STATIC_DRAW, buffer);
28 }
29
30 public void bind() {
31 bo.enable();
32 }
33
34 public void draw() {
35 for ( DrawCommand command : drawCommands )
36 command.draw();
37 }
38
39 public void destroy() {
40 bo.destroy();
41 bo = null;
42
43 drawCommands.clear();
44 }
45
46 public int addDrawCommand(final int mode, final int first, final int count) {
47 drawCommands.add(new DrawCommand(mode, first, count));
48 return count;
49 }
50
51 public static float sin(final float r) {
52 return (float)Math.sin(r);
53 }
54
55 public static float cos(final float r) {
56 return (float)Math.cos(r);
57 }
58
59 protected static class DrawCommand {
60
61 private int mode;
62 private int first;
63 private int count;
64
65 private DrawCommand(final int mode, final int first, final int count) {
66 this.mode = mode;
67 this.first = first;
68 this.count = count;
69 }
70
71 void draw() {
72 glDrawArrays(mode, first, count);
73 }
74
75 }
76
77 }
0 package org.lwjgl.test.opengles.util;
1
2 import org.lwjgl.BufferUtils;
3
4 import java.nio.FloatBuffer;
5
6 /**
7 * Utility class that emulates immediate mode vertex data submission.
8 * Can be used to create VBO data.
9 */
10 public final class ImmediateModeBuffer {
11
12 private FloatBuffer buffer;
13
14 public ImmediateModeBuffer(final int startSize) {
15 this.buffer = BufferUtils.createFloatBuffer(startSize);
16 }
17
18 private void checkSize(final int count) {
19 while ( buffer.remaining() < count ) {
20 final FloatBuffer newBuffer = BufferUtils.createFloatBuffer(buffer.capacity() << 1);
21 buffer.flip();
22 newBuffer.put(buffer);
23 buffer = newBuffer;
24 }
25 }
26
27 public FloatBuffer getBuffer() {
28 buffer.flip();
29 return buffer;
30 }
31
32 public void glVertex2f(final float x, final float y) {
33 checkSize(2);
34 buffer.put(x).put(y);
35 }
36
37 public void glVertex3f(final float x, final float y, final float z) {
38 checkSize(3);
39 buffer.put(x).put(y).put(z);
40 }
41
42 public void glVertex4f(final float x, final float y, final float z, final float w) {
43 checkSize(4);
44 buffer.put(x).put(y).put(z).put(w);
45 }
46
47 public void glNormal3f(final float x, final float y, final float z) {
48 checkSize(3);
49 buffer.put(x).put(y).put(z);
50 }
51
52 public void glTexCoord2f(final float s, final float t) {
53 checkSize(2);
54 buffer.put(s).put(t);
55 }
56
57 }
0 package org.lwjgl.test.opengles.util;
1
2 import org.lwjgl.BufferUtils;
3
4 import java.io.BufferedInputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.nio.ByteBuffer;
8
9 import static org.lwjgl.opengles.GLES20.*;
10
11 public class Shader implements GLObject {
12
13 protected static ByteBuffer fileBuffer = BufferUtils.createByteBuffer(1024 * 10);
14
15 private int type;
16 private int ID;
17
18 public Shader() {
19 }
20
21 public Shader(final int type, final CharSequence source) {
22 createFromSource(type, source);
23 }
24
25 public int getID() {
26 return ID;
27 }
28
29 public int getType() {
30 return type;
31 }
32
33 public void destroy() {
34 if ( ID == 0 )
35 throw new IllegalStateException("The shader has not been created");
36
37 glDeleteShader(ID);
38 ID = 0;
39 }
40
41 public void createFromFile(final int type, final ClassLoader loader, final String file) throws IOException {
42 final InputStream inputStream = loader.getResourceAsStream(file);
43
44 if ( inputStream == null )
45 throw new IllegalArgumentException("A shader source file could not be found: " + file);
46
47 final BufferedInputStream stream = new BufferedInputStream(inputStream);
48
49 byte character;
50 while ( (character = (byte)stream.read()) != -1 )
51 fileBuffer.put(character);
52 fileBuffer.flip();
53
54 stream.close();
55
56 final byte[] array = new byte[fileBuffer.remaining()];
57 fileBuffer.get(array);
58
59 final String source = new String(array);
60
61 fileBuffer.clear();
62
63 createFromSource(type, source);
64 }
65
66 public void createFromSource(final int type, final CharSequence source) {
67 if ( ID != 0 )
68 throw new IllegalStateException("The shader has already been created");
69
70 this.type = type;
71 this.ID = glCreateShader(type);
72
73 glShaderSource(ID, source);
74
75 glCompileShader(ID);
76
77 if ( glGetShaderi(ID, GL_COMPILE_STATUS) == GL_FALSE ) {
78 printInfoLog();
79 destroy();
80 throw new RuntimeException("A compilation error occured in a shader.");
81 }
82 }
83
84 public void printInfoLog() {
85 if ( ID == 0 )
86 throw new IllegalStateException("The shader has not been created");
87
88 final int logLength = glGetShaderi(ID, GL_INFO_LOG_LENGTH);
89 if ( logLength <= 1 )
90 return;
91
92 System.out.println("\nInfo Log of Shader Object: " + ID);
93 System.out.println("--------------------------");
94 System.out.println(glGetShaderInfoLog(ID, logLength));
95 }
96
97 }
0 package org.lwjgl.test.opengles.util;
1
2 import static org.lwjgl.opengles.GLES20.*;
3
4 public class ShaderProgram implements GLObject {
5
6 private final int ID;
7
8 public ShaderProgram(final Shader... shaders) {
9 this.ID = glCreateProgram();
10
11 for ( Shader shader : shaders )
12 glAttachShader(ID, shader.getID());
13
14 glLinkProgram(ID);
15
16 if ( glGetProgrami(ID, GL_LINK_STATUS) == GL_FALSE ) {
17 printInfoLog();
18 destroy();
19 throw new RuntimeException("Failed to link a Shader Program: " + ID);
20 }
21 }
22
23 public void validate() {
24 glValidateProgram(ID);
25
26 final boolean error = glGetProgrami(ID, GL_VALIDATE_STATUS) == GL_FALSE;
27
28 if ( error ) {
29 printInfoLog();
30 throw new RuntimeException("Failed to validate a Shader Program.");
31 }
32 }
33
34 public int getID() {
35 return ID;
36 }
37
38 public void destroy() {
39 glDeleteProgram(ID);
40 }
41
42 public void enable() {
43 glUseProgram(ID);
44 }
45
46 public static void disable() {
47 glUseProgram(0);
48 }
49
50 public int getUniformLocation(final String uniform) {
51 final int location = glGetUniformLocation(ID, uniform);
52
53 if ( location == -1 )
54 throw new IllegalArgumentException("Invalid uniform name specified: " + uniform);
55
56 return location;
57 }
58
59 public int getAttributeLocation(final String attrib) {
60 final int location = glGetAttribLocation(ID, attrib);
61
62 if ( location == -1 )
63 throw new IllegalArgumentException("Invalid attribute name specified: " + attrib);
64
65 return location;
66 }
67
68 private void printInfoLog() {
69 final int logLength = glGetProgrami(ID, GL_INFO_LOG_LENGTH);
70
71 System.out.println(logLength);
72 if ( logLength <= 1 )
73 return;
74
75 System.out.println("\nInfo Log of Shader Program: " + ID);
76 System.out.println("-------------------");
77 System.out.println(glGetProgramInfoLog(ID, logLength));
78 System.out.println("-------------------");
79 }
80
81 }
0 package org.lwjgl.test.opengles.util;
1
2 import java.nio.FloatBuffer;
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import static org.lwjgl.opengles.GLES20.*;
7
8 /** VBO implementation of GLU Sphere. */
9 public final class Sphere {
10
11 /* QuadricNormal */
12 public static final int GLU_SMOOTH = 100000;
13 public static final int GLU_FLAT = 100001;
14 public static final int GLU_NONE = 100002;
15
16 /* QuadricDrawStyle */
17 public static final int GLU_POINT = 100010;
18 public static final int GLU_LINE = 100011;
19 public static final int GLU_FILL = 100012;
20 public static final int GLU_SILHOUETTE = 100013;
21
22 /* QuadricOrientation */
23 public static final int GLU_OUTSIDE = 100020;
24 public static final int GLU_INSIDE = 100021;
25
26 static final float PI = (float)Math.PI;
27
28 private int drawStyle;
29 private int orientation;
30 private boolean textureFlag;
31 private int normals;
32
33 private BufferObjectArray bo;
34
35 private final List<DrawCommand> drawCommands = new ArrayList<DrawCommand>(4);
36
37 public Sphere() {
38 this(GLU_FILL, GLU_OUTSIDE, false, GLU_SMOOTH);
39 }
40
41 public Sphere(final int drawStyle, final int orientation, final boolean textureFlag, final int normals) {
42 setDrawStyle(drawStyle);
43 setOrientation(orientation);
44 setTextureFlag(textureFlag);
45 setNormals(normals);
46 }
47
48 public Sphere(final float radius, final int slices, final int stacks) {
49 this();
50 updateGeometry(radius, slices, stacks);
51 }
52
53 public Sphere(final float radius, final int slices, final int stacks,
54 final int drawStyle, final int orientation, final boolean textureFlag, final int normals) {
55 this(drawStyle, orientation, textureFlag, normals);
56 updateGeometry(radius, slices, stacks);
57 }
58
59 public void updateGeometry(final float radius, final int slices, final int stacks) {
60 if ( bo != null )
61 destroy();
62
63 bo = new BufferObjectArray(GL_STATIC_DRAW, createBuffer(radius, slices, stacks));
64 }
65
66 public void bind() {
67 bo.enable();
68 }
69
70 public void draw() {
71 for ( DrawCommand command : drawCommands )
72 command.draw();
73 }
74
75 public void destroy() {
76 bo.destroy();
77 bo = null;
78
79 drawCommands.clear();
80 }
81
82 /**
83 * specifies the draw style for quadrics.
84 * <p/>
85 * The legal values are as follows:
86 * <p/>
87 * GLU.FILL: Quadrics are rendered with polygon primitives. The polygons
88 * are drawn in a counterclockwise fashion with respect to
89 * their normals (as defined with glu.quadricOrientation).
90 * <p/>
91 * GLU.LINE: Quadrics are rendered as a set of lines.
92 * <p/>
93 * GLU.SILHOUETTE: Quadrics are rendered as a set of lines, except that edges
94 * separating coplanar faces will not be drawn.
95 * <p/>
96 * GLU.POINT: Quadrics are rendered as a set of points.
97 *
98 * @param drawStyle The drawStyle to set
99 */
100 public void setDrawStyle(int drawStyle) {
101 switch ( drawStyle ) {
102 case GLU_FILL:
103 case GLU_LINE:
104 case GLU_SILHOUETTE:
105 case GLU_POINT:
106 break;
107 default:
108 throw new IllegalArgumentException("Invalid draw style specified: " + drawStyle);
109 }
110
111 this.drawStyle = drawStyle;
112 }
113
114 /**
115 * specifies what kind of normals are desired for quadrics.
116 * The legal values are as follows:
117 * <p/>
118 * GLU.NONE: No normals are generated.
119 * <p/>
120 * GLU.FLAT: One normal is generated for every facet of a quadric.
121 * <p/>
122 * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This
123 * is the default.
124 *
125 * @param normals The normals to set
126 */
127 public void setNormals(int normals) {
128 switch ( normals ) {
129 case GLU_NONE:
130 case GLU_FLAT:
131 case GLU_SMOOTH:
132 break;
133 default:
134 throw new IllegalArgumentException("Invalid normal kind specified: " + normals);
135 }
136
137 this.normals = normals;
138 }
139
140 /**
141 * specifies what kind of orientation is desired for.
142 * The orientation values are as follows:
143 * <p/>
144 * GLU.OUTSIDE: Quadrics are drawn with normals pointing outward.
145 * <p/>
146 * GLU.INSIDE: Normals point inward. The default is GLU.OUTSIDE.
147 * <p/>
148 * Note that the interpretation of outward and inward depends on the quadric
149 * being drawn.
150 *
151 * @param orientation The orientation to set
152 */
153 public void setOrientation(int orientation) {
154 if ( orientation != GLU_OUTSIDE && orientation != GLU_INSIDE )
155 throw new IllegalArgumentException("Invalid orientation specified: " + orientation);
156
157 this.orientation = orientation;
158 }
159
160 /**
161 * specifies if texture coordinates should be generated for
162 * quadrics rendered with qobj. If the value of textureCoords is true,
163 * then texture coordinates are generated, and if textureCoords is false,
164 * they are not.. The default is false.
165 * <p/>
166 * The manner in which texture coordinates are generated depends upon the
167 * specific quadric rendered.
168 *
169 * @param textureFlag The textureFlag to set
170 */
171 public void setTextureFlag(boolean textureFlag) {
172 this.textureFlag = textureFlag;
173 }
174
175 /**
176 * Returns the drawStyle.
177 *
178 * @return int
179 */
180 public int getDrawStyle() {
181 return drawStyle;
182 }
183
184 /**
185 * Returns the normals.
186 *
187 * @return int
188 */
189 public int getNormals() {
190 return normals;
191 }
192
193 /**
194 * Returns the orientation.
195 *
196 * @return int
197 */
198 public int getOrientation() {
199 return orientation;
200 }
201
202 /**
203 * Returns the textureFlag.
204 *
205 * @return boolean
206 */
207 public boolean getTextureFlag() {
208 return textureFlag;
209 }
210
211 private static float sin(final float r) {
212 return (float)Math.sin(r);
213 }
214
215 private static float cos(final float r) {
216 return (float)Math.cos(r);
217 }
218
219 private int addDrawCommand(final int mode, final int first, final int count) {
220 drawCommands.add(new DrawCommand(mode, first, count));
221 return count;
222 }
223
224 /**
225 * draws a sphere of the given radius centered around the origin.
226 * The sphere is subdivided around the z axis into slices and along the z axis
227 * into stacks (similar to lines of longitude and latitude).
228 * <p/>
229 * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then
230 * any normals generated point away from the center of the sphere. Otherwise,
231 * they point toward the center of the sphere.
232 * <p/>
233 * If texturing is turned on (with glu.quadricTexture), then texture
234 * coordinates are generated so that t ranges from 0.0 at z=-radius to 1.0 at
235 * z=radius (t increases linearly along longitudinal lines), and s ranges from
236 * 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75
237 * at the -x axis, and back to 1.0 at the +y axis.
238 */
239 public FloatBuffer createBuffer(float radius, int slices, int stacks) {
240 float rho, theta;
241 float x, y, z;
242 float s, t, ds, dt;
243 int i, j;
244
245 final boolean normals = this.normals != GLU_NONE;
246 final float nsign = this.orientation == GLU_INSIDE ? -1.0f : 1.0f;
247
248 final float drho = PI / stacks;
249 final float dtheta = 2.0f * PI / slices;
250
251 final ImmediateModeBuffer imb = new ImmediateModeBuffer(16 * 1024); // TODO: We can calculate this to avoid re-allocs
252 int lastDrawIndex = 0;
253
254 if ( this.drawStyle == GLU_FILL ) {
255 if ( !this.textureFlag ) {
256 lastDrawIndex += addDrawCommand(GL_TRIANGLE_FAN, lastDrawIndex, slices + 2);
257
258 // draw +Z end as a triangle fan
259 imb.glNormal3f(0.0f, 0.0f, 1.0f);
260 imb.glVertex3f(0.0f, 0.0f, nsign * radius);
261 for ( j = 0; j <= slices; j++ ) {
262 theta = (j == slices) ? 0.0f : j * dtheta;
263 x = -sin(theta) * sin(drho);
264 y = cos(theta) * sin(drho);
265 z = nsign * cos(drho);
266 if ( normals )
267 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
268 imb.glVertex3f(x * radius, y * radius, z * radius);
269 }
270 }
271
272 ds = 1.0f / slices;
273 dt = 1.0f / stacks;
274 t = 1.0f; // because loop now runs from 0
275
276 final int imin, imax;
277 if ( this.textureFlag ) {
278 imin = 0;
279 imax = stacks;
280 } else {
281 imin = 1;
282 imax = stacks - 1;
283 }
284
285 // draw intermediate stacks as quad strips
286 for ( i = imin; i < imax; i++ ) {
287 lastDrawIndex += addDrawCommand(GL_TRIANGLE_STRIP, lastDrawIndex, (slices + 1) * 2);
288
289 rho = i * drho;
290 s = 0.0f;
291 for ( j = 0; j <= slices; j++ ) {
292 theta = (j == slices) ? 0.0f : j * dtheta;
293
294 x = -sin(theta) * sin(rho);
295 y = cos(theta) * sin(rho);
296 z = nsign * cos(rho);
297 if ( normals )
298 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
299 if ( textureFlag )
300 imb.glTexCoord2f(s, t);
301 imb.glVertex3f(x * radius, y * radius, z * radius);
302
303 x = -sin(theta) * sin(rho + drho);
304 y = cos(theta) * sin(rho + drho);
305 z = nsign * cos(rho + drho);
306 if ( normals )
307 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
308 if ( textureFlag )
309 imb.glTexCoord2f(s, t - dt);
310 s += ds;
311 imb.glVertex3f(x * radius, y * radius, z * radius);
312 }
313 t -= dt;
314 }
315
316 if ( !this.textureFlag ) {
317 lastDrawIndex += addDrawCommand(GL_TRIANGLE_FAN, lastDrawIndex, slices + 2);
318
319 // draw -Z end as a triangle fan
320 imb.glNormal3f(0.0f, 0.0f, -1.0f);
321 imb.glVertex3f(0.0f, 0.0f, -radius * nsign);
322 rho = PI - drho;
323 s = 1.0f;
324 for ( j = slices; j >= 0; j-- ) {
325 theta = (j == slices) ? 0.0f : j * dtheta;
326 x = -sin(theta) * sin(rho);
327 y = cos(theta) * sin(rho);
328 z = nsign * cos(rho);
329 if ( normals )
330 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
331 s -= ds;
332 imb.glVertex3f(x * radius, y * radius, z * radius);
333 }
334 }
335 } else if ( this.drawStyle == GLU_LINE || this.drawStyle == GLU_SILHOUETTE ) {
336 // draw stack lines
337 for ( i = 1; i < stacks; i++ ) { // stack line at i==stacks-1 was missing here
338 lastDrawIndex += addDrawCommand(GL_LINE_LOOP, lastDrawIndex, slices);
339
340 rho = i * drho;
341 for ( j = 0; j < slices; j++ ) {
342 theta = j * dtheta;
343 x = cos(theta) * sin(rho);
344 y = sin(theta) * sin(rho);
345 z = cos(rho);
346 if ( normals )
347 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
348 imb.glVertex3f(x * radius, y * radius, z * radius);
349 }
350 }
351 // draw slice lines
352 for ( j = 0; j < slices; j++ ) {
353 lastDrawIndex += addDrawCommand(GL_LINE_STRIP, lastDrawIndex, stacks + 1);
354
355 theta = j * dtheta;
356 for ( i = 0; i <= stacks; i++ ) {
357 rho = i * drho;
358 x = cos(theta) * sin(rho);
359 y = sin(theta) * sin(rho);
360 z = cos(rho);
361 if ( normals )
362 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
363 imb.glVertex3f(x * radius, y * radius, z * radius);
364 }
365 }
366 } else if ( this.drawStyle == GLU_POINT ) {
367 lastDrawIndex += addDrawCommand(GL_POINTS, lastDrawIndex, 2 + (stacks - 2) * slices);
368
369 // top and bottom-most points
370 if ( normals )
371 imb.glNormal3f(0.0f, 0.0f, nsign);
372 imb.glVertex3f(0.0f, 0.0f, radius);
373 if ( normals )
374 imb.glNormal3f(0.0f, 0.0f, -nsign);
375 imb.glVertex3f(0.0f, 0.0f, -radius);
376
377 // loop over stacks
378 for ( i = 1; i < stacks - 1; i++ ) {
379 rho = i * drho;
380 for ( j = 0; j < slices; j++ ) {
381 theta = j * dtheta;
382 x = cos(theta) * sin(rho);
383 y = sin(theta) * sin(rho);
384 z = cos(rho);
385 if ( normals )
386 imb.glNormal3f(x * nsign, y * nsign, z * nsign);
387 imb.glVertex3f(x * radius, y * radius, z * radius);
388 }
389 }
390 }
391
392 return imb.getBuffer();
393 }
394
395 private static class DrawCommand {
396
397 private int mode;
398 private int first;
399 private int count;
400
401 private DrawCommand(final int mode, final int first, final int count) {
402 this.mode = mode;
403 this.first = first;
404 this.count = count;
405 }
406
407 void draw() {
408 glDrawArrays(mode, first, count);
409 }
410
411 }
412
413 }
3434
3535 /**
3636 * A mutable Color class
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Color.java 2983 2008-04-07 18:36:09Z matzon $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public final class Color implements ReadableColor, Serializable, WritableColor {
4242
3434
3535 /**
3636 * 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 $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public final class Dimension implements Serializable, ReadableDimension, WritableDimension {
4242
4141 /**
4242 * Display initialization utility, that can be used to find display modes and pick
4343 * one for you based on your criteria.
44 * @author $Author: spasi $
45 * @version $Revision: 3418 $
46 * $Id: Display.java 3418 2010-09-28 21:11:35Z spasi $
44 * @author $Author$
45 * @version $Revision$
46 * $Id$
4747 */
4848 public final class Display {
4949
3434
3535 /**
3636 * 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 $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public final class Point implements ReadablePoint, WritablePoint, Serializable {
4242
3434
3535 /**
3636 * Readonly interface for Colors
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: ReadableColor.java 3418 2010-09-28 21:11:35Z spasi $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public interface ReadableColor {
4242
3232
3333 /**
3434 * Readonly interface for Dimensions
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadableDimension.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838 */
3939 public interface ReadableDimension {
4040
3232
3333 /**
3434 * Readonly interface for Points
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadablePoint.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838 */
3939 public interface ReadablePoint {
4040
3232
3333 /**
3434 * Readonly interface for Rectangles
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadableRectangle.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838 */
3939 public interface ReadableRectangle extends ReadableDimension, ReadablePoint {
4040
3434
3535 /**
3636 * 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 $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public final class Rectangle implements ReadableRectangle, WritableRectangle, Serializable {
4242
3434 *
3535 * Simple interface to things that can be Rendered.
3636 *
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: Renderable.java 3418 2010-09-28 21:11:35Z spasi $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public interface Renderable {
4242
4040 * all timers are updated consistently with each other.
4141 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3418 $
44 * $Id: Timer.java 3418 2010-09-28 21:11:35Z spasi $
43 * @version $Revision$
44 * $Id$
4545 */
4646 public class Timer {
4747
5252 * Utitlity class for loading wavefiles.
5353 *
5454 * @author Brian Matzon <brian@matzon.dk>
55 * @version $Revision: 3438 $
56 * $Id: WaveData.java 3438 2010-10-12 15:34:26Z matzon $
55 * @version $Revision$
56 * $Id$
5757 */
5858 public class WaveData {
5959 /** actual wave data */
217217 && total < buf.length) {
218218 total += read;
219219 }
220 buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16);
220 buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16, audioformat.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
221221 } catch (IOException ioe) {
222222 return null;
223223 }
236236 return wavedata;
237237 }
238238
239 private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) {
239 private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data, ByteOrder order) {
240240 ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
241241 dest.order(ByteOrder.nativeOrder());
242242 ByteBuffer src = ByteBuffer.wrap(audio_bytes);
243 src.order(ByteOrder.LITTLE_ENDIAN);
243 src.order(order);
244244 if (two_bytes_data) {
245245 ShortBuffer dest_short = dest.asShortBuffer();
246246 ShortBuffer src_short = src.asShortBuffer();
3434
3535 /**
3636 * Write interface for Colors
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: WritableColor.java 3418 2010-09-28 21:11:35Z spasi $
37 * @author $Author$
38 * @version $Revision$
39 * $Id$
4040 */
4141 public interface WritableColor {
4242 /**
3232
3333 /**
3434 * Write interface for Dimensions
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritableDimension.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838
3939 */
4040 public interface WritableDimension {
3232
3333 /**
3434 * Write interface for Points
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritablePoint.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838 */
3939 public interface WritablePoint {
4040 void setLocation(int x, int y);
3232
3333 /**
3434 * Write interface for Rectangles
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritableRectangle.java 3418 2010-09-28 21:11:35Z spasi $
35 * @author $Author$
36 * @version $Revision$
37 * $Id$
3838 */
3939 public interface WritableRectangle extends WritablePoint, WritableDimension {
4040
3030 */
3131 package org.lwjgl.util.applet;
3232
33 import org.lwjgl.LWJGLUtil;
34
3335 import java.applet.Applet;
3436 import java.applet.AppletStub;
3537 import java.awt.BorderLayout;
4042 import java.awt.Image;
4143 import java.awt.MediaTracker;
4244 import java.awt.image.ImageObserver;
43 import java.io.DataInputStream;
44 import java.io.DataOutputStream;
45 import java.io.BufferedInputStream;
4546 import java.io.File;
4647 import java.io.FileInputStream;
4748 import java.io.FileOutputStream;
5657 import java.io.Writer;
5758 import java.lang.reflect.Constructor;
5859 import java.lang.reflect.Field;
59 import java.lang.reflect.Method;
6060 import java.net.HttpURLConnection;
6161 import java.net.JarURLConnection;
6262 import java.net.SocketPermission;
6565 import java.net.URLConnection;
6666 import java.security.AccessControlException;
6767 import java.security.AccessController;
68 import java.security.AllPermission;
6869 import java.security.CodeSource;
6970 import java.security.PermissionCollection;
71 import java.security.Permissions;
7072 import java.security.PrivilegedExceptionAction;
71 import java.security.SecureClassLoader;
7273 import java.security.cert.Certificate;
7374 import java.util.Enumeration;
7475 import java.util.HashMap;
76 import java.util.Iterator;
77 import java.util.LinkedList;
78 import java.util.Queue;
7579 import java.util.StringTokenizer;
7680 import java.util.Vector;
81 import java.util.concurrent.ExecutorService;
82 import java.util.concurrent.Executors;
83 import java.util.concurrent.Future;
7784 import java.util.jar.JarEntry;
7885 import java.util.jar.JarFile;
7986 import java.util.jar.JarOutputStream;
8087 import java.util.jar.Pack200;
88 import java.util.zip.CRC32;
89 import java.util.zip.CheckedInputStream;
8190 import java.util.zip.GZIPInputStream;
82
83 import sun.security.util.SecurityConstants;
91 import java.util.zip.ZipEntry;
92 import java.util.zip.ZipFile;
8493
8594 /**
8695 * <p>
96105 * The following applet parameters are required:
97106 * <ul>
98107 * <li>al_main - [String] Full package and class the applet to instantiate and display when loaded.</li>
99 * <li>al_logo - [String Path of of the logo resource to paint while loading.</li>
100 * <li>al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.</li>
101 * <li>al_jars - [String] Comma seperated list of jars to download.</li>
108 * <li>al_jars - [String] Comma separated list of jars to download.</li>
109 * <p>
102110 * <li>al_windows - [String] Jar containing native files for windows.</li>
103111 * <li>al_linux - [String] Jar containing native files for linux.</li>
104112 * <li>al_mac - [String] Jar containing native files for mac.</li>
105113 * <li>al_solaris - [String] Jar containing native files for solaris.</li>
106114 * <li>al_freebsd - [String] Jar containing native files for freebsd.</li>
115 * <li>al_openbsd - [String] Jar containing native files for openbsd.</li>
107116 * </ul>
108117 * </p>
109118 * <p>
110119 * Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader.
111120 * <ul>
121 * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li>
112122 * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
113123 * reused if the version matches. If version doesn't match all of the files are reloaded.</li>
114 * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li>
124 *
115125 * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
116 * <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>
117 * <ul>
126 * <li>al_min_jre - [String] Specify the minimum jre version that the applet requires, should be in format like 1.6.0_24 or a subset like 1.6 <i>Default: 1.5</i>.</li>
127 * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multiple domains and needs to share the cache. <i>Default: true</i>.</li>
128 * <li>al_lookup_threads - [int] Specify the number of concurrent threads to use to get file information before downloading. <i>Default: 1</i>.</li>
129 * <p>
118130 * <li>al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.</li>
119 * <li>al_windows32 - [String] If specifed it will be used instead of al_windows on 32bit windows systems.</li>
120 * <li>al_linux64 - [String] If specifed it will be used instead of al_linux on 64bit linux systems.</li>
121 * <li>al_linux32 - [String] If specifed it will be used instead of al_linux on 32bit linux systems.</li>
122 * <ul>
131 * <li>al_windows32 - [String] If specified it will be used instead of al_windows on 32bit windows systems.</li>
132 * <li>al_linux64 - [String] If specified it will be used instead of al_linux on 64bit linux systems.</li>
133 * <li>al_linux32 - [String] If specified it will be used instead of al_linux on 32bit linux systems.</li>
134 * <li>al_mac32 - [String] If specified it will be used instead of al_mac on 64bit mac systems.</li>
135 * <li>al_mac64 - [String] If specified it will be used instead of al_mac on 32bit mac systems.</li>
136 * <li>al_macppc - [String] If specified it will be used instead of al_mac on PPC mac systems.</li>
137 * <p>
123138 * <li>boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. <i>Default: #ffffff</i>.</li>
124139 * <li>boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. <i>Default: #000000</i>.</li>
140 * <p>
141 * <li>al_logo - [String Path of of the logo resource to paint while loading.<i>Default: "appletlogo.gif"</i>.</li>
142 * <li>al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.<i>Default: "appletprogress.gif"</i>.</li>
143 * <p>
144 * <li>lwjgl_arguments - </li> [String] used to pass LWJGL parameters to LWJGL e.g. ("-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true -Dorg.lwjgl.util.Debug=true").</li>
125145 * </ul>
126146 * </p>
127 * @author kappaOne
147 * @author kappaOne <one.kappa@gmail.com>
128148 * @author Brian Matzon <brian@matzon.dk>
129149 * @version $Revision$
130150 * $Id$
151 *
152 * Contributors:
153 * <ul>
154 * <li>Arielsan</li>
155 * <li>Bobjob</li>
156 * <li>Dashiva</li>
157 * <li>Dr_evil</li>
158 * <li>Elias Naur</li>
159 * <li>Kevin Glass</li>
160 * <li>Matthias Mann</li>
161 * <li>Mickelukas</li>
162 * <li>NateS</li>
163 * <li>Pelle Johnsen</li>
164 * <li>Riven</li>
165 * <li>Ruben01</li>
166 * <li>Shannon Smith</li>
167 * </ul>
168 *
131169 */
132170 public class AppletLoader extends Applet implements Runnable, AppletStub {
133171
134172 /** initializing */
135173 public static final int STATE_INIT = 1;
174
175 /** checking version of jre */
176 public static final int STATE_CHECK_JRE_VERSION = 2;
136177
137178 /** determining which packages that are required */
138 public static final int STATE_DETERMINING_PACKAGES = 2;
179 public static final int STATE_DETERMINING_PACKAGES = 3;
139180
140181 /** checking for already downloaded files */
141 public static final int STATE_CHECKING_CACHE = 3;
182 public static final int STATE_CHECKING_CACHE = 4;
183
184 /** checking if any updates are available for cache files */
185 public static final int STATE_CHECKING_FOR_UPDATES = 5;
142186
143187 /** downloading packages */
144 public static final int STATE_DOWNLOADING = 4;
188 public static final int STATE_DOWNLOADING = 6;
145189
146190 /** extracting packages */
147 public static final int STATE_EXTRACTING_PACKAGES = 5;
191 public static final int STATE_EXTRACTING_PACKAGES = 7;
192
193 /** validating packages */
194 public static final int STATE_VALIDATING_PACKAGES = 8;
148195
149196 /** updating the classpath */
150 public static final int STATE_UPDATING_CLASSPATH = 6;
197 public static final int STATE_UPDATING_CLASSPATH = 9;
151198
152199 /** switching to real applet */
153 public static final int STATE_SWITCHING_APPLET = 7;
200 public static final int STATE_SWITCHING_APPLET = 10;
154201
155202 /** initializing real applet */
156 public static final int STATE_INITIALIZE_REAL_APPLET = 8;
203 public static final int STATE_INITIALIZE_REAL_APPLET = 11;
157204
158205 /** stating real applet */
159 public static final int STATE_START_REAL_APPLET = 9;
206 public static final int STATE_START_REAL_APPLET = 12;
160207
161208 /** done */
162 public static final int STATE_DONE = 10;
209 public static final int STATE_DONE = 13;
163210
164211 /** used to calculate length of progress bar */
165 protected int percentage;
166
167 /** current size of download in bytes */
168 protected int currentSizeDownload;
212 protected volatile int percentage;
169213
170214 /** total size of download in bytes */
171 protected int totalSizeDownload;
215 protected int totalDownloadSize;
172216
173217 /** current size of extracted in bytes */
174218 protected int currentSizeExtract;
209253 /** applet to load after all downloads are complete */
210254 protected Applet lwjglApplet;
211255
212 /** whether a fatal error occured */
213 protected boolean fatalError;
214
215256 /** whether we're running in debug mode */
216257 protected boolean debugMode;
217258
241282
242283 /** whether pack200 is supported */
243284 protected boolean pack200Supported;
285
286 /** whether to run in headless mode */
287 protected boolean headless = false;
288
289 /** whether to switch applets in headless mode or wait longer */
290 protected boolean headlessWaiting = true;
291
292 /** messages to be passed via liveconnect in headless mode */
293 protected String[] headlessMessage;
294
295 /** threads to use when fetching information of files to be downloaded */
296 protected int concurrentLookupThreads;
297
298 /** whether a fatal error occurred */
299 protected boolean fatalError;
300
301 /** whether a certificate refused error occurred */
302 protected boolean certificateRefused;
303
304 /** whether the minimum required JRE version is not found */
305 protected boolean minimumJreNotFound;
244306
245307 /** generic error message to display on error */
246308 protected String[] genericErrorMessage = { "An error occured while loading the applet.",
247309 "Please contact support to resolve this issue.",
248310 "<placeholder for error message>"};
249311
250 /** whether a certificate refused error occured */
251 protected boolean certificateRefused;
252
253 /** error message to display if user refuses to accept certicate*/
312 /** error message to display if user refuses to accept certificate*/
254313 protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.",
255314 "Please accept the permissions dialog to allow",
256315 "the applet to continue the loading process."};
257
316
317 /** error message to display if minimum JRE version is not met */
318 protected String[] minimumJREMessage = { "Your version of Java is out of date.",
319 "Visit java.com to get the latest version.",
320 "Java <al_min_jre> or greater is required."};
321
322 /** fatal error message to display */
323 protected String[] errorMessage;
324
258325 /** have natives been loaded by another instance of this applet */
259326 protected static boolean natives_loaded;
260
327
261328 /*
262329 * @see java.applet.Applet#init()
263330 */
265332 setState(STATE_INIT);
266333
267334 // sanity check
268 String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"};
335 String[] requiredArgs = {"al_main", "al_jars"};
269336 for ( String requiredArg : requiredArgs ) {
270337 if ( getParameter(requiredArg) == null ) {
271338 fatalErrorOccured("missing required applet parameter: " + requiredArg, null);
272339 return;
273340 }
274341 }
275
342
276343 // whether to use cache system
277344 cacheEnabled = getBooleanParameter("al_cache", true);
278345
282349 // whether to prepend host to cache path
283350 prependHost = getBooleanParameter("al_prepend_host", true);
284351
352 // whether to run in headless mode
353 headless = getBooleanParameter("al_headless", false);
354
355 // obtain the number of concurrent lookup threads to use
356 concurrentLookupThreads = getIntParameter("al_lookup_threads", 1); // defaults to 1
357
285358 // get colors of applet
286359 bgColor = getColor("boxbgcolor", Color.white);
287360 setBackground(bgColor);
288361 fgColor = getColor("boxfgcolor", Color.black);
289362
290 // load logos, if value is "" then skip
291 if (getParameter("al_logo").length() > 0) {
292 logo = getImage(getParameter("al_logo"));
293 }
294 if (getParameter("al_progressbar").length() > 0) {
295 progressbar = getImage(getParameter("al_progressbar"));
363 if (!headless) {
364 // load logos
365 logo = getImage(getStringParameter("al_logo", "appletlogo.gif"));
366 progressbar = getImage(getStringParameter("al_progressbar", "appletprogress.gif"));
296367 }
297368
298369 // check for lzma support
337408 loaderThread.setName("AppletLoader.loaderThread");
338409 loaderThread.start();
339410
340 animationThread = new Thread() {
341 public void run() {
342 while(loaderThread != null) {
343 repaint();
344 AppletLoader.this.sleep(100);
411 if (!headless) {
412 animationThread = new Thread() {
413 public void run() {
414 while(loaderThread != null) {
415 repaint();
416 AppletLoader.this.sleep(100);
417 }
418 animationThread = null;
345419 }
346 animationThread = null;
347 }
348 };
349 animationThread.setName("AppletLoader.animationthread");
350 animationThread.start();
420 };
421 animationThread.setName("AppletLoader.animationthread");
422 animationThread.start();
423 }
351424 }
352425 }
353426 }
390463 return lwjglApplet;
391464 }
392465
466 /**
467 * Retrieves the current status of the AppletLoader and is
468 * used by liveconnect when running in headless mode.
469 *
470 * This method will return the current progress of the AppletLoader
471 * as a value from 0-100. In the case of a fatal error it will
472 * return -1. If the certificate is refused it will return -2.
473 * If the minimum jre requirement is not met will return -3.
474 *
475 * When method returns 100 the AppletLoader will sleep until the
476 * method is called again. When called again it will switch to the
477 * LWJGL Applet. This is a useful trigger to start the LWJGL applet
478 * when needed.
479 */
480 public int getStatus() {
481 if (fatalError) {
482 headlessMessage = errorMessage;
483
484 if (certificateRefused) return -2;
485 if (minimumJreNotFound) return -3;
486 return -1;
487 }
488
489 if (percentage == 100 && headlessWaiting) {
490 headlessWaiting = false;
491 }
492
493 if (percentage == 95) {
494 percentage = 100; // ready to switch applet
495 }
496
497 String[] message = {getDescriptionForState(), subtaskMessage};
498 headlessMessage = message;
499
500 return percentage;
501 }
502
503 /**
504 * Retrieves the current message for the current status.
505 * Used by liveconnect when running in headless mode.
506 */
507 public String[] getMessages() {
508 return headlessMessage;
509 }
510
393511 /**
394512 * Transfers the call of AppletResize from the stub to the lwjglApplet.
395513 */
413531 cleanUp(); // clean up resources
414532 return;
415533 }
534
535 // no drawing in headless mode
536 if (headless) return;
416537
417538 // create offscreen if missing
418539 if (offscreen == null) {
445566 og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null));
446567
447568 og.setColor(fgColor);
448 String message = getDescriptionForState();
449
569
450570 // if we had a failure of some sort, notify the user
451571 if (fatalError) {
452 String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;
453
454572 for(int i=0; i<errorMessage.length; i++) {
455573 if(errorMessage[i] != null) {
456574 int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2;
474592 }
475593
476594 // draw message
595 String message = getDescriptionForState();
596
477597 int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
478598 int messageY = y + 20;
479599
488608 og.drawString(subtaskMessage, messageX, messageY+20);
489609 }
490610
491 // draw loading bar, clipping it depending on percentage done
611 // draw loading progress bar, clipping it depending on percentage done
492612 if (progressbar != null) {
493613 int barSize = (progressbar.getWidth(null) * percentage) / 100;
494614 og.clipRect(x-progressbar.getWidth(null)/2, 0, barSize, offscreen.getHeight(null));
552672 switch (state) {
553673 case STATE_INIT:
554674 return "Initializing loader";
675 case STATE_CHECK_JRE_VERSION:
676 return "Checking version";
555677 case STATE_DETERMINING_PACKAGES:
556678 return "Determining packages to load";
557679 case STATE_CHECKING_CACHE:
558680 return "Calculating download size";
681 case STATE_CHECKING_FOR_UPDATES:
682 return "Checking for updates";
559683 case STATE_DOWNLOADING:
560684 return "Downloading packages";
561685 case STATE_EXTRACTING_PACKAGES:
562686 return "Extracting downloaded packages";
687 case STATE_VALIDATING_PACKAGES:
688 return "Validating packages";
563689 case STATE_UPDATING_CLASSPATH:
564690 return "Updating classpath";
565691 case STATE_SWITCHING_APPLET:
582708 */
583709 protected String trimExtensionByCapabilities(String file) {
584710 if (!pack200Supported) {
585 file = file.replaceAll(".pack", "");
586 }
587
588 if (!lzmaSupported) {
589 file = file.replaceAll(".lzma", "");
711 file = file.replace(".pack", "");
712 }
713
714 if (!lzmaSupported && file.endsWith(".lzma")) {
715 file = file.replace(".lzma", "");
716 System.out.println("LZMA decoder (lzma.jar) not found, trying " + file + " without lzma extension.");
590717 }
591718 return file;
592719 }
618745 nativeJarList = getParameter("al_windows");
619746 }
620747
621 } else if (osName.startsWith("Linux")) {
748 } else if (osName.startsWith("Linux") || osName.startsWith("Unix")) {
622749
623750 // check if arch specific natives have been specified
624751 if (System.getProperty("os.arch").endsWith("64")) {
632759 }
633760
634761 } else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) {
635 nativeJarList = getParameter("al_mac");
762
763 // check if arch specific natives have been specified
764 if (System.getProperty("os.arch").endsWith("64")) {
765 nativeJarList = getParameter("al_mac64");
766 } else if (System.getProperty("os.arch").contains("ppc")) {
767 nativeJarList = getParameter("al_macppc");
768 } else {
769 nativeJarList = getParameter("al_mac32");
770 }
771
772 if (nativeJarList == null) {
773 nativeJarList = getParameter("al_mac");
774 }
775
636776 } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
637777 nativeJarList = getParameter("al_solaris");
638778 } else if (osName.startsWith("FreeBSD")) {
639779 nativeJarList = getParameter("al_freebsd");
780 } else if (osName.startsWith("OpenBSD")) {
781 nativeJarList = getParameter("al_openbsd");
640782 } else {
641783 fatalErrorOccured("OS (" + osName + ") not supported", null);
642784 return;
671813 }
672814
673815 /**
674 * 4 steps
816 * 9 steps
675817 *
676 * 1) check version of applet and decide whether to download jars
677 * 2) download the jars
678 * 3) extract natives
679 * 4) add to jars to class path
680 * 5) switch applets
818 * 1) check jre version meets minimum requirements
819 * 2) check applet cache and decide which jars to download
820 * 3) download the jars
821 * 4) extract native files
822 * 5) validate jars for any corruption
823 * 6) save applet cache information
824 * 7) add jars to class path
825 * 8) set any lwjgl properties
826 * 9) switch to loaded applet
681827 */
682828 public void run() {
683 setState(STATE_CHECKING_CACHE);
684
685 percentage = 5;
829 percentage = 5;
686830
687831 try {
688832 debug_sleep(2000);
833
834 // check JRE version meets minimum requirements
835 if (!isMinJREVersionAvailable()) {
836 minimumJreNotFound = true;
837 fatalErrorOccured("Java " + getStringParameter("al_min_jre", "1.5") + " or greater is required.", null);
838 return;
839 }
689840
690841 // parse the urls for the jars into the url list
691842 loadJarURLs();
692843
693 // get path where applet will be stored
694 String path = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
695 public String run() throws Exception {
696
697 // we append the code base to avoid naming collisions with al_title
698 String codebase = "";
699 if(prependHost) {
700 codebase = getCodeBase().getHost();
701 if(codebase == null || codebase.length() == 0) {
702 codebase = "localhost";
703 }
704 codebase += File.separator;
705 }
706 return getCacheDir() + File.separator + codebase + getParameter("al_title") + File.separator;
707 }
708 });
844 // get path where applet files will be stored
845 String path = getCacheDirectory();
709846
710847 File dir = new File(path);
711848
719856 // if specified applet version already available don't download anything
720857 boolean versionAvailable = false;
721858
722 // version of applet
859 // version string of applet
723860 String version = getParameter("al_version");
724 float latestVersion = 0;
725
726 // if applet version specifed, check if you have latest version of applet
861
862 // if applet version specifed, compare with version in the cache
727863 if (version != null) {
728
729 latestVersion = Float.parseFloat(version);
730
731 // if version file exists
732 if (versionFile.exists()) {
733 // compare to new version
734 if (latestVersion != readVersionFile(versionFile)) {
735 versionAvailable = true;
736 percentage = 90;
737
738 if(debugMode) {
739 System.out.println("Loading Cached Applet Version " + latestVersion);
740 }
741 debug_sleep(2000);
742 }
743 }
864 versionAvailable = compareVersion(versionFile, version.toLowerCase());
744865 }
745866
746867 // if jars not available or need updating download them
755876 extractJars(path); // 55-65%
756877
757878 // Extracts Native Files
758 extractNatives(path); // 65-85%
879 extractNatives(path); // 65-80%
880
881 // Validate Jars // 80-90%
882 validateJars(path);
759883
760884 // save version information once jars downloaded successfully
761885 if (version != null) {
762886 percentage = 90;
763 writeVersionFile(versionFile, latestVersion);
887 writeObjectFile(versionFile, version.toLowerCase());
764888 }
765889
766890 // save file names with last modified info once downloaded successfully
767 writeCacheFile(new File(dir, "cache"), filesLastModified);
891 writeObjectFile(new File(dir, "timestamps"), filesLastModified);
768892 }
769893
770894 // add the downloaded jars and natives to classpath
773897 // set lwjgl properties
774898 setLWJGLProperties();
775899
776 // make applet switch on EDT as an AWT/Swing permission dialog could be called
900 // if headless mode then sleep, until told to continue
901 if (headless) {
902 while(headlessWaiting) {
903 Thread.sleep(100);
904 }
905 }
906
907 // make applet switch on the EDT as an AWT/Swing permission dialog could be called
777908 EventQueue.invokeAndWait(new Runnable() {
778909 public void run() {
779910 try {
786917 }
787918 });
788919
789 } catch (AccessControlException ace) {
790 fatalErrorOccured(ace.getMessage(), ace);
791 certificateRefused = true;
792920 } catch (Exception e) {
921 certificateRefused = e instanceof AccessControlException;
793922 fatalErrorOccured("This occurred while '" + getDescriptionForState() + "'", e);
794923 } finally {
795924 loaderThread = null;
796925 }
926 }
927
928 /**
929 * When this method is supplied with a JRE version it will compare it to the
930 * current JRE version.
931 *
932 * minimum requried JRE version is set using al_min_jre parameter, if not
933 * this is not set then the value will default to version 1.5
934 *
935 * The minimumVersion should follow a structure such as x.x.x_x
936 * Example values would include 1.6.0_10 or a subset like 1.6.0 or 1.6
937 *
938 * @return returns true if the available version is greater or equal to the
939 * minimum version required
940 *
941 * @throws Exception a NumberFormatException is thrown if the string is not valid
942 */
943 public boolean isMinJREVersionAvailable() throws Exception {
944 setState(STATE_CHECK_JRE_VERSION);
945
946 String minimumVersion = getStringParameter("al_min_jre", "1.5");
947 String javaVersion = System.getProperty("java.version");
948
949 // remove dash and anything after it (letters) from version string e.g. 1.5.0_01-ea
950 minimumVersion = javaVersion.split("-")[0];
951 javaVersion = minimumVersion.split("-")[0];
952
953 // split version string into a string arrays
954 String[] jvmVersionData = javaVersion.split("[_\\.]");
955 String[] minVersionData = minimumVersion.split("[_\\.]");
956
957 int maxLength = Math.max(jvmVersionData.length, minVersionData.length);
958
959 // convert string arrays into int arrays
960 int[] jvmVersion = new int[maxLength];
961 int[] minVersion = new int[maxLength];
962
963 for (int i = 0; i < jvmVersionData.length; i++) {
964 jvmVersion[i] = Integer.parseInt(jvmVersionData[i]);
965 }
966
967 for (int i = 0; i < minVersionData.length; i++) {
968 minVersion[i] = Integer.parseInt(minVersionData[i]);
969 }
970
971 // compare versions
972 for (int i = 0; i < maxLength; i++) {
973 if (jvmVersion[i] < minVersion[i]) return false; // minVersion is greater then jvmVersion
974 }
975
976 return true;
977 }
978
979 /**
980 * This method will return true if the version stored in the file
981 * matches the supplied String version.
982 *
983 * @param versionFile - location to file containing version information
984 * @param version - String version that needs to be compared
985 * @return returns true if the version in file matches specified version
986 */
987 protected boolean compareVersion(File versionFile, String version) {
988 // if version file exists
989 if (versionFile.exists()) {
990 String s = readStringFile(versionFile);
991
992 // compare to version with file
993 if (s != null && s.equals(version)) {
994 percentage = 90; // not need to download cache files again
995
996 if(debugMode) {
997 System.out.println("Loading Cached Applet Version: " + version);
998 }
999 debug_sleep(2000);
1000
1001 return true; // version matches file
1002 }
1003 }
1004
1005 return false;
7971006 }
7981007
7991008 /**
8211030 }
8221031
8231032 /**
824 * get path to the lwjgl cache directory
1033 * This method will return the location of the cache directory. All the
1034 * applet files will be downloaded and stored here. A folder will be
1035 * created inside the LWJGL cache directory from the al_title parameter.
1036 * This folder will also be prepended by the host name of the codebase
1037 * to avoid conflict with same named applets on other hosts.
1038 *
1039 * @return path to applets cache directory
1040 * @throws Exception if access is denied
1041 */
1042 protected String getCacheDirectory() throws Exception {
1043
1044 String path = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
1045 public String run() throws Exception {
1046
1047 // we append the code base to avoid naming collisions with al_title
1048 String codebase = "";
1049 if(prependHost) {
1050 codebase = getCodeBase().getHost();
1051 if(codebase == null || codebase.length() == 0) {
1052 codebase = "localhost";
1053 }
1054 codebase += File.separator;
1055 }
1056 return getLWJGLCacheDir() + File.separator + codebase + getParameter("al_title") + File.separator;
1057 }
1058 });
1059
1060 return path;
1061 }
1062
1063 /**
1064 * Get path to the lwjgl cache directory. This location will be where
1065 * the OS keeps temporary files.
8251066 *
8261067 * @return path to the lwjgl cache directory
8271068 */
828 protected String getCacheDir() {
1069 protected String getLWJGLCacheDir() {
8291070 String cacheDir = System.getProperty("deployment.user.cachedir");
8301071
8311072 if (cacheDir == null || System.getProperty("os.name").startsWith("Win")) {
8361077 }
8371078
8381079 /**
839 * read the current version file
1080 * read String object from File
1081 *
1082 * @param file to be read
1083 * @return the String stored in the file or null if it fails
1084 */
1085 protected String readStringFile(File file) {
1086 try {
1087 return (String)readObjectFile(file);
1088 } catch (Exception e) {
1089 // failed to read version file
1090 e.printStackTrace();
1091 }
1092
1093 // return null if failed to read file
1094 return null;
1095 }
1096
1097 /**
1098 * read the HashMap from File
8401099 *
8411100 * @param file the file to read
842 * @return the version value of saved file
843 * @throws Exception if it fails to read value
844 */
845 protected float readVersionFile(File file) throws Exception {
846 DataInputStream dis = new DataInputStream(new FileInputStream(file));
847 float version = dis.readFloat();
848 dis.close();
849 return version;
850 }
851
852 /**
853 * write out version file of applet
1101 * @return the hashmap stored in the file or an empty hashmap if it fails
1102 */
1103 @SuppressWarnings("unchecked")
1104 protected HashMap<String, Long> readHashMapFile(File file) {
1105
1106 try {
1107 return (HashMap<String, Long>) readObjectFile(file);
1108 } catch (Exception e) {
1109 // failed to read hashmap from file
1110 e.printStackTrace();
1111 }
1112
1113 // return an empty map if failed to read file
1114 return new HashMap<String, Long>();
1115 }
1116
1117 /**
1118 * read the object from the File
1119 *
1120 * @param file the file to read
1121 * @return the object contained in the file or null if it fails
1122 * @throws Exception if it fails to read object from file
1123 */
1124 protected Object readObjectFile(File file) throws Exception {
1125 FileInputStream fis = new FileInputStream(file);
1126
1127 try {
1128 ObjectInputStream dis = new ObjectInputStream(fis);
1129 Object object = dis.readObject();
1130 dis.close();
1131 return object;
1132 } catch (Exception e) {
1133 // failed to read file
1134 throw e;
1135 } finally {
1136 fis.close();
1137 }
1138 }
1139
1140 /**
1141 * write object to specified File
8541142 *
8551143 * @param file the file to write out to
856 * @param version the version of the applet as a float
1144 * @param object the contents of the file
8571145 * @throws Exception if it fails to write file
8581146 */
859 protected void writeVersionFile(File file, float version) throws Exception {
860 DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
861 dos.writeFloat(version);
862 dos.close();
863 }
864
865 /**
866 * read the current cache file
867 *
868 * @param file the file to read
869 * @return the hashmap containing the files names and lastModified times
870 * @throws Exception if it fails to read hashmap
871 */
872 @SuppressWarnings("unchecked")
873 protected HashMap<String, Long> readCacheFile(File file) throws Exception {
874 ObjectInputStream dis = new ObjectInputStream(new FileInputStream(file));
875 HashMap<String, Long> hashMap = (HashMap<String, Long>)dis.readObject();
876 dis.close();
877 return hashMap;
878 }
879
880 /**
881 * write out cache file of applet
882 *
883 * @param file the file to write out to
884 * @param filesLastModified the hashmap containing files names and lastModified times
885 * @throws Exception if it fails to write file
886 */
887 protected void writeCacheFile(File file, HashMap<String, Long> filesLastModified) throws Exception {
888 ObjectOutputStream dos = new ObjectOutputStream(new FileOutputStream(file));
889 dos.writeObject(filesLastModified);
890 dos.close();
1147 protected void writeObjectFile(File file, Object object) throws Exception {
1148 FileOutputStream fos = new FileOutputStream(file);
1149 try {
1150 ObjectOutputStream dos = new ObjectOutputStream(fos);
1151 dos.writeObject(object);
1152 dos.close();
1153 } finally {
1154 fos.close();
1155 }
8911156 }
8921157
8931158 /**
9071172 URL[] urls = new URL[urlList.length];
9081173
9091174 for (int i = 0; i < urlList.length; i++) {
910 urls[i] = new URL("file:" + path + getJarName(urlList[i]));
911 }
912
1175 String file = new File(path, getJarName(urlList[i])).toURI().toString();
1176 // fix JVM bug where ! is not escaped
1177 file = file.replace("!", "%21");
1178 urls[i] = new URL(file);
1179 }
1180
1181 // get AppletLoader certificates
1182 final Certificate[] certs = getCurrentCertificates();
1183
1184 // detect if we are running on a mac and save result as boolean
1185 String osName = System.getProperty("os.name");
1186 final boolean isMacOS = (osName.startsWith("Mac") || osName.startsWith("Darwin"));
1187
9131188 // add downloaded jars to the classpath with required permissions
9141189 classLoader = new URLClassLoader(urls) {
9151190 protected PermissionCollection getPermissions (CodeSource codesource) {
9161191 PermissionCollection perms = null;
9171192
9181193 try {
919 // getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed
920 Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class });
921 method.setAccessible(true);
922 perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource});
1194 // no permissions
1195 perms = new Permissions();
1196
1197 // if certificates match the AppletLoader certificates then we should be all set
1198 if (certificatesMatch(certs, codesource.getCertificates())) {
1199 perms.add(new AllPermission());
1200 return perms;
1201 }
9231202
9241203 String host = getCodeBase().getHost();
925
9261204 if (host != null && (host.length() > 0)) {
9271205 // add permission for downloaded jars to access host they were from
928 perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
1206 perms.add(new SocketPermission(host, "connect,accept"));
9291207 }
9301208 else if ( "file".equals(codesource.getLocation().getProtocol()) ) {
9311209 // if running locally add file permission
9321210 String path = codesource.getLocation().getFile().replace('/', File.separatorChar);
933 perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION));
1211 perms.add(new FilePermission(path, "read"));
9341212 }
9351213
9361214 } catch (Exception e) {
9421220
9431221 // allow non lwjgl native to be found from cache directory
9441222 protected String findLibrary (String libname) {
945 return path + "natives" + File.separator + System.mapLibraryName(libname);
1223 String libPath = path + "natives" + File.separator + LWJGLUtil.mapLibraryName(libname);
1224
1225 if (new File(libPath).exists()) {
1226 return libPath;
1227 }
1228
1229 return super.findLibrary(libname);
9461230 }
9471231 };
9481232
10221306 percentage = 100;
10231307
10241308 debug_sleep(2000);
1025
1309
1310 // set correct context classloader for lwjgl applet
1311 Thread.currentThread().setContextClassLoader(classLoader);
1312
10261313 Class appletClass = classLoader.loadClass(getParameter("al_main"));
10271314 lwjglApplet = (Applet) appletClass.newInstance();
10281315
10511338 * @throws Exception - if fails to get infomation
10521339 */
10531340 protected void getJarInfo(File dir) throws Exception {
1054
1341 setState(STATE_CHECKING_CACHE);
1342
10551343 filesLastModified = new HashMap<String, Long>();
10561344
10571345 // store file sizes and mark which files not to download
10581346 fileSizes = new int[urlList.length];
10591347
1060 URLConnection urlconnection;
1061
1062 File cacheFile = new File(dir, "cache");
1063
1064 // if cache file exists, load it
1065 if (cacheFile.exists()) {
1066 filesLastModified = readCacheFile(cacheFile);
1348 File timestampsFile = new File(dir, "timestamps");
1349
1350 // if timestamps file exists, load it
1351 if (timestampsFile.exists()) {
1352 setState(STATE_CHECKING_FOR_UPDATES);
1353 filesLastModified = readHashMapFile(timestampsFile);
10671354 }
10681355
10691356 // calculate total size of jars to download
1070 for (int i = 0; i < urlList.length; i++) {
1071 urlconnection = urlList[i].openConnection();
1072 urlconnection.setDefaultUseCaches(false);
1073 if (urlconnection instanceof HttpURLConnection) {
1074 ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
1075 }
1076
1077 fileSizes[i] = urlconnection.getContentLength();
1078
1079 long lastModified = urlconnection.getLastModified();
1080 String fileName = getFileName(urlList[i]);
1081
1082
1083 if (cacheEnabled && lastModified != 0 &&
1084 filesLastModified.containsKey(fileName)) {
1085 long savedLastModified = filesLastModified.get(fileName);
1086
1087 // if lastModifed time is the same, don't redownload
1088 if (savedLastModified == lastModified) {
1089 fileSizes[i] = -2; // mark it to not redownload
1090 }
1091 }
1092
1093 if (fileSizes[i] >= 0) {
1094 totalSizeDownload += fileSizes[i];
1095 }
1096
1097 // put key and value in the hashmap
1098 filesLastModified.put(fileName, lastModified);
1099
1100 // update progress bar
1101 percentage = 5 + (int)(10 * i/(float)urlList.length);
1102 }
1357
1358 ExecutorService executorService = Executors.newFixedThreadPool(concurrentLookupThreads);
1359 Queue<Future> requests = new LinkedList<Future>();
1360
1361 // create unique object to sync code in requests
1362 final Object sync = new Integer(1);
1363
1364 for (int j = 0; j < urlList.length; j++) {
1365 final int i = j;
1366
1367 Future request = executorService.submit(new Runnable() {
1368
1369 public void run() {
1370
1371 try {
1372
1373 URLConnection urlconnection = urlList[i].openConnection();
1374 urlconnection.setDefaultUseCaches(false);
1375 if (urlconnection instanceof HttpURLConnection) {
1376 ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
1377 }
1378
1379 fileSizes[i] = urlconnection.getContentLength();
1380
1381 long lastModified = urlconnection.getLastModified();
1382 String fileName = getFileName(urlList[i]);
1383
1384 if (cacheEnabled && lastModified != 0 && filesLastModified.containsKey(fileName)) {
1385 long savedLastModified = filesLastModified.get(fileName);
1386
1387 // if lastModifed time is the same, don't redownload
1388 if (savedLastModified == lastModified) {
1389 fileSizes[i] = -2; // mark it to not redownload
1390 }
1391 }
1392
1393 if (fileSizes[i] >= 0) {
1394 synchronized (sync) {
1395 totalDownloadSize += fileSizes[i];
1396 }
1397 }
1398
1399 // put key and value in the hashmap
1400 filesLastModified.put(fileName, lastModified);
1401
1402 } catch (Exception e) {
1403 throw new RuntimeException("Failed to fetch information for " + urlList[i], e);
1404 }
1405 }});
1406
1407 requests.add(request);
1408 }
1409
1410 while (!requests.isEmpty()) {
1411 Iterator<Future> iterator = requests.iterator();
1412 while (iterator.hasNext()) {
1413 Future request = iterator.next();
1414 if (request.isDone()) {
1415 request.get(); // will throw an exception if request thrown an exception.
1416 iterator.remove();
1417
1418 // update progress bar
1419 percentage = 5 + (int) (10 * (urlList.length - requests.size()) / (float) urlList.length);
1420 }
1421 }
1422
1423 Thread.sleep(10);
1424 }
1425
1426 executorService.shutdown();
11031427 }
11041428
11051429 /**
11101434 * @throws Exception if download fails
11111435 */
11121436 protected void downloadJars(String path) throws Exception {
1113
11141437 setState(STATE_DOWNLOADING);
11151438
11161439 URLConnection urlconnection;
11171440
11181441 int initialPercentage = percentage = 15;
1442 int amountDownloaded = 0;
11191443
11201444 // download each jar
11211445 byte buffer[] = new byte[65536];
11271451 int unsuccessfulAttempts = 0;
11281452 int maxUnsuccessfulAttempts = 3;
11291453 boolean downloadFile = true;
1454
1455 String currentFile = getFileName(urlList[i]);
11301456
11311457 // download the jar a max of 3 times
11321458 while(downloadFile) {
11331459 downloadFile = false;
11341460
11351461 debug_sleep(2000);
1136
1137 urlconnection = urlList[i].openConnection();
1138
1139 if (urlconnection instanceof HttpURLConnection) {
1140 urlconnection.setRequestProperty("Cache-Control", "no-cache");
1141 urlconnection.connect();
1142 }
1143
1144 String currentFile = getFileName(urlList[i]);
1145 InputStream inputstream = getJarInputStream(currentFile, urlconnection);
1146 FileOutputStream fos = new FileOutputStream(path + currentFile);
1147
1148
1149 int bufferSize;
1150 long downloadStartTime = System.currentTimeMillis();
1151 int downloadedAmount = 0;
1152 int fileSize = 0;
1153 String downloadSpeedMessage = "";
1154
1155 while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
1156 debug_sleep(10);
1157 fos.write(buffer, 0, bufferSize);
1158 currentSizeDownload += bufferSize;
1159 fileSize += bufferSize;
1160 percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
1161 subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
1162
1163 downloadedAmount += bufferSize;
1164 long timeLapse = System.currentTimeMillis() - downloadStartTime;
1165 // update only if a second or more has passed
1166 if (timeLapse >= 1000) {
1167 // get kb/s, nice that bytes/millis is same as kilobytes/seconds
1168 float downloadSpeed = (float) downloadedAmount / timeLapse;
1169 // round to two decimal places
1170 downloadSpeed = ((int)(downloadSpeed*100))/100f;
1171 // set current speed message
1172 downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
1173 // reset downloaded amount
1174 downloadedAmount = 0;
1175 // reset start time
1176 downloadStartTime = System.currentTimeMillis();
1462
1463 try {
1464 urlconnection = urlList[i].openConnection();
1465 urlconnection.setUseCaches(false);
1466
1467 if (urlconnection instanceof HttpURLConnection) {
1468 urlconnection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache");
1469 urlconnection.connect();
1470 }
1471
1472
1473 InputStream inputstream = getJarInputStream(currentFile, urlconnection);
1474 FileOutputStream fos = new FileOutputStream(path + currentFile);
1475
1476
1477 int bufferSize;
1478 int currentDownload = 0;
1479
1480 long downloadStartTime = System.currentTimeMillis();
1481 int downloadedAmount = 0;
1482 String downloadSpeedMessage = "";
1483
1484 try {
1485 while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
1486 debug_sleep(10);
1487 fos.write(buffer, 0, bufferSize);
1488 currentDownload += bufferSize;
1489
1490 int totalDownloaded = amountDownloaded + currentDownload;
1491 percentage = initialPercentage + ((totalDownloaded * 45) / totalDownloadSize);
1492 subtaskMessage = "Retrieving: " + currentFile + " " + ((totalDownloaded * 100) / totalDownloadSize) + "%";
1493
1494 downloadedAmount += bufferSize;
1495 long timeLapse = System.currentTimeMillis() - downloadStartTime;
1496 // update only if a second or more has passed
1497 if (timeLapse >= 1000) {
1498 // get kb/s, nice that bytes/millis is same as kilobytes/seconds
1499 float downloadSpeed = (float) downloadedAmount / timeLapse;
1500 // round to two decimal places
1501 downloadSpeed = ((int)(downloadSpeed*100))/100f;
1502 // set current speed message
1503 downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
1504 // reset downloaded amount
1505 downloadedAmount = 0;
1506 // reset start time
1507 downloadStartTime = System.currentTimeMillis();
1508 }
1509
1510 subtaskMessage += downloadSpeedMessage;
1511 }
1512
1513 } finally {
1514 inputstream.close();
1515 fos.close();
11771516 }
1178
1179 subtaskMessage += downloadSpeedMessage;
1517
1518 // download complete, verify if it was successful
1519 if (urlconnection instanceof HttpURLConnection) {
1520 if (currentDownload == fileSizes[i]) {
1521 // successful download
1522 }
1523 else if (fileSizes[i] <= 0 && currentDownload != 0) {
1524 // If contentLength for fileSizes[i] <= 0, we don't know if the download
1525 // is complete. We're going to guess the download is complete.
1526 }
1527 else {
1528 throw new Exception("size mismatch on download of " + currentFile +
1529 " expected " + fileSizes[i] + " got " + currentDownload);
1530 }
1531 }
1532
1533 // successful file download, update total amount downloaded
1534 amountDownloaded += fileSizes[i];
1535
1536 } catch (Exception e) {
1537 e.printStackTrace(); // output exception to console
1538
1539 // Failed to download the file
1540 unsuccessfulAttempts++;
1541
1542 // download failed try again
1543 if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
1544 downloadFile = true;
1545 Thread.sleep(100); // wait a bit before retrying
1546 }
1547 else {
1548 // retry attempts exhasted, download failed
1549 throw new Exception("failed to download " + currentFile +
1550 " after " + maxUnsuccessfulAttempts + " attempts");
1551 }
11801552 }
1181
1182 inputstream.close();
1183 fos.close();
1184
1185 // download complete, verify if it was successful
1186 if (urlconnection instanceof HttpURLConnection) {
1187 if (fileSize == fileSizes[i]) {
1188 // successful download
1189 }
1190 else if (fileSizes[i] <= 0) {
1191 // If contentLength for fileSizes[i] <= 0, we don't know if the download
1192 // is complete. We're going to guess the download is complete.
1193 }
1194 else {
1195 unsuccessfulAttempts++;
1196 // download failed try again
1197 if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
1198 downloadFile = true;
1199 currentSizeDownload -= fileSize; // reset progress bar
1200 }
1201 else {
1202 // retry attempts exhasted, download failed
1203 throw new Exception("failed to download " + currentFile);
1204 }
1205 }
1206 }
12071553 }
12081554 }
12091555 subtaskMessage = "";
12751621 Constructor constructor = clazz.getDeclaredConstructor(InputStream.class);
12761622 InputStream inputHandle = (InputStream) constructor.newInstance(fileInputHandle);
12771623
1278 OutputStream outputHandle;
1279 outputHandle = new FileOutputStream(out);
1624 OutputStream outputHandle = new FileOutputStream(out);
12801625
12811626 byte [] buffer = new byte [1<<14];
12821627
1283 int ret = inputHandle.read(buffer);
1284 while (ret >= 1) {
1285 outputHandle.write(buffer,0,ret);
1286 ret = inputHandle.read(buffer);
1287 }
1288
1289 inputHandle.close();
1290 outputHandle.close();
1291
1292 outputHandle = null;
1293 inputHandle = null;
1628 try {
1629 int ret = inputHandle.read(buffer);
1630 while (ret >= 1) {
1631 outputHandle.write(buffer,0,ret);
1632 ret = inputHandle.read(buffer);
1633 }
1634 } finally {
1635 inputHandle.close();
1636 outputHandle.close();
1637 }
12941638
12951639 // delete LZMA file, as it is no longer needed
12961640 f.delete();
13091653
13101654 InputStream inputHandle = new GZIPInputStream(fileInputHandle);
13111655
1312 OutputStream outputHandle;
1313 outputHandle = new FileOutputStream(out);
1314
1315 byte [] buffer = new byte [1<<14];
1316
1317 int ret = inputHandle.read(buffer);
1318 while (ret >= 1) {
1319 outputHandle.write(buffer,0,ret);
1320 ret = inputHandle.read(buffer);
1321 }
1322
1323 inputHandle.close();
1324 outputHandle.close();
1325
1326 outputHandle = null;
1327 inputHandle = null;
1656 OutputStream outputHandle = new FileOutputStream(out);
1657
1658 try {
1659 byte [] buffer = new byte [1<<14];
1660
1661 int ret = inputHandle.read(buffer);
1662 while (ret >= 1) {
1663 outputHandle.write(buffer,0,ret);
1664 ret = inputHandle.read(buffer);
1665 }
1666 } finally {
1667 inputHandle.close();
1668 outputHandle.close();
1669 }
13281670
13291671 // delete GZip file, as it is no longer needed
13301672 f.delete();
13401682 File f = new File(in);
13411683 FileOutputStream fostream = new FileOutputStream(out);
13421684 JarOutputStream jostream = new JarOutputStream(fostream);
1343
1344 Pack200.Unpacker unpacker = Pack200.newUnpacker();
1345 unpacker.unpack(f, jostream);
1346 jostream.close();
1685
1686 try {
1687 Pack200.Unpacker unpacker = Pack200.newUnpacker();
1688 unpacker.unpack(f, jostream);
1689 } finally {
1690 jostream.close();
1691 fostream.close();
1692 }
13471693
13481694 // delete pack file as its no longer needed
13491695 f.delete();
13691715 String filename = getFileName(urlList[i]);
13701716
13711717 if (filename.endsWith(".pack.lzma")) {
1372 subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", "");
1718 subtaskMessage = "Extracting: " + filename + " to " + replaceLast(filename, ".lzma", "");
13731719 debug_sleep(1000);
1374 extractLZMA(path + filename, path + filename.replaceAll(".lzma", ""));
1375
1376 subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", "");
1720 extractLZMA(path + filename, path + replaceLast(filename, ".lzma", ""));
1721
1722 subtaskMessage = "Extracting: " + replaceLast(filename, ".lzma", "") + " to " + replaceLast(filename, ".pack.lzma", "");
13771723 debug_sleep(1000);
1378 extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", ""));
1724 extractPack(path + replaceLast(filename, ".lzma", ""), path + replaceLast(filename, ".pack.lzma", ""));
13791725 }
13801726 else if (filename.endsWith(".pack.gz")) {
1381 subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".gz", "");
1727 subtaskMessage = "Extracting: " + filename + " to " + replaceLast(filename, ".gz", "");
13821728 debug_sleep(1000);
1383 extractGZip(path + filename, path + filename.replaceAll(".gz", ""));
1384
1385 subtaskMessage = "Extracting: " + filename.replaceAll(".gz", "") + " to " + filename.replaceAll(".pack.gz", "");
1729 extractGZip(path + filename, path + replaceLast(filename, ".gz", ""));
1730
1731 subtaskMessage = "Extracting: " + replaceLast(filename, ".gz", "") + " to " + replaceLast(filename, ".pack.gz", "");
13861732 debug_sleep(1000);
1387 extractPack(path + filename.replaceAll(".gz", ""), path + filename.replaceAll(".pack.gz", ""));
1733 extractPack(path + replaceLast(filename, ".gz", ""), path + replaceLast(filename, ".pack.gz", ""));
13881734 }
13891735 else if (filename.endsWith(".pack")) {
1390 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", "");
1736 subtaskMessage = "Extracting: " + filename + " to " + replaceLast(filename, ".pack", "");
13911737 debug_sleep(1000);
1392 extractPack(path + filename, path + filename.replace(".pack", ""));
1738 extractPack(path + filename, path + replaceLast(filename, ".pack", ""));
13931739 }
13941740 else if (filename.endsWith(".lzma")) {
1395 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".lzma", "");
1741 subtaskMessage = "Extracting: " + filename + " to " + replaceLast(filename, ".lzma", "");
13961742 debug_sleep(1000);
1397 extractLZMA(path + filename, path + filename.replace(".lzma", ""));
1743 extractLZMA(path + filename, path + replaceLast(filename, ".lzma", ""));
13981744 }
13991745 else if (filename.endsWith(".gz")) {
1400 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".gz", "");
1746 subtaskMessage = "Extracting: " + filename + " to " + replaceLast(filename, ".gz", "");
14011747 debug_sleep(1000);
1402 extractGZip(path + filename, path + filename.replace(".gz", ""));
1748 extractGZip(path + filename, path + replaceLast(filename, ".gz", ""));
14031749 }
14041750 }
14051751 }
14161762
14171763 setState(STATE_EXTRACTING_PACKAGES);
14181764
1419 float percentageParts = 20f/nativeJarCount; // parts for each native jar from 20%
1765 float percentageParts = 15f/nativeJarCount; // parts for each native jar from 15%
14201766
14211767 // create native folder
14221768 File nativeFolder = new File(path + "natives");
14241770 nativeFolder.mkdir();
14251771 }
14261772
1427 // get the current certificate to compare against native files
1428 Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
1429
1430 // workaround for bug where cached applet loader does not have certificates!?
1431 if (certificate == null) {
1432 URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
1433
1434 // manually load the certificate
1435 JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
1436 jurl.setDefaultUseCaches(true);
1437 certificate = jurl.getCertificates();
1438 }
1773 // get the current AppletLoader certificates to compare against certificates of the native files
1774 Certificate[] certificate = getCurrentCertificates();
14391775
14401776 for (int i = urlList.length - nativeJarCount; i < urlList.length; i++) {
14411777
14971833 InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
14981834 OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
14991835
1500 int bufferSize;
1501 byte buffer[] = new byte[65536];
1502
1503 while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
1504 debug_sleep(10);
1505 out.write(buffer, 0, bufferSize);
1506 currentSizeExtract += bufferSize;
1507
1508 // update progress bar
1509 percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
1510 subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
1836 try {
1837 int bufferSize;
1838 byte buffer[] = new byte[65536];
1839
1840 while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
1841 debug_sleep(10);
1842 out.write(buffer, 0, bufferSize);
1843 currentSizeExtract += bufferSize;
1844
1845 // update progress bar
1846 percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
1847 subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
1848 }
1849 } finally {
1850 in.close();
1851 out.close();
15111852 }
1512
1513 // validate if the certificate for native file is correct
1514 validateCertificateChain(certificate, entry.getCertificates());
1515
1516 in.close();
1517 out.close();
1853
1854 // validate the certificate for the native file being extracted
1855 if (!certificatesMatch(certificate, entry.getCertificates())) {
1856 f.delete(); // delete extracted native as its certificates doesn't match
1857 throw new Exception("The certificate(s) in " + nativeJar + " do not match the AppletLoader!");
1858 }
15181859 }
15191860 subtaskMessage = "";
15201861
15281869 }
15291870
15301871 /**
1531 * Validates the certificate chain for a single file
1872 * Compare two certificate chains to see if they match
15321873 *
1533 * @param ownCerts Chain of certificates to check against
1534 * @param native_certs Chain of certificates to check
1535 */
1536 protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) throws Exception {
1537 if (native_certs == null)
1538 throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all");
1539
1540 if (ownCerts.length != native_certs.length)
1541 throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]");
1542
1543 for (int i = 0; i < ownCerts.length; i++) {
1544 if (!ownCerts[i].equals(native_certs[i])) {
1545 throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]);
1546 }
1874 * @param certs1 first chain of certificates
1875 * @param certs2 second chain of certificates
1876 *
1877 * @return true if the certificate chains are the same
1878 */
1879 protected static boolean certificatesMatch(Certificate[] certs1, Certificate[] certs2) throws Exception {
1880 if (certs1 == null || certs2 == null) {
1881 return false;
1882 }
1883
1884 if (certs1.length != certs2.length) {
1885 System.out.println("Certificate chain differs in length [" + certs1.length + " vs " + certs2.length + "]!");
1886 return false;
1887 }
1888
1889 for (int i = 0; i < certs1.length; i++) {
1890 if (!certs1[i].equals(certs2[i])) {
1891 System.out.println("Certificate mismatch found!");
1892 return false;
1893 }
1894 }
1895
1896 return true;
1897 }
1898
1899 /**
1900 * Returns the current certificate chain of the AppletLoader
1901 *
1902 * @return - certificate chain of AppletLoader
1903 */
1904 protected static Certificate[] getCurrentCertificates() throws Exception {
1905 // get the current certificate to compare against native files
1906 Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
1907
1908 // workaround for bug where cached applet loader does not have certificates!?
1909 if (certificate == null) {
1910 URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
1911
1912 // manually load the certificate
1913 JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
1914 jurl.setDefaultUseCaches(true);
1915 certificate = jurl.getCertificates();
1916 jurl.setDefaultUseCaches(false);
1917 }
1918
1919 return certificate;
1920 }
1921
1922 /**
1923 * Check and validate jars which will be loaded into the classloader to make
1924 * sure that they are not corrupt. This ensures corrupt files are never marked
1925 * as successful downloadeds by the cache system.
1926 *
1927 * @param path - where the jars are stored
1928 * @throws Exception if a corrupt jar is found
1929 */
1930 protected void validateJars(String path) throws Exception {
1931
1932 setState(STATE_VALIDATING_PACKAGES);
1933
1934 percentage = 80;
1935
1936 float percentageParts = 10f / urlList.length; // percentage for each file out of 10%
1937
1938 for (int i = 0; i < urlList.length - nativeJarCount; i++) {
1939
1940 debug_sleep(1000);
1941
1942 // if file not downloaded, no need to validate again
1943 if (fileSizes[i] == -2) continue;
1944
1945 subtaskMessage = "Validating: " + getJarName(urlList[i]);
1946
1947 File file = new File(path, getJarName(urlList[i]));
1948 if (!isZipValid(file)) {
1949 throw new Exception("The file " + getJarName(urlList[i]) + " is corrupt!");
1950 }
1951
1952 percentage = 80 + (int)(percentageParts * i);
1953 }
1954
1955 subtaskMessage = "";
1956 }
1957
1958 /**
1959 * This method will check if a zip file is valid by running through it
1960 * and checking for any corruption and CRC failures
1961 *
1962 * @param file - zip file to test
1963 * @return boolean - runs false if the file is corrupt
1964 */
1965 protected boolean isZipValid(File file) {
1966
1967 try {
1968 ZipFile zipFile = new ZipFile(file);
1969
1970 try {
1971 Enumeration e = zipFile.entries();
1972
1973 byte[] buffer = new byte[4096];
1974
1975 while(e.hasMoreElements()) {
1976 ZipEntry zipEntry = (ZipEntry) e.nextElement();
1977
1978 CRC32 crc = new CRC32();
1979
1980 BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
1981 CheckedInputStream cis = new CheckedInputStream(bis, crc);
1982
1983 while(cis.read(buffer, 0, buffer.length) != -1) {
1984 // scroll through zip entry
1985 }
1986
1987 if (crc.getValue() != zipEntry.getCrc()) {
1988 return false; // CRC match failed, corrupt zip
1989 }
1990 }
1991
1992 return true; // valid zip file
1993 } finally {
1994 zipFile.close();
1995 }
1996 } catch (IOException e) {
1997 e.printStackTrace();
1998 return false;
15471999 }
15482000 }
15492001
15552007 */
15562008 protected Image getImage(String s) {
15572009
2010 // if s is "" then don't load an image
2011 if (s.length() == 0) return null;
2012
15582013 Image image = null;
15592014
15602015 try {
15742029 }
15752030
15762031 // show error as image could not be loaded
1577 fatalErrorOccured("Unable to load logo and progressbar images", null);
2032 fatalErrorOccured("Unable to load the logo/progressbar image: " + s, null);
15782033 return null;
15792034 }
15802035
15862041 */
15872042 public Image getImage(URL url) {
15882043 try {
2044 MediaTracker tracker = new MediaTracker(this);
2045
15892046 Image image = super.getImage(url);
15902047
15912048 // wait for image to load
1592 MediaTracker tracker = new MediaTracker(this);
1593 tracker.addImage(image, 0);
2049 tracker.addImage(image, 0);
15942050 tracker.waitForAll();
15952051
15962052 // if no errors return image
16142070 String fileName = url.getFile();
16152071
16162072 if (fileName.endsWith(".pack.lzma")) {
1617 fileName = fileName.replaceAll(".pack.lzma", "");
2073 fileName = replaceLast(fileName, ".pack.lzma", "");
16182074 } else if (fileName.endsWith(".pack.gz")) {
1619 fileName = fileName.replaceAll(".pack.gz", "");
2075 fileName = replaceLast(fileName, ".pack.gz", "");
16202076 } else if (fileName.endsWith(".pack")) {
1621 fileName = fileName.replaceAll(".pack", "");
2077 fileName = replaceLast(fileName, ".pack", "");
16222078 } else if (fileName.endsWith(".lzma")) {
1623 fileName = fileName.replaceAll(".lzma", "");
2079 fileName = replaceLast(fileName, ".lzma", "");
16242080 } else if (fileName.endsWith(".gz")) {
1625 fileName = fileName.replaceAll(".gz", "");
2081 fileName = replaceLast(fileName, ".gz", "");
16262082 }
16272083
16282084 return fileName.substring(fileName.lastIndexOf('/') + 1);
16802136 return defaultColor;
16812137 }
16822138 }
1683
1684 /**
1685 * Retrieves the boolean value for the applet
2139
2140 /**
2141 * Replaces the last occurrence of the specified target substring with
2142 * the specified replacement string in a string.
2143 *
2144 * @param original - String to search
2145 * @param target - substring to find
2146 * @param replacement - what to replace target substring with
2147 * @return - return the modified string, if target substring not found return original string
2148 */
2149 public String replaceLast(String original, String target, String replacement) {
2150 int index = original.lastIndexOf(target);
2151
2152 if(index == -1) {
2153 return original;
2154 }
2155
2156 return original.substring(0, index) + replacement + original.substring(index + target.length());
2157 }
2158
2159 /**
2160 * Retrieves the String value for the parameter
16862161 * @param name Name of parameter
16872162 * @param defaultValue default value to return if no such parameter
16882163 * @return value of parameter or defaultValue
16892164 */
2165 protected String getStringParameter(String name, String defaultValue) {
2166 String parameter = getParameter(name);
2167 if (parameter != null) {
2168 return parameter;
2169 }
2170 return defaultValue;
2171 }
2172
2173 /**
2174 * Retrieves the boolean value for the parameter
2175 * @param name Name of parameter
2176 * @param defaultValue default value to return if no such parameter
2177 * @return value of parameter or defaultValue
2178 */
16902179 protected boolean getBooleanParameter(String name, boolean defaultValue) {
16912180 String parameter = getParameter(name);
1692 if(parameter != null) {
2181 if (parameter != null) {
16932182 return Boolean.parseBoolean(parameter);
16942183 }
16952184 return defaultValue;
16962185 }
1697
1698 /**
1699 * Sets the state of the loaded and prints some debug information
2186
2187 /**
2188 * Retrieves the int value for the applet
2189 * @param name Name of parameter
2190 * @param defaultValue default value to return if no such parameter
2191 * @return value of parameter or defaultValue
2192 */
2193 protected int getIntParameter(String name, int defaultValue) {
2194 String parameter = getParameter(name);
2195 if (parameter != null) {
2196 return Integer.parseInt(parameter);
2197 }
2198 return defaultValue;
2199 }
2200
2201 /**
2202 * Sets the error message and print debug information
17002203 *
17012204 * @param error Error message to print
17022205 */
17032206 protected void fatalErrorOccured(String error, Exception e) {
17042207 fatalError = true;
1705 genericErrorMessage[genericErrorMessage.length-1] = error;
2208
2209 if (minimumJreNotFound) {
2210 errorMessage = minimumJREMessage;
2211 errorMessage[errorMessage.length-1] = error;
2212 }
2213 else if (certificateRefused) {
2214 errorMessage = certificateRefusedMessage;
2215 }
2216 else {
2217 errorMessage = genericErrorMessage;
2218 errorMessage[errorMessage.length-1] = error;
2219 }
2220
17062221 System.out.println(error);
17072222 if(e != null) {
17082223 System.out.println(e.getMessage());
17132228
17142229 /**
17152230 * set the state of applet loader
1716 * @param new state of applet loader
2231 * @param state new state of applet loader
17172232 * */
17182233 protected void setState(int state) {
17192234 this.state = state;
17452260 }
17462261 }
17472262
1748 }
2263 }
3535 * AutoType and AutoSize is annotated with @Auto.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 * $Id: Auto.java 2983 2008-04-07 18:36:09Z matzon $
38 * @version $Revision$
39 * $Id$
4040 */
4141
4242 import java.lang.annotation.Target;
3636 * according to the remaining() of a Buffer parameter.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3412 $
40 * $Id: AutoSize.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
4848 public @interface AutoSize {
4949 String value(); // The name of the Buffer parameter
5050 String expression() default ""; // This value is added after the argument
51 boolean useExpression() default false; // When this is true, the expression result will be used directly.
5152 boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used.
5253 boolean isNative() default false; // When this is true, auto-sizing will be performed in native code.
5354 }
3636 * to the type of a Buffer parameter.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: AutoType.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3279 $
37 * $Id: BufferKind.java 3279 2010-03-11 21:06:49Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 public enum BufferKind {
3636 * integer VBO/PBO offset.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: BufferObject.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3636 * OpenGL.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: CachedReference.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3262 $
37 * $Id: CachedResult.java 3262 2010-01-04 18:47:49Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
37 * $Id: Check.java 3412 2010-09-26 23:43:24Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
37 * $Id: Code.java 3412 2010-09-26 23:43:24Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.ElementType;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Const.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
37 * $Id: Constant.java 3412 2010-09-26 23:43:24Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Extension.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
4545 String className() default "";
4646 boolean isFinal() default true;
4747 String postfix();
48
49 /** The extension name as it appears in the extension string. The default is the API prefix followed by the interface name, converted to lower-case. */
50 String nativeName() default "";
4851 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
3433 import java.io.PrintWriter;
3534 import java.util.Collection;
36
37 import com.sun.mirror.declaration.FieldDeclaration;
38 import com.sun.mirror.declaration.Modifier;
39 import com.sun.mirror.type.PrimitiveType;
40 import com.sun.mirror.type.TypeMirror;
35 import java.util.Set;
36 import javax.annotation.processing.ProcessingEnvironment;
37 import javax.lang.model.element.Modifier;
38 import javax.lang.model.element.VariableElement;
39 import javax.lang.model.type.PrimitiveType;
40 import javax.lang.model.type.TypeKind;
41 import javax.lang.model.type.TypeMirror;
4142
4243 public class FieldsGenerator {
4344
44 private static void validateField(FieldDeclaration field) {
45 private static void validateField(VariableElement field) {
4546 // Check if field is "public static final"
46 Collection<Modifier> modifiers = field.getModifiers();
47 Set<Modifier> modifiers = field.getModifiers();
4748 if ( modifiers.size() != 3
4849 || !modifiers.contains(Modifier.PUBLIC)
4950 || !modifiers.contains(Modifier.STATIC)
5253 }
5354
5455 // Check suported types (int, long, float, String)
55 TypeMirror field_type = field.getType();
56 if ( field_type instanceof PrimitiveType ) {
56 TypeMirror field_type = field.asType();
57 if ( "java.lang.String".equals(field_type.toString()) ) {
58 } else if ( field_type instanceof PrimitiveType ) {
5759 PrimitiveType field_type_prim = (PrimitiveType)field_type;
58 PrimitiveType.Kind field_kind = field_type_prim.getKind();
59 if ( field_kind != PrimitiveType.Kind.INT
60 && field_kind != PrimitiveType.Kind.LONG
61 && field_kind != PrimitiveType.Kind.FLOAT ) {
62 throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
60 TypeKind field_kind = field_type_prim.getKind();
61 if ( field_kind != TypeKind.INT
62 && field_kind != TypeKind.LONG
63 && field_kind != TypeKind.FLOAT
64 && field_kind != TypeKind.BYTE ) {
65 throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long', 'float' or 'byte' " + field_kind.toString());
6366 }
64 } else if ( "java.lang.String".equals(field_type.toString()) ) {
6567 } else {
6668 throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
6769 }
7274 }
7375 }
7476
75 private static void generateField(PrintWriter writer, FieldDeclaration field, FieldDeclaration prev_field) {
77 private static void generateField(PrintWriter writer, VariableElement field, VariableElement prev_field, ProcessingEnvironment env) {
7678 validateField(field);
7779
7880 Object value = field.getConstantValue();
8486 field_value_string = "0x" + Long.toHexString((Long)field.getConstantValue()).toUpperCase() + 'L';
8587 } else if ( field_value_class.equals(Float.class) ) {
8688 field_value_string = field.getConstantValue() + "f";
89 } else if ( value.getClass().equals(Byte.class) ) {
90 field_value_string = "0x" + Integer.toHexString((Byte)field.getConstantValue()).toUpperCase();
8791 } else if ( field_value_class.equals(String.class) ) {
8892 field_value_string = "\"" + field.getConstantValue() + "\"";
8993 } else {
9094 throw new RuntimeException("Field is of unexpected type. This means there is a bug in validateField().");
9195 }
9296
93 boolean hadDoc = prev_field != null && prev_field.getDocComment() != null;
94 boolean hasDoc = field.getDocComment() != null;
95 boolean newBatch = prev_field == null || !prev_field.getType().equals(field.getType()) || (!hadDoc && field.getDocComment() != null) || (hadDoc && hasDoc && !prev_field.getDocComment().equals(field.getDocComment()));
97 boolean hadDoc = prev_field != null && env.getElementUtils().getDocComment(prev_field) != null;
98 boolean hasDoc = env.getElementUtils().getDocComment(field) != null;
99 boolean newBatch = prev_field == null || !prev_field.asType().equals(field.asType()) || (!hadDoc && env.getElementUtils().getDocComment(field) != null) || (hadDoc && hasDoc && !env.getElementUtils().getDocComment(prev_field).equals(env.getElementUtils().getDocComment(field)));
96100
97101 // Print field declaration
98102 if ( newBatch ) {
99 if ( prev_field != null )
103 if ( prev_field != null ) {
100104 writer.println(";\n");
105 }
101106
102 Utils.printDocComment(writer, field);
103 writer.print("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = " + field_value_string);
104 } else
107 Utils.printDocComment(writer, field, env);
108 writer.print("\tpublic static final " + field.asType().toString() + " " + field.getSimpleName() + " = " + field_value_string);
109 } else {
105110 writer.print(",\n\t\t" + field.getSimpleName() + " = " + field_value_string);
111 }
106112 }
107113
108 public static void generateFields(PrintWriter writer, Collection<FieldDeclaration> fields) {
114 public static void generateFields(ProcessingEnvironment env, PrintWriter writer, Collection<? extends VariableElement> fields) {
109115 if ( 0 < fields.size() ) {
110116 writer.println();
111 FieldDeclaration prev_field = null;
112 for ( FieldDeclaration field : fields ) {
113 generateField(writer, field, prev_field);
117 VariableElement prev_field = null;
118 for ( VariableElement field : fields ) {
119 generateField(writer, field, prev_field, env);
114120 prev_field = field;
115121 }
116122 writer.println(";");
117123 }
118124 }
119125
120 }
126 }
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
37 * $Id: GenerateAutos.java 3412 2010-09-26 23:43:24Z spasi $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.lang.annotation.Target;
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.io.File;
34 import java.io.FileFilter;
35 import java.util.Iterator;
36 import java.util.Map;
37 import java.util.Set;
38 import javax.annotation.processing.*;
39 import javax.lang.model.SourceVersion;
40 import javax.lang.model.element.Element;
41 import javax.lang.model.element.TypeElement;
42 import javax.lang.model.util.ElementFilter;
43 import javax.tools.Diagnostic;
44
45 /**
46 * Generator tool for creating the java classes and native code from an
47 * annotated template java interface.
48 *
49 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision$ $Id$
51 */
52 @SupportedAnnotationTypes({ "*" })
53 @SupportedSourceVersion(SourceVersion.RELEASE_6)
54 @SupportedOptions({ "binpath", "typemap", "generatechecks", "contextspecific" })
55 public class GeneratorProcessor extends AbstractProcessor {
56
57 private static boolean first_round = true;
58
59 @Override
60 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
61 if ( roundEnv.processingOver() || !first_round ) {
62 System.exit(0);
63 return true;
64 }
65 Map<String, String> options = processingEnv.getOptions();
66 String typemap_classname = options.get("typemap");
67 String bin_path = options.get("binpath");
68 boolean generate_error_checks = options.containsKey("generatechecks");
69 boolean context_specific = options.containsKey("contextspecific");
70 if ( bin_path == null ) {
71 throw new RuntimeException("No path specified for the bin directory with -Abinpath=<path>");
72 }
73
74 if ( typemap_classname == null ) {
75 throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>");
76 }
77
78 Element lastFile = null;
79 try {
80 long generatorLM = getGeneratorLastModified(bin_path);
81 TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
82 for ( Iterator<TypeElement> it = ElementFilter.typesIn(roundEnv.getRootElements()).iterator(); it.hasNext(); ) {
83 lastFile = it.next();
84 lastFile.accept(new GeneratorVisitor(processingEnv, type_map, generate_error_checks, context_specific, generatorLM), null);
85 }
86 first_round = false;
87 return true;
88 } catch (Exception e) {
89 if ( lastFile == null ) {
90 throw new RuntimeException(e);
91 } else {
92 throw new RuntimeException("\n-- Failed to process template: " + lastFile.asType().toString() + " --", e);
93 }
94 }
95 }
96
97 /**
98 * Gets the time of the latest change on the Generator classes.
99 *
100 * @return time of the latest change
101 */
102 private static long getGeneratorLastModified(final String bin_path) {
103 long lastModified = getDirectoryLastModified(bin_path, "/org/lwjgl/util/generator");
104 lastModified = Math.max(lastModified, getDirectoryLastModified(bin_path, "/org/lwjgl/util/generator/openal"));
105 lastModified = Math.max(lastModified, getDirectoryLastModified(bin_path, "/org/lwjgl/util/generator/opengl"));
106 lastModified = Math.max(lastModified, getDirectoryLastModified(bin_path, "/org/lwjgl/util/generator/opencl"));
107
108 return lastModified;
109 }
110
111 private static long getDirectoryLastModified(final String bin_path, final String path) {
112 final File pck = new File(bin_path + path);
113 if ( !pck.exists() || !pck.isDirectory() ) {
114 return Long.MAX_VALUE;
115 }
116
117 final File[] classes = pck.listFiles(new FileFilter() {
118 public boolean accept(final File pathname) {
119 return pathname.isFile() && pathname.getName().endsWith(".class");
120 }
121 });
122
123 if ( classes == null || classes.length == 0 ) {
124 return Long.MAX_VALUE;
125 }
126
127 long lastModified = 0;
128
129 for ( File clazz : classes ) {
130 long lm = clazz.lastModified();
131 if ( lastModified < lm ) {
132 lastModified = lm;
133 }
134 }
135
136 return lastModified;
137 }
138
139 }
+0
-168
src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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.File;
35 import java.io.FileFilter;
36 import java.util.Arrays;
37 import java.util.Collection;
38 import java.util.Map;
39 import java.util.Set;
40
41 import com.sun.mirror.apt.*;
42 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
43 import com.sun.mirror.declaration.TypeDeclaration;
44
45 import static com.sun.mirror.util.DeclarationVisitors.*;
46 import static java.util.Collections.*;
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: 3430 $
54 * $Id: GeneratorProcessorFactory.java 3430 2010-10-04 17:04:46Z spasi $
55 */
56 public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
57
58 private static boolean first_round = true;
59
60 // Process any set of annotations
61 private static final Collection<String> supportedAnnotations =
62 unmodifiableCollection(Arrays.asList("*"));
63
64 private static final Collection<String> supportedOptions =
65 unmodifiableCollection(Arrays.asList("-Atypemap", "-Ageneratechecks", "-Acontextspecific"));
66
67 public Collection<String> supportedAnnotationTypes() {
68 return supportedAnnotations;
69 }
70
71 public Collection<String> supportedOptions() {
72 return supportedOptions;
73 }
74
75 public void roundComplete(RoundCompleteEvent event) {
76 first_round = false;
77 }
78
79 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
80 // Only process the initial types, not the generated ones
81 if ( first_round ) {
82 env.addListener(this);
83 return new GeneratorProcessor(env);
84 } else
85 return AnnotationProcessors.NO_OP;
86 }
87
88 private static class GeneratorProcessor implements AnnotationProcessor {
89
90 private final AnnotationProcessorEnvironment env;
91
92 GeneratorProcessor(AnnotationProcessorEnvironment env) {
93 this.env = env;
94 }
95
96 public void process() {
97 Map<String, String> options = env.getOptions();
98 String typemap_classname = null;
99 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
100 boolean context_specific = options.containsKey("-Acontextspecific");
101 for ( String k : options.keySet() ) {
102 int delimiter = k.indexOf('=');
103 if ( delimiter != -1 ) {
104 if ( k.startsWith("-Atypemap") ) {
105 typemap_classname = k.substring(delimiter + 1);
106 }
107 }
108 }
109 if ( typemap_classname == null )
110 throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>");
111
112 TypeDeclaration lastFile = null;
113 try {
114 long generatorLM = getGeneratorLastModified();
115 TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
116 for ( TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations() ) {
117 lastFile = typedecl;
118 typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP));
119 }
120 } catch (Exception e) {
121 if ( lastFile == null )
122 throw new RuntimeException(e);
123 else
124 throw new RuntimeException("\n-- Failed to process template: " + lastFile.getQualifiedName() + " --", e);
125 }
126 }
127
128 /**
129 * Gets the time of the latest change on the Generator classes.
130 *
131 * @return time of the latest change
132 */
133 private static long getGeneratorLastModified() {
134 long lastModified = getDirectoryLastModified("/bin/org/lwjgl/util/generator");
135 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/openal"));
136 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opengl"));
137 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opencl"));
138
139 return lastModified;
140 }
141
142 private static long getDirectoryLastModified(final String path) {
143 final File pck = new File(System.getProperty("user.dir") + path);
144 if ( !pck.exists() || !pck.isDirectory() )
145 return Long.MAX_VALUE;
146
147 final File[] classes = pck.listFiles(new FileFilter() {
148 public boolean accept(final File pathname) {
149 return pathname.isFile() && pathname.getName().endsWith(".class");
150 }
151 });
152
153 if ( classes == null || classes.length == 0 )
154 return Long.MAX_VALUE;
155
156 long lastModified = 0;
157
158 for ( File clazz : classes ) {
159 long lm = clazz.lastModified();
160 if ( lastModified < lm )
161 lastModified = lm;
162 }
163
164 return lastModified;
165 }
166 }
167 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
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.io.*;
33 import java.io.File;
34 import java.io.FileInputStream;
35 import java.io.IOException;
36 import java.io.PrintWriter;
4037 import java.lang.annotation.Annotation;
38 import java.nio.Buffer;
39 import java.nio.ByteBuffer;
4140 import java.nio.channels.FileChannel;
42 import java.util.*;
43
44 import java.nio.*;
41 import java.util.Collection;
42 import java.util.List;
43 import javax.annotation.processing.ProcessingEnvironment;
44 import javax.lang.model.element.*;
45 import javax.lang.model.type.TypeKind;
46 import javax.lang.model.type.TypeMirror;
47 import javax.lang.model.util.ElementKindVisitor6;
48 import javax.tools.Diagnostic;
49 import javax.tools.Diagnostic.Kind;
50 import javax.tools.FileObject;
51 import javax.tools.StandardLocation;
4552
4653 /**
47 *
4854 * Generator visitor for the generator tool
4955 *
5056 * @author elias_naur <elias_naur@users.sourceforge.net>
51 * @version $Revision: 3430 $
52 * $Id: GeneratorVisitor.java 3430 2010-10-04 17:04:46Z spasi $
57 * @version $Revision$ $Id$
5358 */
54 public class GeneratorVisitor extends SimpleDeclarationVisitor {
55 private final AnnotationProcessorEnvironment env;
56 private final TypeMap type_map;
57 private final boolean generate_error_checks;
58 private final boolean context_specific;
59 private final long generatorLM;
60
61 public GeneratorVisitor(AnnotationProcessorEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) {
59 public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
60
61 private final ProcessingEnvironment env;
62 private final TypeMap type_map;
63 private final boolean generate_error_checks;
64 private final boolean context_specific;
65 private final long generatorLM;
66
67 public GeneratorVisitor(ProcessingEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) {
6268 this.env = env;
6369 this.type_map = type_map;
6470 this.generate_error_checks = generate_error_checks;
6672 this.generatorLM = generatorLM;
6773 }
6874
69 private void validateMethod(MethodDeclaration method) {
70 if (method.isVarArgs())
75 private void validateMethod(ExecutableElement method) {
76 if ( method.isVarArgs() ) {
7177 throw new RuntimeException("Method " + method.getSimpleName() + " is variadic");
78 }
7279 Collection<Modifier> modifiers = method.getModifiers();
73 if (!modifiers.contains(Modifier.PUBLIC))
80 if ( !modifiers.contains(Modifier.PUBLIC) ) {
7481 throw new RuntimeException("Method " + method.getSimpleName() + " is not public");
75 if (method.getThrownTypes().size() > 0)
82 }
83 if ( method.getThrownTypes().size() > 0 ) {
7684 throw new RuntimeException("Method " + method.getSimpleName() + " throws checked exceptions");
85 }
7786 validateParameters(method);
7887 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
79 if (strip_annotation != null && method.getAnnotation(Alternate.class) == null) {
88 if ( strip_annotation != null && method.getAnnotation(Alternate.class) == null ) {
8089 String postfix_param_name = strip_annotation.value();
81 ParameterDeclaration postfix_param = Utils.findParameter(method, postfix_param_name);
82 if (Utils.isParameterMultiTyped(postfix_param))
90 VariableElement postfix_param = Utils.findParameter(method, postfix_param_name);
91 if ( Utils.isParameterMultiTyped(postfix_param) ) {
8392 throw new RuntimeException("Postfix parameter can't be the same as a multityped parameter in method " + method);
84 if (Utils.getNIOBufferType(postfix_param.getType()) == null)
93 }
94 if ( Utils.getNIOBufferType(postfix_param.asType()) == null ) {
8595 throw new RuntimeException("Postfix parameter type must be a nio Buffer");
86 }
87 if (Utils.getResultParameter(method) != null && !method.getReturnType().equals(env.getTypeUtils().getVoidType()))
96 }
97 }
98 if ( Utils.getResultParameter(method) != null && !method.getReturnType().equals(env.getTypeUtils().getNoType(TypeKind.VOID)) ) {
8899 throw new RuntimeException(method + " return type is not void but a parameter is annotated with Result");
89 if (method.getAnnotation(CachedResult.class) != null) {
90 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null)
100 }
101 if ( method.getAnnotation(CachedResult.class) != null ) {
102 if ( Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null ) {
91103 throw new RuntimeException(method + " return type is not a Buffer, but is annotated with CachedResult");
92 if (method.getAnnotation(AutoSize.class) == null)
104 }
105 if ( method.getAnnotation(AutoSize.class) == null ) {
93106 throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoSize annotation");
107 }
94108 }
95109 validateTypes(method, method.getAnnotationMirrors(), method.getReturnType());
96110 }
97111
98 private void validateType(MethodDeclaration method, Class<?extends Annotation> annotation_type, Class type) {
112 private void validateType(ExecutableElement method, Class<? extends Annotation> annotation_type, Class type) {
99113 Class[] valid_types = type_map.getValidAnnotationTypes(type);
100 for ( Class valid_type : valid_types )
101 if ( valid_type.equals(annotation_type) )
114 for ( Class valid_type : valid_types ) {
115 if ( valid_type.equals(annotation_type) ) {
102116 return;
103 throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type +
104 " in method " + method);
105 }
106
107 private void validateTypes(MethodDeclaration method, Collection<AnnotationMirror> annotations, TypeMirror type_mirror) {
108 for (AnnotationMirror annotation : annotations) {
117 }
118 }
119 throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type
120 + " in method " + method);
121 }
122
123 private void validateTypes(ExecutableElement method, List<? extends AnnotationMirror> annotations, TypeMirror type_mirror) {
124 for ( AnnotationMirror annotation : annotations ) {
109125 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
110 if (native_type_annotation != null) {
126 if ( native_type_annotation != null ) {
111127 Class<? extends Annotation> annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
112128 Class type = Utils.getJavaType(type_mirror);
113 if (Buffer.class.equals(type))
129 if ( Buffer.class.equals(type) ) {
114130 continue;
131 }
115132 validateType(method, annotation_type, type);
116133 }
117134 }
118135 }
119136
120 private void validateParameters(MethodDeclaration method) {
121 for (ParameterDeclaration param : method.getParameters()) {
122 validateTypes(method, param.getAnnotationMirrors(), param.getType());
123 Class<?> param_type = Utils.getJavaType(param.getType());
124 if (Utils.getNIOBufferType(param.getType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class) {
137 private void validateParameters(ExecutableElement method) {
138 for ( VariableElement param : method.getParameters() ) {
139 validateTypes(method, param.getAnnotationMirrors(), param.asType());
140 Class<?> param_type = Utils.getJavaType(param.asType());
141 if ( Utils.getNIOBufferType(param.asType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class ) {
125142 Check parameter_check_annotation = param.getAnnotation(Check.class);
126143 NullTerminated null_terminated_annotation = param.getAnnotation(NullTerminated.class);
127 if (parameter_check_annotation == null && null_terminated_annotation == null) {
144 if ( parameter_check_annotation == null && null_terminated_annotation == null ) {
128145 boolean found_auto_size_param = false;
129 for (ParameterDeclaration inner_param : method.getParameters()) {
146 for ( VariableElement inner_param : method.getParameters() ) {
130147 AutoSize auto_size_annotation = inner_param.getAnnotation(AutoSize.class);
131 if (auto_size_annotation != null &&
132 auto_size_annotation.value().equals(param.getSimpleName())) {
148 if ( auto_size_annotation != null
149 && auto_size_annotation.value().equals(param.getSimpleName().toString()) ) {
133150 found_auto_size_param = true;
134151 break;
135152 }
136153 }
137 if (!found_auto_size_param
138 && param.getAnnotation(Result.class) == null
139 && param.getAnnotation(Constant.class) == null
140 && !Utils.isReturnParameter(method, param)
141 )
142 throw new RuntimeException(param + " has no Check, Result nor Constant annotation, is not the return parameter and no other parameter has" +
143 " an @AutoSize annotation on it in method " + method);
144 }
145 if (param.getAnnotation(CachedReference.class) != null && param.getAnnotation(Result.class) != null)
154 if ( !found_auto_size_param
155 && param.getAnnotation(Result.class) == null
156 && param.getAnnotation(Constant.class) == null
157 && !Utils.isReturnParameter(method, param) ) {
158 throw new RuntimeException(param + " has no Check, Result nor Constant annotation, is not the return parameter and no other parameter has"
159 + " an @AutoSize annotation on it in method " + method);
160 }
161 }
162 if ( param.getAnnotation(CachedReference.class) != null && param.getAnnotation(Result.class) != null ) {
146163 throw new RuntimeException(param + " can't be annotated with both CachedReference and Result");
147 if (param.getAnnotation(BufferObject.class) != null && param.getAnnotation(Result.class) != null)
164 }
165 if ( param.getAnnotation(BufferObject.class) != null && param.getAnnotation(Result.class) != null ) {
148166 throw new RuntimeException(param + " can't be annotated with both BufferObject and Result");
167 }
149168 //if (param.getAnnotation(Constant.class) != null)
150 //throw new RuntimeException("Buffer parameter " + param + " cannot be Constant");
169 //throw new RuntimeException("Buffer parameter " + param + " cannot be Constant");
151170 } else {
152 if (param.getAnnotation(BufferObject.class) != null)
171 if ( param.getAnnotation(BufferObject.class) != null ) {
153172 throw new RuntimeException(param + " type is not a buffer, but annotated as a BufferObject");
154 if (param.getAnnotation(CachedReference.class) != null)
173 }
174 if ( param.getAnnotation(CachedReference.class) != null ) {
155175 throw new RuntimeException(param + " type is not a buffer, but annotated as a CachedReference");
156 }
157 }
158 }
159
160 private static void generateMethodsNativePointers(PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
161 for (MethodDeclaration method : methods) {
162 if ( method.getAnnotation(Alternate.class) == null )
176 }
177 }
178 }
179 }
180
181 private static void generateMethodsNativePointers(PrintWriter writer, Collection<? extends ExecutableElement> methods) {
182 for ( ExecutableElement method : methods ) {
183 if ( method.getAnnotation(Alternate.class) == null ) {
163184 generateMethodNativePointers(writer, method);
164 }
165 }
166
167 private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) {
168 if ( method.getAnnotation(Extern.class) == null )
185 }
186 }
187 }
188
189 private static void generateMethodNativePointers(PrintWriter writer, ExecutableElement method) {
190 if ( method.getAnnotation(Extern.class) == null ) {
169191 writer.print("static ");
192 }
170193 writer.println(Utils.getTypedefName(method) + " " + method.getSimpleName() + ";");
171194 }
172195
173 private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException {
196 private void generateJavaSource(TypeElement d, PrintWriter java_writer) throws IOException {
174197 java_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
175198 java_writer.println();
176 java_writer.println("package " + d.getPackage().getQualifiedName() + ";");
199 java_writer.println("package " + env.getElementUtils().getPackageOf(d).getQualifiedName().toString() + ";");
177200 java_writer.println();
178201 java_writer.println("import org.lwjgl.*;");
179202 java_writer.println("import java.nio.*;");
180203 Imports imports = d.getAnnotation(Imports.class);
181204 if ( imports != null ) {
182 for ( String i : imports.value() )
205 for ( String i : imports.value() ) {
183206 java_writer.println("import " + i + ";");
207 }
184208 }
185209 java_writer.println();
186 Utils.printDocComment(java_writer, d);
187 if ( d.getAnnotation(Private.class) == null )
210 Utils.printDocComment(java_writer, d, env);
211 if ( d.getAnnotation(Private.class) == null ) {
188212 java_writer.print("public ");
213 }
189214 boolean is_final = Utils.isFinal(d);
190 if (is_final)
215 if ( is_final ) {
191216 java_writer.write("final ");
217 }
192218 java_writer.print("class " + Utils.getSimpleClassName(d));
193 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
194 if (super_interfaces.size() > 1)
219 List<? extends TypeMirror> super_interfaces = d.getInterfaces();
220 if ( super_interfaces.size() > 1 ) {
195221 throw new RuntimeException(d + " extends more than one interface");
196 if (super_interfaces.size() == 1) {
197 InterfaceDeclaration super_interface = super_interfaces.iterator().next().getDeclaration();
198 java_writer.print(" extends " + Utils.getSimpleClassName(super_interface));
222 }
223 if ( super_interfaces.size() == 1 ) {
224 TypeMirror super_interface = super_interfaces.iterator().next();
225 java_writer.print(" extends " + Utils.getSimpleClassName(env.getElementUtils().getTypeElement(super_interface.toString())));
199226 }
200227 java_writer.println(" {");
201 FieldsGenerator.generateFields(java_writer, d.getFields());
228 FieldsGenerator.generateFields(env, java_writer, Utils.getFields(d));
202229 java_writer.println();
203 if (is_final) {
230 if ( is_final ) {
204231 // Write private constructor to avoid instantiation
205232 java_writer.println("\tprivate " + Utils.getSimpleClassName(d) + "() {}");
206233 }
207 if (d.getMethods().size() > 0 && !context_specific) {
234 if ( Utils.getMethods(d).size() > 0 && !context_specific ) {
208235 java_writer.println();
209236 java_writer.println("\tstatic native void " + Utils.STUB_INITIALIZER_NAME + "() throws LWJGLException;");
210237 }
212239 java_writer.println("}");
213240 java_writer.close();
214241 String qualified_interface_name = Utils.getQualifiedClassName(d);
215 env.getMessager().printNotice("Generated class " + qualified_interface_name);
216 }
217
218 private void generateNativeSource(InterfaceDeclaration d) throws IOException {
242 env.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generated class " + qualified_interface_name);
243 }
244
245 private void generateNativeSource(TypeElement d) throws IOException {
246 if ( d.getKind().equals(ElementKind.ANNOTATION_TYPE) ) {
247 return;
248 }
219249 String qualified_interface_name = Utils.getQualifiedClassName(d);
220 String qualified_native_name = Utils.getNativeQualifiedName(qualified_interface_name)+ ".c";
221 PrintWriter native_writer = env.getFiler().createTextFile(Filer.Location.CLASS_TREE, "", new File(qualified_native_name), "UTF-8");
250 String qualified_native_name = Utils.getNativeQualifiedName(qualified_interface_name) + ".c";
251 PrintWriter native_writer = new PrintWriter(env.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", qualified_native_name).openWriter());
222252 native_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
223253 native_writer.println();
224254 native_writer.println("#include <jni.h>");
225255 type_map.printNativeIncludes(native_writer);
226256 native_writer.println();
227 TypedefsGenerator.generateNativeTypedefs(type_map, native_writer, d.getMethods());
257 TypedefsGenerator.generateNativeTypedefs(type_map, native_writer, Utils.getMethods(d));
228258 native_writer.println();
229 if (!context_specific) {
230 generateMethodsNativePointers(native_writer, d.getMethods());
259 if ( !context_specific ) {
260 generateMethodsNativePointers(native_writer, Utils.getMethods(d));
231261 native_writer.println();
232262 }
233263 NativeMethodStubsGenerator.generateNativeMethodStubs(env, type_map, native_writer, d, generate_error_checks, context_specific);
234 if (!context_specific) {
264 if ( !context_specific ) {
235265 native_writer.print("JNIEXPORT void JNICALL " + Utils.getQualifiedNativeMethodName(qualified_interface_name, Utils.STUB_INITIALIZER_NAME));
236266 native_writer.println("(JNIEnv *env, jclass clazz) {");
237267 native_writer.println("\tJavaMethodAndExtFunction functions[] = {");
244274 native_writer.println("}");
245275 }
246276 native_writer.close();
247 env.getMessager().printNotice("Generated C source " + qualified_interface_name);
248 }
249
250 public void visitInterfaceDeclaration(InterfaceDeclaration d) {
251 final File input = d.getPosition().file();
252 final File outputJava = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java");
277 env.getMessager().printMessage(Kind.NOTE, "Generated C source " + qualified_interface_name);
278 }
279
280 @Override
281 public Void visitTypeAsInterface(TypeElement e, Void p) {
282 final File input = new File("src/templates/" + e.getQualifiedName().toString().replace('.', '/') + ".java");
283 final File outputJava = new File("src/generated/" + env.getElementUtils().getPackageOf(e).getQualifiedName().toString().replace('.', '/'), Utils.getSimpleClassName(e) + ".java");
253284
254285 PrintWriter java_writer = null;
255
256286 try {
257 final Collection<? extends MethodDeclaration> methods = d.getMethods();
258 if ( methods.size() == 0 && d.getFields().size() == 0 )
259 return;
287 final Collection<? extends ExecutableElement> methods = Utils.getMethods(e);
288 if ( methods.isEmpty() && Utils.getFields(e).isEmpty() ) {
289 return DEFAULT_VALUE;
290 }
260291
261292 // Skip this class if the output exists and the input has not been modified.
262293 if ( outputJava.exists() && Math.max(input.lastModified(), generatorLM) < outputJava.lastModified() )
263 return;
264
265 for ( final MethodDeclaration method : methods )
294 return DEFAULT_VALUE;
295
296 //env.getMessager().printMessage(Kind.NOTE, "methods count : " + Utils.getMethods(e).size() + " fields count : " + Utils.getFields(e).size(), e);
297 for ( final ExecutableElement method : methods ) {
266298 validateMethod(method);
267 java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
268 generateJavaSource(d, java_writer);
299 }
300
301 // TODO: Back-port LWJGL 3's generation file handling (generate in-memory and avoid touching files if nothing has changed)
302 java_writer = new PrintWriter(env.getFiler().createSourceFile(Utils.getQualifiedClassName(e), env.getElementUtils().getPackageOf(e)).openWriter());
303 generateJavaSource(e, java_writer);
269304
270305 if ( methods.size() > 0 ) {
271 boolean hasNative = false;
272 for ( final MethodDeclaration method : methods ) {
306 boolean noNative = true;
307 for ( final ExecutableElement method : methods ) {
273308 Alternate alt_annotation = method.getAnnotation(Alternate.class);
274309 if ( (alt_annotation == null || alt_annotation.nativeAlt()) && method.getAnnotation(Reuse.class) == null ) {
275 hasNative = true;
310 noNative = false;
276311 break;
277312 }
278313 }
279 if ( !hasNative )
280 return;
281
282 final String outputPath = env.getOptions().get("-d") + '/' + Utils.getNativeQualifiedName(Utils.getQualifiedClassName(d));
283 final File outputNative = new File(outputPath + ".c");
284 final File outputBackup = new File(outputPath + "_backup.c");
285
286 // If the native file exists, rename.
287 final ByteBuffer nativeBefore;
288 if ( outputNative.exists() ) {
289 nativeBefore = readFile(outputNative);
290 outputNative.renameTo(outputBackup);
291 } else
292 nativeBefore = null;
314 if ( noNative ) {
315 return DEFAULT_VALUE;
316 }
293317
294318 try {
295 generateNativeSource(d);
296
297 // If the native file did exist, compare with the new file. If they're the same,
298 // reset the last modified time to avoid ridiculous C compilation times.
299 if ( nativeBefore != null && outputNative.length() == nativeBefore.capacity() ) {
300 final ByteBuffer nativeAfter = readFile(outputNative);
301 boolean same = true;
302 for ( int i = nativeBefore.position(); i < nativeBefore.limit(); i++ ) {
303 if ( nativeBefore.get(i) != nativeAfter.get(i) ) {
304 same = false;
305 break;
306 }
307 }
308
309 if ( same ) {
310 outputNative.delete();
311 outputBackup.renameTo(outputNative);
312 }
313 }
314 } finally {
315 if ( outputBackup.exists() )
316 outputBackup.delete();
317 }
318 }
319 } catch (Exception e) {
319 generateNativeSource(e);
320 } catch (IOException ex) {
321 throw new RuntimeException(ex);
322 }
323 }
324 return DEFAULT_VALUE;
325 } catch (Exception ex) {
320326 // If anything goes wrong mid-gen, delete output to allow regen next time we run.
321327 if ( java_writer != null ) java_writer.close();
322328 if ( outputJava.exists() ) outputJava.delete();
323329
324 throw new RuntimeException(e);
330 throw new RuntimeException(ex);
325331 }
326332 }
327333
3636 * stub to use the indirection operator '&' on it.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: Indirect.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3131
3232 package org.lwjgl.util.generator;
3333
34 import com.sun.mirror.type.*;
35 import com.sun.mirror.util.*;
34 import org.lwjgl.PointerBuffer;
35
36 import java.nio.Buffer;
37 import javax.lang.model.type.ArrayType;
38 import javax.lang.model.type.DeclaredType;
39 import javax.lang.model.type.NoType;
40 import javax.lang.model.type.PrimitiveType;
41 import javax.lang.model.util.SimpleTypeVisitor6;
3642
3743 /**
38 *
3944 * A TypeVisitor that translates TypeMirrors to JNI
4045 * type strings.
4146 *
4247 * @author elias_naur <elias_naur@users.sourceforge.net>
43 * @version $Revision: 3412 $
44 * $Id: JNITypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
48 * @version $Revision$
49 * $Id$
4550 */
46 public class JNITypeTranslator implements TypeVisitor {
51 public class JNITypeTranslator extends SimpleTypeVisitor6<Void, Void> {
52
4753 private final StringBuilder signature = new StringBuilder();
54
55 private boolean objectReturn;
4856
4957 public String getSignature() {
5058 return signature.toString();
5159 }
5260
53 public void visitAnnotationType(AnnotationType t) {
54 throw new RuntimeException(t + " is not allowed");
61 public String getReturnSignature() {
62 return objectReturn ? "jobject" : signature.toString();
5563 }
5664
57 public void visitArrayType(ArrayType t) {
65 @Override
66 public Void visitArray(ArrayType t, Void o) {
5867 final String className = t.getComponentType().toString();
5968 if ( "java.lang.CharSequence".equals(className) )
60 signature.append("jobject");
69 signature.append("jlong");
6170 else if ( "java.nio.ByteBuffer".equals(className) )
6271 signature.append("jobjectArray");
6372 else if ( "org.lwjgl.opencl.CLMem".equals(className) )
6473 signature.append("jobjectArray");
6574 else
6675 throw new RuntimeException(t + " is not allowed");
76 return DEFAULT_VALUE;
6777 }
6878
69 public void visitClassType(ClassType t) {
70 signature.append("jobject");
79 private void visitClassType(DeclaredType t) {
80 final Class<?> type = Utils.getJavaType(t);
81 if ( Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) ) {
82 signature.append("jlong");
83 objectReturn = true;
84 } else
85 signature.append("jobject");
7186 }
7287
73 public void visitDeclaredType(DeclaredType t) {
74 throw new RuntimeException(t + " is not allowed");
88 @Override
89 public Void visitDeclared(DeclaredType t, Void o) {
90 if ( t.asElement().getKind().isClass() )
91 visitClassType(t);
92 return DEFAULT_VALUE;
7593 }
7694
77 public void visitEnumType(EnumType t) {
78 throw new RuntimeException(t + " is not allowed");
79 }
80
81 public void visitInterfaceType(InterfaceType t) {
82 throw new RuntimeException(t + " is not allowed");
83 }
84
85 public void visitPrimitiveType(PrimitiveType t) {
95 @Override
96 public Void visitPrimitive(PrimitiveType t, Void o) {
8697 String type;
87 switch (t.getKind()) {
98 switch ( t.getKind() ) {
8899 case LONG:
89100 type = "jlong";
90101 break;
110121 throw new RuntimeException(t + " is not allowed");
111122 }
112123 signature.append(type);
124 return DEFAULT_VALUE;
113125 }
114126
115 public void visitReferenceType(ReferenceType t) {
116 throw new RuntimeException(t + " is not allowed");
127 @Override
128 public Void visitNoType(NoType t, Void o) {
129 signature.append(t.toString());
130 return DEFAULT_VALUE;
117131 }
118132
119 public void visitTypeMirror(TypeMirror t) {
120 throw new RuntimeException(t + " is not allowed");
121 }
122
123 public void visitTypeVariable(TypeVariable t) {
124 throw new RuntimeException(t + " is not allowed");
125 }
126
127 public void visitVoidType(VoidType t) {
128 signature.append(t.toString());
129 }
130
131 public void visitWildcardType(WildcardType t) {
132 throw new RuntimeException(t + " is not allowed");
133 }
134133 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
3433 /**
3635 * This class generates the methods in the generated java source files.
3736 *
3837 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3460 $
40 * $Id: JavaMethodsGenerator.java 3460 2010-11-29 18:25:28Z spasi $
38 * @version $Revision$ $Id$
4139 */
42
4340 import org.lwjgl.PointerBuffer;
4441 import org.lwjgl.util.generator.opengl.GLreturn;
4542
46 import com.sun.mirror.apt.*;
47 import com.sun.mirror.declaration.*;
48 import com.sun.mirror.type.*;
49
50 import java.io.*;
43 import java.io.PrintWriter;
44 import java.nio.*;
5145 import java.util.*;
52 import java.nio.*;
46 import java.util.regex.Matcher;
47 import java.util.regex.Pattern;
48 import javax.annotation.processing.ProcessingEnvironment;
49 import javax.lang.model.element.AnnotationMirror;
50 import javax.lang.model.element.ExecutableElement;
51 import javax.lang.model.element.TypeElement;
52 import javax.lang.model.element.VariableElement;
53 import javax.lang.model.type.TypeKind;
54 import javax.lang.model.type.TypeMirror;
5355
5456 public class JavaMethodsGenerator {
57
5558 private static final String SAVED_PARAMETER_POSTFIX = "_saved";
5659
57 public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) {
58 for (MethodDeclaration method : interface_decl.getMethods())
60 public static void generateMethodsJava(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, TypeElement interface_decl, boolean generate_error_checks, boolean context_specific) {
61 for ( ExecutableElement method : Utils.getMethods(interface_decl) ) {
5962 generateMethodJava(env, type_map, writer, interface_decl, method, generate_error_checks, context_specific);
60 }
61
62 private static void generateMethodJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
63 }
64 }
65
66 /**
67 * TODO : fix info multi-type methods print.
68 */
69 private static void generateMethodJava(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, TypeElement interface_decl, ExecutableElement method, boolean generate_error_checks, boolean context_specific) {
6370 writer.println();
64 if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) {
65 if (method.getAnnotation(GenerateAutos.class) != null) {
71 if ( Utils.isMethodIndirect(generate_error_checks, context_specific, method) ) {
72 if ( method.getAnnotation(GenerateAutos.class) != null ) {
6673 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.AUTOS, generate_error_checks, context_specific);
6774 }
68 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product = TypeInfo.getTypeInfoCrossProduct(type_map, method);
69 for (Map<ParameterDeclaration, TypeInfo> typeinfos_instance : cross_product) {
75 Collection<Map<VariableElement, TypeInfo>> cross_product = TypeInfo.getTypeInfoCrossProduct(type_map, method);
76 for ( Map<VariableElement, TypeInfo> typeinfos_instance : cross_product ) {
7077 printMethodWithMultiType(env, type_map, writer, interface_decl, method, typeinfos_instance, Mode.NORMAL, generate_error_checks, context_specific);
7178 }
7279 }
7784 Reuse reuse_annotation = method.getAnnotation(Reuse.class);
7885 Alternate alt_annotation = method.getAnnotation(Alternate.class);
7986 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !alt_annotation.skipNative()) ) {
80 if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) )
87 if ( alt_annotation != null && method.getSimpleName().toString().equals(alt_annotation.value()) ) {
8188 throw new RuntimeException("An alternate function with native code should have a different name than the main function.");
82
83 if ( reuse_annotation == null )
84 printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
85
86 if (Utils.hasMethodBufferObjectParameter(method)) {
89 }
90
91 if ( reuse_annotation == null ) {
92 printJavaNativeStub(env, writer, method, Mode.NORMAL, generate_error_checks, context_specific);
93 }
94
95 if ( Utils.hasMethodBufferObjectParameter(method) ) {
8796 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific);
88 if ( reuse_annotation == null )
89 printJavaNativeStub(writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
90 }
91 }
92 }
93
94 private static void printJavaNativeStub(PrintWriter writer, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
95 if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) {
97 if ( reuse_annotation == null ) {
98 printJavaNativeStub(env, writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
99 }
100 }
101 }
102 }
103
104 private static void printJavaNativeStub(ProcessingEnvironment env, PrintWriter writer, ExecutableElement method, Mode mode, boolean generate_error_checks, boolean context_specific) {
105 if ( Utils.isMethodIndirect(generate_error_checks, context_specific, method) ) {
96106 writer.print("\tstatic native ");
97107 } else {
98 Utils.printDocComment(writer, method);
108 Utils.printDocComment(writer, method, env);
99109 writer.print("\tpublic static native ");
100110 }
101111 writer.print(getResultType(method, true));
102112 writer.print(" " + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
103 if (mode == Mode.BUFFEROBJECT)
113 if ( mode == Mode.BUFFEROBJECT ) {
104114 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
115 }
105116 writer.print("(");
106117 boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, true, mode);
107 if (context_specific) {
108 if (!first_parameter)
118 if ( context_specific ) {
119 if ( !first_parameter ) {
109120 writer.print(", ");
121 }
110122 writer.print("long " + Utils.FUNCTION_POINTER_VAR_NAME);
111123 }
112124 writer.println(");");
113125 }
114126
115 private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, boolean native_stub, final boolean printTypes, Mode mode) {
127 private static boolean generateParametersJava(PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos_instance, boolean native_stub, final boolean printTypes, Mode mode) {
116128 boolean first_parameter = true;
117 for (ParameterDeclaration param : method.getParameters()) {
118 if ( native_stub && (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
129 for ( VariableElement param : method.getParameters() ) {
130 if ( native_stub && (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) {
119131 continue;
132 }
120133 final Constant constant_annotation = param.getAnnotation(Constant.class);
121 if ( constant_annotation != null && constant_annotation.isNative() )
134 if ( constant_annotation != null && constant_annotation.isNative() ) {
122135 continue;
136 }
123137 AnnotationMirror auto_annotation_mirror = Utils.getParameterAutoAnnotation(param);
124138 boolean hide_auto_parameter = mode == Mode.NORMAL && !native_stub && auto_annotation_mirror != null;
125 if (hide_auto_parameter) {
139 if ( hide_auto_parameter ) {
126140 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
127 if (auto_type_annotation != null) {
128 ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
141 if ( auto_type_annotation != null ) {
142 VariableElement auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
129143 TypeInfo auto_param_type_info = typeinfos_instance.get(auto_parameter);
130 if (auto_param_type_info.getSignedness() == Signedness.BOTH) {
131 if (!first_parameter)
144 if ( auto_param_type_info.getSignedness() == Signedness.BOTH ) {
145 if ( !first_parameter ) {
132146 writer.print(", ");
147 }
133148 first_parameter = false;
134 if ( printTypes )
149 if ( printTypes ) {
135150 writer.print("boolean ");
151 }
136152 writer.print(TypeInfo.UNSIGNED_PARAMETER_NAME);
137153 }
138154 }
139 } else if (
140 param.getAnnotation(Result.class) == null
155 } else if ( param.getAnnotation(Result.class) == null
141156 && (native_stub || ((param.getAnnotation(Constant.class) == null || param.getAnnotation(Constant.class).keepParam()) && !Utils.isReturnParameter(method, param)))
142 && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null)
143 ) {
157 && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) ) {
144158 first_parameter = generateParameterJava(writer, param, typeinfos_instance.get(param), native_stub, printTypes, first_parameter, mode);
145159 }
146160 }
147161 CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
148162 TypeMirror result_type = Utils.getMethodReturnType(method);
149 if ((native_stub && Utils.getNIOBufferType(result_type) != null) || Utils.needResultSize(method)) {
163 if ( (native_stub && Utils.getNIOBufferType(result_type) != null) || Utils.needResultSize(method) ) {
150164 AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
151165 if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) {
152 if (cached_result_annotation == null || !cached_result_annotation.isRange()) {
153 if (!first_parameter)
166 if ( cached_result_annotation == null || !cached_result_annotation.isRange() ) {
167 if ( !first_parameter ) {
154168 writer.print(", ");
169 }
155170 first_parameter = false;
156 if ( printTypes )
171 if ( printTypes ) {
157172 writer.print("long ");
173 }
158174 writer.print(Utils.RESULT_SIZE_NAME);
159175 }
160176 }
161177 }
162 if (cached_result_annotation != null) {
163 if (!first_parameter)
178 if ( cached_result_annotation != null ) {
179 if ( !first_parameter ) {
164180 writer.print(", ");
181 }
165182
166183 if ( mode == Mode.CACHEDRESULT ) {
167 if ( printTypes )
184 if ( printTypes ) {
168185 writer.print("long ");
186 }
169187 writer.print(Utils.CACHED_BUFFER_LENGTH_NAME + ", ");
170188 }
171189
172190 first_parameter = false;
173 if ( printTypes )
191 if ( printTypes ) {
174192 writer.print(getResultType(method, native_stub));
193 }
175194 writer.print(" " + Utils.CACHED_BUFFER_NAME);
176195 }
177196 return first_parameter;
178197 }
179198
180 private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, final boolean printTypes, boolean first_parameter, Mode mode) {
181 Class buffer_type = Utils.getNIOBufferType(param.getType());
182 if (!first_parameter)
199 private static boolean generateParameterJava(PrintWriter writer, VariableElement param, TypeInfo type_info, boolean native_stub, final boolean printTypes, boolean first_parameter, Mode mode) {
200 Class buffer_type = Utils.getNIOBufferType(param.asType());
201 if ( !first_parameter ) {
183202 writer.print(", ");
203 }
184204 BufferObject bo_annotation = param.getAnnotation(BufferObject.class);
185 if (bo_annotation != null && mode == Mode.BUFFEROBJECT) {
186 if (buffer_type == null)
205 if ( bo_annotation != null && mode == Mode.BUFFEROBJECT ) {
206 if ( buffer_type == null ) {
187207 throw new RuntimeException("type of " + param + " is not a nio Buffer parameter but is annotated as buffer object");
188 if ( printTypes )
208 }
209 if ( printTypes ) {
189210 writer.print("long ");
211 }
190212 writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
191213 } else {
192 if ( native_stub && param.getAnnotation(PointerWrapper.class) != null )
214 if ( native_stub && param.getAnnotation(PointerWrapper.class) != null ) {
193215 writer.print("long ");
194 else {
216 } else {
195217 Class type = type_info.getType();
196 if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class) )
197 writer.print("ByteBuffer ");
198 else if ( printTypes )
199 writer.print(type_info.getType().getSimpleName() + " ");
218 if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class || Buffer.class.isAssignableFrom(type)) ) {
219 writer.print("long ");
220 } else if ( printTypes ) {
221 writer.print(type.getSimpleName() + " ");
222 }
200223 }
201224 AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
202 if ( auto_size_annotation != null )
225 if ( auto_size_annotation != null ) {
203226 writer.print(auto_size_annotation.value() + "_");
227 }
204228 writer.print(param.getSimpleName());
205 if ( native_stub && buffer_type != null )
206 writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX);
207229 }
208230 return false;
209231 }
210232
211 private static void printBufferObjectCheck(PrintWriter writer, BufferKind kind, Mode mode) {
233 private static void printBufferObjectCheck(PrintWriter writer, BufferKind kind, Mode mode, boolean context_specific) {
212234 String bo_check_method_name = kind.toString();
213235 writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".ensure" + bo_check_method_name);
214 if (mode == Mode.BUFFEROBJECT)
236 if ( mode == Mode.BUFFEROBJECT ) {
215237 writer.print("enabled");
216 else
238 } else {
217239 writer.print("disabled");
218 writer.println("(caps);");
219 }
220
221 private static void printBufferObjectChecks(PrintWriter writer, MethodDeclaration method, Mode mode) {
240 }
241
242 if ( context_specific ) {
243 writer.println("(caps);");
244 } else {
245 writer.println("();");
246 }
247 }
248
249 private static void printBufferObjectChecks(PrintWriter writer, ExecutableElement method, Mode mode, boolean context_specific) {
222250 EnumSet<BufferKind> check_set = EnumSet.noneOf(BufferKind.class);
223 for (ParameterDeclaration param : method.getParameters()) {
251 for ( VariableElement param : method.getParameters() ) {
224252 BufferObject bo_annotation = param.getAnnotation(BufferObject.class);
225 if (bo_annotation != null)
253 if ( bo_annotation != null ) {
226254 check_set.add(bo_annotation.value());
227 }
228 for (BufferKind kind : check_set)
229 printBufferObjectCheck(writer, kind, mode);
230 }
231
232 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) {
233 Utils.printDocComment(writer, method);
234 if ( interface_decl.getAnnotation(Private.class) == null && method.getAnnotation(Private.class) == null )
255 }
256 }
257 for ( BufferKind kind : check_set ) {
258 printBufferObjectCheck(writer, kind, mode, context_specific);
259 }
260 }
261
262 private static void printMethodWithMultiType(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, TypeElement interface_decl, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos_instance, Mode mode, boolean generate_error_checks, boolean context_specific) {
263 Utils.printDocComment(writer, method, env);
264 if ( method.getAnnotation(Deprecated.class) != null ) {
265 writer.println("\t@Deprecated");
266 }
267 if ( interface_decl.getAnnotation(Private.class) == null && method.getAnnotation(Private.class) == null ) {
235268 writer.print("\tpublic static ");
236 else
269 } else {
237270 writer.print("\tstatic ");
271 }
238272 writer.print(getResultType(method, false));
239273 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
240274 String method_name;
241275 Alternate alt_annotation = method.getAnnotation(Alternate.class);
242 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value();
243 if (strip_annotation != null && mode == Mode.NORMAL)
276 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName().toString() : alt_annotation.value();
277 if ( strip_annotation != null && mode == Mode.NORMAL ) {
244278 method_name = getPostfixStrippedName(type_map, interface_decl, method);
279 }
245280 writer.print(" " + method_name + "(");
246281 generateParametersJava(writer, method, typeinfos_instance, false, true, mode);
247282 writer.println(") {");
248283
249284 final TypeMirror result_type = Utils.getMethodReturnType(method);
250 boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType());
285 boolean has_result = !result_type.equals(env.getTypeUtils().getNoType(TypeKind.VOID));
251286
252287 final Reuse reuse_annotation = method.getAnnotation(Reuse.class);
253288 if ( reuse_annotation != null ) {
254289 writer.print("\t\t");
255 if ( has_result || method.getAnnotation(GLreturn.class) != null )
290 if ( has_result || method.getAnnotation(GLreturn.class) != null ) {
256291 writer.print("return ");
257
258 writer.print(reuse_annotation.value() + "." + method_name + "(");
292 }
293
294 writer.print(reuse_annotation.value() + "." + (reuse_annotation.method().length() > 0 ? reuse_annotation.method() : method_name) + "(");
259295 generateParametersJava(writer, method, typeinfos_instance, false, false, mode);
260296 writer.println(");\n\t}");
261297 return;
262298 }
263299
264 if (context_specific) {
300 if ( context_specific ) {
265301 type_map.printCapabilitiesInit(writer);
266302 writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = " + type_map.getCapabilities() + ".");
267303 writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";");
269305 writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
270306 }
271307 final Code code_annotation = method.getAnnotation(Code.class);
272 if (code_annotation != null && code_annotation.value().length() > 0)
308 if ( code_annotation != null && code_annotation.value().length() > 0 ) {
273309 writer.println(code_annotation.value());
274 printBufferObjectChecks(writer, method, mode);
310 }
311 printBufferObjectChecks(writer, method, mode, context_specific);
275312 printParameterChecks(writer, method, typeinfos_instance, mode, generate_error_checks);
276 printParameterCaching(writer, interface_decl, method, mode);
277
278 if ( code_annotation != null && code_annotation.javaBeforeNative().length() > 0 )
313 printParameterCaching(writer, interface_decl, method, mode, context_specific);
314
315 if ( code_annotation != null && code_annotation.javaBeforeNative().length() > 0 ) {
279316 writer.println(code_annotation.javaBeforeNative());
317 }
280318 writer.print("\t\t");
281319
282320 final PointerWrapper pointer_wrapper_annotation = method.getAnnotation(PointerWrapper.class);
283 if (has_result) {
321 if ( has_result ) {
284322 writer.print(getResultType(method, false) + " " + Utils.RESULT_VAR_NAME);
285323
286324 if ( code_annotation != null && code_annotation.tryBlock() ) {
291329
292330 writer.print(" = ");
293331 if ( pointer_wrapper_annotation != null ) {
294 if ( pointer_wrapper_annotation.factory().length() > 0 )
332 if ( pointer_wrapper_annotation.factory().length() > 0 ) {
295333 writer.print(pointer_wrapper_annotation.factory() + "(");
296 else
334 } else {
297335 writer.print("new " + getResultType(method, false) + "(");
336 }
298337 }
299338 } else if ( method.getAnnotation(GLreturn.class) != null ) {
300339 has_result = true;
301 Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class));
340 Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class), type_map);
302341 }
303342 writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
304 if (mode == Mode.BUFFEROBJECT)
343 if ( mode == Mode.BUFFEROBJECT ) {
305344 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
345 }
306346 writer.print("(");
307 boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode);
308 if (context_specific) {
309 if (!first_parameter)
347 boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode, type_map);
348 if ( context_specific ) {
349 if ( !first_parameter ) {
310350 writer.print(", ");
351 }
311352 writer.print(Utils.FUNCTION_POINTER_VAR_NAME);
312353 }
313354 if ( has_result && pointer_wrapper_annotation != null ) {
314355 writer.print(")");
315 if ( pointer_wrapper_annotation.params().length() > 0 )
356 if ( pointer_wrapper_annotation.params().length() > 0 ) {
316357 writer.print(", " + pointer_wrapper_annotation.params());
358 }
317359 }
318360 writer.println(");");
319361
320 if ( code_annotation != null && code_annotation.javaAfterNative().length() > 0 )
362 if ( code_annotation != null && code_annotation.javaAfterNative().length() > 0 ) {
321363 writer.println(code_annotation.javaAfterNative());
364 }
322365
323366 final String tabs = code_annotation != null && code_annotation.tryBlock() ? "\t\t\t" : "\t\t";
324 if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null)
367 if ( generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null ) {
325368 type_map.printErrorCheckMethod(writer, method, tabs);
369 }
326370 // DISABLED: indirect buffer support
327371 //printNondirectParameterCopies(writer, method, mode);
328 if (has_result) {
372 if ( has_result ) {
329373 if ( method.getAnnotation(GLreturn.class) == null ) {
330 if ( ByteBuffer.class.equals(Utils.getJavaType(result_type)) )
374 if ( ByteBuffer.class.equals(Utils.getJavaType(result_type)) ) {
331375 writer.println(tabs + "return LWJGLUtil.CHECKS && " + Utils.RESULT_VAR_NAME + " == null ? null : " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order.
332 else
376 } else {
333377 writer.println(tabs + "return " + Utils.RESULT_VAR_NAME + ";");
334 } else
335 Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class));
378 }
379 } else {
380 Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class), type_map);
381 }
336382 }
337383
338384 if ( code_annotation != null && code_annotation.tryBlock() ) {
343389 writer.println("\t}");
344390 }
345391
346 private static String getExtensionPostfix(InterfaceDeclaration interface_decl) {
347 String interface_simple_name = interface_decl.getSimpleName();
392 private static String getExtensionPostfix(TypeElement interface_decl) {
393 String interface_simple_name = interface_decl.getSimpleName().toString();
348394 Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
349 if (extension_annotation == null) {
395 if ( extension_annotation == null ) {
350396 int underscore_index = interface_simple_name.indexOf("_");
351 if (underscore_index != -1)
397 if ( underscore_index != -1 ) {
352398 return interface_simple_name.substring(0, underscore_index);
353 else
399 } else {
354400 return "";
355 } else
401 }
402 } else {
356403 return extension_annotation.postfix();
357 }
358
359 private static ParameterDeclaration getAutoTypeParameter(MethodDeclaration method, ParameterDeclaration target_parameter) {
360 for (ParameterDeclaration param : method.getParameters()) {
404 }
405 }
406
407 private static VariableElement getAutoTypeParameter(ExecutableElement method, VariableElement target_parameter) {
408 for ( VariableElement param : method.getParameters() ) {
361409 AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param);
362 if (auto_annotation != null) {
410 if ( auto_annotation != null ) {
363411 Class annotation_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType());
364412 String parameter_name;
365 if (annotation_type.equals(AutoType.class))
413 if ( annotation_type.equals(AutoType.class) ) {
366414 parameter_name = param.getAnnotation(AutoType.class).value();
367 else if (annotation_type.equals(AutoSize.class))
415 } else if ( annotation_type.equals(AutoSize.class) ) {
368416 parameter_name = param.getAnnotation(AutoSize.class).value();
369 else
417 } else {
370418 throw new RuntimeException("Unknown annotation type " + annotation_type);
371 if (target_parameter.getSimpleName().equals(parameter_name))
419 }
420 if ( target_parameter.getSimpleName().toString().equals(parameter_name) ) {
372421 return param;
422 }
373423 }
374424 }
375425 return null;
376426 }
377427
378 private static boolean hasAnyParameterAutoTypeAnnotation(MethodDeclaration method, ParameterDeclaration target_param) {
379 for (ParameterDeclaration param : method.getParameters()) {
428 private static boolean hasAnyParameterAutoTypeAnnotation(ExecutableElement method, VariableElement target_param) {
429 for ( VariableElement param : method.getParameters() ) {
380430 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
381 if (auto_type_annotation != null) {
382 ParameterDeclaration type_target_param = Utils.findParameter(method, auto_type_annotation.value());
383 if (target_param.equals(type_target_param))
431 if ( auto_type_annotation != null ) {
432 VariableElement type_target_param = Utils.findParameter(method, auto_type_annotation.value());
433 if ( target_param.equals(type_target_param) ) {
384434 return true;
435 }
385436 }
386437 }
387438 return false;
388439 }
389440
390 private static String getPostfixStrippedName(TypeMap type_map, InterfaceDeclaration interface_decl, MethodDeclaration method) {
441 private static final Map<String, Pattern> postfixPatterns = new HashMap<String, Pattern>();
442
443 private static Pattern getPostfixPattern(String regex) {
444 Pattern pattern = postfixPatterns.get(regex);
445 if ( pattern == null ) {
446 postfixPatterns.put(regex, pattern = Pattern.compile(regex));
447 }
448 return pattern;
449 }
450
451 private static String getPostfixStrippedName(TypeMap type_map, TypeElement interface_decl, ExecutableElement method) {
391452 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
392 ParameterDeclaration postfix_parameter = Utils.findParameter(method, strip_annotation.value());
453 VariableElement postfix_parameter = Utils.findParameter(method, strip_annotation.value());
393454 String postfix = strip_annotation.postfix();
394 if ( "NULL".equals(postfix) ) {
455 boolean postfixOverride = !("NULL".equals(postfix) && strip_annotation.hasPostfix());
456 if ( !postfixOverride ) {
395457 PostfixTranslator translator = new PostfixTranslator(type_map, postfix_parameter);
396 postfix_parameter.getType().accept(translator);
458 postfix_parameter.asType().accept(translator, null);
397459 postfix = translator.getSignature();
398 }
460 } else if ( !strip_annotation.hasPostfix() ) {
461 postfix = "";
462 }
463
399464 String method_name;
400465 Alternate alt_annotation = method.getAnnotation(Alternate.class);
401 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value();
466 method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName().toString() : alt_annotation.value();
402467
403468 String extension_postfix = "NULL".equals(strip_annotation.extension()) ? getExtensionPostfix(interface_decl) : strip_annotation.extension();
404 String result;
405
406 if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "v" + extension_postfix))
407 result = method_name.substring(0, method_name.length() - (postfix.length() + 1 + extension_postfix.length()));
408 else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + extension_postfix))
409 result = method_name.substring(0, method_name.length() - (postfix.length() + extension_postfix.length()));
410 else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "i_v" + extension_postfix) )
411 result = method_name.substring(0, method_name.length() - (postfix.length() + 3 + extension_postfix.length()));
412 else if ( method_name.endsWith("i_v" + extension_postfix) )
413 result = method_name.substring(0, method_name.length() - (3 + extension_postfix.length()));
414 else if (method_name.endsWith("v" + extension_postfix))
415 result = method_name.substring(0, method_name.length() - (1 + extension_postfix.length()));
416 else
417 throw new RuntimeException(method + " is specified as being postfix stripped on parameter " + postfix_parameter + ", but it's postfix is not '" + postfix + "' nor 'v'");
418
419 return result + extension_postfix;
469
470 Matcher matcher = getPostfixPattern(
471 postfixOverride
472 ? (postfix + "(?:v)?" + extension_postfix + "$")
473 : ("(?:" + postfix + "(?:v)?|i(?:64)?_v|v)" + extension_postfix + "$")
474 ).matcher(method_name);
475
476 if ( !matcher.find() ) {
477 throw new RuntimeException(method_name + " is specified as being postfix stripped on parameter " + postfix_parameter + ", but it's postfix is neither '" + postfix + "' nor 'v'");
478 }
479
480 return method_name.substring(0, matcher.start()) + extension_postfix;
420481 }
421482
422483 private static int getBufferElementSizeExponent(Class c) {
423 if (IntBuffer.class.equals(c))
484 if ( IntBuffer.class.equals(c) ) {
424485 return 2;
425 else if (LongBuffer.class.equals(c))
486 } else if ( LongBuffer.class.equals(c) ) {
426487 return 3;
427 else if (DoubleBuffer.class.equals(c))
488 } else if ( DoubleBuffer.class.equals(c) ) {
428489 return 3;
429 else if (ShortBuffer.class.equals(c))
490 } else if ( ShortBuffer.class.equals(c) ) {
430491 return 1;
431 else if (ByteBuffer.class.equals(c))
492 } else if ( ByteBuffer.class.equals(c) ) {
432493 return 0;
433 else if (FloatBuffer.class.equals(c))
494 } else if ( FloatBuffer.class.equals(c) ) {
434495 return 2;
435 else
496 } else {
436497 throw new RuntimeException(c + " is not allowed");
437 }
438
439 private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter) {
440 if (!first_parameter)
498 }
499 }
500
501 private static boolean printMethodCallArgument(PrintWriter writer, ExecutableElement method, VariableElement param, Map<VariableElement, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter, TypeMap type_map) {
502 if ( !first_parameter ) {
441503 writer.print(", ");
504 }
442505
443506 AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param);
444507 Constant constant_annotation = param.getAnnotation(Constant.class);
445 if (constant_annotation != null) {
508 if ( constant_annotation != null ) {
446509 writer.print(constant_annotation.value());
447 } else if (auto_annotation != null && mode == Mode.NORMAL) {
510 } else if ( auto_annotation != null && mode == Mode.NORMAL ) {
448511 Class param_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType());
449 if (AutoType.class.equals(param_type)) {
512 if ( AutoType.class.equals(param_type) ) {
450513 final AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
451 final ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
514 final VariableElement auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
452515 final String auto_type = typeinfos_instance.get(auto_parameter).getAutoType();
453 if ( auto_type == null )
516 if ( auto_type == null ) {
454517 throw new RuntimeException("No auto type for parameter " + param.getSimpleName() + " in method " + method);
518 }
455519 writer.print(auto_type);
456 } else if (AutoSize.class.equals(param_type)) {
520 } else if ( AutoSize.class.equals(param_type) ) {
457521 final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
458 final String auto_parameter_name = auto_size_annotation.value();
459 final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
460 final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
461 final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
462 int shifting = 0;
463 if ( shift_remaining ) {
464 shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
465 if ( shifting > 0 )
466 writer.print("(");
467 }
468 if ( auto_size_annotation.canBeNull() )
469 writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
470 else
471 writer.print(auto_parameter_name + ".remaining()");
472 // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
473 if (shift_remaining && shifting > 0) {
474 writer.print(" << " + shifting);
475 writer.print(")");
522 if ( !auto_size_annotation.useExpression() ) {
523 final String auto_parameter_name = auto_size_annotation.value();
524 final VariableElement auto_target_param = Utils.findParameter(method, auto_parameter_name);
525 final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
526 final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
527 int shifting = 0;
528 if ( shift_remaining ) {
529 shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
530 if ( shifting > 0 ) {
531 writer.print("(");
532 }
533 }
534 if ( auto_size_annotation.canBeNull() ) {
535 writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
536 } else {
537 writer.print(auto_parameter_name + ".remaining()");
538 }
539 // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
540 if ( shift_remaining && shifting > 0 ) {
541 writer.print(" << " + shifting);
542 writer.print(")");
543 }
476544 }
477545 writer.print(auto_size_annotation.expression());
478 } else
546 } else {
479547 throw new RuntimeException("Unknown auto annotation " + param_type);
480 } else {
481 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
548 }
549 } else {
550 if ( mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null ) {
482551 writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
483552 } else {
484553 Class type = typeinfos_instance.get(param).getType();
485554 Check check_annotation = param.getAnnotation(Check.class);
486555 boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null;
487 if (hide_buffer) {
488 writer.print("null");
556 if ( hide_buffer ) {
557 writer.print("0L");
489558 } else {
490559 if ( type == CharSequence.class || type == CharSequence[].class ) {
491560 final String offset = Utils.getStringOffset(method, param);
492561
493562 writer.print("APIUtil.getBuffer");
494 if ( param.getAnnotation(NullTerminated.class) != null )
563 if ( param.getAnnotation(NullTerminated.class) != null ) {
495564 writer.print("NT");
496 writer.print("(" + param.getSimpleName());
497 if ( offset != null )
565 }
566 writer.print('(');
567 writer.print(type_map.getAPIUtilParam(true));
568 writer.print(param.getSimpleName());
569 if ( offset != null ) {
498570 writer.print(", " + offset);
571 }
499572 writer.print(")");
500 hide_buffer = true;
501573 } else {
502574 final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
503 if ( auto_size_annotation != null )
575 if ( auto_size_annotation != null ) {
504576 writer.print(auto_size_annotation.value() + "_");
505 writer.print(param.getSimpleName());
506 if ( PointerBuffer.class.isAssignableFrom(type) ) {
507 if ( check_annotation != null && check_annotation.canBeNull() )
508 writer.print(" != null ? " + param.getSimpleName());
509 writer.print(".getBuffer()");
510 if ( check_annotation != null && check_annotation.canBeNull() )
511 writer.print(" : null");
512577 }
513 }
514 }
515 Class buffer_type = Utils.getNIOBufferType(param.getType());
516 if (buffer_type != null) {
517 writer.print(", ");
518 if (!hide_buffer) {
519 int shifting;
520 if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) {
521 shifting = getBufferElementSizeExponent(type == Buffer.class ? ByteBuffer.class : type); // TODO: This will always throw an exception
522 //shifting = 0;
523 } else
524 shifting = 0;
525 writer.print(param.getSimpleName());
526 if (check_annotation != null && check_annotation.canBeNull())
527 writer.print(" != null ? " + param.getSimpleName());
528 if ( type == PointerBuffer.class )
529 writer.print(".positionByte()");
530 else
531 writer.print(".position()");
532 if (shifting > 0)
533 writer.print(" << " + shifting);
534 if (check_annotation != null && check_annotation.canBeNull())
535 writer.print(" : 0");
536 } else if ( type == CharSequence.class || type == CharSequence[].class ) {
537 final String offset = Utils.getStringOffset(method, param);
538 writer.print(offset == null ? "0" : offset);
539 } else
540 writer.print("0");
541 } else if ( type != long.class ) {
578
579 final Class buffer_type = Utils.getNIOBufferType(param.asType());
580 if ( buffer_type == null ) {
581 writer.print(param.getSimpleName());
582 } else {
583 writer.print("MemoryUtil.getAddress");
584 if ( check_annotation != null && check_annotation.canBeNull() ) {
585 writer.print("Safe");
586 }
587 writer.print("(");
588 writer.print(param.getSimpleName());
589 writer.print(")");
590 }
591 }
592 }
593 if ( type != long.class ) {
542594 PointerWrapper pointer_annotation = param.getAnnotation(PointerWrapper.class);
543595 if ( pointer_annotation != null ) {
544 if ( pointer_annotation.canBeNull() )
596 if ( pointer_annotation.canBeNull() ) {
545597 writer.print(" == null ? 0 : " + param.getSimpleName());
598 }
546599 writer.print(".getPointer()");
547600 }
548601 }
551604 return false;
552605 }
553606
554 private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) {
607 private static boolean printMethodCallArguments(PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos_instance, Mode mode, TypeMap type_map) {
555608 boolean first_parameter = true;
556 for ( ParameterDeclaration param : method.getParameters() ) {
557 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
609 for ( VariableElement param : method.getParameters() ) {
610 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) {
558611 continue;
612 }
559613
560614 final Constant constant_annotation = param.getAnnotation(Constant.class);
561 if ( constant_annotation== null || !constant_annotation.isNative() )
562 first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter);
563 }
564 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) {
565 if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) {
615 if ( constant_annotation == null || !constant_annotation.isNative() ) {
616 first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter, type_map);
617 }
618 }
619 if ( Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null ) {
620 if ( method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange() ) {
566621 first_parameter = false;
567622 Utils.printExtraCallArguments(writer, method, "");
568623 } else {
569624 AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
570625 if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) {
571 if (!first_parameter)
626 if ( !first_parameter ) {
572627 writer.print(", ");
628 }
573629 first_parameter = false;
574630
575631 String result_size_expression;
576 if ( mode == Mode.CACHEDRESULT )
632 if ( mode == Mode.CACHEDRESULT ) {
577633 result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME;
578 else if ( auto_size_annotation == null )
634 } else if ( auto_size_annotation == null ) {
579635 result_size_expression = Utils.RESULT_SIZE_NAME;
580 else
636 } else {
581637 result_size_expression = auto_size_annotation.value();
638 }
582639
583640 Utils.printExtraCallArguments(writer, method, result_size_expression);
584641 }
587644 return first_parameter;
588645 }
589646
590 private static void printParameterCaching(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Mode mode) {
591 for (ParameterDeclaration param : method.getParameters()) {
592 Class java_type = Utils.getJavaType(param.getType());
593 CachedReference cachedReference = param.getAnnotation(CachedReference.class);
594 if (Buffer.class.isAssignableFrom(java_type) &&
595 cachedReference != null &&
596 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
597 param.getAnnotation(Result.class) == null) {
598 writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + "StateTracker.getReferences(caps).");
599 if(cachedReference.name().length() > 0) {
600 writer.print(cachedReference.name());
601 } else {
602 writer.print(Utils.getReferenceName(interface_decl, method, param));
603 }
604 if(cachedReference.index().length() > 0) {
605 writer.print("[" + cachedReference.index() + "]");
606 }
647 private static void printParameterCaching(PrintWriter writer, TypeElement interface_decl, ExecutableElement method, Mode mode, boolean context_specific) {
648 for ( VariableElement param : method.getParameters() ) {
649 Class java_type = Utils.getJavaType(param.asType());
650 CachedReference cachedReference = param.getAnnotation(CachedReference.class);
651 if ( Buffer.class.isAssignableFrom(java_type)
652 && cachedReference != null
653 && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null)
654 && param.getAnnotation(Result.class) == null ) {
655 writer.print("\t\tif ( LWJGLUtil.CHECKS ) StateTracker.");
656 if ( context_specific ) {
657 writer.print("getReferences(caps).");
658 } else {
659 writer.print("getTracker().");
660 }
661 if ( cachedReference.name().length() > 0 ) {
662 writer.print(cachedReference.name());
663 } else {
664 writer.print(Utils.getReferenceName(interface_decl, method, param));
665 }
666 if ( cachedReference.index().length() > 0 ) {
667 writer.print("[" + cachedReference.index() + "]");
668 }
607669 writer.println(" = " + param.getSimpleName() + ";");
608670 }
609671 }
610672 }
611673
612 private static void printNondirectParameterCopies(PrintWriter writer, MethodDeclaration method, Mode mode) {
613 for (ParameterDeclaration param : method.getParameters()) {
614 Class java_type = Utils.getJavaType(param.getType());
615 if (Utils.isAddressableType(java_type) &&
616 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
617 (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) &&
618 param.getAnnotation(Result.class) == null) {
619 if (Buffer.class.isAssignableFrom(java_type)) {
620 boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
621 if (out_parameter)
622 writer.println("\t\tNondirectBufferWrapper.copy(" + param.getSimpleName() + ", " + param.getSimpleName() + SAVED_PARAMETER_POSTFIX + ");");
623 }
624 }
625 }
626 }
627
628 private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode, final boolean generate_error_checks) {
674 private static void printParameterChecks(PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos, Mode mode, final boolean generate_error_checks) {
629675 if ( mode == Mode.NORMAL ) {
630676 final GenerateAutos gen_autos_annotation = method.getAnnotation(GenerateAutos.class);
631677 if ( gen_autos_annotation != null && gen_autos_annotation.sizeVariables().length > 0 ) {
632678 // For the auto-generated parameters, declare and init a size variable (that can be reused by @Code)
633 for ( final ParameterDeclaration param : method.getParameters() ) {
634 if ( Arrays.binarySearch(gen_autos_annotation.sizeVariables(), param.getSimpleName()) >= 0 ) {
679 for ( final VariableElement param : method.getParameters() ) {
680 if ( Arrays.binarySearch(gen_autos_annotation.sizeVariables(), param.getSimpleName().toString()) >= 0 ) {
635681 final int shifting = getBufferElementSizeExponent(typeinfos.get(param).getType());
636682 final Check check_annotation = param.getAnnotation(Check.class);
637683
638684 writer.print("\t\tlong " + param.getSimpleName() + "_size = ");
639 if ( check_annotation == null || !check_annotation.canBeNull() )
685 if ( check_annotation == null || !check_annotation.canBeNull() ) {
640686 writer.println(param.getSimpleName() + ".remaining() << " + shifting + ";");
641 else
687 } else {
642688 writer.println(param.getSimpleName() + " == null ? 0 : " + param.getSimpleName() + ".remaining() << " + shifting + ";");
643 }
644 }
645 }
646 }
647
648 for (ParameterDeclaration param : method.getParameters()) {
649 Class java_type = Utils.getJavaType(param.getType());
650 if ( java_type.isArray() || (Utils.isAddressableType(java_type) &&
651 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
652 (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) &&
653 param.getAnnotation(Result.class) == null &&
654 !Utils.isReturnParameter(method, param)) ) {
689 }
690 }
691 }
692 }
693 }
694
695 for ( VariableElement param : method.getParameters() ) {
696 Class java_type = Utils.getJavaType(param.asType());
697 if ( java_type.isArray() || (Utils.isAddressableType(java_type)
698 && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null)
699 && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null)
700 && param.getAnnotation(Result.class) == null
701 && !Utils.isReturnParameter(method, param)) ) {
655702 String check_value = null;
656703 boolean can_be_null = false;
657704 Check check_annotation = param.getAnnotation(Check.class);
658 if (check_annotation != null) {
705 if ( check_annotation != null ) {
659706 check_value = check_annotation.value();
660707 can_be_null = check_annotation.canBeNull();
661708 }
662 if ((Buffer.class.isAssignableFrom(java_type) || PointerBuffer.class.isAssignableFrom(java_type)) && param.getAnnotation(Constant.class) == null) {
663 boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support
664 boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
709 if ( (Buffer.class.isAssignableFrom(java_type) || PointerBuffer.class.isAssignableFrom(java_type)) && param.getAnnotation(Constant.class) == null ) {
665710 TypeInfo typeinfo = typeinfos.get(param);
666 printParameterCheck(writer, method, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, param.getAnnotation(NullTerminated.class), indirect_buffer_allowed, out_parameter, generate_error_checks);
667 } else if ( String.class.equals(java_type)) {
668 if (!can_be_null)
711 printParameterCheck(writer, method, param.getSimpleName().toString(), typeinfo.getType().getSimpleName(), check_value, can_be_null, param.getAnnotation(NullTerminated.class), generate_error_checks);
712 } else if ( String.class.equals(java_type) ) {
713 if ( !can_be_null ) {
669714 writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");");
715 }
670716 } else if ( java_type.isArray() ) {
671 final TypeInfo typeinfo = typeinfos.get(param);
672 printArrayParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null);
673 }
674 }
675 }
676 if (method.getAnnotation(CachedResult.class) != null)
677 printParameterCheck(writer, method, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false, generate_error_checks);
678 }
679
680 private static void printParameterCheck(PrintWriter writer, MethodDeclaration method, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter, final boolean generate_error_checks) {
681 if (indirect_buffer_allowed && out_parameter) {
682 writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";");
683 }
717 printArrayParameterCheck(writer, param.getSimpleName().toString(), check_value, can_be_null);
718 }
719 }
720 }
721 if ( method.getAnnotation(CachedResult.class) != null ) {
722 printParameterCheck(writer, method, Utils.CACHED_BUFFER_NAME, null, null, true, null, generate_error_checks);
723 }
724 }
725
726 private static void printParameterCheck(PrintWriter writer, ExecutableElement method, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean generate_error_checks) {
684727 String tabs;
685 if (can_be_null) {
728 if ( can_be_null ) {
686729 writer.print("\t\tif (" + name + " != null)");
687 if ( null_terminated != null )
730 if ( null_terminated != null ) {
688731 writer.println(" {");
689 else
732 } else {
690733 writer.println();
734 }
691735 tabs = "\t\t\t";
692 } else
736 } else {
693737 tabs = "\t\t";
694 if (indirect_buffer_allowed) {
695 writer.print(tabs + name + " = NondirectBufferWrapper.wrap");
696 if (out_parameter)
697 writer.print("NoCopy");
698 } else
699 writer.print(tabs + "BufferChecks.check");
700 if (check_value != null && check_value.length() > 0) {
738 }
739 writer.print(tabs + "BufferChecks.check");
740 if ( check_value != null && check_value.length() > 0 ) {
701741 writer.print("Buffer");
702 if ( "Buffer".equals(type) )
742 if ( "Buffer".equals(type) ) {
703743 writer.print("Size"); // Check size only, Buffer.isDirect() was added in 1.6, cannot use yet. TODO: Remove?
744 }
704745 writer.print("(" + name + ", " + check_value);
705746 } else {
706747 writer.print("Direct(" + name);
713754 writer.println("\t\t\t" + name + " = APIUtil.getBufferIntDebug();"); // Use an exclusive buffer here
714755 }
715756 }
716 if (null_terminated != null) {
757 if ( null_terminated != null ) {
717758 writer.print(tabs + "BufferChecks.checkNullTerminated(");
718759 writer.print(name);
719760 if ( null_terminated.value().length() > 0 ) {
721762 writer.print(null_terminated.value());
722763 }
723764 writer.println(");");
724 if ( can_be_null )
765 if ( can_be_null ) {
725766 writer.println("\t\t}");
726 }
727 }
728
729 private static void printArrayParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null) {
767 }
768 }
769 }
770
771 private static void printArrayParameterCheck(PrintWriter writer, String name, String check_value, boolean can_be_null) {
730772 String tabs;
731773 if ( can_be_null ) {
732774 writer.println("\t\tif (" + name + " != null)");
733775 tabs = "\t\t\t";
734 } else
776 } else {
735777 tabs = "\t\t";
778 }
736779
737780 writer.print(tabs + "BufferChecks.checkArray(" + name);
738 if ( check_value != null && check_value.length() > 0)
781 if ( check_value != null && check_value.length() > 0 ) {
739782 writer.print(", " + check_value);
783 }
740784 writer.println(");");
741785 }
742786
743 private static String getResultType(MethodDeclaration method, boolean native_stub) {
744 if ( native_stub && method.getAnnotation(PointerWrapper.class) != null )
787 private static String getResultType(ExecutableElement method, boolean native_stub) {
788 if ( native_stub && method.getAnnotation(PointerWrapper.class) != null ) {
745789 return "long";
746 else if ( !native_stub && method.getAnnotation(GLreturn.class) != null )
790 } else if ( !native_stub && method.getAnnotation(GLreturn.class) != null ) {
747791 return Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
748 else
792 } else {
749793 return Utils.getJavaType(Utils.getMethodReturnType(method)).getSimpleName();
750 }
751
752 private static String getDefaultResultValue(MethodDeclaration method) {
794 }
795 }
796
797 private static String getDefaultResultValue(ExecutableElement method) {
753798 if ( method.getAnnotation(GLreturn.class) != null ) {
754799 final String type = Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
755 if ( "boolean".equals(type) )
800 if ( "boolean".equals(type) ) {
756801 return "false";
757 else if ( Character.isLowerCase(type.charAt(0)) )
802 } else if ( Character.isLowerCase(type.charAt(0)) ) {
758803 return "0";
759 else
804 } else {
760805 return "null";
806 }
761807 } else {
762808 final Class type = Utils.getJavaType(Utils.getMethodReturnType(method));
763809 if ( type.isPrimitive() ) {
764 if ( type == boolean.class )
810 if ( type == boolean.class ) {
765811 return "false";
766 else
812 } else {
767813 return "0";
768 } else
814 }
815 } else {
769816 return "null";
817 }
770818 }
771819 }
772820
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
34 import org.lwjgl.opencl.CLMem;
35
3633 import java.nio.ByteBuffer;
37
38 import com.sun.mirror.type.*;
39 import com.sun.mirror.util.*;
34 import javax.lang.model.type.*;
35 import javax.lang.model.util.SimpleTypeVisitor6;
4036
4137 /**
42 * A TypeVisitor that translates (annotated) TypeMirrors to
43 * java types (represented by a Class)
38 * A TypeVisitor that translates (annotated) TypeMirrors to java types
39 * (represented by a Class)
4440 *
4541 * @author elias_naur <elias_naur@users.sourceforge.net>
46 * @version $Revision: 3430 $
47 * $Id: JavaTypeTranslator.java 3430 2010-10-04 17:04:46Z spasi $
42 * @version $Revision$ $Id$
4843 */
49 public class JavaTypeTranslator implements TypeVisitor {
44 public class JavaTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
45
5046 private Class type;
5147
5248 public Class getType() {
5349 return type;
5450 }
5551
56 public void visitAnnotationType(AnnotationType t) {
57 throw new RuntimeException(t + " is not allowed");
58 }
59
60 public void visitArrayType(ArrayType t) {
52 @Override
53 public Void visitArray(ArrayType t, Void o) {
6154 final TypeMirror componentType = t.getComponentType();
62 if ( componentType instanceof PrimitiveType ) {
63 type = getPrimitiveArrayClassFromKind(((PrimitiveType)componentType).getKind());
64 } else {
65 try {
66 final Class c = Class.forName(t.getComponentType().toString());
67 if ( CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c) )
68 type = Class.forName("[L" + t.getComponentType() + ";");
69 else {
55 try {
56 final Class c = Class.forName(t.getComponentType().toString());
57 if ( CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
58 type = Class.forName("[L" + t.getComponentType() + ";");
59 }
60 } catch (ClassNotFoundException ex) {
61 type = null;
62 } finally {
63 if ( type == null ) {
64 if ( componentType instanceof PrimitiveType ) {
65 type = getPrimitiveArrayClassFromKind(componentType.getKind());
66 } else {
7067 throw new RuntimeException(t + " is not allowed");
7168 }
72 } catch (ClassNotFoundException e) {
73 throw new RuntimeException(e);
7469 }
70 return DEFAULT_VALUE;
7571 }
7672 }
7773
78 public static Class getPrimitiveClassFromKind(PrimitiveType.Kind kind) {
74 public static Class getPrimitiveClassFromKind(TypeKind kind) {
7975 switch ( kind ) {
8076 case LONG:
8177 return long.class;
9692 }
9793 }
9894
99 private static Class getPrimitiveArrayClassFromKind(PrimitiveType.Kind kind) {
95 private static Class getPrimitiveArrayClassFromKind(TypeKind kind) {
10096 switch ( kind ) {
10197 case LONG:
10298 return long[].class;
117113 }
118114 }
119115
120 public void visitPrimitiveType(PrimitiveType t) {
116 @Override
117 public Void visitPrimitive(PrimitiveType t, Void p) {
121118 type = getPrimitiveClassFromKind(t.getKind());
119 return DEFAULT_VALUE;
122120 }
123121
124 public void visitDeclaredType(DeclaredType t) {
125 throw new RuntimeException(t + " is not allowed");
122 @Override
123 public Void visitDeclared(DeclaredType t, Void o) {
124 if ( t.asElement().getKind().isClass() ) {
125 visitClassType(t);
126 } else if ( t.asElement().getKind().isInterface() ) {
127 visitInterfaceType(t);
128 } else {
129 throw new RuntimeException(t.asElement().getKind() + " is not allowed");
130 }
131 return DEFAULT_VALUE;
126132 }
127133
128 public void visitEnumType(EnumType t) {
129 throw new RuntimeException(t + " is not allowed");
130 }
131
132 public void visitClassType(ClassType t) {
134 private void visitClassType(DeclaredType t) {
133135 type = NativeTypeTranslator.getClassFromType(t);
134136 }
135137
136 public void visitInterfaceType(InterfaceType t) {
138 private void visitInterfaceType(DeclaredType t) {
137139 type = NativeTypeTranslator.getClassFromType(t);
138140 }
139141
140 public void visitReferenceType(ReferenceType t) {
141 throw new RuntimeException(t + " is not allowed");
142 @Override
143 public Void visitNoType(NoType t, Void p) {
144 type = void.class;
145 return DEFAULT_VALUE;
142146 }
143147
144 public void visitTypeMirror(TypeMirror t) {
145 throw new RuntimeException(t + " is not allowed");
146 }
147
148 public void visitTypeVariable(TypeVariable t) {
149 throw new RuntimeException(t + " is not allowed");
150 }
151
152 public void visitVoidType(VoidType t) {
153 type = void.class;
154 }
155
156 public void visitWildcardType(WildcardType t) {
157 throw new RuntimeException(t + " is not allowed");
158 }
159148 }
3636 * This class generates the functions in the native source files.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3418 $
40 * $Id: NativeMethodStubsGenerator.java 3418 2010-09-28 21:11:35Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import org.lwjgl.PointerBuffer;
4444
45 import com.sun.mirror.apt.*;
46 import com.sun.mirror.declaration.*;
47 import com.sun.mirror.type.*;
48
49 import java.io.*;
50 import java.util.*;
51 import java.nio.*;
45 import java.io.PrintWriter;
46 import java.nio.Buffer;
47 import java.util.List;
48 import javax.annotation.processing.ProcessingEnvironment;
49 import javax.lang.model.element.Element;
50 import javax.lang.model.element.ExecutableElement;
51 import javax.lang.model.element.TypeElement;
52 import javax.lang.model.element.VariableElement;
53 import javax.lang.model.type.TypeKind;
54 import javax.lang.model.type.TypeMirror;
5255
5356 public class NativeMethodStubsGenerator {
54 private static final String BUFFER_ADDRESS_POSTFIX = "_address";
55 public static final String BUFFER_POSITION_POSTFIX = "_position";
56 private static final String STRING_LIST_NAME = "_str";
57 private static final String POINTER_LIST_NAME = "_ptr";
58
59 public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) {
60 for (MethodDeclaration method : d.getMethods()) {
57 private static final String BUFFER_ADDRESS_POSTFIX = "_address";
58 public static final String BUFFER_POSITION_POSTFIX = "_position";
59 private static final String STRING_LIST_NAME = "_str";
60 private static final String POINTER_LIST_NAME = "_ptr";
61
62 public static void generateNativeMethodStubs(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, TypeElement d, boolean generate_error_checks, boolean context_specific) {
63 for ( ExecutableElement method : Utils.getMethods(d) ) {
6164 Alternate alt_annotation = method.getAnnotation(Alternate.class);
6265 if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null )
6366 continue;
6467 generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific);
65 if (Utils.hasMethodBufferObjectParameter(method))
68 if ( Utils.hasMethodBufferObjectParameter(method) )
6669 generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
6770 }
6871 }
6972
70 private static void generateParameters(PrintWriter writer, Collection<ParameterDeclaration> params, Mode mode) {
71 for (ParameterDeclaration param : params) {
73 private static void generateParameters(PrintWriter writer, List<? extends VariableElement> params, Mode mode) {
74 for ( VariableElement param : params ) {
7275 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
7376 continue;
7477 final Constant constant_annotation = param.getAnnotation(Constant.class);
7780 }
7881 }
7982
80 private static void generateParameter(PrintWriter writer, ParameterDeclaration param, Mode mode) {
83 private static void generateParameter(PrintWriter writer, VariableElement param, Mode mode) {
8184 writer.print(", ");
82 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
85 if ( mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null ) {
8386 writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
8487 } else if ( param.getAnnotation(PointerWrapper.class) != null ) {
8588 writer.print("jlong " + param.getSimpleName());
8689 } else {
8790 JNITypeTranslator translator = new JNITypeTranslator();
88 param.getType().accept(translator);
91 param.asType().accept(translator, null);
8992 writer.print(translator.getSignature() + " " + param.getSimpleName());
90 if (Utils.getNIOBufferType(param.getType()) != null)
91 writer.print(", jint " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
92 }
93 }
94
95 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) {
93 }
94 }
95
96 private static void generateMethodStub(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, ExecutableElement method, Mode mode, boolean generate_error_checks, boolean context_specific) {
9697 if ( !context_specific && method.getAnnotation(Alternate.class) == null )
9798 writer.print("static ");
9899 else
106107 writer.print("jlong");
107108 } else {
108109 JNITypeTranslator translator = new JNITypeTranslator();
109 result_type.accept(translator);
110 writer.print(translator.getSignature());
110 result_type.accept(translator, null);
111 writer.print(translator.getReturnSignature());
111112 }
112113 writer.print(" JNICALL ");
113114
114115 writer.print(Utils.getQualifiedNativeMethodName(interface_name, method, generate_error_checks, context_specific));
115 if (mode == Mode.BUFFEROBJECT)
116 if ( mode == Mode.BUFFEROBJECT )
116117 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
117118 writer.print("(JNIEnv *env, jclass clazz");
118119 generateParameters(writer, method.getParameters(), mode);
119 if (Utils.getNIOBufferType(result_type) != null) {
120 if ( Utils.getNIOBufferType(result_type) != null ) {
120121 if ( (cached_result_annotation == null || !cached_result_annotation.isRange()) && (auto_size_annotation == null || !auto_size_annotation.isNative()) )
121122 writer.print(", jlong " + Utils.RESULT_SIZE_NAME);
122 if (cached_result_annotation != null)
123 if ( cached_result_annotation != null )
123124 writer.print(", jobject " + Utils.CACHED_BUFFER_NAME);
124125 }
125 if (context_specific) {
126 if ( context_specific ) {
126127 writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME);
127128 }
128129 writer.println(") {");
129130
130131 generateBufferParameterAddresses(type_map, writer, method, mode);
131132 Alternate alt_annotation = method.getAnnotation(Alternate.class);
132 if (context_specific) {
133 if ( context_specific ) {
133134 String typedef_name = Utils.getTypedefName(method);
134135 writer.print("\t" + typedef_name + " " + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()));
135136 writer.print(" = (" + typedef_name + ")((intptr_t)");
138139
139140 final Code code_annotation = method.getAnnotation(Code.class);
140141
141 final boolean hasResult = !result_type.equals(env.getTypeUtils().getVoidType());
142 final boolean hasResult = !result_type.equals(env.getTypeUtils().getNoType(TypeKind.VOID));
142143 final boolean resultPreDeclare = hasResult && (hasPointerArrayInits(method.getParameters()) || (code_annotation != null && (code_annotation.nativeAfterVars().length() > 0 || code_annotation.nativeBeforeCall().length() > 0)));
143144 if ( resultPreDeclare )
144145 printResultParam(type_map, writer, method, result_type, true);
165166 writer.println(code_annotation.nativeAfterCall());
166167
167168 generateStringDeallocations(writer, method.getParameters());
168 if (!result_type.equals(env.getTypeUtils().getVoidType())) {
169 if ( !result_type.equals(env.getTypeUtils().getNoType(TypeKind.VOID)) ) {
169170 writer.print("\treturn ");
170171 Class java_result_type = Utils.getJavaType(result_type);
171 if (Buffer.class.isAssignableFrom(java_result_type)) {
172 if (cached_result_annotation != null)
172 if ( Buffer.class.isAssignableFrom(java_result_type) ) {
173 if ( cached_result_annotation != null )
173174 writer.print("safeNewBufferCached(env, ");
174175 else
175176 writer.print("safeNewBuffer(env, ");
176 } else if (String.class.equals(java_result_type)) {
177 } else if ( String.class.equals(java_result_type) ) {
177178 writer.print("NewStringNativeUnsigned(env, ");
178179 } else if ( method.getAnnotation(PointerWrapper.class) != null ) {
179180 writer.print("(intptr_t)");
180181 }
181182 writer.print(Utils.RESULT_VAR_NAME);
182 if (Buffer.class.isAssignableFrom(java_result_type)) {
183 if ( Buffer.class.isAssignableFrom(java_result_type) ) {
183184 final String size_parameter_name;
184185 if ( auto_size_annotation != null && (auto_size_annotation.isNative() || (cached_result_annotation != null && cached_result_annotation.isRange())) )
185186 size_parameter_name = auto_size_annotation.value();
189190 writer.print(", ");
190191 Utils.printExtraCallArguments(writer, method, size_parameter_name);
191192 }
192 if (Buffer.class.isAssignableFrom(java_result_type) ||
193 String.class.equals(java_result_type))
193 if ( Buffer.class.isAssignableFrom(java_result_type) ||
194 String.class.equals(java_result_type) )
194195 writer.print(")");
195196 writer.println(";");
196197 }
198199 writer.println();
199200 }
200201
201 private static void printResultParam(final TypeMap type_map, final PrintWriter writer, final MethodDeclaration method, final TypeMirror result_type, final boolean preDeclare) {
202 final ParameterDeclaration result_param = Utils.getResultParameter(method);
203 final Declaration return_declaration = result_param == null ? method : result_param;
202 private static void printResultParam(final TypeMap type_map, final PrintWriter writer, final ExecutableElement method, final TypeMirror result_type, final boolean preDeclare) {
203 final VariableElement result_param = Utils.getResultParameter(method);
204 final Element return_declaration = result_param == null ? method : result_param;
204205 final NativeTypeTranslator result_translator = new NativeTypeTranslator(type_map, return_declaration);
205 result_type.accept(result_translator);
206 result_type.accept(result_translator, null);
206207 if ( preDeclare )
207208 writer.print("\t");
208209 writer.print(result_translator.getSignature() + " " + Utils.RESULT_VAR_NAME);
209 if ( preDeclare)
210 if ( preDeclare )
210211 writer.println(";");
211212 else
212213 writer.print(result_param == null ? " = " : ";\n\t");
213214 }
214215
215 private static void generateCallParameters(PrintWriter writer, TypeMap type_map, Collection<ParameterDeclaration> params) {
216 if (params.size() > 0) {
216 private static void generateCallParameters(PrintWriter writer, TypeMap type_map, List<? extends VariableElement> params) {
217 if ( params.size() > 0 ) {
217218 boolean first = true;
218 for ( ParameterDeclaration param : params ) {
219 for ( VariableElement param : params ) {
219220 if ( param.getAnnotation(Helper.class) != null )
220221 continue;
221222
229230 }
230231 }
231232
232 private static void generateCallParameter(PrintWriter writer, TypeMap type_map, ParameterDeclaration param) {
233 private static void generateCallParameter(PrintWriter writer, TypeMap type_map, VariableElement param) {
233234 if ( param.getAnnotation(Helper.class) != null )
234235 return;
235236
240241 }
241242
242243 boolean is_indirect = param.getAnnotation(Indirect.class) != null;
243 if (is_indirect || param.getAnnotation(PointerArray.class) != null) {
244 if ( is_indirect || param.getAnnotation(PointerArray.class) != null ) {
244245 writer.print("(");
245246 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
246 param.getType().accept(translator);
247 param.asType().accept(translator, null);
247248 writer.print(translator.getSignature());
248249 writer.print("*)");
249250 }
250251 if ( param.getAnnotation(PointerWrapper.class) != null )
251252 writer.print("(" + param.getAnnotation(PointerWrapper.class).value() + ")(intptr_t)");
252 if (param.getAnnotation(Result.class) != null || is_indirect)
253 if ( param.getAnnotation(Result.class) != null || is_indirect )
253254 writer.print("&");
254255
255256 if ( param.getAnnotation(Result.class) != null ) {
257258 } else {
258259 writer.print(param.getSimpleName());
259260 if ( param.getAnnotation(PointerArray.class) != null )
260 writer.print(getPointerArrayName(Utils.getJavaType(param.getType())));
261 else if ( Utils.isAddressableType(param.getType()) )
261 writer.print(getPointerArrayName(Utils.getJavaType(param.asType())));
262 else if ( Utils.isAddressableType(param.asType()) )
262263 writer.print(BUFFER_ADDRESS_POSTFIX);
263264 }
264265 }
265266
266 private static void generateStringDeallocations(PrintWriter writer, Collection<ParameterDeclaration> params) {
267 for (ParameterDeclaration param : params) {
268 final Class java_type = Utils.getJavaType(param.getType());
267 private static void generateStringDeallocations(PrintWriter writer, List<? extends VariableElement> params) {
268 for ( VariableElement param : params ) {
269 final Class java_type = Utils.getJavaType(param.asType());
269270 if ( java_type.equals(String.class) && param.getAnnotation(Result.class) == null )
270271 writer.println("\tfree(" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ");");
271 else if (param.getAnnotation(PointerArray.class) != null ) // Free the string array mem
272 else if ( param.getAnnotation(PointerArray.class) != null ) // Free the string array mem
272273 writer.println("\tfree(" + param.getSimpleName() + getPointerArrayName(java_type) + ");");
273274 }
274275 }
275276
276 private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) {
277 private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, ExecutableElement method, Mode mode) {
277278 strLoopDeclared = false;
278279 ptrLoopDeclared = false;
279 for ( ParameterDeclaration param : method.getParameters() ) {
280 for ( VariableElement param : method.getParameters() ) {
280281 final Constant constant_annotation = param.getAnnotation(Constant.class);
281 if ( param.getAnnotation(Result.class) == null && (constant_annotation == null || !constant_annotation.isNative()) && Utils.isAddressableType(param.getType()))
282 generateBufferParameterAddress(type_map, writer, method, param, mode);
282 if ( param.getAnnotation(Result.class) == null && (constant_annotation == null || !constant_annotation.isNative()) && Utils.isAddressableType(param.asType()) )
283 generateBufferParameterAddress(type_map, writer, param, mode);
283284 }
284285 }
285286
286287 private static boolean strLoopDeclared;
287288 private static boolean ptrLoopDeclared;
288289
289 private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode) {
290 private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, VariableElement param, Mode mode) {
290291 final Check check_annotation = param.getAnnotation(Check.class);
291292 final PointerArray array_annotation = param.getAnnotation(PointerArray.class);
292 final Class java_type = Utils.getJavaType(param.getType());
293 final Class java_type = Utils.getJavaType(param.asType());
293294
294295 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
295 param.getType().accept(translator);
296 param.asType().accept(translator, null);
296297 final String native_type = translator.getSignature();
297298
298299 if ( !java_type.isArray() || CharSequence.class.isAssignableFrom(java_type.getComponentType()) ) {
299300 writer.print("\t" + native_type + param.getSimpleName());
300 writer.print(BUFFER_ADDRESS_POSTFIX + " = ((");
301 writer.print(BUFFER_ADDRESS_POSTFIX + " = (");
301302 writer.print(native_type);
302 writer.print(")");
303
304 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
305 writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))");
303 writer.print(")(intptr_t)");
304
305 if ( mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null ) {
306 writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + ")");
306307 } else {
307 if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class) || PointerBuffer.class.isAssignableFrom(java_type) ) {
308 boolean explicitly_byte_sized = java_type.equals(Buffer.class) ||
309 translator.getAnnotationType().equals(type_map.getVoidType()) ||
310 param.getAnnotation(NativeType.class) != null;
311 if (explicitly_byte_sized)
312 writer.print("(((char *)");
313 if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) {
314 writer.print("safeGetBufferAddress(env, " + param.getSimpleName());
315 } else {
316 writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName());
317 }
318 writer.print("))");
319 writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
320 if (explicitly_byte_sized)
321 writer.print("))");
322 } else if (java_type.equals(String.class)) {
323 writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))");
308 if ( Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class) || PointerBuffer.class.isAssignableFrom(java_type) ) {
309 writer.print(param.getSimpleName());
310 } else if ( java_type.equals(String.class) ) {
311 writer.print("GetStringNativeChars(env, " + param.getSimpleName() + ")");
324312 } else if ( array_annotation == null )
325313 throw new RuntimeException("Illegal type " + java_type);
326314 }
331319 final String n = getPointerArrayName(java_type);
332320 final String arrayType;
333321 if ( POINTER_LIST_NAME.equals(n) ) {
334 if ( n.equals(param.getSimpleName()) )
322 if ( n.equals(param.getSimpleName().toString()) )
335323 throw new RuntimeException("The name '" + n + "' is not valid for object array arguments annotated with PointerArray");
336324
337325 arrayType = translator.getSignature(true) + (org.lwjgl.PointerWrapper.class.isAssignableFrom(java_type.getComponentType()) ? " " : "");
338326
339327 // Declare loop counters and allocate object array
340328 if ( !ptrLoopDeclared ) {
341 writer.println("\tunsigned int " + n + "_i;");
329 writer.println("\tint " + n + "_i;");
342330 writer.println("\tjobject " + n + "_object;");
343331 ptrLoopDeclared = true;
344332 }
345333 } else {
346 if ( n.equals(param.getSimpleName()) )
334 if ( n.equals(param.getSimpleName().toString()) )
347335 throw new RuntimeException("The name '" + n + "' is not valid for arguments annotated with PointerArray");
348336
349337 arrayType = translator.getSignature(true);
350338
351339 // Declare loop counters and allocate string array
352340 if ( !strLoopDeclared ) {
353 writer.println("\tunsigned int " + n + "_i;");
341 writer.println("\tint " + n + "_i;");
354342 writer.println("\t" + arrayType + n + "_address;");
355343 strLoopDeclared = true;
356344 }
371359 return STRING_LIST_NAME;
372360 }
373361
374 private static boolean hasPointerArrayInits(Collection<ParameterDeclaration> params) {
375 for ( ParameterDeclaration param : params ) {
362 private static boolean hasPointerArrayInits(List<? extends VariableElement> params) {
363 for ( VariableElement param : params ) {
376364 PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class);
377365 if ( pointerArray_annotation != null )
378366 return true;
380368 return false;
381369 }
382370
383 private static void generatePointerArrayInits(TypeMap type_map, PrintWriter writer, Collection<ParameterDeclaration> params) {
384 for ( ParameterDeclaration param : params ) {
371 private static void generatePointerArrayInits(TypeMap type_map, PrintWriter writer, List<? extends VariableElement> params) {
372 for ( VariableElement param : params ) {
385373 PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class);
386374 if ( pointerArray_annotation != null ) {
387 final Class java_type = Utils.getJavaType(param.getType());
375 final Class java_type = Utils.getJavaType(param.asType());
388376 final Class<?> component_type = java_type.isArray() ? java_type.getComponentType() : null;
389377 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
390 param.getType().accept(translator);
378 param.asType().accept(translator, null);
391379
392380 final String n = getPointerArrayName(java_type);
393381 if ( POINTER_LIST_NAME.equals(n) ) {
395383 writer.println("\t" + n + "_i = 0;");
396384 // Fill pointer array with the buffer pointers
397385 writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {");
398 if ( component_type.isAssignableFrom(Buffer.class) )
399 writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);");
386 writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);");
387 writer.print("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = (" + translator.getSignature(true) + ")");
388 if ( Buffer.class.isAssignableFrom(component_type) )
389 writer.println("(*env)->GetDirectBufferAddress(env, " + n + "_object);");
400390 else
401 writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);");
402 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = (" + translator.getSignature(true) + ")(intptr_t)getPointerWrapperAddress(env, " + n + "_object);");
391 writer.println("(intptr_t)getPointerWrapperAddress(env, " + n + "_object);");
403392 writer.println("\t}");
404393 } else {
405394 final String lengths = pointerArray_annotation.lengths();
411400 writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {");
412401 if ( lengths.length() == 0 ) {
413402 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = " + n + "_address;");
414 writer.println("\t\t" + n + "_address += strlen(" + n + "_address) + 1;");
403 writer.println("\t\t" + n + "_address += strlen((const char *)" + n + "_address) + 1;");
415404 } else {
416405 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i] = " + n + "_address;");
417406 writer.println("\t\t" + n + "_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[" + n + "_i++];");
3636 * a native type.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3412 $
40 * $Id: NativeType.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
3433 /**
3534 *
36 * A TypeVisitor that translates types (and optional native type
37 * annotations) to the native type string.
35 * A TypeVisitor that translates types (and optional native type annotations) to
36 * the native type string.
3837 *
3938 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3412 $
41 * $Id: NativeTypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$ $Id$
4240 */
43
4441 import org.lwjgl.PointerBuffer;
4542
4643 import java.lang.annotation.Annotation;
4744 import java.nio.*;
4845 import java.util.ArrayList;
4946 import java.util.Collection;
50
51 import com.sun.mirror.declaration.AnnotationMirror;
52 import com.sun.mirror.declaration.Declaration;
53 import com.sun.mirror.type.*;
54 import com.sun.mirror.util.TypeVisitor;
47 import java.util.List;
48 import javax.lang.model.element.AnnotationMirror;
49 import javax.lang.model.element.Element;
50 import javax.lang.model.type.*;
51 import javax.lang.model.util.SimpleTypeVisitor6;
5552
5653 /**
57 * $Id: NativeTypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
54 * $Id$
5855 * <p/>
59 * A TypeVisitor that translates (annotated) TypeMirrors to
60 * native types
56 * A TypeVisitor that translates (annotated) TypeMirrors to native types
6157 *
6258 * @author elias_naur <elias_naur@users.sourceforge.net>
63 * @version $Revision: 3412 $
59 * @version $Revision$
6460 */
65 public class NativeTypeTranslator implements TypeVisitor {
66
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) {
61 public class NativeTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
62
63 private Collection<Class> native_types;
64 private boolean is_indirect;
65 private final Element declaration;
66 private final TypeMap type_map;
67
68 public NativeTypeTranslator(TypeMap type_map, Element declaration) {
7369 this.declaration = declaration;
7470 this.type_map = type_map;
7571 }
8076
8177 public String getSignature(final boolean skipConst) {
8278 StringBuilder signature = new StringBuilder();
83 if ( !skipConst && declaration.getAnnotation(Const.class) != null )
79 if ( !skipConst && declaration.getAnnotation(Const.class) != null ) {
8480 signature.append("const ");
81 }
8582
8683 if ( declaration.getAnnotation(PointerWrapper.class) != null ) {
8784 signature.append(declaration.getAnnotation(PointerWrapper.class).value());
9289 signature.append(getAnnotationType().getSimpleName());
9390 }
9491
95 if ( is_indirect )
92 if ( is_indirect ) {
9693 signature.append(" *");
94 }
9795 return signature.toString();
9896 }
9997
10098 public Class getAnnotationType() {
101 if ( native_types.size() != 1 )
102 throw new RuntimeException("Expected only one native type for declaration " + declaration +
103 ", but got " + native_types.size());
99 if ( native_types.size() != 1 ) {
100 throw new RuntimeException("Expected only one native type for declaration " + declaration
101 + ", but got " + native_types.size());
102 }
104103 return native_types.iterator().next();
105104 }
106105
107 public void visitAnnotationType(AnnotationType t) {
108 throw new RuntimeException(t + " is not allowed");
109 }
110
111 public void visitArrayType(ArrayType t) {
106 @Override
107 public Void visitArray(ArrayType t, Void o) {
112108 final Class<?> type = Utils.getJavaType(t).getComponentType();
113109
114110 if ( CharSequence.class.isAssignableFrom(type) ) {
121117 native_types.add(type_map.getByteBufferArrayType());
122118 } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) {
123119 is_indirect = false;
124 } else
120 } else {
125121 throw new RuntimeException(t + " is not allowed");
126 }
127
128 public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
129 if ( IntBuffer.class.equals(c) )
130 return PrimitiveType.Kind.INT;
131 else if ( DoubleBuffer.class.equals(c) )
132 return PrimitiveType.Kind.DOUBLE;
133 else if ( ShortBuffer.class.equals(c) )
134 return PrimitiveType.Kind.SHORT;
135 else if ( ByteBuffer.class.equals(c) || PointerBuffer.class.equals(c) )
136 return PrimitiveType.Kind.BYTE;
137 else if ( FloatBuffer.class.equals(c) )
138 return PrimitiveType.Kind.FLOAT;
139 else if ( LongBuffer.class.equals(c) )
140 return PrimitiveType.Kind.LONG;
141 else
122 }
123 return DEFAULT_VALUE;
124 }
125
126 public static TypeKind getPrimitiveKindFromBufferClass(Class c) {
127 if ( IntBuffer.class.equals(c) ) {
128 return TypeKind.INT;
129 } else if ( DoubleBuffer.class.equals(c) ) {
130 return TypeKind.DOUBLE;
131 } else if ( ShortBuffer.class.equals(c) ) {
132 return TypeKind.SHORT;
133 } else if ( ByteBuffer.class.equals(c) || PointerBuffer.class.equals(c) ) {
134 return TypeKind.BYTE;
135 } else if ( FloatBuffer.class.equals(c) ) {
136 return TypeKind.FLOAT;
137 } else if ( LongBuffer.class.equals(c) ) {
138 return TypeKind.LONG;
139 } else {
142140 throw new RuntimeException(c + " is not allowed");
141 }
143142 }
144143
145144 @SuppressWarnings("unchecked")
146145 public static Class<? extends Annotation> getClassFromType(DeclaredType t) {
147146 try {
148 return (Class<? extends Annotation>)Class.forName(t.getDeclaration().getQualifiedName());
147 return (Class<? extends Annotation>)Class.forName(t.toString());
149148 } catch (ClassNotFoundException e) {
150149 throw new RuntimeException(e);
151150 }
152151 }
153152
154 private void getNativeTypeFromAnnotatedPrimitiveType(PrimitiveType.Kind kind) {
153 private void getNativeTypeFromAnnotatedPrimitiveType(TypeKind kind) {
155154 native_types = translateAnnotations();
156 if ( native_types.size() == 0 )
155 if ( native_types.isEmpty() ) {
157156 native_types.add(type_map.getNativeTypeFromPrimitiveType(kind));
158 }
159
160 public void visitClassType(ClassType t) {
157 }
158 }
159
160 private void visitClassType(DeclaredType t) {
161161 is_indirect = true;
162162
163163 Class<?> c = getClassFromType(t);
167167 } else if ( Buffer.class.equals(c) ) {
168168 native_types = new ArrayList<Class>();
169169 native_types.add(type_map.getVoidType());
170 } else if ( Buffer.class.isAssignableFrom(c) ) {
171 PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
170 } else if ( Buffer.class.isAssignableFrom(c) || PointerBuffer.class.isAssignableFrom(c) ) {
171 TypeKind kind = getPrimitiveKindFromBufferClass(c);
172172 getNativeTypeFromAnnotatedPrimitiveType(kind);
173 } else if ( PointerBuffer.class.isAssignableFrom(c) ) {
174 native_types = new ArrayList<Class>();
175 native_types.add(PointerBuffer.class);
176173 } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
177174 native_types = new ArrayList<Class>();
178175 native_types.add(PointerWrapper.class);
179176
180177 is_indirect = false;
181 } else
178 } else {
182179 throw new RuntimeException(t + " is not allowed");
183 }
184
185 public void visitPrimitiveType(PrimitiveType t) {
180 }
181 }
182
183 @Override
184 public Void visitPrimitive(PrimitiveType t, Void p) {
186185 getNativeTypeFromAnnotatedPrimitiveType(t.getKind());
187 }
188
189 public void visitDeclaredType(DeclaredType t) {
190 throw new RuntimeException(t + " is not allowed");
191 }
192
193 public void visitEnumType(EnumType t) {
194 throw new RuntimeException(t + " is not allowed");
195 }
196
197 public void visitInterfaceType(InterfaceType t) {
198 throw new RuntimeException(t + " is not allowed");
199 }
200
201 // Check if the annotation is itself annotated with a certain annotation type
202
186 return DEFAULT_VALUE;
187 }
188
189 private void visitInterfaceType(DeclaredType t) {
190 // See ARB_debug_label.glObjectPtrLabel
191 Class<?> c = getClassFromType(t);
192 if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
193 native_types = new ArrayList<Class>();
194 native_types.add(PointerWrapper.class);
195
196 is_indirect = false;
197 } else {
198 throw new RuntimeException(t + " is not allowed");
199 }
200 }
201
202 @Override
203 public Void visitDeclared(DeclaredType t, Void p) {
204 if ( t.asElement().getKind().isInterface() ) {
205 visitInterfaceType(t);
206 } else if ( t.asElement().getKind().isClass() ) {
207 visitClassType(t);
208 }
209 return DEFAULT_VALUE;
210 }
211
212 /* Check if the annotation is itself annotated with a certain annotation type
213 * @discuss compare (DeclaredType).getAnnotation(Class) and (Element).getAnnotation(Class), they mean different Annotation's.
214 */
203215 public static <T extends Annotation> T getAnnotation(AnnotationMirror annotation, Class<T> type) {
204 return annotation.getAnnotationType().getDeclaration().getAnnotation(type);
216 return annotation.getAnnotationType().asElement().getAnnotation(type);
205217 }
206218
207219 private static Class translateAnnotation(AnnotationMirror annotation) {
208220 NativeType native_type = getAnnotation(annotation, NativeType.class);
209221 if ( native_type != null ) {
210222 return getClassFromType(annotation.getAnnotationType());
211 } else
223 } else {
212224 return null;
213 }
214
215 private Collection<Class> translateAnnotations() {
216 Collection<Class> result = new ArrayList<Class>();
225 }
226 }
227
228 private List<Class> translateAnnotations() {
229 List<Class> result = new ArrayList<Class>();
217230 for ( AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()) ) {
218231 Class translated_result = translateAnnotation(annotation);
219232 if ( translated_result != null ) {
223236 return result;
224237 }
225238
226 public void visitReferenceType(ReferenceType t) {
227 throw new RuntimeException(t + " is not allowed");
228 }
229
230 public void visitTypeMirror(TypeMirror t) {
231 throw new RuntimeException(t + " is not allowed");
232 }
233
234 public void visitTypeVariable(TypeVariable t) {
235 throw new RuntimeException(t + " is not allowed");
236 }
237
238 public void visitVoidType(VoidType t) {
239 @Override
240 public Void visitNoType(NoType t, Void p) {
239241 native_types = translateAnnotations();
240 if ( native_types.size() == 0 )
242 if ( native_types.isEmpty() ) {
241243 native_types.add(void.class);
242 }
243
244 public void visitWildcardType(WildcardType t) {
245 throw new RuntimeException(t + " is not allowed");
246 }
244 }
245 return DEFAULT_VALUE;
246 }
247
247248 }
3636 * error checking even if it is enabled.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: NoErrorCheck.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3636 * checked for a trailing '\0'
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3260 $
40 * $Id: NullTerminated.java 3260 2009-12-04 04:49:19Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Platform.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 import java.io.PrintWriter;
3737 * window system (glX, wgl, ...)
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 2983 $
41 * $Id: PlatformDependent.java 2983 2008-04-07 18:36:09Z matzon $
40 * @version $Revision$
41 * $Id$
4242 */
4343
4444 import java.lang.annotation.Target;
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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 /** Marker interface for pointer types. */
37 @Target(ElementType.ANNOTATION_TYPE)
38 public @interface PointerType {
39
40 }
3737 * postfixes.
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3412 $
41 * $Id: PostfixTranslator.java 3412 2010-09-26 23:43:24Z spasi $
40 * @version $Revision$
41 * $Id$
4242 */
43
44 import com.sun.mirror.declaration.*;
45 import com.sun.mirror.type.*;
46 import com.sun.mirror.util.*;
4743
4844 import java.lang.annotation.Annotation;
4945 import java.nio.*;
46 import javax.lang.model.element.AnnotationMirror;
47 import javax.lang.model.element.Element;
48 import javax.lang.model.type.DeclaredType;
49 import javax.lang.model.type.PrimitiveType;
50 import javax.lang.model.type.TypeKind;
51 import javax.lang.model.util.SimpleTypeVisitor6;
5052
51 public class PostfixTranslator implements TypeVisitor {
53 public class PostfixTranslator extends SimpleTypeVisitor6<Void, Void> {
5254 private final StringBuilder signature = new StringBuilder();
53 private final Declaration declaration;
55 private final Element declaration;
5456 private final TypeMap type_map;
5557
56 public PostfixTranslator(TypeMap type_map, Declaration declaration) {
58 public PostfixTranslator(TypeMap type_map, Element declaration) {
5759 this.declaration = declaration;
5860 this.type_map = type_map;
5961 }
6264 return signature.toString();
6365 }
6466
65 public void visitAnnotationType(AnnotationType t) {
66 throw new RuntimeException(t + " is not allowed");
67 }
68
69 public void visitArrayType(ArrayType t) {
70 throw new RuntimeException(t + " is not allowed");
71 }
72
73 private static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
74 if (IntBuffer.class.equals(c) || int.class.equals(c) )
75 return PrimitiveType.Kind.INT;
76 else if (DoubleBuffer.class.equals(c) || double.class.equals(c) )
77 return PrimitiveType.Kind.DOUBLE;
78 else if (ShortBuffer.class.equals(c) || short.class.equals(c) )
79 return PrimitiveType.Kind.SHORT;
80 else if (ByteBuffer.class.equals(c) || byte.class.equals(c) )
81 return PrimitiveType.Kind.BYTE;
82 else if (FloatBuffer.class.equals(c) || float.class.equals(c))
83 return PrimitiveType.Kind.FLOAT;
84 else if (LongBuffer.class.equals(c) || long.class.equals(c) )
85 return PrimitiveType.Kind.LONG;
67 private static TypeKind getPrimitiveKindFromBufferClass(Class c) {
68 if ( IntBuffer.class.equals(c) || int.class.equals(c) )
69 return TypeKind.INT;
70 else if ( DoubleBuffer.class.equals(c) || double.class.equals(c) )
71 return TypeKind.DOUBLE;
72 else if ( ShortBuffer.class.equals(c) || short.class.equals(c) )
73 return TypeKind.SHORT;
74 else if ( ByteBuffer.class.equals(c) || byte.class.equals(c) )
75 return TypeKind.BYTE;
76 else if ( FloatBuffer.class.equals(c) || float.class.equals(c) )
77 return TypeKind.FLOAT;
78 else if ( LongBuffer.class.equals(c) || long.class.equals(c) )
79 return TypeKind.LONG;
8680 else
8781 throw new RuntimeException(c + " is not allowed");
8882 }
8983
90 public void visitClassType(ClassType t) {
84 private void visitClassType(DeclaredType t) {
9185 Class<?> c = NativeTypeTranslator.getClassFromType(t);
92 PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
86 TypeKind kind = getPrimitiveKindFromBufferClass(c);
9387 visitPrimitiveTypeKind(kind);
9488 }
9589
96 public void visitDeclaredType(DeclaredType t) {
97 throw new RuntimeException(t + " is not allowed");
98 }
99
100 public void visitEnumType(EnumType t) {
101 throw new RuntimeException(t + " is not allowed");
102 }
103
104 public void visitInterfaceType(InterfaceType t) {
105 throw new RuntimeException(t + " is not allowed");
90 @Override
91 public Void visitDeclared(DeclaredType t, Void o) {
92 if ( t.asElement().getKind().isClass() )
93 visitClassType(t);
94 return DEFAULT_VALUE;
10695 }
10796
10897 private boolean translateAnnotation(AnnotationMirror annotation) {
10998 NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
110 if (native_type != null) {
99 if ( native_type != null ) {
111100 Class<? extends Annotation> annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
112101 signature.append(type_map.translateAnnotation(annotation_class));
113102 return true;
117106
118107 private boolean translateAnnotations() {
119108 boolean result = false;
120 for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()))
121 if (translateAnnotation(annotation)) {
122 if (result)
109 for ( AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()) )
110 if ( translateAnnotation(annotation) ) {
111 if ( result )
123112 throw new RuntimeException("Multiple native types");
124113 result = true;
125114 }
126115 return result;
127116 }
128117
129 public void visitPrimitiveType(PrimitiveType t) {
118 @Override
119 public Void visitPrimitive(PrimitiveType t, Void o) {
130120 visitPrimitiveTypeKind(t.getKind());
121 return DEFAULT_VALUE;
131122 }
132123
133 private void visitPrimitiveTypeKind(PrimitiveType.Kind kind) {
124 private void visitPrimitiveTypeKind(TypeKind kind) {
134125 boolean annotated_translation = translateAnnotations();
135 if (annotated_translation)
126 if ( annotated_translation )
136127 return;
137128 // No annotation type was specified, fall back to default
138129 String type;
139 switch (kind) {
130 switch ( kind ) {
140131 case INT:
141132 type = "i";
142133 break;
160151 }
161152 signature.append(type);
162153 }
163
164 public void visitReferenceType(ReferenceType t) {
165 throw new RuntimeException(t + " is not allowed");
166 }
167
168 public void visitTypeMirror(TypeMirror t) {
169 throw new RuntimeException(t + " is not allowed");
170 }
171
172 public void visitTypeVariable(TypeVariable t) {
173 throw new RuntimeException(t + " is not allowed");
174 }
175
176 public void visitVoidType(VoidType t) {
177 }
178
179 public void visitWildcardType(WildcardType t) {
180 throw new RuntimeException(t + " is not allowed");
181 }
182154 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator;
3332
3433 /**
3635 * This class generates the initNatives native function.
3736 *
3837 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3418 $
40 * $Id: RegisterStubsGenerator.java 3418 2010-09-28 21:11:35Z spasi $
38 * @version $Revision$ $Id$
4139 */
42
43 import org.lwjgl.opencl.CLMem;
44
45 import com.sun.mirror.declaration.*;
46 import com.sun.mirror.type.*;
47
48 import java.io.*;
49 import java.util.*;
40 import java.io.PrintWriter;
41 import java.util.Arrays;
42 import java.util.EnumSet;
43 import java.util.Iterator;
44 import java.util.List;
45 import java.util.regex.Pattern;
46 import javax.lang.model.element.ExecutableElement;
47 import javax.lang.model.element.TypeElement;
48 import javax.lang.model.element.VariableElement;
49 import javax.lang.model.type.TypeMirror;
5050
5151 public class RegisterStubsGenerator {
52 public static void generateMethodsNativeStubBind(PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) {
53 Iterator<? extends MethodDeclaration> it = d.getMethods().iterator();
54 while (it.hasNext()) {
55 MethodDeclaration method = it.next();
52
53 public static void generateMethodsNativeStubBind(PrintWriter writer, TypeElement d, boolean generate_error_checks, boolean context_specific) {
54 Iterator<? extends ExecutableElement> it = Utils.getMethods(d).iterator();
55 while ( it.hasNext() ) {
56 ExecutableElement method = it.next();
5657 Alternate alt_annotation = method.getAnnotation(Alternate.class);
57 if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null )
58 if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null ) {
5859 continue;
60 }
5961 EnumSet<Platform> platforms;
6062 PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class);
61 if (platform_annotation != null)
63 if ( platform_annotation != null ) {
6264 platforms = EnumSet.copyOf(Arrays.asList(platform_annotation.value()));
63 else
65 } else {
6466 platforms = EnumSet.of(Platform.ALL);
65 for (Platform platform : platforms) {
67 }
68 for ( Platform platform : platforms ) {
6669 platform.printPrologue(writer);
6770 boolean has_buffer_parameter = Utils.hasMethodBufferObjectParameter(method);
6871 printMethodNativeStubBind(writer, d, method, platform, Mode.NORMAL, it.hasNext() || has_buffer_parameter, generate_error_checks, context_specific);
69 if (has_buffer_parameter) {
72 if ( has_buffer_parameter ) {
7073 printMethodNativeStubBind(writer, d, method, platform, Mode.BUFFEROBJECT, it.hasNext(), generate_error_checks, context_specific);
7174 }
7275 platform.printEpilogue(writer);
7578 writer.println();
7679 }
7780
78 private static String getTypeSignature(TypeMirror type, boolean add_position_signature) {
79 SignatureTranslator v = new SignatureTranslator(add_position_signature);
80 type.accept(v);
81 private static String getTypeSignature(TypeMirror type) {
82 SignatureTranslator v = new SignatureTranslator();
83 type.accept(v, null);
8184 return v.getSignature();
8285 }
8386
84 private static String getMethodSignature(MethodDeclaration method, Mode mode) {
85 Collection<ParameterDeclaration> params = method.getParameters();
87 private static String getMethodSignature(ExecutableElement method, Mode mode) {
88 List<? extends VariableElement> params = method.getParameters();
8689 String signature = "(";
87 for (ParameterDeclaration param : params) {
88 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
90 for ( VariableElement param : params ) {
91 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) {
8992 continue;
93 }
9094
9195 final Constant constant_annotation = param.getAnnotation(Constant.class);
92 if ( constant_annotation != null && constant_annotation.isNative() )
96 if ( constant_annotation != null && constant_annotation.isNative() ) {
9397 continue;
98 }
9499
95 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null)
96 signature += "I";
97 else
98 signature += getTypeSignature(param.getType(), true);
100 if ( mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null ) {
101 signature += "J";
102 } else {
103 signature += getTypeSignature(param.asType());
104 }
99105 }
100106
101107 final TypeMirror result_type = Utils.getMethodReturnType(method);
102108 final CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
103109 final AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
104110
105 if ( Utils.getNIOBufferType(result_type) != null && (auto_size_annotation == null || !auto_size_annotation.isNative()) )
111 final boolean isNIOBuffer = Utils.getNIOBufferType(result_type) != null;
112 if ( isNIOBuffer && (auto_size_annotation == null || !auto_size_annotation.isNative()) ) {
106113 signature += "J";
114 }
107115
108 String result_type_signature = getTypeSignature(result_type, false);
109 if ( cached_result_annotation != null )
116 final String result_type_signature = isNIOBuffer ? "Ljava/nio/ByteBuffer;" : getTypeSignature(result_type);
117 if ( cached_result_annotation != null ) {
110118 signature += result_type_signature;
119 }
111120
112121 signature += ")";
113122 signature += result_type_signature;
114123 return signature;
115124 }
116125
117 private static void printMethodNativeStubBind(PrintWriter writer, InterfaceDeclaration d, MethodDeclaration method, Platform platform, Mode mode, boolean has_more, boolean generate_error_checks, boolean context_specific) {
126 private static final Pattern GL_PATTERN = Pattern.compile("gl");
127
128 private static void printMethodNativeStubBind(PrintWriter writer, TypeElement d, ExecutableElement method, Platform platform, Mode mode, boolean has_more, boolean generate_error_checks, boolean context_specific) {
118129 writer.print("\t\t{\"" + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
119 if (mode == Mode.BUFFEROBJECT)
130 if ( mode == Mode.BUFFEROBJECT ) {
120131 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
132 }
121133 writer.print("\", \"" + getMethodSignature(method, mode) + "\", (void *)&");
122134 writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific));
123 if (mode == Mode.BUFFEROBJECT)
135 if ( mode == Mode.BUFFEROBJECT ) {
124136 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
137 }
125138
126139 final Alternate alt_annotation = method.getAnnotation(Alternate.class);
127 final String methodName = alt_annotation == null ? method.getSimpleName() : alt_annotation.value();
128 String opengl_handle_name = methodName.replaceFirst("gl", platform.getPrefix());
129 writer.print(", \"" + opengl_handle_name + "\", (void *)&" + methodName + "}");
130 if (has_more)
140 final String methodName = alt_annotation == null ? method.getSimpleName().toString() : alt_annotation.value();
141 String opengl_handle_name = GL_PATTERN.matcher(methodName).replaceFirst(platform.getPrefix());
142 writer.print(", \"" + opengl_handle_name + "\", (void *)&" + methodName + ", " + (method.getAnnotation(Optional.class) == null ? "false" : "true") + "}");
143 if ( has_more ) {
131144 writer.println(",");
145 }
132146 }
133147
134148 }
3636 * specified parameter.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: Result.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
4444 public @interface Reuse {
4545 /** The extension Class that defines the method. */
4646 String value();
47
47 String method() default "";
4848 }
3636 * A TypeVisitor that translates types to JNI signatures.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3443 $
40 * $Id: SignatureTranslator.java 3443 2010-10-12 21:13:03Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import org.lwjgl.PointerBuffer;
44 import org.lwjgl.PointerWrapper;
4445
45 import com.sun.mirror.type.*;
46 import com.sun.mirror.util.*;
46 import java.nio.Buffer;
47 import java.nio.ByteBuffer;
48 import java.util.regex.Pattern;
49 import javax.lang.model.type.ArrayType;
50 import javax.lang.model.type.DeclaredType;
51 import javax.lang.model.type.NoType;
52 import javax.lang.model.type.PrimitiveType;
53 import javax.lang.model.util.SimpleTypeVisitor6;
4754
48 import java.nio.*;
49
50 class SignatureTranslator implements TypeVisitor {
51 private final boolean add_position_signature;
55 class SignatureTranslator extends SimpleTypeVisitor6<Void, Void> {
5256 private final StringBuilder signature = new StringBuilder();
5357
54 SignatureTranslator(boolean add_position_signature) {
55 this.add_position_signature = add_position_signature;
56 }
58 SignatureTranslator() {}
59
60 private static final Pattern DOT_PATTERN = Pattern.compile("\\.");
5761
5862 private static String getNativeNameFromClassName(String class_name) {
59 return class_name.replaceAll("\\.", "/");
63 return DOT_PATTERN.matcher(class_name).replaceAll("/");
6064 }
6165
6266 public String getSignature() {
6367 return signature.toString();
6468 }
6569
66 public void visitAnnotationType(AnnotationType t) {
67 throw new RuntimeException(t + " is not allowed");
70 @Override
71 public Void visitArray(ArrayType t, Void o) {
72 final Class type = Utils.getJavaType(t.getComponentType());
73 if ( CharSequence.class.isAssignableFrom(type) )
74 signature.append("J");
75 else if ( Buffer.class.isAssignableFrom(type) )
76 signature.append("[Ljava/nio/ByteBuffer;");
77 else if ( PointerWrapper.class.isAssignableFrom(type) )
78 signature.append("[L" + getNativeNameFromClassName(type.getName()) + ";");
79 else
80 throw new RuntimeException(t + " is not allowed");
81 return DEFAULT_VALUE;
6882 }
6983
70 public void visitArrayType(ArrayType t) {
71 final Class type = Utils.getJavaType(t.getComponentType());
72 if ( CharSequence.class.isAssignableFrom(type) )
73 signature.append("Ljava/nio/ByteBuffer;I");
74 else if ( Buffer.class.isAssignableFrom(type) )
75 signature.append("[Ljava/nio/ByteBuffer;");
76 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
77 signature.append("[L" + getNativeNameFromClassName(type.getName()) + ";");
84 private void visitClassType(DeclaredType t) {
85 Class type = NativeTypeTranslator.getClassFromType(t);
86
87 if ( PointerWrapper.class.isAssignableFrom(type) || (Utils.isAddressableType(type) && !String.class.equals(type)) )
88 signature.append("J");
89 else {
90 String type_name;
91 if ( (CharSequence.class.isAssignableFrom(type) && !String.class.equals(type)) || CharSequence[].class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) )
92 type_name = ByteBuffer.class.getName();
93 else
94 type_name = t.toString();
95
96 signature.append("L");
97 signature.append(getNativeNameFromClassName(type_name));
98 signature.append(";");
99 }
100 }
101
102 @Override
103 public Void visitDeclared(DeclaredType t, Void o) {
104 if ( t.asElement().getKind().isClass() )
105 visitClassType(t);
106 else if ( t.asElement().getKind().isInterface() )
107 visitInterfaceType(t);
108 return DEFAULT_VALUE;
109 }
110
111 private void visitInterfaceType(DeclaredType t) {
112 Class type = NativeTypeTranslator.getClassFromType(t);
113 if ( PointerWrapper.class.isAssignableFrom(type) )
114 signature.append("J");
78115 else
79116 throw new RuntimeException(t + " is not allowed");
80117 }
81118
82 public void visitClassType(ClassType t) {
83 Class type = NativeTypeTranslator.getClassFromType(t);
84 String type_name;
85 if ( (CharSequence.class.isAssignableFrom(type) && !String.class.equals(type)) || CharSequence[].class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) )
86 type_name = ByteBuffer.class.getName();
87 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) {
88 signature.append("J");
89 return;
90 } else
91 type_name = t.getDeclaration().getQualifiedName();
92
93 signature.append("L");
94 signature.append(getNativeNameFromClassName(type_name));
95 signature.append(";");
96 if ( add_position_signature && Utils.isAddressableType(type) && !String.class.equals(type) )
97 signature.append("I");
98 }
99
100 public void visitDeclaredType(DeclaredType t) {
101 throw new RuntimeException(t + " is not allowed");
102 }
103
104 public void visitEnumType(EnumType t) {
105 throw new RuntimeException(t + " is not allowed");
106 }
107
108 public void visitInterfaceType(InterfaceType t) {
109 throw new RuntimeException(t + " is not allowed");
110 }
111
112 public void visitPrimitiveType(PrimitiveType t) {
113 switch (t.getKind()) {
119 @Override
120 public Void visitPrimitive(PrimitiveType t, Void o) {
121 switch ( t.getKind() ) {
114122 case BOOLEAN:
115123 signature.append("Z");
116124 break;
135143 default:
136144 throw new RuntimeException("Unsupported type " + t);
137145 }
146 return DEFAULT_VALUE;
138147 }
139148
140 public void visitReferenceType(ReferenceType t) {
141 throw new RuntimeException(t + " is not allowed");
149 @Override
150 public Void visitNoType(NoType t, Void o) {
151 signature.append("V");
152 return DEFAULT_VALUE;
142153 }
143154
144 public void visitTypeMirror(TypeMirror t) {
145 throw new RuntimeException(t + " is not allowed");
146 }
147
148 public void visitTypeVariable(TypeVariable t) {
149 throw new RuntimeException(t + " is not allowed");
150 }
151
152 public void visitVoidType(VoidType t) {
153 signature.append("V");
154 }
155
156 public void visitWildcardType(WildcardType t) {
157 throw new RuntimeException(t + " is not allowed");
158 }
159155 }
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Signedness.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision$
37 * $Id$
3838 */
3939
4040 public enum Signedness {
3636 * according to a specified Buffer parameter.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3256 $
40 * $Id: StripPostfix.java 3256 2009-12-01 03:37:27Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
4343 import java.lang.annotation.Target;
3232
3333 /**
3434 *
35 * This class represent a parameter configuration. There are multiple
36 * TypeInfos in case of multityped parameters.
35 * This class represent a parameter configuration. There are multiple TypeInfos
36 * in case of multityped parameters.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3412 $
40 * $Id: TypeInfo.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$ $Id$
4140 */
42
41 import org.lwjgl.PointerBuffer;
4342 import org.lwjgl.util.generator.opengl.GLvoid;
4443
45 import com.sun.mirror.declaration.*;
46 import com.sun.mirror.type.*;
47
4844 import java.lang.annotation.Annotation;
45 import java.nio.*;
4946 import java.util.*;
50 import java.nio.*;
47 import javax.lang.model.element.AnnotationMirror;
48 import javax.lang.model.element.ExecutableElement;
49 import javax.lang.model.element.VariableElement;
50 import javax.lang.model.type.TypeKind;
51 import javax.lang.model.type.TypeMirror;
5152
5253 public class TypeInfo {
54
5355 public static final String UNSIGNED_PARAMETER_NAME = "unsigned";
5456
5557 private final Signedness signedness;
56 private final Class type;
57 private final String auto_type;
58 private final Class type;
59 private final String auto_type;
5860
5961 private TypeInfo(Class type, Signedness signedness, String auto_type) {
6062 this.type = type;
7173 }
7274
7375 public String getAutoType() {
74 if (auto_type == null)
76 if ( auto_type == null ) {
7577 throw new RuntimeException("No auto type assigned");
78 }
7679 return auto_type;
7780 }
7881
79 private static Class getTypeFromPrimitiveKind(PrimitiveType.Kind kind) {
82 private static Class getTypeFromPrimitiveKind(TypeKind kind) {
8083 Class type;
81 switch (kind) {
84 switch ( kind ) {
8285 case LONG:
8386 type = long.class;
8487 break;
106109 return type;
107110 }
108111
109 private static Class getBufferTypeFromPrimitiveKind(PrimitiveType.Kind kind) {
112 private static Class getBufferTypeFromPrimitiveKind(TypeKind kind, AnnotationMirror annotation) {
110113 Class type;
111 switch (kind) {
114 switch ( kind ) {
112115 case INT:
113116 type = IntBuffer.class;
114117 break;
122125 type = ShortBuffer.class;
123126 break;
124127 case LONG:
125 type = LongBuffer.class;
128 if ( annotation.getAnnotationType().asElement().getAnnotation(PointerType.class) != null ) {
129 type = PointerBuffer.class;
130 } else {
131 type = LongBuffer.class;
132 }
126133 break;
127134 case BYTE: /* fall through */
135
128136 case BOOLEAN:
129137 type = ByteBuffer.class;
130138 break;
139147 return new TypeInfo(java_type, Signedness.NONE, null);
140148 }
141149
142 public static Map<ParameterDeclaration, TypeInfo> getDefaultTypeInfoMap(MethodDeclaration method) {
143 Map<ParameterDeclaration, TypeInfo> map = new HashMap<ParameterDeclaration, TypeInfo>();
144 for (ParameterDeclaration param : method.getParameters()) {
145 TypeInfo type_info = getDefaultTypeInfo(param.getType());
150 public static Map<VariableElement, TypeInfo> getDefaultTypeInfoMap(ExecutableElement method) {
151 Map<VariableElement, TypeInfo> map = new HashMap<VariableElement, TypeInfo>();
152 for ( VariableElement param : method.getParameters() ) {
153 TypeInfo type_info = getDefaultTypeInfo(param.asType());
146154 map.put(param, type_info);
147155 }
148156 return map;
149157 }
150158
151 private static Collection<TypeInfo> getTypeInfos(TypeMap type_map, Declaration param, TypeMirror decl_type) {
152 Collection<AnnotationMirror> annotations = Utils.getSortedAnnotations(param.getAnnotationMirrors());
159 private static Collection<TypeInfo> getTypeInfos(TypeMap type_map, VariableElement param) {
160 List<? extends AnnotationMirror> annotations = Utils.getSortedAnnotations(param.getAnnotationMirrors());
161 GLvoid void_annotation = param.getAnnotation(GLvoid.class);
162
153163 Map<Class, TypeInfo> types = new HashMap<Class, TypeInfo>();
154164 Collection<TypeInfo> multityped_result = new ArrayList<TypeInfo>();
155165 boolean add_default_type = true;
156 for (AnnotationMirror annotation : annotations) {
166 for ( AnnotationMirror annotation : annotations ) {
157167 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
158 if (native_type_annotation != null) {
168 if ( native_type_annotation != null ) {
159169 Class<? extends Annotation> annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
160170 Signedness signedness = type_map.getSignednessFromType(annotation_type);
161171 Class inverse_type = type_map.getInverseType(annotation_type);
162172 String auto_type = type_map.getAutoTypeFromAnnotation(annotation);
163 if (inverse_type != null) {
164 if (types.containsKey(inverse_type)) {
173 if ( inverse_type != null ) {
174 if ( types.containsKey(inverse_type) ) {
165175 TypeInfo inverse_type_info = types.get(inverse_type);
166176 String inverse_auto_type = inverse_type_info.getAutoType();
167 auto_type = signedness == Signedness.UNSIGNED ? auto_type + " : " + inverse_auto_type :
168 inverse_auto_type + " : " + auto_type;
177 auto_type = signedness == Signedness.UNSIGNED ? auto_type + " : " + inverse_auto_type : inverse_auto_type + " : " + auto_type;
169178 auto_type = UNSIGNED_PARAMETER_NAME + " ? " + auto_type;
170179 signedness = Signedness.BOTH;
171180 types.remove(inverse_type);
173182 }
174183 }
175184 Class type;
176 PrimitiveType.Kind kind;
177 GLvoid void_annotation = param.getAnnotation(GLvoid.class);
185 TypeKind kind;
178186 kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
179 if (Utils.getNIOBufferType(decl_type) != null)
180 type = getBufferTypeFromPrimitiveKind(kind);
181 else
187 if ( Utils.getNIOBufferType(param.asType()) != null ) {
188 type = getBufferTypeFromPrimitiveKind(kind, annotation);
189 } else {
182190 type = getTypeFromPrimitiveKind(kind);
191 }
183192 TypeInfo type_info = new TypeInfo(type, signedness, auto_type);
184193 types.put(annotation_type, type_info);
185194 multityped_result.add(type_info);
186195 add_default_type = false;
187196 }
188197 }
189 if (add_default_type) {
190 TypeInfo default_type_info = getDefaultTypeInfo(decl_type);
198 if ( add_default_type ) {
199 TypeInfo default_type_info = getDefaultTypeInfo(param.asType());
191200 Collection<TypeInfo> result = new ArrayList<TypeInfo>();
192201 result.add(default_type_info);
193202 return result;
194 } else
203 } else {
195204 return multityped_result;
196 }
197
198 private static Map<ParameterDeclaration, Collection<TypeInfo>> getTypeInfoMap(TypeMap type_map, MethodDeclaration method) {
199 Map<ParameterDeclaration, Collection<TypeInfo>> map = new HashMap<ParameterDeclaration, Collection<TypeInfo>>();
200 for (ParameterDeclaration param : method.getParameters()) {
201 Collection<TypeInfo> types = getTypeInfos(type_map, param, param.getType());
205 }
206 }
207
208 private static Map<VariableElement, Collection<TypeInfo>> getTypeInfoMap(TypeMap type_map, ExecutableElement method) {
209 Map<VariableElement, Collection<TypeInfo>> map = new HashMap<VariableElement, Collection<TypeInfo>>();
210 for ( VariableElement param : method.getParameters() ) {
211 Collection<TypeInfo> types = getTypeInfos(type_map, param);
202212 map.put(param, types);
203213 }
204214 return map;
205215 }
206216
207 public static Collection<Map<ParameterDeclaration, TypeInfo>> getTypeInfoCrossProduct(TypeMap type_map, MethodDeclaration method) {
208 Collection<ParameterDeclaration> parameter_collection = method.getParameters();
209 ParameterDeclaration[] parameters = new ParameterDeclaration[parameter_collection.size()];
210 parameter_collection.toArray(parameters);
211 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product = new ArrayList<Map<ParameterDeclaration, TypeInfo>>();
212 getCrossProductRecursive(0, parameters, getTypeInfoMap(type_map, method),
213 new HashMap<ParameterDeclaration, TypeInfo>(), cross_product);
217 public static Collection<Map<VariableElement, TypeInfo>> getTypeInfoCrossProduct(TypeMap type_map, ExecutableElement method) {
218 List<? extends VariableElement> parameter_collection = method.getParameters();
219 Collection<Map<VariableElement, TypeInfo>> cross_product = new ArrayList<Map<VariableElement, TypeInfo>>();
220 getCrossProductRecursive(0, parameter_collection, getTypeInfoMap(type_map, method),
221 new HashMap<VariableElement, TypeInfo>(), cross_product);
214222 return cross_product;
215223 }
216224
217 private static void getCrossProductRecursive(int index, ParameterDeclaration[] parameters, Map<ParameterDeclaration,
218 Collection<TypeInfo>> typeinfos_map, Map<ParameterDeclaration, TypeInfo> current_instance,
219 Collection<Map<ParameterDeclaration, TypeInfo>> cross_product) {
220 if (index == parameters.length) {
225 private static void getCrossProductRecursive(int index, List<? extends VariableElement> parameters, Map<VariableElement, Collection<TypeInfo>> typeinfos_map, Map<VariableElement, TypeInfo> current_instance, Collection<Map<VariableElement, TypeInfo>> cross_product) {
226 if ( index == parameters.size() ) {
227 /**
228 * the last parameter is treated as multi-type only
229 */
221230 cross_product.add(current_instance);
222231 return;
223232 }
224 ParameterDeclaration param = parameters[index];
233 VariableElement param = parameters.get(index);
225234 Collection<TypeInfo> typeinfos = typeinfos_map.get(param);
226 if (typeinfos != null) {
227 for (TypeInfo typeinfo : typeinfos) {
228 Map<ParameterDeclaration, TypeInfo> instance = new HashMap<ParameterDeclaration, TypeInfo>(current_instance);
235 if ( typeinfos != null ) {
236 for ( TypeInfo typeinfo : typeinfos ) {
237 Map<VariableElement, TypeInfo> instance = new HashMap<VariableElement, TypeInfo>(current_instance);
229238 instance.put(param, typeinfo);
230239 getCrossProductRecursive(index + 1, parameters, typeinfos_map, instance, cross_product);
231240 }
3636 * The interface to the OpenAL/OpenGL specific generator behaviour
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3412 $
40 * $Id: TypeMap.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
43 import java.io.PrintWriter;
4744 import java.lang.annotation.Annotation;
45 import javax.lang.model.element.AnnotationMirror;
46 import javax.lang.model.element.ExecutableElement;
47 import javax.lang.model.type.TypeKind;
4848
4949 public interface TypeMap {
5050 void printCapabilitiesInit(PrintWriter writer);
5151 String getCapabilities();
52 void printErrorCheckMethod(PrintWriter writer, MethodDeclaration method, String tabs);
52 String getAPIUtilParam(boolean comma);
53 void printErrorCheckMethod(PrintWriter writer, ExecutableElement method, String tabs);
5354 String getRegisterNativesFunctionName();
54 PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type);
55 TypeKind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type);
5556 String getTypedefPostfix();
5657 String getFunctionPrefix();
5758 void printNativeIncludes(PrintWriter writer);
6162 Class[] getValidAnnotationTypes(Class type);
6263 Class<? extends Annotation> getVoidType();
6364 String translateAnnotation(Class<? extends Annotation> annotation_type);
64 Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind);
65 Class getNativeTypeFromPrimitiveType(TypeKind kind);
6566 String getAutoTypeFromAnnotation(AnnotationMirror annotation);
6667 Class<? extends Annotation> getInverseType(Class<? extends Annotation> type);
6768 Signedness getSignednessFromType(Class<? extends Annotation> type);
3636 * A TypeVisitor that generates the native typedefs.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3412 $
40 * $Id: TypedefsGenerator.java 3412 2010-09-26 23:43:24Z spasi $
39 * @version $Revision$
40 * $Id$
4141 */
4242
43 import com.sun.mirror.declaration.*;
44 import com.sun.mirror.type.*;
45
46 import java.io.*;
47 import java.util.*;
43 import java.io.PrintWriter;
44 import java.util.Collection;
45 import javax.lang.model.element.ExecutableElement;
46 import javax.lang.model.element.VariableElement;
47 import javax.lang.model.type.TypeMirror;
4848
4949 public class TypedefsGenerator {
50 private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) {
50 private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, ExecutableElement method) {
5151 TypeMirror return_type = method.getReturnType();
5252 writer.print("typedef ");
5353 writer.print(type_map.getTypedefPostfix());
5454 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, method);
55 return_type.accept(translator);
55 return_type.accept(translator, null);
5656 writer.print(translator.getSignature());
5757 writer.print(" (");
5858 writer.print(type_map.getFunctionPrefix());
6161 writer.println(");");
6262 }
6363
64 private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection<ParameterDeclaration> params) {
65 if (params.size() > 0) {
64 private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection<? extends VariableElement> params) {
65 if ( params.size() > 0 ) {
6666 boolean first = true;
67 for ( ParameterDeclaration param : params ) {
67 for ( VariableElement param : params ) {
6868 if ( param.getAnnotation(Helper.class) != null )
6969 continue;
7070
7878 }
7979 }
8080
81 private static void generateNativeTypedefsParameter(TypeMap type_map, PrintWriter writer, ParameterDeclaration param) {
81 private static void generateNativeTypedefsParameter(TypeMap type_map, PrintWriter writer, VariableElement param) {
8282 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
83 param.getType().accept(translator);
83 param.asType().accept(translator, null);
8484 writer.print(translator.getSignature());
85 if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(PointerArray.class) != null)
85 if ( param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(PointerArray.class) != null )
8686 writer.print("*");
8787 writer.print(" " + param.getSimpleName());
8888 }
8989
90 public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
91 for (MethodDeclaration method : methods) {
90 public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection<? extends ExecutableElement> methods) {
91 for ( ExecutableElement method : methods ) {
9292 if ( method.getAnnotation(Alternate.class) == null && method.getAnnotation(Reuse.class) == null )
9393 generateNativeTypedefs(type_map, writer, method);
9494 }
3535 * Various utility methods to the generator.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3443 $
39 * $Id: Utils.java 3443 2010-10-12 21:13:03Z spasi $
38 * @version $Revision$ $Id$
4039 */
41
4240 import org.lwjgl.PointerBuffer;
41 import org.lwjgl.PointerWrapper;
4342 import org.lwjgl.util.generator.opengl.GLboolean;
4443 import org.lwjgl.util.generator.opengl.GLchar;
4544 import org.lwjgl.util.generator.opengl.GLcharARB;
4948 import java.nio.Buffer;
5049 import java.nio.ByteBuffer;
5150 import java.util.*;
52
53 import com.sun.mirror.declaration.*;
54 import com.sun.mirror.type.PrimitiveType;
55 import com.sun.mirror.type.TypeMirror;
51 import java.util.regex.Pattern;
52 import javax.annotation.processing.ProcessingEnvironment;
53 import javax.lang.model.element.*;
54 import javax.lang.model.type.TypeKind;
55 import javax.lang.model.type.TypeMirror;
56 import javax.lang.model.type.TypeVisitor;
57 import javax.lang.model.util.ElementFilter;
5658
5759 public class Utils {
5860
59 public static final String TYPEDEF_POSTFIX = "PROC";
60 public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
61 public static final String FUNCTION_POINTER_POSTFIX = "_pointer";
62 public static final String CHECKS_CLASS_NAME = "GLChecks";
63 public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities";
64 public static final String STUB_INITIALIZER_NAME = "initNativeStubs";
65 public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
66 public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
67 public static final String RESULT_SIZE_NAME = "result_size";
68 public static final String RESULT_VAR_NAME = "__result";
69 public static final String CACHED_BUFFER_LENGTH_NAME = "length";
70 public static final String CACHED_BUFFER_NAME = "old_buffer";
71 private static final String OVERLOADED_METHOD_PREFIX = "n";
72
73 public static String getTypedefName(MethodDeclaration method) {
61 public static final String TYPEDEF_POSTFIX = "PROC";
62 public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
63 public static final String FUNCTION_POINTER_POSTFIX = "_pointer";
64 public static final String CHECKS_CLASS_NAME = "GLChecks";
65 public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities";
66 public static final String STUB_INITIALIZER_NAME = "initNativeStubs";
67 public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
68 public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
69 public static final String RESULT_SIZE_NAME = "result_size";
70 public static final String RESULT_VAR_NAME = "__result";
71 public static final String CACHED_BUFFER_LENGTH_NAME = "length";
72 public static final String CACHED_BUFFER_NAME = "old_buffer";
73 private static final String OVERLOADED_METHOD_PREFIX = "n";
74
75 public static String getTypedefName(ExecutableElement method) {
7476 Alternate alt_annotation = method.getAnnotation(Alternate.class);
7577 return (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + TYPEDEF_POSTFIX;
7678 }
7779
78 public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method) {
80 public static String getFunctionAddressName(TypeElement interface_decl, ExecutableElement method) {
7981 return getFunctionAddressName(interface_decl, method, false);
8082 }
8183
82 public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) {
84 public static String getFunctionAddressName(TypeElement interface_decl, ExecutableElement method, boolean forceAlt) {
8385 final Alternate alt_annotation = method.getAnnotation(Alternate.class);
8486
85 /* Removed prefix so that we can identify reusable entry points, removed postfix because it's not needed and looks nicer.
86 String interfaceName = interface_decl.getSimpleName(); // If we add this back, we need to fix @Reuse (add a param for the template name)
87 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
88 return interfaceName + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX;
89 else
90 return interfaceName + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX;
91 */
92 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
93 return method.getSimpleName();
94 else
87 /* Removed prefix so that we can identify reusable entry points, removed postfix because it's not needed and looks nicer.
88 String interfaceName = interface_decl.getSimpleName(); // If we add this back, we need to fix @Reuse (add a param for the template name)
89 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
90 return interfaceName + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX;
91 else
92 return interfaceName + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX;
93 */
94 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) {
95 return method.getSimpleName().toString();
96 } else {
9597 return alt_annotation.value();
96 }
97
98 public static boolean isFinal(InterfaceDeclaration d) {
98 }
99 }
100
101 public static boolean isFinal(Element d) {
99102 Extension extension_annotation = d.getAnnotation(Extension.class);
100103 return extension_annotation == null || extension_annotation.isFinal();
101104 }
102105
103106 private static class AnnotationMirrorComparator implements Comparator<AnnotationMirror> {
107
108 /**
109 * Sort annotations.
110 */
111 @Override
104112 public int compare(AnnotationMirror a1, AnnotationMirror a2) {
105 String n1 = a1.getAnnotationType().getDeclaration().getQualifiedName();
106 String n2 = a2.getAnnotationType().getDeclaration().getQualifiedName();
107 int result = n1.compareTo(n2);
108 return result;
113 String n1 = a1.getAnnotationType().toString();
114 String n2 = a2.getAnnotationType().toString();
115 return n1.compareTo(n2);
109116 }
110117
111118 public boolean equals(AnnotationMirror a1, AnnotationMirror a2) {
113120 }
114121 }
115122
116 public static Collection<AnnotationMirror> getSortedAnnotations(Collection<AnnotationMirror> annotations) {
123 public static List<AnnotationMirror> getSortedAnnotations(List<? extends AnnotationMirror> annotations) {
117124 List<AnnotationMirror> annotation_list = new ArrayList<AnnotationMirror>(annotations);
118125 Collections.sort(annotation_list, new AnnotationMirrorComparator());
119126 return annotation_list;
120127 }
121128
122 public static String getReferenceName(InterfaceDeclaration interface_decl, MethodDeclaration method, ParameterDeclaration param) {
129 public static String getReferenceName(TypeElement interface_decl, ExecutableElement method, VariableElement param) {
123130 return interface_decl.getSimpleName() + "_" + method.getSimpleName() + "_" + param.getSimpleName();
124131 }
125132
130137 public static boolean isAddressableType(Class type) {
131138 if ( type.isArray() ) {
132139 final Class component_type = type.getComponentType();
133 return isAddressableTypeImpl(component_type) || org.lwjgl.PointerWrapper.class.isAssignableFrom(component_type);
140 return isAddressableTypeImpl(component_type) || PointerWrapper.class.isAssignableFrom(component_type);
134141 }
135142 return isAddressableTypeImpl(type);
136143 }
141148
142149 public static Class getJavaType(TypeMirror type_mirror) {
143150 JavaTypeTranslator translator = new JavaTypeTranslator();
144 type_mirror.accept(translator);
151 type_mirror.accept((TypeVisitor)translator, null);
145152 return translator.getType();
146153 }
147154
148 private static boolean hasParameterMultipleTypes(ParameterDeclaration param) {
155 private static boolean hasParameterMultipleTypes(VariableElement param) {
149156 int num_native_annotations = 0;
150 for (AnnotationMirror annotation : param.getAnnotationMirrors())
151 if (NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null)
157 for ( AnnotationMirror annotation : param.getAnnotationMirrors() ) {
158 if ( NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null ) {
152159 num_native_annotations++;
160 }
161 }
153162 return num_native_annotations > 1;
154163 }
155164
156 public static boolean isParameterMultiTyped(ParameterDeclaration param) {
157 boolean result = Buffer.class.equals(Utils.getJavaType(param.getType()));
158 if (!result && hasParameterMultipleTypes(param))
165 public static boolean isParameterMultiTyped(VariableElement param) {
166 boolean result = Buffer.class.equals(Utils.getJavaType(param.asType()));
167 if ( !result && hasParameterMultipleTypes(param) ) {
159168 throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types");
169 }
160170 return result;
161171 }
162172
163 public static ParameterDeclaration findParameter(MethodDeclaration method, String name) {
164 for (ParameterDeclaration param : method.getParameters())
165 if (param.getSimpleName().equals(name))
173 public static VariableElement findParameter(ExecutableElement method, String name) {
174 for ( VariableElement param : method.getParameters() ) {
175 if ( param.getSimpleName().toString().equals(name) ) {
166176 return param;
177 }
178 }
167179 throw new RuntimeException("Parameter " + name + " not found");
168180 }
169181
170 public static void printDocComment(PrintWriter writer, Declaration decl) {
182 public static void printDocComment(PrintWriter writer, Element decl, ProcessingEnvironment pe) {
171183 final String overloadsComment;
172 if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null )
184 if ( (decl instanceof ExecutableElement) && decl.getAnnotation(Alternate.class) != null ) {
173185 overloadsComment = "Overloads " + decl.getAnnotation(Alternate.class).value() + ".";
174 else
186 } else {
175187 overloadsComment = null;
176
177 String doc_comment = decl.getDocComment();
178 if (doc_comment != null) {
179 final String tab = decl instanceof InterfaceDeclaration ? "" : "\t";
188 }
189
190 String doc_comment = pe.getElementUtils().getDocComment(decl);
191 if ( doc_comment != null ) {
192 final String tab = (decl instanceof TypeElement) ? "" : "\t";
180193 writer.println(tab + "/**");
181194
182195 if ( overloadsComment != null ) {
186199
187200 final StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n", true);
188201 boolean lastWasNL = false;
189 while (doc_lines.hasMoreTokens()) {
202 while ( doc_lines.hasMoreTokens() ) {
190203 final String t = doc_lines.nextToken();
191204 if ( "\n".equals(t) ) {
192 if ( lastWasNL )
205 if ( lastWasNL ) {
193206 writer.println(tab + " * <p>");
207 }
194208 lastWasNL = true;
195209 } else {
196210 writer.println(tab + " * " + t);
199213 }
200214
201215 writer.println(tab + " */");
202 } else if ( overloadsComment != null )
216 } else if ( overloadsComment != null ) {
203217 writer.println("\t/** " + overloadsComment + " */");
204 }
205
206 public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) {
207 for (AnnotationMirror annotation : param.getAnnotationMirrors())
208 if (NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null)
218 }
219 }
220
221 public static AnnotationMirror getParameterAutoAnnotation(VariableElement param) {
222 for ( AnnotationMirror annotation : param.getAnnotationMirrors() ) {
223 if ( NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null ) {
209224 return annotation;
225 }
226 }
210227 return null;
211228 }
212229
213230 // DISABLED: We always generate indirect methods. (affects OpenAL only at the time of this change)
214 public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, MethodDeclaration method) {
215 /*
216 for (ParameterDeclaration param : method.getParameters()) {
217 if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null ||
218 param.getAnnotation(Constant.class) != null)
219 return true;
220 }
221 return hasMethodBufferObjectParameter(method) || method.getAnnotation(Code.class) != null ||
222 method.getAnnotation(CachedResult.class) != null ||
223 (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) ||
224 context_specific;
225 */
231 public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, ExecutableElement method) {
232 /*
233 for (VariableElement param : method.getParameters()) {
234 if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null ||
235 param.getAnnotation(Constant.class) != null)
236 return true;
237 }
238 return hasMethodBufferObjectParameter(method) || method.getAnnotation(Code.class) != null ||
239 method.getAnnotation(CachedResult.class) != null ||
240 (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) ||
241 context_specific;
242 */
226243 return true;
227244 }
228245
246 private static final Pattern DOT_PATTERN = Pattern.compile("\\.");
247
229248 public static String getNativeQualifiedName(String qualified_name) {
230 return qualified_name.replaceAll("\\.", "_");
249 return DOT_PATTERN.matcher(qualified_name).replaceAll("_");
231250 }
232251
233252 public static String getQualifiedNativeMethodName(String qualified_class_name, String method_name) {
253 // Escape '_' in method name
254 if ( method_name.indexOf('_') != -1 ) {
255 method_name = method_name.replace("_", "_1");
256 }
257
234258 return "Java_" + getNativeQualifiedName(qualified_class_name) + "_" + method_name;
235259 }
236260
237 public static String getQualifiedNativeMethodName(String qualified_class_name, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
261 public static String getQualifiedNativeMethodName(String qualified_class_name, ExecutableElement method, boolean generate_error_checks, boolean context_specific) {
238262 String method_name = getSimpleNativeMethodName(method, generate_error_checks, context_specific);
239263 return getQualifiedNativeMethodName(qualified_class_name, method_name);
240264 }
241265
242 public static ParameterDeclaration getResultParameter(MethodDeclaration method) {
243 ParameterDeclaration result_param = null;
244 for (ParameterDeclaration param : method.getParameters()) {
245 if (param.getAnnotation(Result.class) != null) {
246 if (result_param != null)
266 public static VariableElement getResultParameter(ExecutableElement method) {
267 VariableElement result_param = null;
268 for ( VariableElement param : method.getParameters() ) {
269 if ( param.getAnnotation(Result.class) != null ) {
270 if ( result_param != null ) {
247271 throw new RuntimeException("Multiple parameters annotated with Result in method " + method);
272 }
248273 result_param = param;
249274 }
250275 }
251276 return result_param;
252277 }
253278
254 public static TypeMirror getMethodReturnType(MethodDeclaration method) {
279 public static TypeMirror getMethodReturnType(ExecutableElement method) {
255280 TypeMirror result_type;
256 ParameterDeclaration result_param = getResultParameter(method);
257 if (result_param != null) {
258 result_type = result_param.getType();
259 } else
281 VariableElement result_param = getResultParameter(method);
282 if ( result_param != null ) {
283 result_type = result_param.asType();
284 } else {
260285 result_type = method.getReturnType();
286 }
261287 return result_type;
262288 }
263289
264 public static String getMethodReturnType(MethodDeclaration method, GLreturn return_annotation, boolean buffer) {
265 ParameterDeclaration return_param = null;
266 for ( ParameterDeclaration param : method.getParameters() ) {
267 if ( param.getSimpleName().equals(return_annotation.value()) ) {
290 public static String getMethodReturnType(ExecutableElement method, GLreturn return_annotation, boolean buffer) {
291 VariableElement return_param = null;
292 for ( VariableElement param : method.getParameters() ) {
293 if ( param.getSimpleName().toString().equals(return_annotation.value()) ) {
268294 return_param = param;
269295 break;
270296 }
271297 }
272 if ( return_param == null )
298 if ( return_param == null ) {
273299 throw new RuntimeException("The @GLreturn parameter \"" + return_annotation.value() + "\" could not be found in method: " + method);
274
275 PrimitiveType.Kind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.getType()));
276 if ( return_param.getAnnotation(GLboolean.class) != null )
277 kind = PrimitiveType.Kind.BOOLEAN;
278
279 if ( kind == PrimitiveType.Kind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) )
300 }
301
302 TypeKind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.asType()));
303 if ( return_param.getAnnotation(GLboolean.class) != null ) {
304 kind = TypeKind.BOOLEAN;
305 }
306
307 if ( kind == TypeKind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) ) {
280308 return "String";
281 else {
309 } else {
282310 final String type = JavaTypeTranslator.getPrimitiveClassFromKind(kind).getName();
283311 return buffer ? Character.toUpperCase(type.charAt(0)) + type.substring(1) : type;
284312 }
285313 }
286314
287 public static boolean needResultSize(MethodDeclaration method) {
315 public static boolean needResultSize(ExecutableElement method) {
288316 return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoSize.class) == null;
289317 }
290318
291 public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) {
319 public static void printExtraCallArguments(PrintWriter writer, ExecutableElement method, String size_parameter_name) {
292320 writer.print(size_parameter_name);
293 if (method.getAnnotation(CachedResult.class) != null) {
321 if ( method.getAnnotation(CachedResult.class) != null ) {
294322 writer.print(", " + CACHED_BUFFER_NAME);
295323 }
296324 }
297325
298 private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) {
326 private static String getClassName(TypeElement interface_decl, String opengl_name) {
299327 Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
300 if (extension_annotation != null && !"".equals(extension_annotation.className())) {
328 if ( extension_annotation != null && !"".equals(extension_annotation.className()) ) {
301329 return extension_annotation.className();
302330 }
303331 StringBuilder result = new StringBuilder();
304 for (int i = 0; i < opengl_name.length(); i++) {
332 for ( int i = 0; i < opengl_name.length(); i++ ) {
305333 int ch = opengl_name.codePointAt(i);
306 if (ch == '_') {
334 if ( ch == '_' ) {
307335 i++;
308336 result.appendCodePoint(Character.toUpperCase(opengl_name.codePointAt(i)));
309 } else
337 } else {
310338 result.appendCodePoint(ch);
339 }
311340 }
312341 return result.toString();
313342 }
314343
315 public static boolean hasMethodBufferObjectParameter(MethodDeclaration method) {
316 for (ParameterDeclaration param : method.getParameters()) {
317 if (param.getAnnotation(BufferObject.class) != null) {
344 public static boolean hasMethodBufferObjectParameter(ExecutableElement method) {
345 for ( VariableElement param : method.getParameters() ) {
346 if ( param.getAnnotation(BufferObject.class) != null ) {
318347 return true;
319348 }
320349 }
321350 return false;
322351 }
323352
324 public static String getQualifiedClassName(InterfaceDeclaration interface_decl) {
325 return interface_decl.getPackage().getQualifiedName() + "." + getSimpleClassName(interface_decl);
326 }
327
328 public static String getSimpleClassName(InterfaceDeclaration interface_decl) {
329 return getClassName(interface_decl, interface_decl.getSimpleName());
353 public static String getQualifiedClassName(TypeElement interface_decl) {
354 return interface_decl.getEnclosingElement().asType().toString() + "." + getSimpleClassName(interface_decl);
355 }
356
357 public static String getSimpleClassName(TypeElement interface_decl) {
358 return getClassName(interface_decl, interface_decl.getSimpleName().toString());
330359 }
331360
332361 public static Class<?> getNIOBufferType(TypeMirror t) {
333362 Class<?> param_type = getJavaType(t);
334 if (Buffer.class.isAssignableFrom(param_type))
363 if ( Buffer.class.isAssignableFrom(param_type) ) {
335364 return param_type;
336 else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class )
365 } else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class ) {
337366 return ByteBuffer.class;
338 else
367 } else {
339368 return null;
340 }
341
342 public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
369 }
370 }
371
372 public static String getSimpleNativeMethodName(ExecutableElement method, boolean generate_error_checks, boolean context_specific) {
343373 String method_name;
344374 Alternate alt_annotation = method.getAnnotation(Alternate.class);
345 method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value();
346 if (isMethodIndirect(generate_error_checks, context_specific, method))
375 method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName().toString() : alt_annotation.value();
376 if ( isMethodIndirect(generate_error_checks, context_specific, method) ) {
347377 method_name = OVERLOADED_METHOD_PREFIX + method_name;
378 }
348379 return method_name;
349380 }
350381
351 static boolean isReturnParameter(MethodDeclaration method, ParameterDeclaration param) {
382 static boolean isReturnParameter(ExecutableElement method, VariableElement param) {
352383 GLreturn string_annotation = method.getAnnotation(GLreturn.class);
353 if ( string_annotation == null || !string_annotation.value().equals(param.getSimpleName()) )
384 if ( string_annotation == null || !string_annotation.value().equals(param.getSimpleName().toString()) ) {
354385 return false;
355
356 if ( param.getAnnotation(OutParameter.class) == null )
386 }
387
388 if ( param.getAnnotation(OutParameter.class) == null ) {
357389 throw new RuntimeException("The parameter specified in @GLreturn is not annotated with @OutParameter in method: " + method);
358
359 if ( param.getAnnotation(Check.class) != null )
390 }
391
392 if ( param.getAnnotation(Check.class) != null ) {
360393 throw new RuntimeException("The parameter specified in @GLreturn is annotated with @Check in method: " + method);
361
362 if ( param.getAnnotation(GLchar.class) != null && Utils.getJavaType(param.getType()).equals(ByteBuffer.class) && string_annotation.maxLength().length() == 0 )
394 }
395
396 if ( param.getAnnotation(GLchar.class) != null && Utils.getJavaType(param.asType()).equals(ByteBuffer.class) && string_annotation.maxLength().length() == 0 ) {
363397 throw new RuntimeException("The @GLreturn annotation is missing a maxLength parameter in method: " + method);
398 }
364399
365400 return true;
366401 }
367402
368 static String getStringOffset(MethodDeclaration method, ParameterDeclaration param) {
403 static String getStringOffset(ExecutableElement method, VariableElement param) {
369404 String offset = null;
370 for ( ParameterDeclaration p : method.getParameters() ) {
371 if ( param != null && p.getSimpleName().equals(param.getSimpleName()) )
405 for ( VariableElement p : method.getParameters() ) {
406 if ( param != null && p.getSimpleName().equals(param.getSimpleName()) ) {
372407 break;
373
374 final Class type = Utils.getJavaType(p.getType());
408 }
409
410 if ( p.getAnnotation(NullTerminated.class) != null ) {
411 continue;
412 }
413
414 final Class type = Utils.getJavaType(p.asType());
375415 if ( type.equals(CharSequence.class) ) {
376 if ( offset == null )
416 if ( offset == null ) {
377417 offset = p.getSimpleName() + ".length()";
378 else
418 } else {
379419 offset += " + " + p.getSimpleName() + ".length()";
380 if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1";
381
420 }
421 //if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1";
382422 } else if ( type.equals(CharSequence[].class) ) {
383 if ( offset == null )
423 if ( offset == null ) {
384424 offset = "APIUtil.getTotalLength(" + p.getSimpleName() + ")";
385 else
425 } else {
386426 offset += " + APIUtil.getTotalLength(" + p.getSimpleName() + ")";
387 if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length";
427 }
428 //if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length";
388429 }
389430
390431 }
391432 return offset;
392433 }
393434
394 static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
435 static void printGLReturnPre(PrintWriter writer, ExecutableElement method, GLreturn return_annotation, TypeMap type_map) {
395436 final String return_type = getMethodReturnType(method, return_annotation, true);
396437
397438 if ( "String".equals(return_type) ) {
398439 if ( !return_annotation.forceMaxLength() ) {
399 writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths();");
440 writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths(" + type_map.getAPIUtilParam(false) + ");");
400441 writer.print("\t\t");
401442 }
402 writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + return_annotation.maxLength());
403 /*
404 Params that use the return buffer will advance its position while filling it. When we return, the position will be
405 at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was
406 large enough to hold everything, so that no re-allocations happen while filling.
407 */
443 writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + type_map.getAPIUtilParam(true) + return_annotation.maxLength());
444 /*
445 Params that use the return buffer will advance its position while filling it. When we return, the position will be
446 at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was
447 large enough to hold everything, so that no re-allocations happen while filling.
448 */
408449 final String offset = getStringOffset(method, null);
409 if ( offset != null )
450 if ( offset != null ) {
410451 writer.print(" + " + offset);
452 }
411453 writer.println(");");
412454 } else {
413455 final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type;
414 writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(");
415 if ( "Byte".equals(buffer_type) )
416 writer.print('1');
456 writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(" + type_map.getAPIUtilParam(false));
457 if ( "Byte".equals(buffer_type) ) {
458 writer.print((type_map.getAPIUtilParam(false).length() > 0 ? ", " : "") + "1");
459 }
417460 writer.println(");");
418461 }
419462
421464 if ( code_annotation != null && code_annotation.tryBlock() ) {
422465 writer.println("\t\ttry {");
423466 writer.print("\t\t\t");
424 } else
467 } else {
425468 writer.print("\t\t");
426 }
427
428 static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
469 }
470 }
471
472 static void printGLReturnPost(PrintWriter writer, ExecutableElement method, GLreturn return_annotation, TypeMap type_map) {
429473 final String return_type = getMethodReturnType(method, return_annotation, true);
430474
431475 if ( "String".equals(return_type) ) {
432476 writer.print("\t\t" + return_annotation.value() + ".limit(");
433477 final String offset = getStringOffset(method, null);
434 if ( offset != null)
478 if ( offset != null ) {
435479 writer.print(offset + " + ");
436 if ( return_annotation.forceMaxLength() )
480 }
481 if ( return_annotation.forceMaxLength() ) {
437482 writer.print(return_annotation.maxLength());
438 else
483 } else {
439484 writer.print(return_annotation.value() + "_length.get(0)");
485 }
440486 writer.println(");");
441 writer.println("\t\treturn APIUtil.getString(" + return_annotation.value() + ");");
487 writer.println("\t\treturn APIUtil.getString(" + type_map.getAPIUtilParam(true) + return_annotation.value() + ");");
442488 } else {
443489 writer.print("\t\treturn " + return_annotation.value() + ".get(0)");
444 if ( "Boolean".equals(return_type) )
490 if ( "Boolean".equals(return_type) ) {
445491 writer.print(" == 1");
492 }
446493 writer.println(";");
447494 }
448495 }
449496
497 public static Collection<VariableElement> getFields(TypeElement d) {
498 return ElementFilter.fieldsIn(new LinkedHashSet<Element>(d.getEnclosedElements()));
499 }
500
501 public static Collection<ExecutableElement> getMethods(TypeElement d) {
502 return ElementFilter.methodsIn(new LinkedHashSet<Element>(d.getEnclosedElements()));
503 }
504
450505 }
4343 import org.lwjgl.util.generator.Signedness;
4444 import org.lwjgl.util.generator.TypeMap;
4545
46 import com.sun.mirror.declaration.*;
47 import com.sun.mirror.type.*;
48
49 import java.io.*;
46 import java.io.PrintWriter;
5047 import java.lang.annotation.Annotation;
51 import java.util.*;
5248 import java.nio.*;
49 import java.util.HashMap;
50 import java.util.Map;
51 import javax.lang.model.element.AnnotationMirror;
52 import javax.lang.model.element.ExecutableElement;
53 import javax.lang.model.type.TypeKind;
5354
5455 public class ALTypeMap implements TypeMap {
55 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
56 private static final Map<Class, TypeKind> native_types_to_primitive;
5657
5758 static {
58 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
59 native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN);
60 native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE);
61 native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT);
62 native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT);
63 native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE);
64 native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT);
65 native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT);
66 native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT);
67 native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE);
68 native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE);
70 }
71
72 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
73 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
74 if (kind == null)
59 native_types_to_primitive = new HashMap<Class, TypeKind>();
60 native_types_to_primitive.put(ALboolean.class, TypeKind.BOOLEAN);
61 native_types_to_primitive.put(ALbyte.class, TypeKind.BYTE);
62 native_types_to_primitive.put(ALenum.class, TypeKind.INT);
63 native_types_to_primitive.put(ALfloat.class, TypeKind.FLOAT);
64 native_types_to_primitive.put(ALdouble.class, TypeKind.DOUBLE);
65 native_types_to_primitive.put(ALint.class, TypeKind.INT);
66 native_types_to_primitive.put(ALshort.class, TypeKind.SHORT);
67 native_types_to_primitive.put(ALsizei.class, TypeKind.INT);
68 native_types_to_primitive.put(ALubyte.class, TypeKind.BYTE);
69 native_types_to_primitive.put(ALuint.class, TypeKind.INT);
70 native_types_to_primitive.put(ALvoid.class, TypeKind.BYTE);
71 }
72
73 @Override
74 public TypeKind getPrimitiveTypeFromNativeType(Class native_type) {
75 TypeKind kind = native_types_to_primitive.get(native_type);
76 if ( kind == null )
7577 throw new RuntimeException("Unsupported type " + native_type);
7678 return kind;
7779 }
7880
81 @Override
7982 public Signedness getSignednessFromType(Class type) {
80 if (ALuint.class.equals(type))
83 if ( ALuint.class.equals(type) )
8184 return Signedness.UNSIGNED;
82 else if (ALint.class.equals(type))
85 else if ( ALint.class.equals(type) )
8386 return Signedness.SIGNED;
84 else if (ALshort.class.equals(type))
87 else if ( ALshort.class.equals(type) )
8588 return Signedness.SIGNED;
86 else if (ALbyte.class.equals(type))
89 else if ( ALbyte.class.equals(type) )
8790 return Signedness.SIGNED;
8891 else
8992 return Signedness.NONE;
9093 }
9194
95 @Override
9296 public String translateAnnotation(Class annotation_type) {
93 if (annotation_type.equals(ALuint.class))
97 if ( annotation_type.equals(ALuint.class) )
9498 return "i";
95 else if (annotation_type.equals(ALint.class))
99 else if ( annotation_type.equals(ALint.class) )
96100 return "i";
97 else if (annotation_type.equals(ALshort.class))
101 else if ( annotation_type.equals(ALshort.class) )
98102 return "s";
99 else if (annotation_type.equals(ALbyte.class))
103 else if ( annotation_type.equals(ALbyte.class) )
100104 return "b";
101 else if (annotation_type.equals(ALfloat.class))
105 else if ( annotation_type.equals(ALfloat.class) )
102106 return "f";
103 else if (annotation_type.equals(ALdouble.class))
107 else if ( annotation_type.equals(ALdouble.class) )
104108 return "d";
105 else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class))
109 else if ( annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class) )
106110 return "";
107111 else
108112 throw new RuntimeException(annotation_type + " is not allowed");
109113 }
110114
111 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
115 @Override
116 public Class getNativeTypeFromPrimitiveType(TypeKind kind) {
112117 Class type;
113 switch (kind) {
118 switch ( kind ) {
114119 case INT:
115120 type = ALint.class;
116121 break;
136141 }
137142
138143 private static Class[] getValidBufferTypes(Class type) {
139 if (type.equals(IntBuffer.class))
140 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
141 else if (type.equals(FloatBuffer.class))
142 return new Class[]{ALfloat.class};
143 else if (type.equals(ByteBuffer.class))
144 return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class};
145 else if (type.equals(ShortBuffer.class))
146 return new Class[]{ALshort.class};
147 else if (type.equals(DoubleBuffer.class))
148 return new Class[]{ALdouble.class};
149 else
150 return new Class[]{};
144 if ( type.equals(IntBuffer.class) )
145 return new Class[] { ALenum.class, ALint.class, ALsizei.class, ALuint.class };
146 else if ( type.equals(FloatBuffer.class) )
147 return new Class[] { ALfloat.class };
148 else if ( type.equals(ByteBuffer.class) )
149 return new Class[] { ALboolean.class, ALbyte.class, ALvoid.class };
150 else if ( type.equals(ShortBuffer.class) )
151 return new Class[] { ALshort.class };
152 else if ( type.equals(DoubleBuffer.class) )
153 return new Class[] { ALdouble.class };
154 else
155 return new Class[] { };
151156 }
152157
153158 private static Class[] getValidPrimitiveTypes(Class type) {
154 if (type.equals(int.class))
155 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
156 else if (type.equals(double.class))
157 return new Class[]{ALdouble.class};
158 else if (type.equals(float.class))
159 return new Class[]{ALfloat.class};
160 else if (type.equals(short.class))
161 return new Class[]{ALshort.class};
162 else if (type.equals(byte.class))
163 return new Class[]{ALbyte.class};
164 else if (type.equals(boolean.class))
165 return new Class[]{ALboolean.class};
166 else if (type.equals(void.class))
167 return new Class[]{ALvoid.class};
168 else
169 return new Class[]{};
170 }
171
159 if ( type.equals(int.class) )
160 return new Class[] { ALenum.class, ALint.class, ALsizei.class, ALuint.class };
161 else if ( type.equals(double.class) )
162 return new Class[] { ALdouble.class };
163 else if ( type.equals(float.class) )
164 return new Class[] { ALfloat.class };
165 else if ( type.equals(short.class) )
166 return new Class[] { ALshort.class };
167 else if ( type.equals(byte.class) )
168 return new Class[] { ALbyte.class };
169 else if ( type.equals(boolean.class) )
170 return new Class[] { ALboolean.class };
171 else if ( type.equals(void.class) )
172 return new Class[] { ALvoid.class };
173 else
174 return new Class[] { };
175 }
176
177 @Override
172178 public void printCapabilitiesInit(final PrintWriter writer) {
173179 throw new UnsupportedOperationException();
174180 }
175181
182 @Override
176183 public String getCapabilities() {
177184 throw new UnsupportedOperationException();
178185 }
179186
180 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
187 @Override
188 public String getAPIUtilParam(boolean comma) {
189 return "";
190 }
191
192 @Override
193 public void printErrorCheckMethod(final PrintWriter writer, final ExecutableElement method, final String tabs) {
181194 writer.println(tabs + "Util.checkALError();");
182195 }
183196
197 @Override
184198 public String getRegisterNativesFunctionName() {
185199 return "extal_InitializeClass";
186200 }
187201
202 @Override
188203 public String getTypedefPostfix() {
189204 return "";
190205 }
191206
207 @Override
192208 public String getFunctionPrefix() {
193209 return "ALAPIENTRY";
194210 }
195211
212 @Override
196213 public void printNativeIncludes(PrintWriter writer) {
197214 writer.println("#include \"extal.h\"");
198215 }
199216
200 public Class<? extends Annotation> getStringElementType() {
217 @Override
218 public Class<? extends Annotation> getStringElementType() {
201219 return ALubyte.class;
202220 }
203221
222 @Override
204223 public Class<? extends Annotation> getStringArrayType() {
205224 return ALubyte.class;
206225 }
207226
227 @Override
208228 public Class<? extends Annotation> getByteBufferArrayType() {
209229 return ALubyte.class;
210230 }
211231
232 @Override
212233 public Class[] getValidAnnotationTypes(Class type) {
213234 Class[] valid_types;
214 if (Buffer.class.isAssignableFrom(type))
235 if ( Buffer.class.isAssignableFrom(type) )
215236 valid_types = getValidBufferTypes(type);
216 else if (type.isPrimitive())
237 else if ( type.isPrimitive() )
217238 valid_types = getValidPrimitiveTypes(type);
218 else if (type.equals(String.class))
219 valid_types = new Class[]{ALubyte.class};
220 else
221 valid_types = new Class[]{};
239 else if ( type.equals(String.class) )
240 valid_types = new Class[] { ALubyte.class };
241 else
242 valid_types = new Class[] { };
222243 return valid_types;
223244 }
224245
246 @Override
225247 public Class<? extends Annotation> getVoidType() {
226248 return ALvoid.class;
227249 }
228250
251 @Override
229252 public Class<? extends Annotation> getInverseType(Class type) {
230 if (ALuint.class.equals(type))
253 if ( ALuint.class.equals(type) )
231254 return ALint.class;
232 else if (ALint.class.equals(type))
255 else if ( ALint.class.equals(type) )
233256 return ALuint.class;
234257 else
235258 return null;
236259 }
237260
261 @Override
238262 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
239263 return null;
240264 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator.opencl;
3332
3433 import org.lwjgl.util.generator.*;
3534
3635 import java.io.PrintWriter;
37 import java.util.Collection;
3836 import java.util.Iterator;
39
40 import com.sun.mirror.declaration.InterfaceDeclaration;
41 import com.sun.mirror.declaration.MethodDeclaration;
42 import com.sun.mirror.declaration.TypeDeclaration;
37 import java.util.Set;
38 import javax.annotation.processing.ProcessingEnvironment;
39 import javax.lang.model.element.ExecutableElement;
40 import javax.lang.model.element.TypeElement;
4341
4442 /**
4543 * CLCapabilities generator.
4947 public class CLCapabilitiesGenerator {
5048
5149 static void generateClassPrologue(final PrintWriter writer) {
52 writer.println("public final class " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + " {");
50 writer.println("public final class " + CLGeneratorProcessor.CLCAPS_CLASS_NAME + " {");
5351 writer.println();
5452 }
5553
56 static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) {
54 static void generateSymbolAddresses(ProcessingEnvironment env, final PrintWriter writer, final TypeElement d) {
55 if ( d.getAnnotation(CLPlatformExtension.class) == null && d.getAnnotation(CLDeviceExtension.class) == null && !d.getSimpleName().toString().startsWith("CL") ) {
56 throw new RuntimeException("An OpenCL extension is missing an extension type annotation: " + d.getSimpleName());
57 }
5758 final Alias alias_annotation = d.getAnnotation(Alias.class);
5859 final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
5960
6061 boolean foundNative = false;
61 for ( final MethodDeclaration method : d.getMethods() ) {
62 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
62 for ( final ExecutableElement method : Utils.getMethods(d) ) {
63 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null ) {
6364 continue;
65 }
6466
6567 if ( !foundNative ) {
6668 //writer.println("\t// " + d.getSimpleName());
67 writer.println("\tstatic final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
69 writer.println("\tstatic final boolean " + CLGeneratorProcessor.getExtensionName(d.getSimpleName().toString() + ";"));
6870 foundNative = true;
6971 }
7072 writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress(");
7173
72 if ( aliased )
74 if ( aliased ) {
7375 writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});");
74 else
76 } else {
7577 writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");");
78 }
7679 }
7780
78 if ( foundNative )
81 if ( foundNative ) {
7982 writer.println();
83 }
8084 }
8185
82 static void generateConstructor(final PrintWriter writer, final Collection<TypeDeclaration> interface_decls) {
83 writer.println("\tprivate " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + "() {}");
86 static void generateConstructor(ProcessingEnvironment env, final PrintWriter writer, final Set<? extends TypeElement> interface_decls) {
87 writer.println("\tprivate " + CLGeneratorProcessor.CLCAPS_CLASS_NAME + "() {}");
8488 writer.println();
8589 writer.println("\tstatic {");
8690
87 for ( final TypeDeclaration d : interface_decls ) {
88 if ( d.getMethods().isEmpty() )
89 continue;
91 for ( final TypeElement d : interface_decls ) {
92 if ( d.getKind().isInterface() ) {
93 if ( Utils.getMethods(d).isEmpty() ) {
94 continue;
95 }
9096
91 //writer.println("\t\tif ( " + getExtensionSupportedName(d.getSimpleName()) + "() )");
92 //writer.println("\t\t\t" + SUPPORTED_EXTS + ".add(\"" + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + "\");");
93 writer.println("\t\t" + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + " = " + getExtensionSupportedName(d.getSimpleName()) + "();");
97 //writer.println("\t\tif ( " + getExtensionSupportedName(d.getSimpleName()) + "() )");
98 //writer.println("\t\t\t" + SUPPORTED_EXTS + ".add(\"" + CLGeneratorProcessor.getExtensionName(d.getSimpleName()) + "\");");
99 writer.println("\t\t" + CLGeneratorProcessor.getExtensionName(d.getSimpleName().toString()) + " = " + getExtensionSupportedName(d.getSimpleName().toString()) + "();");
100 }
94101 }
95102
96103 writer.println("\t}\n");
97104 }
98105
99 static void generateExtensionChecks(final PrintWriter writer, final InterfaceDeclaration d) {
100 Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
101 if ( !methods.hasNext() )
106 static void generateExtensionChecks(ProcessingEnvironment env, final PrintWriter writer, TypeElement d) {
107 Iterator<? extends ExecutableElement> methods = Utils.getMethods(d).iterator();
108 if ( !methods.hasNext() ) {
102109 return;
110 }
103111
104 writer.println("\tprivate static boolean " + getExtensionSupportedName(d.getSimpleName()) + "() {");
112 writer.println("\tprivate static boolean " + getExtensionSupportedName(d.getSimpleName().toString()) + "() {");
105113 writer.println("\t\treturn ");
106114
107115 boolean first = true;
108116 while ( methods.hasNext() ) {
109 MethodDeclaration method = methods.next();
110 if ( method.getAnnotation(Alternate.class) != null )
117 ExecutableElement method = methods.next();
118 if ( method.getAnnotation(Alternate.class) != null ) {
111119 continue;
120 }
112121
113 if ( !first )
122 if ( !first ) {
114123 writer.println(" &");
115 else
124 } else {
116125 first = false;
126 }
117127
118128 final boolean optional = method.getAnnotation(Optional.class) != null;
119129
120130 writer.print("\t\t\t");
121 if ( optional )
131 if ( optional ) {
122132 writer.print('(');
133 }
123134 writer.print(Utils.getFunctionAddressName(d, method) + " != 0");
124 if ( optional )
135 if ( optional ) {
125136 writer.print(" || true)");
137 }
126138 }
127139 writer.println(";");
128140 writer.println("\t}");
134146 }
135147
136148 public static void generateCapabilitiesGetters(final PrintWriter writer) {
137 writer.println("\tpublic static CLPlatformCapabilities getPlatformCapabilities(final CLPlatform platform) {\n" +
138 "\t\tplatform.checkValid();\n" +
139 "\n" +
140 "\t\tCLPlatformCapabilities caps = (CLPlatformCapabilities)platform.getCapabilities();\n" +
141 "\t\tif ( caps == null )\n" +
142 "\t\t\tplatform.setCapabilities(caps = new CLPlatformCapabilities(platform));\n" +
143 "\n" +
144 "\t\treturn caps;\n" +
145 "\t}\n");
149 writer.println("\tpublic static CLPlatformCapabilities getPlatformCapabilities(final CLPlatform platform) {\n"
150 + "\t\tplatform.checkValid();\n"
151 + "\n"
152 + "\t\tCLPlatformCapabilities caps = (CLPlatformCapabilities)platform.getCapabilities();\n"
153 + "\t\tif ( caps == null )\n"
154 + "\t\t\tplatform.setCapabilities(caps = new CLPlatformCapabilities(platform));\n"
155 + "\n"
156 + "\t\treturn caps;\n"
157 + "\t}\n");
146158
147 writer.println("\tpublic static CLDeviceCapabilities getDeviceCapabilities(final CLDevice device) {\n" +
148 "\t\tdevice.checkValid();\n" +
149 "\n" +
150 "\t\tCLDeviceCapabilities caps = (CLDeviceCapabilities)device.getCapabilities();\n" +
151 "\t\tif ( caps == null )\n" +
152 "\t\t\tdevice.setCapabilities(caps = new CLDeviceCapabilities(device));\n" +
153 "\n" +
154 "\t\treturn caps;\n" +
155 "\t}\n");
159 writer.println("\tpublic static CLDeviceCapabilities getDeviceCapabilities(final CLDevice device) {\n"
160 + "\t\tdevice.checkValid();\n"
161 + "\n"
162 + "\t\tCLDeviceCapabilities caps = (CLDeviceCapabilities)device.getCapabilities();\n"
163 + "\t\tif ( caps == null )\n"
164 + "\t\t\tdevice.setCapabilities(caps = new CLDeviceCapabilities(device));\n"
165 + "\n"
166 + "\t\treturn caps;\n"
167 + "\t}\n");
156168
157169 }
158 }
170 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator.opencl;
32
33 import org.lwjgl.PointerWrapper;
34 import org.lwjgl.opencl.CLDevice;
35 import org.lwjgl.opencl.CLPlatform;
36
37 import java.io.IOException;
38 import java.io.PrintWriter;
39 import java.lang.annotation.Annotation;
40 import java.util.Set;
41 import javax.annotation.processing.*;
42 import javax.lang.model.SourceVersion;
43 import javax.lang.model.element.TypeElement;
44 import javax.lang.model.util.ElementFilter;
45
46 /**
47 * Generator tool for creating the OpenCL capabilities classes
48 *
49 * @author Spasi
50 */
51 @SupportedAnnotationTypes({ "*" })
52 @SupportedSourceVersion(SourceVersion.RELEASE_6)
53 @SupportedOptions({ "generatechecks", "contextspecific" })
54 public class CLGeneratorProcessor extends AbstractProcessor {
55
56 public static final String CLCAPS_CLASS_NAME = "CLCapabilities";
57 public static final String PLATFORM_CAPS_CLASS_NAME = "CLPlatformCapabilities";
58 public static final String DEVICE_CAPS_CLASS_NAME = "CLDeviceCapabilities";
59
60 private static final String EXTENSION_PREFIX = "CL_";
61 private static final String CORE_PREFIX = "Open";
62
63 private static boolean first_round = true;
64
65 static String getExtensionName(String interface_name) {
66 if ( interface_name.startsWith("CL") ) {
67 return CORE_PREFIX + interface_name;
68 } else {
69 return EXTENSION_PREFIX + interface_name;
70 }
71 }
72
73 @Override
74 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
75 if ( roundEnv.processingOver() || !first_round ) {
76 System.exit(0);
77 return true;
78 }
79 try {
80 Set<TypeElement> templates = ElementFilter.typesIn(roundEnv.getRootElements());
81 /**
82 * provide the full set of ex-InterfaceDeclaration
83 * annotated templates elements
84 */
85 generateCLCapabilitiesSource(templates);
86 generateCLPDCapabilitiesSource(templates, CLPlatformExtension.class, PLATFORM_CAPS_CLASS_NAME, CLPlatform.class, "platform");
87 generateCLPDCapabilitiesSource(templates, CLDeviceExtension.class, DEVICE_CAPS_CLASS_NAME, CLDevice.class, "device");
88 first_round = false;
89 return true;
90 } catch (IOException e) {
91 throw new RuntimeException(e);
92 }
93 }
94
95 private static void printHeader(final PrintWriter writer) {
96 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
97 writer.println();
98 writer.println("package org.lwjgl.opencl;");
99 writer.println();
100 }
101
102 private void generateCLCapabilitiesSource(Set<TypeElement> templates) throws IOException {
103 final PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opencl." + CLCAPS_CLASS_NAME, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opencl")).openWriter());
104 printHeader(writer);
105
106 CLCapabilitiesGenerator.generateClassPrologue(writer);
107 for ( TypeElement d : templates ) {
108 if ( d.getKind().isInterface() ) {
109 CLCapabilitiesGenerator.generateSymbolAddresses(processingEnv, writer, d);
110 }
111 }
112 writer.println();
113
114 CLCapabilitiesGenerator.generateConstructor(processingEnv, writer, templates);
115
116 CLCapabilitiesGenerator.generateCapabilitiesGetters(writer);
117 for ( TypeElement d : templates ) {
118 if ( d.getKind().isInterface() ) {
119 CLCapabilitiesGenerator.generateExtensionChecks(processingEnv, writer, d);
120 }
121 }
122
123 writer.println("}");
124 writer.close();
125 }
126
127 private void generateCLPDCapabilitiesSource(Set<TypeElement> templates, final Class<? extends Annotation> capsType, final String capsName, final Class<? extends PointerWrapper> objectType, final String objectName) throws IOException {
128 final PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opencl." + capsName, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opencl")).openWriter());
129 printHeader(writer);
130 writer.println("import java.util.*;");
131 writer.println();
132
133 CLPDCapabilitiesGenerator.generateClassPrologue(writer, capsName);
134
135 for ( TypeElement t : templates ) {
136 if ( t.getKind().isInterface() && t.getAnnotation(capsType) != null ) {
137 CLPDCapabilitiesGenerator.generateExtensions(writer, (TypeElement)t);
138 }
139 }
140 writer.println();
141
142 CLPDCapabilitiesGenerator.generateConstructor(processingEnv, writer, templates, capsType, capsName, objectType, objectName);
143
144 CLPDCapabilitiesGenerator.generateGetters(writer);
145
146 CLPDCapabilitiesGenerator.generateToString(writer, templates, capsType);
147
148 writer.println("}");
149 writer.close();
150 }
151 }
+0
-181
src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.util.generator.opencl;
33
34 import org.lwjgl.PointerWrapper;
35 import org.lwjgl.opencl.CLDevice;
36 import org.lwjgl.opencl.CLPlatform;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.io.PrintWriter;
41 import java.lang.annotation.Annotation;
42 import java.util.Arrays;
43 import java.util.Collection;
44 import java.util.Set;
45
46 import com.sun.mirror.apt.*;
47 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
48 import com.sun.mirror.declaration.InterfaceDeclaration;
49 import com.sun.mirror.declaration.TypeDeclaration;
50 import com.sun.mirror.util.DeclarationFilter;
51
52 import static java.util.Collections.*;
53
54 /**
55 * Generator tool for creating the OpenCL capabilities classes
56 *
57 * @author Spasi
58 */
59 public class CLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
60
61 public static final String CLCAPS_CLASS_NAME = "CLCapabilities";
62 public static final String PLATFORM_CAPS_CLASS_NAME = "CLPlatformCapabilities";
63 public static final String DEVICE_CAPS_CLASS_NAME = "CLDeviceCapabilities";
64
65 private static final String EXTENSION_PREFIX = "CL_";
66 private static final String CORE_PREFIX = "Open";
67
68 private static boolean first_round = true;
69
70 // Process any set of annotations
71 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*"));
72
73 public Collection<String> supportedAnnotationTypes() {
74 return supportedAnnotations;
75 }
76
77 public Collection<String> supportedOptions() {
78 return unmodifiableCollection(Arrays.asList("-Acontextspecific"));
79 }
80
81 public void roundComplete(RoundCompleteEvent event) {
82 first_round = false;
83 }
84
85 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
86 // Only process the initial types, not the generated ones
87 if ( first_round ) {
88 env.addListener(this);
89 return new GeneratorProcessor(env);
90 } else
91 return AnnotationProcessors.NO_OP;
92 }
93
94 static String getExtensionName(String interface_name) {
95 if ( interface_name.startsWith("CL") )
96 return CORE_PREFIX + interface_name;
97 else
98 return EXTENSION_PREFIX + interface_name;
99 }
100
101 private static class GeneratorProcessor implements AnnotationProcessor {
102
103 private final AnnotationProcessorEnvironment env;
104
105 GeneratorProcessor(AnnotationProcessorEnvironment env) {
106 this.env = env;
107 }
108
109 public void process() {
110 try {
111 generateCLCapabilitiesSource();
112 generateCLPDCapabilitiesSource(CLPlatformExtension.class, PLATFORM_CAPS_CLASS_NAME, CLPlatform.class, "platform");
113 generateCLPDCapabilitiesSource(CLDeviceExtension.class, DEVICE_CAPS_CLASS_NAME, CLDevice.class, "device");
114 } catch (IOException e) {
115 throw new RuntimeException(e);
116 }
117 }
118
119 private static void printHeader(final PrintWriter writer) {
120 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
121 writer.println();
122 writer.println("package org.lwjgl.opencl;");
123 writer.println();
124 }
125
126 private void generateCLCapabilitiesSource() throws IOException {
127 final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(CLCAPS_CLASS_NAME + ".java"), null);
128 printHeader(writer);
129
130 CLCapabilitiesGenerator.generateClassPrologue(writer);
131
132 final Collection<TypeDeclaration> templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations());
133
134 for ( final TypeDeclaration t : templates ) {
135 if ( t.getAnnotation(CLPlatformExtension.class) == null && t.getAnnotation(CLDeviceExtension.class) == null && !t.getSimpleName().startsWith("CL") )
136 throw new RuntimeException("An OpenCL extension is missing an extension type annotation: " + t.getSimpleName());
137
138 CLCapabilitiesGenerator.generateSymbolAddresses(writer, (InterfaceDeclaration)t);
139 }
140 writer.println();
141
142 CLCapabilitiesGenerator.generateConstructor(writer, templates);
143
144 CLCapabilitiesGenerator.generateCapabilitiesGetters(writer);
145
146 for ( final TypeDeclaration template : templates )
147 CLCapabilitiesGenerator.generateExtensionChecks(writer, (InterfaceDeclaration)template);
148
149 writer.println("}");
150 writer.close();
151 }
152
153 private void generateCLPDCapabilitiesSource(final Class<? extends Annotation> capsType, final String capsName, final Class<? extends PointerWrapper> objectType, final String objectName) throws IOException {
154 final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(capsName + ".java"), null);
155 printHeader(writer);
156 writer.println("import java.util.*;");
157 writer.println();
158
159 CLPDCapabilitiesGenerator.generateClassPrologue(writer, capsName);
160
161 final Collection<TypeDeclaration> templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations());
162
163 for ( final TypeDeclaration t : templates ) {
164 if ( t.getAnnotation(capsType) != null )
165 CLPDCapabilitiesGenerator.generateExtensions(writer, (InterfaceDeclaration)t);
166 }
167 writer.println();
168
169 CLPDCapabilitiesGenerator.generateConstructor(writer, templates, capsType, capsName, objectType, objectName);
170
171 CLPDCapabilitiesGenerator.generateGetters(writer);
172
173 CLPDCapabilitiesGenerator.generateToString(writer, templates, capsType);
174
175 writer.println("}");
176 writer.close();
177 }
178
179 }
180 }
3232 package org.lwjgl.util.generator.opencl;
3333
3434 import org.lwjgl.PointerWrapper;
35 import org.lwjgl.util.generator.Extension;
3536 import org.lwjgl.util.generator.Private;
37 import org.lwjgl.util.generator.Utils;
3638
3739 import java.io.PrintWriter;
3840 import java.lang.annotation.Annotation;
39 import java.util.Collection;
40
41 import com.sun.mirror.declaration.InterfaceDeclaration;
42 import com.sun.mirror.declaration.TypeDeclaration;
41 import java.util.Set;
42 import javax.annotation.processing.ProcessingEnvironment;
43 import javax.lang.model.element.TypeElement;
4344
4445 /**
4546 * CL platform/device capabilities generator.
5051
5152 // TODO: Add future versions here
5253 private static final int[][] CL_VERSIONS = {
53 { 1 }, // OpenCL 1
54 { 1, 2 }, // OpenCL 1
5455 };
5556
5657 static void generateClassPrologue(final PrintWriter writer, final String name) {
6667 writer.println();
6768 }
6869
69 static void generateExtensions(final PrintWriter writer, final InterfaceDeclaration d) {
70 static void generateExtensions(final PrintWriter writer, final TypeElement d) {
7071 writer.print("\t");
7172
7273 if ( d.getAnnotation(Private.class) == null )
7374 writer.print("public ");
7475
75 writer.println("final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
76 writer.println("final boolean " + CLGeneratorProcessor.getExtensionName(d.getSimpleName().toString()) + ";");
7677 }
7778
78 static void generateConstructor(final PrintWriter writer, final Collection<TypeDeclaration> templates,
79 final Class<? extends Annotation> capsType, final String capsName,
80 final Class<? extends PointerWrapper> objectType, final String objectName) {
79 static void generateConstructor(ProcessingEnvironment env, final PrintWriter writer, final Set<? extends TypeElement> templates,
80 final Class<? extends Annotation> capsType, final String capsName,
81 final Class<? extends PointerWrapper> objectType, final String objectName) {
8182 writer.println("\tpublic " + capsName + "(final " + objectType.getSimpleName() + ' ' + objectName + ") {");
8283
8384 writer.println("\t\tfinal String extensionList = " + objectName + ".getInfoString(CL10.CL_" + objectName.toUpperCase() + "_EXTENSIONS);\n" +
101102
102103 writer.println("\t\tfinal Set<String> extensions = APIUtil.getExtensions(extensionList);");
103104
104 for ( final TypeDeclaration t : templates ) {
105 for ( final TypeElement t : templates ) {
105106 if ( t.getAnnotation(capsType) == null )
106107 continue;
107108
108 final String extName = CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName());
109 final String extName = CLGeneratorProcessor.getExtensionName(t.getSimpleName().toString());
109110
110 writer.print("\t\t" + extName + " = extensions.contains(\"" + extName.toLowerCase() + "\")");
111 if ( !t.getMethods().isEmpty() )
111 String nativeName = extName.toLowerCase();
112 Extension ext = t.getAnnotation(Extension.class);
113 if ( ext != null && !ext.nativeName().isEmpty() )
114 nativeName = ext.nativeName();
115
116 writer.print("\t\t" + extName + " = extensions.contains(\"" + nativeName + "\")");
117 if ( !Utils.getMethods(t).isEmpty() )
112118 writer.print(" && CLCapabilities." + extName);
113119 writer.println(";");
114120 }
126132 writer.println("\t}\n");
127133 }
128134
129 public static void generateToString(final PrintWriter writer, final Collection<TypeDeclaration> templates, final Class<? extends Annotation> capsType) {
135 public static void generateToString(final PrintWriter writer, final Set<? extends TypeElement> templates, final Class<? extends Annotation> capsType) {
130136 writer.println("\tpublic String toString() {");
131137 writer.println("\t\tfinal StringBuilder buf = new StringBuilder();\n");
132138
133139 writer.println("\t\tbuf.append(\"OpenCL \").append(majorVersion).append('.').append(minorVersion);");
134140 writer.println();
135141 writer.println("\t\tbuf.append(\" - Extensions: \");");
136 for ( final TypeDeclaration t : templates ) {
142 for ( final TypeElement t : templates ) {
137143 if ( t.getAnnotation(capsType) == null )
138144 continue;
139145
140 writer.println("\t\tif ( " + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()) + " ) buf.append(\"" + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()).toLowerCase() + " \");");
146 writer.println("\t\tif ( " + CLGeneratorProcessor.getExtensionName(t.getSimpleName().toString()) + " ) buf.append(\"" + CLGeneratorProcessor.getExtensionName(t.getSimpleName().toString()).toLowerCase() + " \");");
141147 }
142148
143149 writer.println("\n\t\treturn buf.toString();");
4747 import java.nio.*;
4848 import java.util.HashMap;
4949 import java.util.Map;
50
51 import com.sun.mirror.declaration.AnnotationMirror;
52 import com.sun.mirror.declaration.MethodDeclaration;
53 import com.sun.mirror.declaration.ParameterDeclaration;
54 import com.sun.mirror.type.PrimitiveType;
50 import javax.lang.model.element.AnnotationMirror;
51 import javax.lang.model.element.ExecutableElement;
52 import javax.lang.model.element.VariableElement;
53 import javax.lang.model.type.TypeKind;
5554
5655 public class CLTypeMap implements TypeMap {
5756
58 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
57 private static final Map<Class, TypeKind> native_types_to_primitive;
5958
6059 static {
61 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
62 native_types_to_primitive.put(cl_void.class, PrimitiveType.Kind.BYTE);
63 native_types_to_primitive.put(cl_byte.class, PrimitiveType.Kind.BYTE);
64 native_types_to_primitive.put(cl_char.class, PrimitiveType.Kind.BYTE);
65 native_types_to_primitive.put(cl_uchar.class, PrimitiveType.Kind.BYTE);
66 native_types_to_primitive.put(cl_short.class, PrimitiveType.Kind.SHORT);
67 native_types_to_primitive.put(cl_bool.class, PrimitiveType.Kind.INT);
68 native_types_to_primitive.put(cl_int.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(cl_uint.class, PrimitiveType.Kind.INT);
70 native_types_to_primitive.put(cl_long.class, PrimitiveType.Kind.LONG);
71 native_types_to_primitive.put(size_t.class, PrimitiveType.Kind.LONG);
72 native_types_to_primitive.put(cl_bitfield.class, PrimitiveType.Kind.LONG);
73 native_types_to_primitive.put(cl_float.class, PrimitiveType.Kind.FLOAT);
74 native_types_to_primitive.put(cl_double.class, PrimitiveType.Kind.DOUBLE);
75 }
76
77 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
78 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
60 native_types_to_primitive = new HashMap<Class, TypeKind>();
61 native_types_to_primitive.put(cl_void.class, TypeKind.BYTE);
62 native_types_to_primitive.put(cl_byte.class, TypeKind.BYTE);
63 native_types_to_primitive.put(cl_char.class, TypeKind.BYTE);
64 native_types_to_primitive.put(cl_uchar.class, TypeKind.BYTE);
65 native_types_to_primitive.put(cl_short.class, TypeKind.SHORT);
66 native_types_to_primitive.put(cl_bool.class, TypeKind.INT);
67 native_types_to_primitive.put(cl_int.class, TypeKind.INT);
68 native_types_to_primitive.put(cl_uint.class, TypeKind.INT);
69 native_types_to_primitive.put(cl_long.class, TypeKind.LONG);
70 native_types_to_primitive.put(size_t.class, TypeKind.LONG);
71 native_types_to_primitive.put(cl_bitfield.class, TypeKind.LONG);
72 native_types_to_primitive.put(cl_float.class, TypeKind.FLOAT);
73 native_types_to_primitive.put(cl_double.class, TypeKind.DOUBLE);
74 }
75
76 @Override
77 public TypeKind getPrimitiveTypeFromNativeType(Class native_type) {
78 TypeKind kind = native_types_to_primitive.get(native_type);
7979 if ( kind == null )
8080 throw new RuntimeException("Unsupported type " + native_type);
8181 return kind;
8282 }
8383
84 @Override
8485 public void printCapabilitiesInit(final PrintWriter writer) {
8586 }
8687
88 @Override
8789 public String getCapabilities() {
8890 return "CLCapabilities";
8991 }
9092
91 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
93 @Override
94 public String getAPIUtilParam(boolean comma) {
95 return "";
96 }
97
98 @Override
99 public void printErrorCheckMethod(final PrintWriter writer, final ExecutableElement method, final String tabs) {
92100 final Check check = method.getAnnotation(Check.class);
93101 if ( check != null ) // Get the error code from an IntBuffer output parameter
94102 writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
98106 writer.println(tabs + "Util.checkCLError(__result);");
99107 else {
100108 boolean hasErrCodeParam = false;
101 for ( final ParameterDeclaration param : method.getParameters() ) {
102 if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) {
109 for ( final VariableElement param : method.getParameters() ) {
110 if ( "errcode_ret".equals(param.getSimpleName().toString()) && Utils.getJavaType(param.asType()) == IntBuffer.class ) {
103111 hasErrCodeParam = true;
104112 break;
105113 }
110118 }
111119 }
112120
121 @Override
113122 public String getRegisterNativesFunctionName() {
114123 return "extcl_InitializeClass";
115124 }
116125
126 @Override
117127 public Signedness getSignednessFromType(Class type) {
118128 if ( cl_uint.class.equals(type) )
119129 return Signedness.UNSIGNED;
123133 return Signedness.NONE;
124134 }
125135
136 @Override
126137 public String translateAnnotation(Class annotation_type) {
127138 if ( annotation_type.equals(cl_uint.class) || annotation_type.equals(cl_int.class) )
128139 return "i";
138149 throw new RuntimeException(annotation_type + " is not allowed");
139150 }
140151
141 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
152 @Override
153 public Class getNativeTypeFromPrimitiveType(TypeKind kind) {
142154 Class type;
143155 switch ( kind ) {
144156 case INT:
168180 return type;
169181 }
170182
183 @Override
171184 public Class<? extends Annotation> getVoidType() {
172185 return cl_void.class;
173186 }
174187
188 @Override
175189 public Class<? extends Annotation> getStringElementType() {
176190 return cl_char.class;
177191 }
178192
193 @Override
179194 public Class<? extends Annotation> getStringArrayType() {
180195 return cl_char.class;
181196 }
182197
198 @Override
183199 public Class<? extends Annotation> getByteBufferArrayType() {
184200 return cl_uchar.class;
185201 }
224240 return new Class[] { };
225241 }
226242
243 @Override
227244 public String getTypedefPostfix() {
228245 return "CL_API_ENTRY ";
229246 }
230247
248 @Override
231249 public String getFunctionPrefix() {
232250 return "CL_API_CALL";
233251 }
234252
253 @Override
235254 public void printNativeIncludes(PrintWriter writer) {
236255 writer.println("#include \"extcl.h\"");
237256 }
238257
258 @Override
239259 public Class[] getValidAnnotationTypes(Class type) {
240260 Class[] valid_types;
241261 if ( Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) )
255275 return valid_types;
256276 }
257277
278 @Override
258279 public Class<? extends Annotation> getInverseType(Class type) {
259280 return null;
260281 }
261282
283 @Override
262284 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
263285 return null;
264286 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_ulong {
41
42 }
3434
3535 import java.lang.annotation.ElementType;
3636 import java.lang.annotation.Target;
37
38 import com.sun.mirror.type.PrimitiveType;
37 import javax.lang.model.type.TypeKind;
3938
4039 @NativeType
4140 @Target({ ElementType.PARAMETER, ElementType.METHOD })
4241 public @interface cl_void {
43 PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
42 TypeKind value() default TypeKind.BYTE;
4443 }
0 package org.lwjgl.util.generator.opengl;
1
2 import org.lwjgl.util.generator.NativeType;
3
4 import java.lang.annotation.ElementType;
5 import java.lang.annotation.Target;
6
7 @NativeType
8 @Target({ ElementType.PARAMETER, ElementType.METHOD })
9 public @interface EGLint64NV {
10
11 }
0 package org.lwjgl.util.generator.opengl;
1
2 import org.lwjgl.util.generator.NativeType;
3
4 import java.lang.annotation.ElementType;
5 import java.lang.annotation.Target;
6
7 @NativeType
8 @Target({ ElementType.PARAMETER, ElementType.METHOD })
9 public @interface EGLuint64NV {
10
11 }
3535
3636 import java.io.PrintWriter;
3737 import java.util.Arrays;
38 import java.util.Collection;
3938 import java.util.EnumSet;
4039 import java.util.Iterator;
41
42 import com.sun.mirror.declaration.InterfaceDeclaration;
43 import com.sun.mirror.declaration.MethodDeclaration;
44 import com.sun.mirror.type.InterfaceType;
40 import java.util.List;
41 import javax.annotation.processing.ProcessingEnvironment;
42 import javax.lang.model.element.ExecutableElement;
43 import javax.lang.model.element.TypeElement;
44 import javax.lang.model.type.TypeMirror;
4545
4646 /**
4747 * Generator visitor for the context capabilities generator tool
5252 */
5353 public class GLCapabilitiesGenerator {
5454
55 private static final String STUBS_LOADED_NAME = "loaded_stubs";
56 private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
55 private static final String STUBS_LOADED_NAME = "loaded_stubs";
56 private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
5757 private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses";
58 private static final String CACHED_EXTS_VAR_NAME = "supported_extensions";
59 private static final String PROFILE_MASK_VAR_NAME = "profileMask";
60 private static final String EXTENSION_PREFIX = "GL_";
61 private static final String CORE_PREFIX = "Open";
58 private static final String CACHED_EXTS_VAR_NAME = "supported_extensions";
59 private static final String PROFILE_MASK_VAR_NAME = "profileMask";
60 private static final String EXTENSION_PREFIX = "GL_";
61 private static final String CORE_PREFIX = "Open";
6262
6363 public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
6464 writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
6565 writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
66 writer.println("\tfinal APIUtil util = new APIUtil();");
6667 writer.println("\tfinal StateTracker tracker = new StateTracker();");
6768 writer.println();
6869 if ( !context_specific ) {
8283 return EXTENSION_PREFIX + interface_name;
8384 }
8485
85 public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) {
86 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
86 public static void generateSuperClassAdds(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
87 List<? extends TypeMirror> super_interfaces = d.getInterfaces();
8788 if ( super_interfaces.size() > 1 )
8889 throw new RuntimeException(d + " extends more than one other interface");
8990 if ( super_interfaces.size() == 1 ) {
90 InterfaceType super_interface = super_interfaces.iterator().next();
91 TypeMirror super_interface = super_interfaces.iterator().next();
9192 writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
92 writer.println(translateFieldName(d.getSimpleName()) + "\"))");
93 writer.println(translateFieldName(d.getSimpleName().toString()) + "\"))");
9394 writer.print("\t\t\t");
94 generateAddExtension(writer, super_interface.getDeclaration());
95 }
96 }
97
98 public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) {
99 String translated_field_name = translateFieldName(d.getSimpleName());
95 generateAddExtension(writer, env.getElementUtils().getTypeElement(super_interface.toString()));
96 }
97 }
98
99 public static void generateInitializer(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
100 String translated_field_name = translateFieldName(d.getSimpleName().toString());
100101 writer.print("\t\tthis." + translated_field_name + " = ");
101102 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
102103 writer.print(translated_field_name + "\")");
103 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
104 List<? extends TypeMirror> super_interfaces = d.getInterfaces();
104105 if ( super_interfaces.size() > 1 )
105106 throw new RuntimeException(d + " extends more than one other interface");
106107 if ( super_interfaces.size() == 1 ) {
107 InterfaceType super_interface = super_interfaces.iterator().next();
108 TypeMirror super_interface = super_interfaces.iterator().next();
108109 writer.println();
109110 writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
110 writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")");
111 writer.print(translateFieldName(env.getElementUtils().getTypeElement(super_interface.toString()).getSimpleName().toString()) + "\")");
111112 }
112113 Alias alias_annotation = d.getAnnotation(Alias.class);
113114 if ( alias_annotation != null ) {
161162 writer.println("\t}");
162163 }
163164
164 public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) {
165 if ( d.getMethods().size() > 0 ) {
165 public static void generateUnloadStubs(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
166 if ( Utils.getMethods(d).size() > 0 ) {
166167 writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d));
167168 writer.println(".class);");
168169 }
169170 }
170171
171 public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) {
172 if ( d.getMethods().size() > 0 ) {
172 public static void generateInitStubs(ProcessingEnvironment env, PrintWriter writer, TypeElement d, boolean context_specific) {
173 if ( Utils.getMethods(d).size() > 0 ) {
173174 if ( context_specific ) {
174175 final Alias alias_annotation = d.getAnnotation(Alias.class);
175176
176177 if ( d.getAnnotation(ForceInit.class) != null )
177 writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");");
178 writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName().toString()) + "\");");
178179 writer.print("\t\tif (");
179180 if ( alias_annotation != null )
180181 writer.print("(");
181182 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
182 writer.print(translateFieldName(d.getSimpleName()) + "\")");
183 writer.print(translateFieldName(d.getSimpleName().toString()) + "\")");
183184 if ( alias_annotation != null ) {
184185 writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\"");
185186 writer.print(translateFieldName(alias_annotation.value()) + "\"))");
186187 }
187 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "(");
188 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName().toString()) + "(");
188189 if ( d.getAnnotation(DeprecatedGL.class) != null )
189190 writer.print("forwardCompatible");
190191 if ( d.getAnnotation(Dependent.class) != null ) {
199200 } else
200201 writer.println("))");
201202 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
202 writer.println(translateFieldName(d.getSimpleName()) + "\");");
203 writer.println(translateFieldName(d.getSimpleName().toString()) + "\");");
203204 if ( alias_annotation != null )
204205 writer.println("\t\t}");
205206 } else {
206207 writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
207 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");");
208 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName().toString()) + "\");");
208209 }
209210 }
210211 }
211212
212 private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) {
213 private static void generateAddExtension(PrintWriter writer, TypeElement d) {
213214 writer.print(CACHED_EXTS_VAR_NAME + ".add(\"");
214 writer.println(translateFieldName(d.getSimpleName()) + "\");");
215 }
216
217 public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) {
218 Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
215 writer.println(translateFieldName(d.getSimpleName().toString()) + "\");");
216 }
217
218 public static void generateAddressesInitializers(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
219 Iterator<? extends ExecutableElement> methods = Utils.getMethods(d).iterator();
219220 if ( !methods.hasNext() )
220221 return;
221222
222 writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "(");
223 writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName().toString()) + "(");
223224
224225 boolean optional;
225226 boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null;
240241
241242 boolean first = true;
242243 while ( methods.hasNext() ) {
243 MethodDeclaration method = methods.next();
244 ExecutableElement method = methods.next();
244245 if ( method.getAnnotation(Alternate.class) != null )
245246 continue;
246247
307308 writer.println();
308309 }
309310
310 public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
311 public static void generateSymbolAddresses(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
311312 boolean first = true;
312 for ( final MethodDeclaration method : d.getMethods() ) {
313 for ( final ExecutableElement method : Utils.getMethods(d) ) {
313314 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
314315 continue;
315316
321322 }
322323 }
323324
324 public static void generateField(PrintWriter writer, InterfaceDeclaration d) {
325 writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";");
325 public static void generateField(PrintWriter writer, TypeElement d) {
326 writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName().toString()) + ";");
326327 }
327328 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.*;
35
36 import java.io.PrintWriter;
37 import java.util.Arrays;
38 import java.util.EnumSet;
39 import java.util.Iterator;
40 import java.util.List;
41 import javax.annotation.processing.ProcessingEnvironment;
42 import javax.lang.model.element.ExecutableElement;
43 import javax.lang.model.element.TypeElement;
44 import javax.lang.model.type.TypeMirror;
45
46 /**
47 * Generator visitor for the context capabilities generator tool
48 *
49 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision: 3334 $
51 * $Id: ContextCapabilitiesGenerator.java 3334 2010-04-22 23:21:48Z spasi $
52 */
53 public class GLESCapabilitiesGenerator {
54
55 private static final String STUBS_LOADED_NAME = "loaded_stubs";
56 private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
57 private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses";
58 private static final String CACHED_EXTS_VAR_NAME = "supported_extensions";
59 private static final String EXTENSION_PREFIX = "GL_";
60 private static final String CORE_PREFIX = "Open";
61
62 public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
63 writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
64 writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
65 writer.println();
66 if ( !context_specific ) {
67 writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + ";");
68 }
69 }
70
71 public static void generateInitializerPrologue(PrintWriter writer) {
72 writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "() throws LWJGLException {");
73 writer.println("\t\tSet<String> " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "();");
74 }
75
76 private static String translateFieldName(String interface_name) {
77 if ( interface_name.startsWith("GL") )
78 return CORE_PREFIX + interface_name;
79 else
80 return EXTENSION_PREFIX + interface_name;
81 }
82
83 public static void generateSuperClassAdds(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
84 List<? extends TypeMirror> super_interfaces = d.getInterfaces();
85 if ( super_interfaces.size() > 1 )
86 throw new RuntimeException(d + " extends more than one other interface");
87 if ( super_interfaces.size() == 1 ) {
88 TypeMirror super_interface = super_interfaces.iterator().next();
89 writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
90 writer.println(translateFieldName(d.getSimpleName().toString() + "\"))"));
91 writer.print("\t\t\t");
92 generateAddExtension(writer, env.getElementUtils().getTypeElement(super_interface.toString()));
93 }
94 }
95
96 public static void generateInitializer(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
97 String translated_field_name = translateFieldName(d.getSimpleName().toString());
98 writer.print("\t\tthis." + translated_field_name + " = ");
99 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
100 writer.print(translated_field_name + "\")");
101 List<? extends TypeMirror> super_interfaces = d.getInterfaces();
102 if ( super_interfaces.size() > 1 )
103 throw new RuntimeException(d + " extends more than one other interface");
104 if ( super_interfaces.size() == 1 ) {
105 TypeMirror super_interface = super_interfaces.iterator().next();
106 writer.println();
107 writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
108 writer.print(translateFieldName(env.getElementUtils().getTypeElement(super_interface.toString()).getSimpleName() + "\")"));
109 }
110 Alias alias_annotation = d.getAnnotation(Alias.class);
111 if ( alias_annotation != null ) {
112 writer.println();
113 writer.print("\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\"");
114 writer.print(translateFieldName(alias_annotation.value()) + "\")");
115 }
116 writer.println(";");
117 }
118
119 private static String getAddressesInitializerName(String class_name) {
120 return class_name + POINTER_INITIALIZER_POSTFIX;
121 }
122
123 public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) {
124 writer.println("\tprivate Set<String> " + ALL_INIT_METHOD_NAME + "() throws LWJGLException {");
125
126 if ( context_specific ) {
127 // Load the basic pointers we need to detect OpenGL version and supported extensions.
128 writer.println("\t\tglGetError = GLContext.getFunctionAddress(\"glGetError\");");
129 writer.println("\t\tglGetString = GLContext.getFunctionAddress(\"glGetString\");");
130 }
131
132 // Get the supported extensions set.
133 writer.println("\t\tGLContext.setCapabilities(this);");
134 writer.println("\t\tSet<String> " + CACHED_EXTS_VAR_NAME + " = new HashSet<String>(256);");
135 if ( !context_specific )
136 writer.println("\t\tGLContext.doInitNativeStubs(GLES20.class);");
137 writer.println("\t\tGLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");");
138
139 if ( !context_specific ) {
140 writer.println("\t\tif (" + STUBS_LOADED_NAME + ")");
141 writer.println("\t\t\treturn " + CACHED_EXTS_VAR_NAME + ";");
142 } else {
143 writer.println("\t\tif (!" + getAddressesInitializerName("GLES20") + "())");
144 writer.println("\t\t\tthrow new LWJGLException(\"GL ES 2.0 not supported\");");
145 }
146 }
147
148 public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) {
149 if ( !context_specific )
150 writer.println("\t\t" + STUBS_LOADED_NAME + " = true;");
151 writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";");
152 writer.println("\t}");
153 }
154
155 public static void generateUnloadStubs(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
156 // TODO: Remove GLES
157 if ( Utils.getMethods(d).size() > 0 && !d.getSimpleName().toString().startsWith("GLES") ) {
158 writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d));
159 writer.println(".class);");
160 }
161 }
162
163 public static void generateInitStubs(ProcessingEnvironment env, PrintWriter writer, TypeElement d, boolean context_specific) {
164 if ( Utils.getMethods(d).size() > 0 ) {
165 if ( context_specific ) {
166 final Alias alias_annotation = d.getAnnotation(Alias.class);
167
168 if ( d.getAnnotation(ForceInit.class) != null )
169 writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName().toString()) + "\");");
170 writer.print("\t\tif (");
171 if ( alias_annotation != null )
172 writer.print("(");
173 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
174 writer.print(translateFieldName(d.getSimpleName().toString()) + "\")");
175 if ( alias_annotation != null ) {
176 writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\"");
177 writer.print(translateFieldName(alias_annotation.value()) + "\"))");
178 }
179 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName().toString()) + "(");
180 if ( d.getAnnotation(Dependent.class) != null )
181 writer.print("supported_extensions");
182 if ( alias_annotation != null ) {
183 writer.println(")) {");
184 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
185 writer.println(translateFieldName(alias_annotation.value()) + "\");");
186 } else
187 writer.println("))");
188 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
189 writer.println(translateFieldName(d.getSimpleName().toString()) + "\");");
190 if ( alias_annotation != null )
191 writer.println("\t\t}");
192 } else {
193 writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
194 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName().toString()) + "\");");
195 }
196 }
197 }
198
199 private static void generateAddExtension(PrintWriter writer, TypeElement d) {
200 writer.print(CACHED_EXTS_VAR_NAME + ".add(\"");
201 writer.println(translateFieldName(d.getSimpleName().toString()) + "\");");
202 }
203
204 public static void generateAddressesInitializers(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
205 Iterator<? extends ExecutableElement> methods = Utils.getMethods(d).iterator();
206 if ( !methods.hasNext() )
207 return;
208
209 writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName().toString()) + "(");
210
211 boolean optional;
212 Dependent dependent = d.getAnnotation(Dependent.class);
213 if ( dependent != null ) {
214 writer.print("Set<String> supported_extensions");
215 }
216
217 Alias alias_annotation = d.getAnnotation(Alias.class);
218 boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
219
220 writer.println(") {");
221 writer.println("\t\treturn ");
222
223 boolean first = true;
224 while ( methods.hasNext() ) {
225 ExecutableElement method = methods.next();
226 if ( method.getAnnotation(Alternate.class) != null )
227 continue;
228
229 if ( !first )
230 writer.println(" &");
231 else
232 first = false;
233
234 optional = method.getAnnotation(Optional.class) != null;
235 dependent = method.getAnnotation(Dependent.class);
236
237 writer.print("\t\t\t(");
238 if ( optional )
239 writer.print('(');
240 if ( dependent != null ) {
241 if ( dependent.value().indexOf(',') == -1 )
242 writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || ");
243 else {
244 writer.print("!(false");
245 for ( String extension : dependent.value().split(",") )
246 writer.print(" || supported_extensions.contains(\"" + extension + "\")");
247 writer.print(") || ");
248 }
249 }
250 if ( dependent != null )
251 writer.print('(');
252 writer.print(Utils.getFunctionAddressName(d, method) + " = ");
253 PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class);
254 if ( platform_dependent != null ) {
255 EnumSet<Platform> platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value()));
256 writer.print("GLContext.getPlatformSpecificFunctionAddress(\"");
257 writer.print(Platform.ALL.getPrefix() + "\", ");
258 writer.print("new String[]{");
259 Iterator<Platform> platforms = platform_set.iterator();
260 while ( platforms.hasNext() ) {
261 writer.print("\"" + platforms.next().getOSPrefix() + "\"");
262 if ( platforms.hasNext() )
263 writer.print(", ");
264 }
265 writer.print("}, new String[]{");
266 platforms = platform_set.iterator();
267 while ( platforms.hasNext() ) {
268 writer.print("\"" + platforms.next().getPrefix() + "\"");
269 if ( platforms.hasNext() )
270 writer.print(", ");
271 }
272 writer.print("}, ");
273 } else if ( aliased ) {
274 writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0");
275 } else
276 writer.print("GLContext.getFunctionAddress(");
277 if ( !aliased )
278 writer.print("\"" + method.getSimpleName() + "\")) != 0");
279 if ( dependent != null )
280 writer.print(')');
281 if ( optional )
282 writer.print(" || true)");
283 }
284 writer.println(";");
285 writer.println("\t}");
286 writer.println();
287 }
288
289 public static void generateSymbolAddresses(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
290 boolean first = true;
291 for ( final ExecutableElement method : Utils.getMethods(d) ) {
292 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
293 continue;
294
295 if ( first ) {
296 writer.println("\t// " + d.getSimpleName());
297 first = false;
298 }
299 writer.println("\tint " + Utils.getFunctionAddressName(d, method) + ";");
300 }
301 }
302
303 public static void generateField(PrintWriter writer, TypeElement d) {
304 writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName().toString()) + ";");
305 }
306
307 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator.opengl;
32
33 import org.lwjgl.util.generator.Utils;
34
35 import java.io.IOException;
36 import java.io.PrintWriter;
37 import java.util.Map;
38 import java.util.Set;
39 import javax.annotation.processing.*;
40 import javax.lang.model.SourceVersion;
41 import javax.lang.model.element.TypeElement;
42 import javax.lang.model.util.ElementFilter;
43
44 /**
45 * Generator tool for creating the ContexCapabilities class
46 *
47 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3316 $ $Id: ContextGeneratorProcessorFactory.java 3316
49 * 2010-04-09 23:57:40Z spasi $
50 */
51 @SupportedAnnotationTypes({ "*" })
52 @SupportedSourceVersion(SourceVersion.RELEASE_6)
53 @SupportedOptions({ "contextspecific", "generatechecks" })
54 public class GLESGeneratorProcessor extends AbstractProcessor {
55
56 private static boolean first_round = true;
57
58 @Override
59 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
60 if ( roundEnv.processingOver() || !first_round ) {
61 System.exit(0);
62 return true;
63 }
64 Map<String, String> options = processingEnv.getOptions();
65 boolean generate_error_checks = options.containsKey("generatechecks");
66 boolean context_specific = options.containsKey("contextspecific");
67 try {
68 generateContextCapabilitiesSource(ElementFilter.typesIn(roundEnv.getRootElements()), context_specific, generate_error_checks);
69 first_round = false;
70 return true;
71 } catch (IOException e) {
72 throw new RuntimeException(e);
73 }
74 }
75
76 private void generateContextCapabilitiesSource(Set<TypeElement> templates, boolean context_specific, boolean generate_error_checks) throws IOException {
77 PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opengles." + Utils.CONTEXT_CAPS_CLASS_NAME, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opengles")).openWriter());
78 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
79 writer.println();
80 writer.println("package org.lwjgl.opengles;");
81 writer.println();
82 writer.println("import org.lwjgl.LWJGLException;");
83 writer.println("import org.lwjgl.LWJGLUtil;");
84 writer.println("import java.util.Set;");
85 writer.println("import java.util.HashSet;");
86 writer.println();
87 GLESCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
88 for ( TypeElement interface_decl : templates ) {
89 if ( interface_decl.getKind().isInterface() ) {
90 if ( Utils.isFinal(interface_decl) ) {
91 GLESCapabilitiesGenerator.generateField(writer, interface_decl);
92 }
93 }
94 }
95 writer.println();
96 if ( context_specific ) {
97 for ( TypeElement interface_decl : templates ) {
98 if ( interface_decl.getKind().isInterface() ) {
99 GLESCapabilitiesGenerator.generateSymbolAddresses(processingEnv, writer, interface_decl);
100 }
101 }
102 writer.println();
103 for ( TypeElement interface_decl : templates ) {
104 if ( interface_decl.getKind().isInterface() ) {
105 GLESCapabilitiesGenerator.generateAddressesInitializers(processingEnv, writer, interface_decl);
106 }
107 }
108 writer.println();
109 }
110
111 if ( context_specific ) {
112 writer.println("\tprivate static void remove(Set supported_extensions, String extension) {");
113 writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");");
114 writer.println("\t\tsupported_extensions.remove(extension);");
115 writer.println("\t}\n");
116 }
117
118 GLESCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
119 for ( TypeElement interface_decl : templates ) {
120 if ( interface_decl.getKind().isInterface() ) {
121 GLESCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl, processingEnv);
122 }
123 }
124 for ( TypeElement interface_decl : templates ) {
125 if ( interface_decl.getKind().isInterface() ) {
126 if ( "GLES20".equals(interface_decl.getSimpleName().toString()) ) {
127 continue;
128 }
129 GLESCapabilitiesGenerator.generateInitStubs(processingEnv, writer, interface_decl, context_specific);
130 }
131 }
132 GLESCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
133 writer.println();
134 writer.println("\tstatic void unloadAllStubs() {");
135 if ( !context_specific ) {
136 writer.println("\t\tif (!loaded_stubs)");
137 writer.println("\t\t\treturn;");
138 for ( TypeElement interface_decl : templates ) {
139 if ( interface_decl.getKind().isInterface() ) {
140 GLESCapabilitiesGenerator.generateUnloadStubs(processingEnv, writer, interface_decl);
141 }
142 }
143 writer.println("\t\tloaded_stubs = false;");
144 }
145 writer.println("\t}");
146 writer.println();
147 GLESCapabilitiesGenerator.generateInitializerPrologue(writer);
148 for ( TypeElement interface_decl : templates ) {
149 if ( interface_decl.getKind().isInterface() ) {
150 if ( Utils.isFinal(interface_decl) ) {
151 GLESCapabilitiesGenerator.generateInitializer(writer, interface_decl, processingEnv);
152 }
153 }
154 }
155 writer.println("\t}");
156 writer.println("}");
157 writer.close();
158 }
159
160 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.util.generator.opengl;
33
34 /**
35 *
36 * OpenGL sepcific generator behaviour
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3287 $
40 * $Id: GLTypeMap.java 3287 2010-03-14 23:24:40Z spasi $
41 */
42
43 import org.lwjgl.util.generator.NativeTypeTranslator;
44 import org.lwjgl.util.generator.PointerWrapper;
45 import org.lwjgl.util.generator.Signedness;
46 import org.lwjgl.util.generator.TypeMap;
47
48 import java.io.PrintWriter;
49 import java.lang.annotation.Annotation;
50 import java.nio.*;
51 import java.util.HashMap;
52 import java.util.Map;
53 import javax.lang.model.element.AnnotationMirror;
54 import javax.lang.model.element.ExecutableElement;
55 import javax.lang.model.type.TypeKind;
56
57 public class GLESTypeMap implements TypeMap {
58
59 private static final Map<Class<? extends Annotation>, TypeKind> native_types_to_primitive;
60
61 static {
62 native_types_to_primitive = new HashMap<Class<? extends Annotation>, TypeKind>();
63 native_types_to_primitive.put(GLbitfield.class, TypeKind.INT);
64 native_types_to_primitive.put(GLclampf.class, TypeKind.FLOAT);
65 native_types_to_primitive.put(GLfloat.class, TypeKind.FLOAT);
66 native_types_to_primitive.put(GLint.class, TypeKind.INT);
67 native_types_to_primitive.put(GLshort.class, TypeKind.SHORT);
68 native_types_to_primitive.put(GLsizeiptr.class, TypeKind.LONG);
69 native_types_to_primitive.put(GLuint.class, TypeKind.INT);
70 native_types_to_primitive.put(GLboolean.class, TypeKind.BOOLEAN);
71 native_types_to_primitive.put(GLchar.class, TypeKind.BYTE);
72 native_types_to_primitive.put(GLhalf.class, TypeKind.SHORT);
73 native_types_to_primitive.put(GLsizei.class, TypeKind.INT);
74 native_types_to_primitive.put(GLushort.class, TypeKind.SHORT);
75 native_types_to_primitive.put(GLbyte.class, TypeKind.BYTE);
76 native_types_to_primitive.put(GLenum.class, TypeKind.INT);
77 native_types_to_primitive.put(GLintptr.class, TypeKind.LONG);
78 native_types_to_primitive.put(GLubyte.class, TypeKind.BYTE);
79 native_types_to_primitive.put(GLvoid.class, TypeKind.BYTE);
80 native_types_to_primitive.put(EGLint64NV.class, TypeKind.LONG);
81 native_types_to_primitive.put(EGLuint64NV.class, TypeKind.LONG);
82 native_types_to_primitive.put(GLint64.class, TypeKind.LONG);
83 native_types_to_primitive.put(GLuint64.class, TypeKind.LONG);
84 }
85
86 @Override
87 public TypeKind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type) {
88 TypeKind kind = native_types_to_primitive.get(native_type);
89 if ( kind == null )
90 throw new RuntimeException("Unsupported type " + native_type);
91 return kind;
92 }
93
94 @Override
95 public void printCapabilitiesInit(final PrintWriter writer) {
96 writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
97 }
98
99 @Override
100 public String getCapabilities() {
101 return "caps";
102 }
103
104 @Override
105 public String getAPIUtilParam(boolean comma) {
106 return "";
107 }
108
109 @Override
110 public void printErrorCheckMethod(final PrintWriter writer, final ExecutableElement method, final String tabs) {
111 writer.println(tabs + "Util.checkGLError();");
112 }
113
114 @Override
115 public String getRegisterNativesFunctionName() {
116 return "extgl_InitializeClass";
117 }
118
119 @Override
120 public Signedness getSignednessFromType(Class<? extends Annotation> type) {
121 if ( GLuint.class.equals(type) )
122 return Signedness.UNSIGNED;
123 else if ( GLint.class.equals(type) )
124 return Signedness.SIGNED;
125 else if ( GLushort.class.equals(type) )
126 return Signedness.UNSIGNED;
127 else if ( GLshort.class.equals(type) )
128 return Signedness.SIGNED;
129 else if ( GLubyte.class.equals(type) )
130 return Signedness.UNSIGNED;
131 else if ( GLbyte.class.equals(type) )
132 return Signedness.SIGNED;
133 else if ( EGLuint64NV.class.equals(type) )
134 return Signedness.UNSIGNED;
135 else if ( EGLint64NV.class.equals(type) )
136 return Signedness.SIGNED;
137 else
138 return Signedness.NONE;
139 }
140
141 @Override
142 public String translateAnnotation(Class annotation_type) {
143 if ( annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) )
144 return "i64";
145 else if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) )
146 return "i";
147 else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) )
148 return "s";
149 else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) )
150 return "b";
151 else if ( annotation_type.equals(GLfloat.class) )
152 return "f";
153 else if ( annotation_type.equals(GLhalf.class) )
154 return "h";
155 else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) )
156 return "";
157 else if ( annotation_type.equals(EGLuint64NV.class) || annotation_type.equals(EGLint64NV.class) )
158 return "l";
159 else
160 throw new RuntimeException(annotation_type + " is not allowed");
161 }
162
163 @Override
164 public Class<? extends Annotation> getNativeTypeFromPrimitiveType(TypeKind kind) {
165 Class<? extends Annotation> type;
166 switch ( kind ) {
167 case INT:
168 type = GLint.class;
169 break;
170 case FLOAT:
171 type = GLfloat.class;
172 break;
173 case SHORT:
174 type = GLshort.class;
175 break;
176 case BYTE:
177 type = GLbyte.class;
178 break;
179 case BOOLEAN:
180 type = GLboolean.class;
181 break;
182 case LONG:
183 type = GLint64.class;
184 break;
185 default:
186 throw new RuntimeException(kind + " is not allowed");
187 }
188 return type;
189 }
190
191 @Override
192 public Class<? extends Annotation> getVoidType() {
193 return GLvoid.class;
194 }
195
196 @Override
197 public Class<? extends Annotation> getStringElementType() {
198 return GLubyte.class;
199 }
200
201 @Override
202 public Class<? extends Annotation> getStringArrayType() {
203 return GLchar.class;
204 }
205
206 @Override
207 public Class<? extends Annotation> getByteBufferArrayType() {
208 return GLubyte.class;
209 }
210
211 private static Class[] getValidBufferTypes(Class type) {
212 if ( type.equals(IntBuffer.class) )
213 return new Class[] { GLbitfield.class, GLenum.class, GLint.class, GLsizei.class, GLuint.class, GLvoid.class };
214 else if ( type.equals(FloatBuffer.class) )
215 return new Class[] { GLclampf.class, GLfloat.class };
216 else if ( type.equals(ByteBuffer.class) )
217 return new Class[] { GLboolean.class, GLbyte.class, GLchar.class, GLubyte.class, GLvoid.class };
218 else if ( type.equals(ShortBuffer.class) )
219 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
220 else if ( type.equals(LongBuffer.class) )
221 return new Class[] { GLint64.class, GLuint64.class, EGLint64NV.class, EGLuint64NV.class };
222 else
223 return new Class[] { };
224 }
225
226 private static Class[] getValidPrimitiveTypes(Class type) {
227 if ( type.equals(long.class) )
228 return new Class[] { GLintptr.class, GLsizeiptr.class, GLint64.class, GLuint64.class, EGLuint64NV.class, EGLint64NV.class };
229 else if ( type.equals(int.class) )
230 return new Class[] { GLbitfield.class, GLenum.class, GLint.class, GLuint.class, GLsizei.class };
231 else if ( type.equals(float.class) )
232 return new Class[] { GLclampf.class, GLfloat.class };
233 else if ( type.equals(short.class) )
234 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
235 else if ( type.equals(byte.class) )
236 return new Class[] { GLbyte.class, GLchar.class, GLubyte.class };
237 else if ( type.equals(boolean.class) )
238 return new Class[] { GLboolean.class };
239 else if ( type.equals(void.class) )
240 return new Class[] { GLvoid.class, GLreturn.class };
241 else
242 return new Class[] { };
243 }
244
245 @Override
246 public String getTypedefPostfix() {
247 return "GL_APICALL ";
248 }
249
250 @Override
251 public String getFunctionPrefix() {
252 return "GL_APIENTRY";
253 }
254
255 @Override
256 public void printNativeIncludes(PrintWriter writer) {
257 writer.println("#include \"extgl.h\"");
258 }
259
260 @Override
261 public Class[] getValidAnnotationTypes(Class type) {
262 Class[] valid_types;
263 if ( Buffer.class.isAssignableFrom(type) )
264 valid_types = getValidBufferTypes(type);
265 else if ( type.isPrimitive() )
266 valid_types = getValidPrimitiveTypes(type);
267 else if ( String.class.equals(type) )
268 valid_types = new Class[] { GLubyte.class };
269 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
270 valid_types = new Class[] { PointerWrapper.class };
271 else if ( void.class.equals(type) )
272 valid_types = new Class[] { GLreturn.class };
273 else
274 valid_types = new Class[] { };
275 return valid_types;
276 }
277
278 @Override
279 public Class<? extends Annotation> getInverseType(Class<? extends Annotation> type) {
280 if ( GLuint64.class.equals(type) )
281 return GLint64.class;
282 if ( GLuint.class.equals(type) )
283 return GLint.class;
284 else if ( GLint.class.equals(type) )
285 return GLuint.class;
286 else if ( GLushort.class.equals(type) )
287 return GLshort.class;
288 else if ( GLshort.class.equals(type) )
289 return GLushort.class;
290 else if ( GLubyte.class.equals(type) )
291 return GLbyte.class;
292 else if ( GLbyte.class.equals(type) )
293 return GLubyte.class;
294 else
295 return null;
296 }
297
298 @Override
299 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
300 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
301 if ( annotation_class.equals(GLint.class) )
302 return "GLES20.GL_INT";
303 else if ( annotation_class.equals(GLbyte.class) )
304 return "GLES20.GL_BYTE";
305 else if ( annotation_class.equals(GLshort.class) )
306 return "GLES20.GL_SHORT";
307 if ( annotation_class.equals(GLuint.class) )
308 return "GLES20.GL_UNSIGNED_INT";
309 else if ( annotation_class.equals(GLubyte.class) )
310 return "GLES20.GL_UNSIGNED_BYTE";
311 else if ( annotation_class.equals(GLushort.class) )
312 return "GLES20.GL_UNSIGNED_SHORT";
313 else if ( annotation_class.equals(GLfloat.class) )
314 return "GLES20.GL_FLOAT";
315 else
316 return null;
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 package org.lwjgl.util.generator.opengl;
32
33 import org.lwjgl.util.generator.Utils;
34
35 import java.io.IOException;
36 import java.io.PrintWriter;
37 import java.util.Map;
38 import java.util.Set;
39 import javax.annotation.processing.*;
40 import javax.lang.model.SourceVersion;
41 import javax.lang.model.element.TypeElement;
42 import javax.lang.model.util.ElementFilter;
43
44 /**
45 * Generator tool for creating the ContexCapabilities class
46 *
47 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3316 $ $Id: ContextGeneratorProcessorFactory.java 3316
49 * 2010-04-09 23:57:40Z spasi $
50 */
51 @SupportedAnnotationTypes({ "*" })
52 @SupportedSourceVersion(SourceVersion.RELEASE_6)
53 @SupportedOptions({ "generatechecks", "contextspecific" })
54 public class GLGeneratorProcessor extends AbstractProcessor {
55
56 private static boolean first_round = true;
57
58 @Override
59 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
60 if ( roundEnv.processingOver() || !first_round ) {
61 System.exit(0);
62 return true;
63 }
64 Map<String, String> options = processingEnv.getOptions();
65 boolean generate_error_checks = options.containsKey("generatechecks");
66 boolean context_specific = options.containsKey("contextspecific");
67 try {
68 generateContextCapabilitiesSource(ElementFilter.typesIn(roundEnv.getRootElements()), context_specific, generate_error_checks);
69 first_round = false;
70 return true;
71 } catch (IOException e) {
72 throw new RuntimeException(e);
73 }
74 }
75
76 private void generateContextCapabilitiesSource(Set<TypeElement> templates, boolean context_specific, boolean generate_error_checks) throws IOException {
77 PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opengl." + Utils.CONTEXT_CAPS_CLASS_NAME, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opengl")).openWriter());
78 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
79 writer.println();
80 writer.println("package org.lwjgl.opengl;");
81 writer.println();
82 writer.println("import org.lwjgl.LWJGLException;");
83 writer.println("import org.lwjgl.LWJGLUtil;");
84 writer.println("import java.util.Set;");
85 writer.println("import java.util.HashSet;");
86 writer.println();
87 GLCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
88 for ( TypeElement interface_decl : templates ) {
89 if ( interface_decl.getKind().isInterface() ) {
90 if ( Utils.isFinal(interface_decl) ) {
91 GLCapabilitiesGenerator.generateField(writer, interface_decl);
92 }
93 }
94 }
95 writer.println();
96 for ( TypeElement interface_decl : templates ) {
97 if ( interface_decl.getKind().isInterface() ) {
98 GLCapabilitiesGenerator.generateSymbolAddresses(processingEnv, writer, interface_decl);
99 }
100 }
101 writer.println();
102 if ( context_specific ) {
103 for ( TypeElement interface_decl : templates ) {
104 if ( interface_decl.getKind().isInterface() ) {
105 GLCapabilitiesGenerator.generateAddressesInitializers(processingEnv, writer, interface_decl);
106 }
107 }
108 writer.println();
109 }
110
111 writer.println("\tprivate static void remove(Set supported_extensions, String extension) {");
112 writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");");
113 writer.println("\t\tsupported_extensions.remove(extension);");
114 writer.println("\t}\n");
115
116 GLCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
117 for ( TypeElement interface_decl : templates ) {
118 if ( interface_decl.getKind().isInterface() ) {
119 GLCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl, processingEnv);
120 }
121 }
122 for ( TypeElement interface_decl : templates ) {
123 if ( interface_decl.getKind().isInterface() ) {
124 String simple_name = interface_decl.getSimpleName().toString();
125 if ( "GL11".equals(simple_name) ) {
126 continue;
127 }
128 GLCapabilitiesGenerator.generateInitStubs(processingEnv, writer, interface_decl, context_specific);
129 }
130 }
131 GLCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
132 writer.println();
133 writer.println("\tstatic void unloadAllStubs() {");
134 if ( !context_specific ) {
135 writer.println("\t\tif (!loaded_stubs)");
136 writer.println("\t\t\treturn;");
137 for ( TypeElement interface_decl : templates ) {
138 if ( interface_decl.getKind().isInterface() ) {
139 GLCapabilitiesGenerator.generateUnloadStubs(processingEnv, writer, interface_decl);
140 }
141 }
142 writer.println("\t\tloaded_stubs = false;");
143 }
144 writer.println("\t}");
145 writer.println();
146 GLCapabilitiesGenerator.generateInitializerPrologue(writer);
147 for ( TypeElement interface_decl : templates ) {
148 if ( interface_decl.getKind().isInterface() ) {
149 if ( Utils.isFinal(interface_decl) ) {
150 GLCapabilitiesGenerator.generateInitializer(writer, interface_decl, processingEnv);
151 }
152 }
153 }
154 writer.println("\t\ttracker.init();");
155 writer.println("\t}");
156 writer.println("}");
157 writer.close();
158 }
159 }
+0
-189
src/java/org/lwjgl/util/generator/opengl/GLGeneratorProcessorFactory.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.Utils;
35
36 import static java.util.Collections.unmodifiableCollection;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.io.PrintWriter;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.Map;
44 import java.util.Set;
45
46 import com.sun.mirror.apt.AnnotationProcessor;
47 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
48 import com.sun.mirror.apt.AnnotationProcessorFactory;
49 import com.sun.mirror.apt.AnnotationProcessors;
50 import com.sun.mirror.apt.Filer;
51 import com.sun.mirror.apt.RoundCompleteEvent;
52 import com.sun.mirror.apt.RoundCompleteListener;
53 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
54 import com.sun.mirror.declaration.InterfaceDeclaration;
55 import com.sun.mirror.declaration.TypeDeclaration;
56 import com.sun.mirror.util.DeclarationFilter;
57
58 /**
59 *
60 * Generator tool for creating the ContexCapabilities class
61 *
62 * @author elias_naur <elias_naur@users.sourceforge.net>
63 * @version $Revision: 3316 $
64 * $Id: ContextGeneratorProcessorFactory.java 3316 2010-04-09 23:57:40Z spasi $
65 */
66 public class GLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
67 private static boolean first_round = true;
68
69 // Process any set of annotations
70 private static final Collection<String> supportedAnnotations =
71 unmodifiableCollection(Arrays.asList("*"));
72
73 public Collection<String> supportedAnnotationTypes() {
74 return supportedAnnotations;
75 }
76
77 public Collection<String> supportedOptions() {
78 return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks"));
79 }
80
81 public void roundComplete(RoundCompleteEvent event) {
82 first_round = false;
83 }
84
85 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
86 // Only process the initial types, not the generated ones
87 if (first_round) {
88 env.addListener(this);
89 return new GeneratorProcessor(env);
90 } else
91 return AnnotationProcessors.NO_OP;
92 }
93
94 private static class GeneratorProcessor implements AnnotationProcessor {
95 private final AnnotationProcessorEnvironment env;
96
97 GeneratorProcessor(AnnotationProcessorEnvironment env) {
98 this.env = env;
99 }
100
101 public void process() {
102 Map<String, String> options = env.getOptions();
103 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
104 boolean context_specific = options.containsKey("-Acontextspecific");
105 try {
106 generateContextCapabilitiesSource(context_specific, generate_error_checks);
107 } catch (IOException e) {
108 throw new RuntimeException(e);
109 }
110 }
111
112 private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException {
113 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null);
114 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
115 writer.println();
116 writer.println("package org.lwjgl.opengl;");
117 writer.println();
118 writer.println("import org.lwjgl.LWJGLException;");
119 writer.println("import org.lwjgl.LWJGLUtil;");
120 writer.println("import java.util.Set;");
121 writer.println("import java.util.HashSet;");
122 writer.println();
123 GLCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
124 DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
125 Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
126 for (TypeDeclaration typedecl : interface_decls) {
127 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
128 if (Utils.isFinal(interface_decl))
129 GLCapabilitiesGenerator.generateField(writer, interface_decl);
130 }
131 writer.println();
132 for (TypeDeclaration typedecl : interface_decls) {
133 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
134 GLCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl);
135 }
136 writer.println();
137 if (context_specific) {
138 for (TypeDeclaration typedecl : interface_decls) {
139 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
140 GLCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl);
141 }
142 writer.println();
143 }
144
145 writer.println("\tprivate static void remove(Set supported_extensions, String extension) {");
146 writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");");
147 writer.println("\t\tsupported_extensions.remove(extension);");
148 writer.println("\t}\n");
149
150 GLCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
151 for (TypeDeclaration typedecl : interface_decls) {
152 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
153 GLCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl);
154 }
155 for (TypeDeclaration typedecl : interface_decls) {
156 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
157 String simple_name = interface_decl.getSimpleName();
158 if ( "GL11".equals(simple_name) )
159 continue;
160 GLCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific);
161 }
162 GLCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
163 writer.println();
164 writer.println("\tstatic void unloadAllStubs() {");
165 if (!context_specific) {
166 writer.println("\t\tif (!loaded_stubs)");
167 writer.println("\t\t\treturn;");
168 for (TypeDeclaration typedecl : interface_decls) {
169 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
170 GLCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl);
171 }
172 writer.println("\t\tloaded_stubs = false;");
173 }
174 writer.println("\t}");
175 writer.println();
176 GLCapabilitiesGenerator.generateInitializerPrologue(writer);
177 for (TypeDeclaration typedecl : interface_decls) {
178 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
179 if (Utils.isFinal(interface_decl))
180 GLCapabilitiesGenerator.generateInitializer(writer, interface_decl);
181 }
182 writer.println("\t\ttracker.init();");
183 writer.println("\t}");
184 writer.println("}");
185 writer.close();
186 }
187 }
188 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.util.generator.opengl;
32
33 import org.lwjgl.util.generator.Alternate;
34 import org.lwjgl.util.generator.CachedReference;
35 import org.lwjgl.util.generator.Utils;
36
37 import java.io.IOException;
38 import java.io.PrintWriter;
39 import java.util.Set;
40 import javax.annotation.processing.*;
41 import javax.lang.model.SourceVersion;
42 import javax.lang.model.element.ExecutableElement;
43 import javax.lang.model.element.TypeElement;
44 import javax.lang.model.element.VariableElement;
45 import javax.lang.model.util.ElementFilter;
46
47 /**
48 * Generator tool for creating the References class
49 *
50 * @author elias_naur <elias_naur@users.sourceforge.net>
51 * @version $Revision: 3237 $ $Id: ReferencesGeneratorProcessorFactory.java 3237
52 * 2009-09-08 15:07:15Z spasi $
53 */
54 @SupportedAnnotationTypes({ "*" })
55 @SupportedSourceVersion(SourceVersion.RELEASE_6)
56 @SupportedOptions({ "generatechecks", "contextspecific" })
57 public class GLReferencesGeneratorProcessor extends AbstractProcessor {
58
59 private static final String REFERENCES_CLASS_NAME = "References";
60 private static final String REFERENCES_PARAMETER_NAME = "references";
61
62 private static boolean first_round = true;
63
64 @Override
65 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
66 if ( roundEnv.processingOver() || !first_round ) {
67 System.exit(0);
68 return true;
69 }
70 try {
71 generateReferencesSource(processingEnv, ElementFilter.typesIn(roundEnv.getRootElements()));
72 first_round = false;
73 return true;
74 } catch (IOException e) {
75 throw new RuntimeException(e);
76 }
77 }
78
79 private static void generateClearsFromParameters(PrintWriter writer, TypeElement interface_decl, ExecutableElement method) {
80 for ( VariableElement param : method.getParameters() ) {
81 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
82 if ( cached_reference_annotation != null && cached_reference_annotation.name().length() == 0 ) {
83 Class nio_type = Utils.getNIOBufferType(param.asType());
84 String reference_name = Utils.getReferenceName(interface_decl, method, param);
85 writer.println("\t\tthis." + reference_name + " = null;");
86 }
87 }
88 }
89
90 private static void generateCopiesFromParameters(PrintWriter writer, TypeElement interface_decl, ExecutableElement method) {
91 for ( VariableElement param : method.getParameters() ) {
92 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
93 if ( cached_reference_annotation != null && cached_reference_annotation.name().length() == 0 ) {
94 Class nio_type = Utils.getNIOBufferType(param.asType());
95 String reference_name = Utils.getReferenceName(interface_decl, method, param);
96 writer.print("\t\t\tthis." + reference_name + " = ");
97 writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
98 }
99 }
100 }
101
102 private static void generateClearsFromMethods(ProcessingEnvironment env, PrintWriter writer, TypeElement interface_decl) {
103 for ( ExecutableElement method : Utils.getMethods(interface_decl) ) {
104 if ( method.getAnnotation(Alternate.class) != null ) {
105 continue;
106 }
107
108 generateClearsFromParameters(writer, interface_decl, method);
109 }
110 }
111
112 private static void generateCopiesFromMethods(ProcessingEnvironment env, PrintWriter writer, TypeElement interface_decl) {
113 for ( ExecutableElement method : Utils.getMethods(interface_decl) ) {
114 if ( method.getAnnotation(Alternate.class) != null ) {
115 continue;
116 }
117
118 generateCopiesFromParameters(writer, interface_decl, method);
119 }
120 }
121
122 private static void generateReferencesFromParameters(PrintWriter writer, TypeElement interface_decl, ExecutableElement method) {
123 for ( VariableElement param : method.getParameters() ) {
124 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
125 if ( cached_reference_annotation != null && cached_reference_annotation.name().length() == 0 ) {
126 Class nio_type = Utils.getNIOBufferType(param.asType());
127 if ( nio_type == null ) {
128 throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
129 + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
130 }
131 writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
132 writer.println(";");
133 }
134 }
135 }
136
137 private static void generateReferencesFromMethods(ProcessingEnvironment env, PrintWriter writer, TypeElement interface_decl) {
138 for ( ExecutableElement method : Utils.getMethods(interface_decl) ) {
139 if ( method.getAnnotation(Alternate.class) != null ) {
140 continue;
141 }
142
143 generateReferencesFromParameters(writer, interface_decl, method);
144 }
145 }
146
147 private void generateReferencesSource(ProcessingEnvironment env, Set<TypeElement> templates) throws IOException {
148 PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opengl." + REFERENCES_CLASS_NAME, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opengl")).openWriter());
149 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
150 writer.println();
151 writer.println("package org.lwjgl.opengl;");
152 writer.println();
153 writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {");
154 writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {");
155 writer.println("\t\tsuper(caps);");
156 writer.println("\t}");
157 for ( TypeElement interface_decl : templates ) {
158 if ( interface_decl.getKind().isInterface() ) {
159 generateReferencesFromMethods(env, writer, interface_decl);
160 }
161 }
162 writer.println();
163 writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {");
164 writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);");
165 writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {");
166 for ( TypeElement interface_decl : templates ) {
167 if ( interface_decl.getKind().isInterface() ) {
168 generateCopiesFromMethods(processingEnv, writer, interface_decl);
169 }
170 }
171 writer.println("\t\t}");
172 writer.println("\t}");
173 writer.println("\tvoid clear() {");
174 writer.println("\t\tsuper.clear();");
175 for ( TypeElement interface_decl : templates ) {
176 if ( interface_decl.getKind().isInterface() ) {
177 generateClearsFromMethods(processingEnv, writer, interface_decl);
178 }
179 }
180 writer.println("\t}");
181 writer.println("}");
182 writer.close();
183 }
184
185 }
+0
-208
src/java/org/lwjgl/util/generator/opengl/GLReferencesGeneratorProcessorFactory.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.CachedReference;
35 import org.lwjgl.util.generator.Utils;
36
37 import static java.util.Collections.emptyList;
38 import static java.util.Collections.unmodifiableCollection;
39
40 import java.io.File;
41 import java.io.IOException;
42 import java.io.PrintWriter;
43 import java.util.Arrays;
44 import java.util.Collection;
45 import java.util.Set;
46
47 import com.sun.mirror.apt.AnnotationProcessor;
48 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
49 import com.sun.mirror.apt.AnnotationProcessorFactory;
50 import com.sun.mirror.apt.AnnotationProcessors;
51 import com.sun.mirror.apt.Filer;
52 import com.sun.mirror.apt.RoundCompleteEvent;
53 import com.sun.mirror.apt.RoundCompleteListener;
54 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
55 import com.sun.mirror.declaration.InterfaceDeclaration;
56 import com.sun.mirror.declaration.MethodDeclaration;
57 import com.sun.mirror.declaration.ParameterDeclaration;
58 import com.sun.mirror.declaration.TypeDeclaration;
59 import com.sun.mirror.util.DeclarationFilter;
60
61 /**
62 *
63 * Generator tool for creating the References class
64 *
65 * @author elias_naur <elias_naur@users.sourceforge.net>
66 * @version $Revision: 3237 $
67 * $Id: ReferencesGeneratorProcessorFactory.java 3237 2009-09-08 15:07:15Z spasi $
68 */
69 public class GLReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
70 private static final String REFERENCES_CLASS_NAME = "References";
71 private static final String REFERENCES_PARAMETER_NAME = "references";
72
73 private static boolean first_round = true;
74
75 // Process any set of annotations
76 private static final Collection<String> supportedAnnotations =
77 unmodifiableCollection(Arrays.asList("*"));
78
79 public Collection<String> supportedAnnotationTypes() {
80 return supportedAnnotations;
81 }
82
83 public Collection<String> supportedOptions() {
84 return emptyList();
85 }
86
87 public void roundComplete(RoundCompleteEvent event) {
88 first_round = false;
89 }
90
91 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
92 // Only process the initial types, not the generated ones
93 if (first_round) {
94 env.addListener(this);
95 return new GeneratorProcessor(env);
96 } else
97 return AnnotationProcessors.NO_OP;
98 }
99
100 private static class GeneratorProcessor implements AnnotationProcessor {
101 private final AnnotationProcessorEnvironment env;
102
103 GeneratorProcessor(AnnotationProcessorEnvironment env) {
104 this.env = env;
105 }
106
107 public void process() {
108 try {
109 generateReferencesSource();
110 } catch (IOException e) {
111 throw new RuntimeException(e);
112 }
113 }
114
115 private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
116 for (ParameterDeclaration param : method.getParameters()) {
117 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
118 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
119 Class nio_type = Utils.getNIOBufferType(param.getType());
120 String reference_name = Utils.getReferenceName(interface_decl, method, param);
121 writer.println("\t\tthis." + reference_name + " = null;");
122 }
123 }
124 }
125
126 private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
127 for (ParameterDeclaration param : method.getParameters()) {
128 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
129 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
130 Class nio_type = Utils.getNIOBufferType(param.getType());
131 String reference_name = Utils.getReferenceName(interface_decl, method, param);
132 writer.print("\t\t\tthis." + reference_name + " = ");
133 writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
134 }
135 }
136 }
137
138 private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
139 for (MethodDeclaration method : interface_decl.getMethods()) {
140 generateClearsFromParameters(writer, interface_decl, method);
141 }
142 }
143
144 private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
145 for (MethodDeclaration method : interface_decl.getMethods()) {
146 generateCopiesFromParameters(writer, interface_decl, method);
147 }
148 }
149
150 private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
151 for (ParameterDeclaration param : method.getParameters()) {
152 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
153 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
154 Class nio_type = Utils.getNIOBufferType(param.getType());
155 if (nio_type == null)
156 throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
157 + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
158 writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
159 writer.println(";");
160 }
161 }
162 }
163
164 private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
165 for (MethodDeclaration method : interface_decl.getMethods()) {
166 generateReferencesFromParameters(writer, interface_decl, method);
167 }
168 }
169
170 private void generateReferencesSource() throws IOException {
171 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null);
172 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
173 writer.println();
174 writer.println("package org.lwjgl.opengl;");
175 writer.println();
176 writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {");
177 writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {");
178 writer.println("\t\tsuper(caps);");
179 writer.println("\t}");
180 DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
181 Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
182 for (TypeDeclaration typedecl : interface_decls) {
183 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
184 generateReferencesFromMethods(writer, interface_decl);
185 }
186 writer.println();
187 writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {");
188 writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);");
189 writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {");
190 for (TypeDeclaration typedecl : interface_decls) {
191 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
192 generateCopiesFromMethods(writer, interface_decl);
193 }
194 writer.println("\t\t}");
195 writer.println("\t}");
196 writer.println("\tvoid clear() {");
197 writer.println("\t\tsuper.clear();");
198 for (TypeDeclaration typedecl : interface_decls) {
199 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
200 generateClearsFromMethods(writer, interface_decl);
201 }
202 writer.println("\t}");
203 writer.println("}");
204 writer.close();
205 }
206 }
207 }
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
3231 package org.lwjgl.util.generator.opengl;
3332
3433 /**
3635 * OpenGL sepcific generator behaviour
3736 *
3837 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3392 $
40 * $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z spasi $
38 * @version $Revision: 3392 $ $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z
39 * spasi $
4140 */
42
41 import org.lwjgl.PointerBuffer;
4342 import org.lwjgl.util.generator.NativeTypeTranslator;
4443 import org.lwjgl.util.generator.PointerWrapper;
4544 import org.lwjgl.util.generator.Signedness;
5049 import java.nio.*;
5150 import java.util.HashMap;
5251 import java.util.Map;
53
54 import com.sun.mirror.declaration.AnnotationMirror;
55 import com.sun.mirror.declaration.MethodDeclaration;
56 import com.sun.mirror.type.PrimitiveType;
52 import javax.lang.model.element.AnnotationMirror;
53 import javax.lang.model.element.ExecutableElement;
54 import javax.lang.model.type.TypeKind;
5755
5856 public class GLTypeMap implements TypeMap {
5957
60 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
58 private static final Map<Class, TypeKind> native_types_to_primitive;
6159
6260 static {
63 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
64 native_types_to_primitive.put(GLbitfield.class, PrimitiveType.Kind.INT);
65 native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE);
66 native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT);
67 native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT);
68 native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT);
70 native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG);
71 native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT);
72 native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN);
73 native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE);
74 native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE);
75 native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT);
76 native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG);
77 native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT);
78 native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT);
79 native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE);
80 native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE);
81 native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT);
82 native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT);
83 native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG);
84 native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG);
85 native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE);
86 native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE);
87 native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG);
88 native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG);
89 native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG);
90 native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG);
91 }
92
93 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
94 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
95 if ( kind == null )
61 native_types_to_primitive = new HashMap<Class, TypeKind>();
62 native_types_to_primitive.put(GLbitfield.class, TypeKind.INT);
63 native_types_to_primitive.put(GLcharARB.class, TypeKind.BYTE);
64 native_types_to_primitive.put(GLclampf.class, TypeKind.FLOAT);
65 native_types_to_primitive.put(GLfloat.class, TypeKind.FLOAT);
66 native_types_to_primitive.put(GLint.class, TypeKind.INT);
67 native_types_to_primitive.put(GLshort.class, TypeKind.SHORT);
68 native_types_to_primitive.put(GLsizeiptr.class, TypeKind.LONG);
69 native_types_to_primitive.put(GLuint.class, TypeKind.INT);
70 native_types_to_primitive.put(GLboolean.class, TypeKind.BOOLEAN);
71 native_types_to_primitive.put(GLchar.class, TypeKind.BYTE);
72 native_types_to_primitive.put(GLdouble.class, TypeKind.DOUBLE);
73 native_types_to_primitive.put(GLhalf.class, TypeKind.SHORT);
74 native_types_to_primitive.put(GLintptrARB.class, TypeKind.LONG);
75 native_types_to_primitive.put(GLsizei.class, TypeKind.INT);
76 native_types_to_primitive.put(GLushort.class, TypeKind.SHORT);
77 native_types_to_primitive.put(GLbyte.class, TypeKind.BYTE);
78 native_types_to_primitive.put(GLclampd.class, TypeKind.DOUBLE);
79 native_types_to_primitive.put(GLenum.class, TypeKind.INT);
80 native_types_to_primitive.put(GLhandleARB.class, TypeKind.INT);
81 native_types_to_primitive.put(GLintptr.class, TypeKind.LONG);
82 native_types_to_primitive.put(GLsizeiptrARB.class, TypeKind.LONG);
83 native_types_to_primitive.put(GLubyte.class, TypeKind.BYTE);
84 native_types_to_primitive.put(GLvoid.class, TypeKind.BYTE);
85 native_types_to_primitive.put(GLint64EXT.class, TypeKind.LONG);
86 native_types_to_primitive.put(GLuint64EXT.class, TypeKind.LONG);
87 native_types_to_primitive.put(GLint64.class, TypeKind.LONG);
88 native_types_to_primitive.put(GLuint64.class, TypeKind.LONG);
89 }
90
91 @Override
92 public TypeKind getPrimitiveTypeFromNativeType(Class native_type) {
93 TypeKind kind = native_types_to_primitive.get(native_type);
94 if ( kind == null ) {
9695 throw new RuntimeException("Unsupported type " + native_type);
96 }
9797 return kind;
9898 }
9999
100 @Override
100101 public void printCapabilitiesInit(final PrintWriter writer) {
101102 writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
102103 }
103104
105 @Override
104106 public String getCapabilities() {
105107 return "caps";
106108 }
107109
108 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
110 @Override
111 public String getAPIUtilParam(boolean comma) {
112 return comma ? "caps, " : "caps";
113 }
114
115 @Override
116 public void printErrorCheckMethod(final PrintWriter writer, final ExecutableElement method, final String tabs) {
109117 writer.println(tabs + "Util.checkGLError();");
110118 }
111119
120 @Override
112121 public String getRegisterNativesFunctionName() {
113122 return "extgl_InitializeClass";
114123 }
115124
125 @Override
116126 public Signedness getSignednessFromType(Class type) {
117 if ( GLuint.class.equals(type) )
118 return Signedness.UNSIGNED;
119 else if ( GLint.class.equals(type) )
120 return Signedness.SIGNED;
121 else if ( GLushort.class.equals(type) )
122 return Signedness.UNSIGNED;
123 else if ( GLshort.class.equals(type) )
124 return Signedness.SIGNED;
125 else if ( GLubyte.class.equals(type) )
126 return Signedness.UNSIGNED;
127 else if ( GLbyte.class.equals(type) )
128 return Signedness.SIGNED;
129 else if ( GLuint64EXT.class.equals(type) )
130 return Signedness.UNSIGNED;
131 else if ( GLint64EXT.class.equals(type) )
132 return Signedness.SIGNED;
133 else if ( GLuint64.class.equals(type) )
134 return Signedness.UNSIGNED;
135 else if ( GLint64.class.equals(type) )
136 return Signedness.SIGNED;
137 else
127 if ( GLuint.class.equals(type) ) {
128 return Signedness.UNSIGNED;
129 } else if ( GLint.class.equals(type) ) {
130 return Signedness.SIGNED;
131 } else if ( GLushort.class.equals(type) ) {
132 return Signedness.UNSIGNED;
133 } else if ( GLshort.class.equals(type) ) {
134 return Signedness.SIGNED;
135 } else if ( GLubyte.class.equals(type) ) {
136 return Signedness.UNSIGNED;
137 } else if ( GLbyte.class.equals(type) ) {
138 return Signedness.SIGNED;
139 } else if ( GLuint64EXT.class.equals(type) ) {
140 return Signedness.UNSIGNED;
141 } else if ( GLint64EXT.class.equals(type) ) {
142 return Signedness.SIGNED;
143 } else if ( GLuint64.class.equals(type) ) {
144 return Signedness.UNSIGNED;
145 } else if ( GLint64.class.equals(type) ) {
146 return Signedness.SIGNED;
147 } else {
138148 return Signedness.NONE;
139 }
140
149 }
150 }
151
152 @Override
141153 public String translateAnnotation(Class annotation_type) {
142 if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) )
154 if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) ) {
143155 return "i";
144 else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) )
156 } else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) ) {
145157 return "s";
146 else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) )
158 } else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) ) {
147159 return "b";
148 else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) )
160 } else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) ) {
149161 return "f";
150 else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) )
162 } else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) ) {
151163 return "d";
152 else if ( annotation_type.equals(GLhalf.class) )
164 } else if ( annotation_type.equals(GLhalf.class) ) {
153165 return "h";
154 else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) )
166 } else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) ) {
155167 return "i64";
156 else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) )
168 } else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) ) {
157169 return "";
158 else
170 } else {
159171 throw new RuntimeException(annotation_type + " is not allowed");
160 }
161
162 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
172 }
173 }
174
175 @Override
176 public Class getNativeTypeFromPrimitiveType(TypeKind kind) {
163177 Class type;
164178 switch ( kind ) {
165179 case INT:
189203 return type;
190204 }
191205
206 @Override
192207 public Class<? extends Annotation> getVoidType() {
193208 return GLvoid.class;
194209 }
195210
211 @Override
196212 public Class<? extends Annotation> getStringElementType() {
197213 return GLubyte.class;
198214 }
199215
216 @Override
200217 public Class<? extends Annotation> getStringArrayType() {
201218 return GLchar.class;
202219 }
203220
221 @Override
204222 public Class<? extends Annotation> getByteBufferArrayType() {
205223 return GLchar.class;
206224 }
207225
208226 private static Class[] getValidBufferTypes(Class type) {
209 if ( type.equals(IntBuffer.class) )
227 if ( type.equals(IntBuffer.class) ) {
210228 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class,
211229 GLsizei.class, GLuint.class, GLvoid.class };
212 else if ( type.equals(FloatBuffer.class) )
230 } else if ( type.equals(FloatBuffer.class) ) {
213231 return new Class[] { GLclampf.class, GLfloat.class };
214 else if ( type.equals(ByteBuffer.class) )
232 } else if ( type.equals(ByteBuffer.class) ) {
215233 return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class };
216 else if ( type.equals(ShortBuffer.class) )
234 } else if ( type.equals(ShortBuffer.class) ) {
217235 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
218 else if ( type.equals(DoubleBuffer.class) )
236 } else if ( type.equals(DoubleBuffer.class) ) {
219237 return new Class[] { GLclampd.class, GLdouble.class };
220 else if ( type.equals(LongBuffer.class) )
238 } else if ( type.equals(LongBuffer.class) ) {
221239 return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
222 else
240 } else {
223241 return new Class[] { };
242 }
224243 }
225244
226245 private static Class[] getValidPrimitiveTypes(Class type) {
227 if ( type.equals(long.class) )
246 if ( type.equals(long.class) ) {
228247 return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
229 else if ( type.equals(int.class) )
248 } else if ( type.equals(int.class) ) {
230249 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class,
231250 GLsizei.class };
232 else if ( type.equals(double.class) )
251 } else if ( type.equals(double.class) ) {
233252 return new Class[] { GLclampd.class, GLdouble.class };
234 else if ( type.equals(float.class) )
253 } else if ( type.equals(float.class) ) {
235254 return new Class[] { GLclampf.class, GLfloat.class };
236 else if ( type.equals(short.class) )
255 } else if ( type.equals(short.class) ) {
237256 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
238 else if ( type.equals(byte.class) )
257 } else if ( type.equals(byte.class) ) {
239258 return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class };
240 else if ( type.equals(boolean.class) )
259 } else if ( type.equals(boolean.class) ) {
241260 return new Class[] { GLboolean.class };
242 else if ( type.equals(void.class) )
261 } else if ( type.equals(void.class) ) {
243262 return new Class[] { GLvoid.class, GLreturn.class };
244 else
263 } else {
245264 return new Class[] { };
246 }
247
265 }
266 }
267
268 @Override
248269 public String getTypedefPostfix() {
249270 return "";
250271 }
251272
273 @Override
252274 public String getFunctionPrefix() {
253275 return "APIENTRY";
254276 }
255277
278 @Override
256279 public void printNativeIncludes(PrintWriter writer) {
257280 writer.println("#include \"extgl.h\"");
258281 }
259282
283 @Override
260284 public Class[] getValidAnnotationTypes(Class type) {
261285 Class[] valid_types;
262 if ( Buffer.class.isAssignableFrom(type) )
286 if ( Buffer.class.isAssignableFrom(type) ) {
263287 valid_types = getValidBufferTypes(type);
264 else if ( type.isPrimitive() )
288 } else if ( type.isPrimitive() ) {
265289 valid_types = getValidPrimitiveTypes(type);
266 else if ( String.class.equals(type) )
290 } else if ( String.class.equals(type) ) {
267291 valid_types = new Class[] { GLubyte.class };
268 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
292 } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) {
269293 valid_types = new Class[] { PointerWrapper.class };
270 else if (void.class.equals(type) )
294 } else if ( void.class.equals(type) ) {
271295 valid_types = new Class[] { GLreturn.class };
272 else
296 } else if ( PointerBuffer.class.equals(type) ) {
297 valid_types = new Class[] { GLintptr.class, GLintptrARB.class, GLsizeiptr.class, GLsizeiptrARB.class };
298 } else {
273299 valid_types = new Class[] { };
300 }
274301 return valid_types;
275302 }
276303
304 @Override
277305 public Class<? extends Annotation> getInverseType(Class type) {
278 if ( GLuint.class.equals(type) )
306 if ( GLuint.class.equals(type) ) {
279307 return GLint.class;
280 else if ( GLint.class.equals(type) )
308 } else if ( GLint.class.equals(type) ) {
281309 return GLuint.class;
282 else if ( GLushort.class.equals(type) )
310 } else if ( GLushort.class.equals(type) ) {
283311 return GLshort.class;
284 else if ( GLshort.class.equals(type) )
312 } else if ( GLshort.class.equals(type) ) {
285313 return GLushort.class;
286 else if ( GLubyte.class.equals(type) )
314 } else if ( GLubyte.class.equals(type) ) {
287315 return GLbyte.class;
288 else if ( GLbyte.class.equals(type) )
316 } else if ( GLbyte.class.equals(type) ) {
289317 return GLubyte.class;
290 else if ( GLuint64EXT.class.equals(type) )
318 } else if ( GLuint64EXT.class.equals(type) ) {
291319 return GLint64EXT.class;
292 else if ( GLint64EXT.class.equals(type) )
320 } else if ( GLint64EXT.class.equals(type) ) {
293321 return GLuint64EXT.class;
294 else if ( GLuint64.class.equals(type) )
322 } else if ( GLuint64.class.equals(type) ) {
295323 return GLint64.class;
296 else if ( GLint64.class.equals(type) )
324 } else if ( GLint64.class.equals(type) ) {
297325 return GLuint64.class;
298 else
326 } else {
299327 return null;
300 }
301
328 }
329 }
330
331 @Override
302332 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
303333 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
304 if ( annotation_class.equals(GLint.class) )
334 if ( annotation_class.equals(GLint.class) ) {
305335 return "GL11.GL_INT";
306 else if ( annotation_class.equals(GLbyte.class) )
336 } else if ( annotation_class.equals(GLbyte.class) ) {
307337 return "GL11.GL_BYTE";
308 else if ( annotation_class.equals(GLshort.class) )
338 } else if ( annotation_class.equals(GLshort.class) ) {
309339 return "GL11.GL_SHORT";
310 if ( annotation_class.equals(GLuint.class) )
340 }
341 if ( annotation_class.equals(GLuint.class) ) {
311342 return "GL11.GL_UNSIGNED_INT";
312 else if ( annotation_class.equals(GLubyte.class) )
343 } else if ( annotation_class.equals(GLubyte.class) ) {
313344 return "GL11.GL_UNSIGNED_BYTE";
314 else if ( annotation_class.equals(GLushort.class) )
345 } else if ( annotation_class.equals(GLushort.class) ) {
315346 return "GL11.GL_UNSIGNED_SHORT";
316 else if ( annotation_class.equals(GLfloat.class) )
347 } else if ( annotation_class.equals(GLfloat.class) ) {
317348 return "GL11.GL_FLOAT";
318 else if ( annotation_class.equals(GLdouble.class) )
349 } else if ( annotation_class.equals(GLdouble.class) ) {
319350 return "GL11.GL_DOUBLE";
320 else
351 } else {
321352 return null;
353 }
322354 }
323355 }
3838 */
3939
4040 import org.lwjgl.util.generator.NativeType;
41 import org.lwjgl.util.generator.PointerType;
4142
4243 import java.lang.annotation.Target;
4344 import java.lang.annotation.ElementType;
4445
4546 @NativeType
47 @PointerType
4648 @Target({ElementType.PARAMETER, ElementType.METHOD})
4749 public @interface GLintptr {
4850 }
3838 */
3939
4040 import org.lwjgl.util.generator.NativeType;
41 import org.lwjgl.util.generator.PointerType;
4142
4243 import java.lang.annotation.Target;
4344 import java.lang.annotation.ElementType;
4445
4546 @NativeType
47 @PointerType
4648 @Target({ElementType.PARAMETER, ElementType.METHOD})
4749 public @interface GLintptrARB {
4850 }
3838 */
3939
4040 import org.lwjgl.util.generator.NativeType;
41 import org.lwjgl.util.generator.PointerType;
4142
4243 import java.lang.annotation.Target;
4344 import java.lang.annotation.ElementType;
4445
4546 @NativeType
47 @PointerType
4648 @Target({ElementType.PARAMETER, ElementType.METHOD})
4749 public @interface GLsizeiptr {
4850 }
3838 */
3939
4040 import org.lwjgl.util.generator.NativeType;
41 import org.lwjgl.util.generator.PointerType;
4142
4243 import java.lang.annotation.Target;
4344 import java.lang.annotation.ElementType;
4445
4546 @NativeType
47 @PointerType
4648 @Target({ElementType.PARAMETER, ElementType.METHOD})
4749 public @interface GLsizeiptrARB {
4850 }
3939
4040 import org.lwjgl.util.generator.NativeType;
4141
42 import java.lang.annotation.ElementType;
4243 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 import com.sun.mirror.type.PrimitiveType;
44 import javax.lang.model.type.TypeKind;
4645
4746 @NativeType
48 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 @Target({ ElementType.PARAMETER, ElementType.METHOD })
4948 public @interface GLvoid {
50 PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
49 TypeKind value() default TypeKind.BYTE;
5150 }
9797 * @param src
9898 * @param inverse
9999 *
100 * @return
100 * @return true if the matrix was succesfully inverted
101101 */
102102 private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
103103 int i, j, k, swap;
325325 */
326326 public void setRZAxisDeadZone(float zone) {
327327 }
328
329 public int getRumblerCount() {
330 return 0;
331 }
332
333 public String getRumblerName(int index) {
334 return "rumber n/a";
335 }
336
337 public void setRumblerStrength(int index, float strength) {
338 }
328339 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Retention;
35 import java.lang.annotation.RetentionPolicy;
36 import java.lang.annotation.Target;
37
38 /**
39 * When this annotation is used on a field, automatic cache-line-sized padding
40 * will be inserted around the field. This is useful in multi-threaded algorithms
41 * to avoid cache line false sharing. The annotation defaults to padding after
42 * the field, but can be changed to before or both before and after. It can be
43 * applied to both mapped object fields and POJO primitive fields.
44 *
45 * @author Spasi
46 */
47 @Retention(RetentionPolicy.RUNTIME)
48 @Target(ElementType.FIELD)
49 public @interface CacheLinePad {
50
51 /**
52 * When true, cache-line padding will be inserted before the field.
53 *
54 * @return true if cache-line padding will be inserted before the field
55 */
56 boolean before() default false;
57
58 /**
59 * When true, cache-line padding will be inserted after the field.
60 *
61 * @return true if cache-line padding will be inserted after the field
62 */
63 boolean after() default true;
64
65 }
0 package org.lwjgl.util.mapped;
1
2 import org.lwjgl.LWJGLUtil;
3 import org.lwjgl.MemoryUtil;
4
5 import java.nio.ByteBuffer;
6 import java.nio.ByteOrder;
7 import java.nio.IntBuffer;
8 import java.util.concurrent.Callable;
9 import java.util.concurrent.ExecutorCompletionService;
10 import java.util.concurrent.ExecutorService;
11 import java.util.concurrent.Executors;
12
13 import static org.lwjgl.util.mapped.MappedHelper.*;
14
15 /**
16 * This micro-benchmark tries to detect the CPU's cache line size. This is
17 * done by exploiting cache line false sharing in multi-threaded code:
18 * When 2 threads simultaneously access the same cache line (and at least
19 * 1 access is a write), performance drops considerably. We detect this
20 * performance drop while decreasing the memory padding in every test step.
21 *
22 * @author Spasi
23 */
24 final class CacheLineSize {
25
26 private CacheLineSize() {
27 }
28
29 static int getCacheLineSize() {
30 final int THREADS = 2;
31 final int REPEATS = 100000 * THREADS;
32 final int LOCAL_REPEATS = REPEATS / THREADS;
33
34 // Detection will start from CacheLineMaxSize bytes.
35 final int MAX_SIZE = LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineMaxSize", 1024) / 4; // in # of integers
36 // Detection will stop when the execution time increases by more than CacheLineTimeThreshold %.
37 final double TIME_THRESHOLD = 1.0 + LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineTimeThreshold", 50) / 100.0;
38
39 final ExecutorService executorService = Executors.newFixedThreadPool(THREADS);
40 final ExecutorCompletionService<Long> completionService = new ExecutorCompletionService<Long>(executorService);
41
42 try {
43 // We need to use a NIO buffer in order to guarantee memory alignment.
44 final IntBuffer memory = getMemory(MAX_SIZE);
45
46 // -- WARMUP --
47
48 final int WARMUP = 10;
49 for ( int i = 0; i < WARMUP; i++ )
50 doTest(THREADS, LOCAL_REPEATS, 0, memory, completionService);
51
52 // -- CACHE LINE SIZE DETECTION --
53
54 long totalTime = 0;
55 int count = 0;
56 int cacheLineSize = 64; // fallback to the most common size these days
57 boolean found = false;
58 for ( int i = MAX_SIZE; i >= 1; i >>= 1 ) {
59 final long time = doTest(THREADS, LOCAL_REPEATS, i, memory, completionService);
60 if ( totalTime > 0 ) { // Ignore first run
61 final long avgTime = totalTime / count;
62 if ( (double)time / (double)avgTime > TIME_THRESHOLD ) { // Try to detect a noticeable jump in execution time
63 cacheLineSize = (i << 1) * 4;
64 found = true;
65 break;
66 }
67 }
68 totalTime += time;
69 count++;
70 }
71
72 if ( LWJGLUtil.DEBUG ) {
73 if ( found )
74 LWJGLUtil.log("Cache line size detected: " + cacheLineSize + " bytes");
75 else
76 LWJGLUtil.log("Failed to detect cache line size, assuming " + cacheLineSize + " bytes");
77 }
78
79 return cacheLineSize;
80 } finally {
81 executorService.shutdown();
82 }
83 }
84
85 public static void main(String[] args) {
86 CacheUtil.getCacheLineSize();
87 }
88
89 static long memoryLoop(final int index, final int repeats, final IntBuffer memory, final int padding) {
90 final long address = MemoryUtil.getAddress(memory) + (index * padding * 4);
91
92 final long time = System.nanoTime();
93 for ( int i = 0; i < repeats; i++ ) {
94 // Use volatile access to avoid server VM optimizations.
95 ivput(ivget(address) + 1, address);
96 }
97
98 return System.nanoTime() - time;
99 }
100
101 private static IntBuffer getMemory(final int START_SIZE) {
102 final int PAGE_SIZE = MappedObjectUnsafe.INSTANCE.pageSize();
103
104 final ByteBuffer buffer = ByteBuffer.allocateDirect((START_SIZE * 4) + PAGE_SIZE).order(ByteOrder.nativeOrder());
105
106 // Align to page and, consequently, to cache line. Otherwise results will be inconsistent.
107 if ( MemoryUtil.getAddress(buffer) % PAGE_SIZE != 0 ) {
108 // Round up to page boundary
109 buffer.position(PAGE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (PAGE_SIZE - 1)));
110 }
111
112 return buffer.asIntBuffer();
113 }
114
115 private static long doTest(final int threads, final int repeats, final int padding, final IntBuffer memory, final ExecutorCompletionService<Long> completionService) {
116 for ( int i = 0; i < threads; i++ )
117 submitTest(completionService, i, repeats, memory, padding);
118 return waitForResults(threads, completionService);
119 }
120
121 private static void submitTest(final ExecutorCompletionService<Long> completionService, final int index, final int repeats, final IntBuffer memory, final int padding) {
122 completionService.submit(new Callable<Long>() {
123 public Long call() throws Exception {
124 return memoryLoop(index, repeats, memory, padding);
125 }
126 });
127 }
128
129 private static long waitForResults(final int count, final ExecutorCompletionService<Long> completionService) {
130 try {
131 long totalTime = 0;
132 for ( int i = 0; i < count; i++ )
133 totalTime += completionService.take().get();
134 return totalTime;
135 } catch (Exception e) {
136 throw new RuntimeException(e);
137 }
138 }
139
140 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.LWJGLUtil;
34 import org.lwjgl.MemoryUtil;
35 import org.lwjgl.PointerBuffer;
36
37 import java.nio.*;
38
39 /**
40 * This class provides utility methods for allocating cache-line-aligned
41 * NIO buffers. The CPU cache line size is detected using a micro-benchmark
42 * that exploits the performation degredation that occurs when different
43 * threads write to different locations of the same cache line. The detection
44 * should be reasonably robust on both the server and client VM, but there
45 * are a few system properties that can be used to tune it.
46 *
47 * @author Spasi
48 */
49 public final class CacheUtil {
50
51 private static final int CACHE_LINE_SIZE;
52
53 static {
54 final Integer size = LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineSize"); // forces a specific cache line size
55
56 if ( size != null ) {
57 if ( size < 1 )
58 throw new IllegalStateException("Invalid CacheLineSize specified: " + size);
59 CACHE_LINE_SIZE = size;
60 } else if ( Runtime.getRuntime().availableProcessors() == 1 ) { // We cannot use false sharing to detect it
61 /*
62 Spasi:
63
64 I have implemented a single-threaded benchmark for this, but it requires
65 lots of memory allocations and could not tune it for both the client and
66 server VM. It's not a big deal anyway, 64 bytes should be ok for any
67 single-core CPU.
68 */
69 if ( LWJGLUtil.DEBUG )
70 LWJGLUtil.log("Cannot detect cache line size on single-core CPUs, assuming 64 bytes.");
71 CACHE_LINE_SIZE = 64;
72 } else
73 CACHE_LINE_SIZE = CacheLineSize.getCacheLineSize();
74 }
75
76 private CacheUtil() {
77 }
78
79 /**
80 * Returns the CPU cache line size, in number of bytes.
81 *
82 * @return the cache line size
83 */
84 public static int getCacheLineSize() {
85 return CACHE_LINE_SIZE;
86 }
87
88 /**
89 * Construct a direct, native-ordered and cache-line-aligned bytebuffer with the specified size.
90 *
91 * @param size The size, in bytes
92 *
93 * @return a ByteBuffer
94 */
95 public static ByteBuffer createByteBuffer(int size) {
96 ByteBuffer buffer = ByteBuffer.allocateDirect(size + CACHE_LINE_SIZE);
97
98 // Align to cache line.
99 if ( MemoryUtil.getAddress(buffer) % CACHE_LINE_SIZE != 0 ) {
100 // Round up to cache line boundary
101 buffer.position(CACHE_LINE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (CACHE_LINE_SIZE - 1)));
102 }
103
104 buffer.limit(buffer.position() + size);
105 return buffer.slice().order(ByteOrder.nativeOrder());
106 }
107
108 /**
109 * Construct a direct, native-ordered and cache-line-aligned shortbuffer with the specified number
110 * of elements.
111 *
112 * @param size The size, in shorts
113 *
114 * @return a ShortBuffer
115 */
116 public static ShortBuffer createShortBuffer(int size) {
117 return createByteBuffer(size << 1).asShortBuffer();
118 }
119
120 /**
121 * Construct a direct, native-ordered and cache-line-aligned charbuffer with the specified number
122 * of elements.
123 *
124 * @param size The size, in chars
125 *
126 * @return an CharBuffer
127 */
128 public static CharBuffer createCharBuffer(int size) {
129 return createByteBuffer(size << 1).asCharBuffer();
130 }
131
132 /**
133 * Construct a direct, native-ordered and cache-line-aligned intbuffer with the specified number
134 * of elements.
135 *
136 * @param size The size, in ints
137 *
138 * @return an IntBuffer
139 */
140 public static IntBuffer createIntBuffer(int size) {
141 return createByteBuffer(size << 2).asIntBuffer();
142 }
143
144 /**
145 * Construct a direct, native-ordered and cache-line-aligned longbuffer with the specified number
146 * of elements.
147 *
148 * @param size The size, in longs
149 *
150 * @return an LongBuffer
151 */
152 public static LongBuffer createLongBuffer(int size) {
153 return createByteBuffer(size << 3).asLongBuffer();
154 }
155
156 /**
157 * Construct a direct, native-ordered and cache-line-aligned floatbuffer with the specified number
158 * of elements.
159 *
160 * @param size The size, in floats
161 *
162 * @return a FloatBuffer
163 */
164 public static FloatBuffer createFloatBuffer(int size) {
165 return createByteBuffer(size << 2).asFloatBuffer();
166 }
167
168 /**
169 * Construct a direct, native-ordered and cache-line-aligned doublebuffer with the specified number
170 * of elements.
171 *
172 * @param size The size, in floats
173 *
174 * @return a FloatBuffer
175 */
176 public static DoubleBuffer createDoubleBuffer(int size) {
177 return createByteBuffer(size << 3).asDoubleBuffer();
178 }
179
180 /**
181 * Construct a cache-line-aligned PointerBuffer with the specified number
182 * of elements.
183 *
184 * @param size The size, in memory addresses
185 *
186 * @return a PointerBuffer
187 */
188 public static PointerBuffer createPointerBuffer(int size) {
189 return new PointerBuffer(createByteBuffer(size * PointerBuffer.getPointerSize()));
190 }
191
192 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Retention;
35 import java.lang.annotation.RetentionPolicy;
36 import java.lang.annotation.Target;
37
38 /**
39 * This annotation can be used on fields of {@link MappedObject} subclasses,
40 * to manually specify byte offsets and lengths. This is useful when the
41 * mapped fields require custom alignment. {@link java.nio.ByteBuffer}
42 * fields are required to have this annotation with a hardcoded byte length.
43 *
44 * @author Riven
45 */
46 @Retention(RetentionPolicy.RUNTIME)
47 @Target(ElementType.FIELD)
48 public @interface MappedField {
49
50 /**
51 * Specifies the field byte offset within the mapped object.
52 *
53 * @return the field byte offset
54 */
55 long byteOffset() default -1;
56
57 /**
58 * Specifies the field byte length. Required for {@link java.nio.ByteBuffer} fields.
59 *
60 * @return the field byte length
61 */
62 long byteLength() default -1;
63
64 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.util.Iterator;
34
35 /**
36 * Iterable implementation for {@link MappedObject}.
37 *
38 * @author Riven
39 */
40 final class MappedForeach<T extends MappedObject> implements Iterable<T> {
41
42 final T mapped;
43 final int elementCount;
44
45 MappedForeach(T mapped, int elementCount) {
46 this.mapped = mapped;
47 this.elementCount = elementCount;
48 }
49
50 public Iterator<T> iterator() {
51 return new Iterator<T>() {
52
53 private int index;
54
55 public boolean hasNext() {
56 return this.index < (MappedForeach.this.elementCount);
57 }
58
59 public T next() {
60 mapped.setViewAddress(mapped.getViewAddress(this.index++));
61 return mapped;
62 }
63
64 public void remove() {
65 throw new UnsupportedOperationException();
66 }
67 };
68 }
69
70 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.LWJGLUtil;
34 import org.lwjgl.MemoryUtil;
35
36 import java.nio.ByteBuffer;
37
38 import static org.lwjgl.util.mapped.MappedObjectUnsafe.*;
39
40 /**
41 * [INTERNAL USE ONLY]
42 * <p/>
43 * Helper class used by the bytecode transformer.
44 *
45 * @author Riven
46 */
47 public class MappedHelper {
48
49 public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
50 if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L )
51 throw new IllegalStateException("this method should not be called by user-code");
52
53 if ( LWJGLUtil.CHECKS && !buffer.isDirect() )
54 throw new IllegalArgumentException("bytebuffer must be direct");
55 mo.preventGC = buffer;
56
57 if ( LWJGLUtil.CHECKS && align <= 0 )
58 throw new IllegalArgumentException("invalid alignment");
59
60 if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
61 throw new IllegalStateException("sizeof not a multiple of alignment");
62
63 long addr = MemoryUtil.getAddress(buffer);
64 if ( LWJGLUtil.CHECKS && addr % align != 0 )
65 throw new IllegalStateException("buffer address not aligned on " + align + " bytes");
66
67 mo.baseAddress = mo.viewAddress = addr;
68 }
69
70 public static void checkAddress(long viewAddress, MappedObject mapped) {
71 mapped.checkAddress(viewAddress);
72 }
73
74 public static void put_views(MappedSet2 set, int view) {
75 set.view(view);
76 }
77
78 public static void put_views(MappedSet3 set, int view) {
79 set.view(view);
80 }
81
82 public static void put_views(MappedSet4 set, int view) {
83 set.view(view);
84 }
85
86 public static void put_view(MappedObject mapped, int view, int sizeof) {
87 mapped.setViewAddress(mapped.baseAddress + view * sizeof);
88 }
89
90 public static int get_view(MappedObject mapped, int sizeof) {
91 return (int)(mapped.viewAddress - mapped.baseAddress) / sizeof;
92 }
93
94 public static void put_view_shift(MappedObject mapped, int view, int sizeof_shift) {
95 mapped.setViewAddress(mapped.baseAddress + (view << sizeof_shift));
96 }
97
98 public static int get_view_shift(MappedObject mapped, int sizeof_shift) {
99 return ((int)(mapped.viewAddress - mapped.baseAddress)) >> sizeof_shift;
100 }
101
102 public static void put_view_next(MappedObject mapped, int sizeof) {
103 mapped.setViewAddress(mapped.viewAddress + sizeof);
104 }
105
106 public static MappedObject dup(MappedObject src, MappedObject dst) {
107 dst.baseAddress = src.baseAddress;
108 dst.viewAddress = src.viewAddress;
109 dst.preventGC = src.preventGC;
110 return dst;
111 }
112
113 public static MappedObject slice(MappedObject src, MappedObject dst) {
114 dst.baseAddress = src.viewAddress; // !
115 dst.viewAddress = src.viewAddress;
116 dst.preventGC = src.preventGC;
117 return dst;
118 }
119
120 public static void copy(MappedObject src, MappedObject dst, int bytes) {
121 if ( MappedObject.CHECKS ) {
122 src.checkRange(bytes);
123 dst.checkRange(bytes);
124 }
125
126 INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
127 }
128
129 public static ByteBuffer newBuffer(long address, int capacity) {
130 return MappedObjectUnsafe.newBuffer(address, capacity);
131 }
132
133 // ---- primitive fields read/write
134
135 // byte
136
137 public static void bput(byte value, long addr) {
138 INSTANCE.putByte(addr, value);
139 }
140
141 public static void bput(MappedObject mapped, byte value, int fieldOffset) {
142 INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
143 }
144
145 public static byte bget(long addr) {
146 return INSTANCE.getByte(addr);
147 }
148
149 public static byte bget(MappedObject mapped, int fieldOffset) {
150 return INSTANCE.getByte(mapped.viewAddress + fieldOffset);
151 }
152
153 public static void bvput(byte value, long addr) {
154 INSTANCE.putByteVolatile(null, addr, value);
155 }
156
157 public static void bvput(MappedObject mapped, byte value, int fieldOffset) {
158 INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
159 }
160
161 public static byte bvget(long addr) {
162 return INSTANCE.getByteVolatile(null, addr);
163 }
164
165 public static byte bvget(MappedObject mapped, int fieldOffset) {
166 return INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
167 }
168
169 // short
170
171 public static void sput(short value, long addr) {
172 INSTANCE.putShort(addr, value);
173 }
174
175 public static void sput(MappedObject mapped, short value, int fieldOffset) {
176 INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
177 }
178
179 public static short sget(long addr) {
180 return INSTANCE.getShort(addr);
181 }
182
183 public static short sget(MappedObject mapped, int fieldOffset) {
184 return INSTANCE.getShort(mapped.viewAddress + fieldOffset);
185 }
186
187 public static void svput(short value, long addr) {
188 INSTANCE.putShortVolatile(null, addr, value);
189 }
190
191 public static void svput(MappedObject mapped, short value, int fieldOffset) {
192 INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
193 }
194
195 public static short svget(long addr) {
196 return INSTANCE.getShortVolatile(null, addr);
197 }
198
199 public static short svget(MappedObject mapped, int fieldOffset) {
200 return INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
201 }
202
203 // char
204
205 public static void cput(char value, long addr) {
206 INSTANCE.putChar(addr, value);
207 }
208
209 public static void cput(MappedObject mapped, char value, int fieldOffset) {
210 INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
211 }
212
213 public static char cget(long addr) {
214 return INSTANCE.getChar(addr);
215 }
216
217 public static char cget(MappedObject mapped, int fieldOffset) {
218 return INSTANCE.getChar(mapped.viewAddress + fieldOffset);
219 }
220
221 public static void cvput(char value, long addr) {
222 INSTANCE.putCharVolatile(null, addr, value);
223 }
224
225 public static void cvput(MappedObject mapped, char value, int fieldOffset) {
226 INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
227 }
228
229 public static char cvget(long addr) {
230 return INSTANCE.getCharVolatile(null, addr);
231 }
232
233 public static char cvget(MappedObject mapped, int fieldOffset) {
234 return INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
235 }
236
237 // int
238
239 public static void iput(int value, long addr) {
240 INSTANCE.putInt(addr, value);
241 }
242
243 public static void iput(MappedObject mapped, int value, int fieldOffset) {
244 INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
245 }
246
247 public static int iget(long address) {
248 return INSTANCE.getInt(address);
249 }
250
251 public static int iget(MappedObject mapped, int fieldOffset) {
252 return INSTANCE.getInt(mapped.viewAddress + fieldOffset);
253 }
254
255 public static void ivput(int value, long addr) {
256 INSTANCE.putIntVolatile(null, addr, value);
257 }
258
259 public static void ivput(MappedObject mapped, int value, int fieldOffset) {
260 INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
261 }
262
263 public static int ivget(long address) {
264 return INSTANCE.getIntVolatile(null, address);
265 }
266
267 public static int ivget(MappedObject mapped, int fieldOffset) {
268 return INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
269 }
270
271 // float
272
273 public static void fput(float value, long addr) {
274 INSTANCE.putFloat(addr, value);
275 }
276
277 public static void fput(MappedObject mapped, float value, int fieldOffset) {
278 INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
279 }
280
281 public static float fget(long addr) {
282 return INSTANCE.getFloat(addr);
283 }
284
285 public static float fget(MappedObject mapped, int fieldOffset) {
286 return INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
287 }
288
289 public static void fvput(float value, long addr) {
290 INSTANCE.putFloatVolatile(null, addr, value);
291 }
292
293 public static void fvput(MappedObject mapped, float value, int fieldOffset) {
294 INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
295 }
296
297 public static float fvget(long addr) {
298 return INSTANCE.getFloatVolatile(null, addr);
299 }
300
301 public static float fvget(MappedObject mapped, int fieldOffset) {
302 return INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
303 }
304
305 // long
306
307 public static void jput(long value, long addr) {
308 INSTANCE.putLong(addr, value);
309 }
310
311 public static void jput(MappedObject mapped, long value, int fieldOffset) {
312 INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
313 }
314
315 public static long jget(long addr) {
316 return INSTANCE.getLong(addr);
317 }
318
319 public static long jget(MappedObject mapped, int fieldOffset) {
320 return INSTANCE.getLong(mapped.viewAddress + fieldOffset);
321 }
322
323 public static void jvput(long value, long addr) {
324 INSTANCE.putLongVolatile(null, addr, value);
325 }
326
327 public static void jvput(MappedObject mapped, long value, int fieldOffset) {
328 INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
329 }
330
331 public static long jvget(long addr) {
332 return INSTANCE.getLongVolatile(null, addr);
333 }
334
335 public static long jvget(MappedObject mapped, int fieldOffset) {
336 return INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
337 }
338
339 // address
340
341 public static void aput(long value, long addr) {
342 INSTANCE.putAddress(addr, value);
343 }
344
345 public static void aput(MappedObject mapped, long value, int fieldOffset) {
346 INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
347 }
348
349 public static long aget(long addr) {
350 return INSTANCE.getAddress(addr);
351 }
352
353 public static long aget(MappedObject mapped, int fieldOffset) {
354 return INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
355 }
356
357 // double
358
359 public static void dput(double value, long addr) {
360 INSTANCE.putDouble(addr, value);
361 }
362
363 public static void dput(MappedObject mapped, double value, int fieldOffset) {
364 INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
365 }
366
367 public static double dget(long addr) {
368 return INSTANCE.getDouble(addr);
369 }
370
371 public static double dget(MappedObject mapped, int fieldOffset) {
372 return INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
373 }
374
375 public static void dvput(double value, long addr) {
376 INSTANCE.putDoubleVolatile(null, addr, value);
377 }
378
379 public static void dvput(MappedObject mapped, double value, int fieldOffset) {
380 INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
381 }
382
383 public static double dvget(long addr) {
384 return INSTANCE.getDoubleVolatile(null, addr);
385 }
386
387 public static double dvget(MappedObject mapped, int fieldOffset) {
388 return INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
389 }
390
391 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.LWJGLUtil;
34 import org.lwjgl.MemoryUtil;
35
36 import java.nio.BufferOverflowException;
37 import java.nio.ByteBuffer;
38
39 /**
40 * Base superclass of all mapped objects. Classes that require
41 * data mapping should extend this class and registered with
42 * {@link MappedObjectTransformer#register(Class)}.
43 * <p/>
44 * Subclasses may only specify the default constructor. Any code
45 * inside that constructor is optional, but will not run when the
46 * view is instantiated, see {@link #runViewConstructor()}.
47 * <p/>
48 * Bounds checking may be enabled through a JVM system property: org.lwjgl.util.mapped.Checks=true
49 *
50 * @author Riven
51 */
52 public abstract class MappedObject {
53
54 static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
55
56 protected MappedObject() {
57 //
58 }
59
60 /** The mapped object base memory address, in bytes. Read-only. */
61 public long baseAddress;
62
63 /** The mapped object view memory address, in bytes. Read-only. */
64 public long viewAddress;
65
66 /** The mapped buffer. */
67 ByteBuffer preventGC;
68
69 /**
70 * Holds the value of sizeof of the sub-type of this MappedObject<br>
71 * <br>
72 * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
73 * <code>Vec2.SIZEOF</code> will yield 8 (2 floats)<br>
74 * <code>Vec3.SIZEOF</code> will yield 12 (3 floats)<br>
75 * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
76 * Using Java 5.0's static-import on this method will break functionality.
77 */
78 public static int SIZEOF = -1; // any method that calls these field will have its call-site modified ('final' per subtype)
79
80 /**
81 * The mapped object view offset, in elements. Read/write.
82 * This is a virtual field, used as a convenient getter/setter for {@see viewAddress}.
83 */
84 public int view;
85
86 protected final long getViewAddress(final int view) {
87 // No call-site modification for this, we override in every subclass instead,
88 // so that we can use it in MappedForeach.
89 throw new InternalError("type not registered");
90 }
91
92 public final void setViewAddress(final long address) {
93 if ( CHECKS )
94 checkAddress(address);
95 this.viewAddress = address;
96 }
97
98 final void checkAddress(final long address) {
99 final long base = MemoryUtil.getAddress0(preventGC);
100 final int offset = (int)(address - base);
101 if ( address < base || preventGC.capacity() < (offset + getSizeof()) )
102 throw new IndexOutOfBoundsException(Integer.toString(offset / getSizeof()));
103 }
104
105 final void checkRange(final int bytes) {
106 if ( bytes < 0 )
107 throw new IllegalArgumentException();
108
109 if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) )
110 throw new BufferOverflowException();
111 }
112
113 /** The mapped object memory alignment, in bytes. Read-only. */
114 /**
115 * Returns the mapped object memory alignment, in bytes.
116 *
117 * @return the memory alignment
118 */
119 public final int getAlign() {
120 // No call-site modification for this, we override in every subclass instead.
121 throw new InternalError("type not registered");
122 }
123
124 /**
125 * Returns the mapped object memory sizeof, in bytes.
126 *
127 * @return the sizeof value
128 */
129 public final int getSizeof() {
130 // No call-site modification for this, we override in every subclass instead.
131 throw new InternalError("type not registered");
132 }
133
134 /**
135 * Returns the number of mapped objects that fit in the mapped buffer.
136 *
137 * @return the mapped object capacity
138 */
139 public final int capacity() {
140 // No call-site modification for this, we override in every subclass instead.
141 throw new InternalError("type not registered");
142 }
143
144 /**
145 * Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer.
146 * <p/>
147 * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
148 * <code>Vec2.map(buffer)</code> will return a mapped Vec2 instance.<br>
149 * <code>Vec3.map(buffer)</code> will return a mapped Vec3 instance.<br>
150 * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
151 * Using Java 5.0's static-import on this method will break functionality.
152 */
153 @SuppressWarnings("unused")
154 public static <T extends MappedObject> T map(ByteBuffer bb) {
155 // any method that calls this method will have its call-site modified
156 throw new InternalError("type not registered");
157 }
158
159 /**
160 * Creates a MappedObject instance, mapping the memory region specified. This is useful for mapping
161 * arbitrary regions in memory, e.g. OpenCL CLMem objects, without creating a ByteBuffer first.
162 * <p/>
163 * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
164 * <code>Vec2.map(buffer)</code> will return a mapped Vec2 instance.<br>
165 * <code>Vec3.map(buffer)</code> will return a mapped Vec3 instance.<br>
166 * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
167 * Using Java 5.0's static-import on this method will break functionality.
168 */
169 @SuppressWarnings("unused")
170 public static <T extends MappedObject> T map(long address, int capacity) {
171 // any method that calls this method will have its call-site modified
172 throw new InternalError("type not registered");
173 }
174
175 /**
176 * Creates a MappedObject instance, mapping the memory region of an allocated direct ByteBuffer with a capacity of <code>elementCount*SIZEOF</code>
177 * <p/>
178 * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
179 * <code>Vec2.malloc(int)</code> will return a mapped Vec2 instance.<br>
180 * <code>Vec3.malloc(int)</code> will return a mapped Vec3 instance.<br>
181 * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
182 * Using Java 5.0's static-import on this method will break functionality.
183 */
184 @SuppressWarnings("unused")
185 public static <T extends MappedObject> T malloc(int elementCount) {
186 // any method that calls this method will have its call-site modified
187 throw new InternalError("type not registered");
188 }
189
190 /**
191 * Creates an identical new MappedObject instance, comparable to the
192 * contract of {@link java.nio.ByteBuffer#duplicate}. This is useful when more than one
193 * views of the mapped object are required at the same time, e.g. in
194 * multithreaded access.
195 */
196 public final <T extends MappedObject> T dup() {
197 // any method that calls this method will have its call-site modified
198 throw new InternalError("type not registered");
199 }
200
201 /**
202 * Creates a new MappedObject instance, with a base offset equal to
203 * the offset of the current view, comparable to the contract of {@link java.nio.ByteBuffer#slice}.
204 */
205 public final <T extends MappedObject> T slice() {
206 // any method that calls this method will have its call-site modified
207 throw new InternalError("type not registered");
208 }
209
210 /**
211 * Any code in the default constructor will not run automatically. This method
212 * can be used to execute that code on the current view.
213 */
214 public final void runViewConstructor() {
215 // any method that calls this method will have its call-site modified
216 throw new InternalError("type not registered");
217 }
218
219 /** Moves the current view to the next element. */
220 public final void next() {
221 // No call-site modification for this, we override in every subclass instead,
222 // so that we can use it in MappedSetX.
223 throw new InternalError("type not registered");
224 }
225
226 /**
227 * Copies and amount of <code>SIZEOF - padding</code> bytes, from the current
228 * mapped object, to the specified mapped object.
229 */
230 @SuppressWarnings("unused")
231 public final <T extends MappedObject> void copyTo(T target) {
232 // any method that calls this method will have its call-site modified
233 throw new InternalError("type not registered");
234 }
235
236 /**
237 * Copies and amount of <code>SIZEOF * instances</code> bytes, from the
238 * current mapped object, to the specified mapped object. Note that
239 * this includes any padding bytes that are part of SIZEOF.
240 */
241 @SuppressWarnings("unused")
242 public final <T extends MappedObject> void copyRange(T target, int instances) {
243 // any method that calls this method will have its call-site modified
244 throw new InternalError("type not registered");
245 }
246
247 /**
248 * Creates an {@link Iterable} <MappedObject> that will step through
249 * <code>capacity()</code> views, leaving the <code>view</code> at
250 * the last valid value.<br>
251 * <p/>
252 * For convenience you are encouraged to static-import this specific method:
253 * <code>import static org.lwjgl.util.mapped.MappedObject.foreach;</code>
254 */
255 public static <T extends MappedObject> Iterable<T> foreach(T mapped) {
256 return foreach(mapped, mapped.capacity());
257 }
258
259 /**
260 * Creates an {@link Iterable} <MappedObject> that will step through
261 * <code>elementCount</code> views, leaving the <code>view</code> at
262 * the last valid value.<br>
263 * <p/>
264 * For convenience you are encouraged to static-import this specific method:
265 * <code>import static org.lwjgl.util.mapped.MappedObject.foreach;</code>
266 */
267 public static <T extends MappedObject> Iterable<T> foreach(T mapped, int elementCount) {
268 return new MappedForeach<T>(mapped, elementCount);
269 }
270
271 @SuppressWarnings("unused")
272 public final <T extends MappedObject> T[] asArray() {
273 // any method that calls this method will have its call-site modified
274 throw new InternalError("type not registered");
275 }
276
277 /**
278 * Returns the {@link java.nio.ByteBuffer} that backs this mapped object.
279 *
280 * @return the backing buffer
281 */
282 public final ByteBuffer backingByteBuffer() {
283 return this.preventGC;
284 }
285
286 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.LWJGLUtil;
34
35 import java.io.IOException;
36 import java.io.InputStream;
37 import java.lang.reflect.InvocationTargetException;
38 import java.lang.reflect.Method;
39 import java.net.URLClassLoader;
40
41 /**
42 * This classloader is responsible for applying the bytecode transformation to mapped objects.
43 * The transformation can either be applied using a Java agent, or with the convenient {@link #fork} method.
44 *
45 * @author Riven
46 */
47 public class MappedObjectClassLoader extends URLClassLoader {
48
49 static final String MAPPEDOBJECT_PACKAGE_PREFIX = MappedObjectClassLoader.class.getPackage().getName() + ".";
50
51 static boolean FORKED;
52
53 /**
54 * Forks the specified class containing a main method, passing the specified arguments. See
55 * {@link org.lwjgl.test.mapped.TestMappedObject} for example usage.
56 *
57 * @param mainClass the class containing the main method
58 * @param args the arguments to pass
59 *
60 * @return true if the fork was successful.
61 */
62 public static boolean fork(Class<?> mainClass, String[] args) {
63 if ( FORKED ) {
64 return false;
65 }
66
67 FORKED = true;
68
69 try {
70 MappedObjectClassLoader loader = new MappedObjectClassLoader(mainClass);
71 loader.loadMappedObject();
72
73 Class<?> replacedMainClass = loader.loadClass(mainClass.getName());
74 Method mainMethod = replacedMainClass.getMethod("main", String[].class);
75 mainMethod.invoke(null, new Object[] { args });
76 } catch (InvocationTargetException exc) {
77 Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), exc.getCause());
78 } catch (Throwable cause) {
79 throw new Error("failed to fork", cause);
80 }
81
82 return true;
83 }
84
85 private MappedObjectClassLoader(Class<?> mainClass) {
86 super(((URLClassLoader)mainClass.getClassLoader()).getURLs());
87 }
88
89 protected synchronized Class<?> loadMappedObject() throws ClassNotFoundException {
90 final String name = MappedObject.class.getName();
91 String className = name.replace('.', '/');
92
93 byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
94
95 long t0 = System.nanoTime();
96 bytecode = MappedObjectTransformer.transformMappedObject(bytecode);
97 long t1 = System.nanoTime();
98 total_time_transforming += (t1 - t0);
99
100 if ( MappedObjectTransformer.PRINT_ACTIVITY )
101 printActivity(className, t0, t1);
102
103 Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
104 resolveClass(clazz);
105 return clazz;
106 }
107
108 private static long total_time_transforming;
109
110 @Override
111 protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
112 if ( name.startsWith("java.")
113 || name.startsWith("javax.")
114 || name.startsWith("sun.")
115 || name.startsWith("sunw.")
116 || name.startsWith("org.objectweb.asm.")
117 )
118 return super.loadClass(name, resolve);
119
120 final String className = name.replace('.', '/');
121 final boolean inThisPackage = name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX);
122
123 if ( inThisPackage && (
124 name.equals(MappedObjectClassLoader.class.getName())
125 || name.equals((MappedObjectTransformer.class.getName()))
126 || name.equals((CacheUtil.class.getName()))
127 ) )
128 return super.loadClass(name, resolve);
129
130 byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
131
132 // Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject.
133 if ( !(inThisPackage && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) {
134 long t0 = System.nanoTime();
135 final byte[] newBytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
136 long t1 = System.nanoTime();
137
138 total_time_transforming += (t1 - t0);
139
140 if ( bytecode != newBytecode ) {
141 bytecode = newBytecode;
142 if ( MappedObjectTransformer.PRINT_ACTIVITY )
143 printActivity(className, t0, t1);
144 }
145 }
146
147 Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
148 if ( resolve )
149 resolveClass(clazz);
150 return clazz;
151 }
152
153 private static void printActivity(final String className, final long t0, final long t1) {
154 final StringBuilder msg = new StringBuilder(MappedObjectClassLoader.class.getSimpleName() + ": " + className);
155
156 if ( MappedObjectTransformer.PRINT_TIMING )
157 msg.append("\n\ttransforming took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
158
159 LWJGLUtil.log(msg);
160 }
161
162 private static byte[] readStream(InputStream in) {
163 byte[] bytecode = new byte[256];
164 int len = 0;
165 try {
166 while ( true ) {
167 if ( bytecode.length == len )
168 bytecode = copyOf(bytecode, len * 2);
169 int got = in.read(bytecode, len, bytecode.length - len);
170 if ( got == -1 )
171 break;
172 len += got;
173 }
174 } catch (IOException exc) {
175 // stop!
176 } finally {
177 try {
178 in.close();
179 } catch (IOException exc) {
180 // ignore...
181 }
182 }
183 return copyOf(bytecode, len);
184 }
185
186 private static byte[] copyOf(byte[] original, int newLength) {
187 byte[] copy = new byte[newLength];
188 System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
189 return copy;
190 }
191
192 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.MemoryUtil;
36 import org.objectweb.asm.*;
37 import org.objectweb.asm.tree.*;
38 import org.objectweb.asm.tree.analysis.*;
39 import org.objectweb.asm.tree.analysis.Frame;
40 import org.objectweb.asm.util.TraceClassVisitor;
41
42 import java.io.PrintWriter;
43 import java.io.StringWriter;
44 import java.lang.reflect.Field;
45 import java.lang.reflect.Modifier;
46 import java.nio.Buffer;
47 import java.nio.ByteBuffer;
48 import java.util.HashMap;
49 import java.util.Map;
50
51 import static org.objectweb.asm.ClassWriter.*;
52 import static org.objectweb.asm.Opcodes.*;
53
54 /**
55 * This class implements the bytecode transformation that mapped object go through.
56 * Mapped object classes need to first be registered with the transformer, see {@link #register(Class)}.
57 * <p/>
58 * The transformer supports some debugging tools, enabled through JVM system properties:<br/>
59 * org.lwjgl.util.mapped.PrintTiming=true, prints timing information for the transformation step.<br/>
60 * org.lwjgl.util.mapped.PrintActivity=true, prints activity information.<br/>
61 * org.lwjgl.util.mapped.PrintBytecode=true, prints the transformed bytecode.<br/>
62 * org.lwjgl.util.Debug must also be set to true for the above to work.
63 *
64 * @author Riven
65 */
66 public class MappedObjectTransformer {
67
68 static final boolean PRINT_ACTIVITY = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
69 static final boolean PRINT_TIMING = PRINT_ACTIVITY && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
70 static final boolean PRINT_BYTECODE = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
71
72 static final Map<String, MappedSubtypeInfo> className_to_subtype;
73
74 static final String MAPPED_OBJECT_JVM = jvmClassName(MappedObject.class);
75 static final String MAPPED_HELPER_JVM = jvmClassName(MappedHelper.class);
76
77 static final String MAPPEDSET_PREFIX = jvmClassName(MappedSet.class);
78 static final String MAPPED_SET2_JVM = jvmClassName(MappedSet2.class);
79 static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class);
80 static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class);
81
82 static final String CACHE_LINE_PAD_JVM = "L" + jvmClassName(CacheLinePad.class) + ";";
83
84 // Public methods
85 static final String VIEWADDRESS_METHOD_NAME = "getViewAddress";
86 static final String NEXT_METHOD_NAME = "next";
87 static final String ALIGN_METHOD_NAME = "getAlign";
88 static final String SIZEOF_METHOD_NAME = "getSizeof";
89 static final String CAPACITY_METHOD_NAME = "capacity"; // Used for .asArray().length
90
91 // Internal methods
92 static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; // Used by runViewConstructor
93
94 static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>();
95 static final Map<Integer, String> INSNTYPE_TO_NAME = new HashMap<Integer, String>();
96
97 static boolean is_currently_computing_frames;
98
99 static {
100 getClassEnums(Opcodes.class, OPCODE_TO_NAME, "V1_", "ACC_", "T_", "F_", "MH_");
101 getClassEnums(AbstractInsnNode.class, INSNTYPE_TO_NAME);
102
103 className_to_subtype = new HashMap<String, MappedSubtypeInfo>();
104
105 {
106 // HACK: required for mapped.view++
107 //
108 // because the compiler generates:
109 // => GETFIELD MappedObject.view
110 // => ICONST_1
111 // => IADD
112 // => PUTFIELD MyMappedType.view
113 //
114 // instead of:
115 // => GETFIELD MyMappedType.view
116 // => ICONST_1
117 // => IADD
118 // => PUTFIELD MyMappedType.view
119 //
120 className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1, -1, false));
121 }
122
123 final String vmName = System.getProperty("java.vm.name");
124 if ( vmName != null && !vmName.contains("Server") ) {
125 System.err.println("Warning: " + MappedObject.class.getSimpleName() + "s have inferiour performance on Client VMs, please consider switching to a Server VM.");
126 }
127 }
128
129 /**
130 * Registers a class as a mapped object.
131 * The class must extend {@link org.lwjgl.util.mapped.MappedObject} and be annotated with {@link org.lwjgl.util.mapped.MappedField}.
132 *
133 * @param type the mapped object class.
134 */
135 public static void register(Class<? extends MappedObject> type) {
136 if ( MappedObjectClassLoader.FORKED )
137 return;
138
139 final MappedType mapped = type.getAnnotation(MappedType.class);
140
141 if ( mapped != null && mapped.padding() < 0 )
142 throw new ClassFormatError("Invalid mapped type padding: " + mapped.padding());
143
144 if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) )
145 throw new InternalError("only top-level or static inner classes are allowed");
146
147 final String className = jvmClassName(type);
148 final Map<String, FieldInfo> fields = new HashMap<String, FieldInfo>();
149
150 long sizeof = 0;
151 for ( Field field : type.getDeclaredFields() ) {
152 FieldInfo fieldInfo = registerField(mapped == null || mapped.autoGenerateOffsets(), className, sizeof, field);
153 if ( fieldInfo == null )
154 continue;
155
156 fields.put(field.getName(), fieldInfo);
157
158 sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.lengthPadded);
159 }
160
161 int align = 4;
162 int padding = 0;
163 boolean cacheLinePadded = false;
164
165 if ( mapped != null ) {
166 align = mapped.align();
167 if ( mapped.cacheLinePadding() ) {
168 if ( mapped.padding() != 0 )
169 throw new ClassFormatError("Mapped type padding cannot be specified together with cacheLinePadding.");
170
171 final int cacheLineMod = (int)(sizeof % CacheUtil.getCacheLineSize());
172 if ( cacheLineMod != 0 )
173 padding = CacheUtil.getCacheLineSize() - cacheLineMod;
174
175 cacheLinePadded = true;
176 } else
177 padding = mapped.padding();
178 }
179
180 sizeof += padding;
181
182 final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, align, padding, cacheLinePadded);
183 if ( className_to_subtype.put(className, mappedType) != null )
184 throw new InternalError("duplicate mapped type: " + mappedType.className);
185 }
186
187 private static FieldInfo registerField(final boolean autoGenerateOffsets, final String className, long advancingOffset, final Field field) {
188 if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped
189 return null;
190
191 // we only support primitives and ByteBuffers
192 if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class )
193 throw new ClassFormatError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
194
195 MappedField meta = field.getAnnotation(MappedField.class);
196 if ( meta == null && !autoGenerateOffsets )
197 throw new ClassFormatError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
198
199 Pointer pointer = field.getAnnotation(Pointer.class);
200 if ( pointer != null && field.getType() != long.class )
201 throw new ClassFormatError("The @Pointer annotation can only be used on long fields. @Pointer field found: " + className + "." + field.getName() + ": " + field.getType());
202
203 if ( Modifier.isVolatile(field.getModifiers()) && (pointer != null || field.getType() == ByteBuffer.class) )
204 throw new ClassFormatError("The volatile keyword is not supported for @Pointer or ByteBuffer fields. Volatile field found: " + className + "." + field.getName() + ": " + field.getType());
205
206 // quick hack
207 long byteLength;
208 if ( field.getType() == long.class || field.getType() == double.class ) {
209 if ( pointer == null )
210 byteLength = 8;
211 else
212 byteLength = MappedObjectUnsafe.INSTANCE.addressSize();
213 } else if ( field.getType() == double.class )
214 byteLength = 8;
215 else if ( field.getType() == int.class || field.getType() == float.class )
216 byteLength = 4;
217 else if ( field.getType() == char.class || field.getType() == short.class )
218 byteLength = 2;
219 else if ( field.getType() == byte.class )
220 byteLength = 1;
221 else if ( field.getType() == ByteBuffer.class ) {
222 byteLength = meta.byteLength();
223 if ( byteLength < 0 )
224 throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]");
225 } else
226 throw new ClassFormatError(field.getType().getName());
227
228 if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 )
229 throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName());
230
231 CacheLinePad pad = field.getAnnotation(CacheLinePad.class);
232
233 long byteOffset = advancingOffset;
234 if ( meta != null && meta.byteOffset() != -1 ) {
235 if ( meta.byteOffset() < 0 )
236 throw new ClassFormatError("Invalid field byte offset: " + className + "." + field.getName() + " [byteOffset=" + meta.byteOffset() + "]");
237 if ( pad != null )
238 throw new ClassFormatError("A field byte offset cannot be specified together with cache-line padding: " + className + "." + field.getName());
239
240 byteOffset = meta.byteOffset();
241 }
242
243 long byteLengthPadded = byteLength;
244 if ( pad != null ) {
245 // Pad before
246 if ( pad.before() && byteOffset % CacheUtil.getCacheLineSize() != 0 )
247 byteOffset += CacheUtil.getCacheLineSize() - (byteOffset & (CacheUtil.getCacheLineSize() - 1));
248
249 // Pad after
250 if ( pad.after() && (byteOffset + byteLength) % CacheUtil.getCacheLineSize() != 0 )
251 byteLengthPadded += CacheUtil.getCacheLineSize() - (byteOffset + byteLength) % CacheUtil.getCacheLineSize();
252
253 assert !pad.before() || (byteOffset % CacheUtil.getCacheLineSize() == 0);
254 assert !pad.after() || ((byteOffset + byteLengthPadded) % CacheUtil.getCacheLineSize() == 0);
255 }
256
257 if ( PRINT_ACTIVITY )
258 LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
259
260 return new FieldInfo(byteOffset, byteLength, byteLengthPadded, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null);
261 }
262
263 /** Removes final from methods that will be overriden by subclasses. */
264 static byte[] transformMappedObject(byte[] bytecode) {
265 final ClassWriter cw = new ClassWriter(0);
266
267 ClassVisitor cv = new ClassAdapter(cw) {
268
269 private final String[] DEFINALIZE_LIST = {
270 VIEWADDRESS_METHOD_NAME,
271 NEXT_METHOD_NAME,
272 ALIGN_METHOD_NAME,
273 SIZEOF_METHOD_NAME,
274 CAPACITY_METHOD_NAME,
275 };
276
277 public MethodVisitor visitMethod(int access, final String name, final String desc, final String signature, final String[] exceptions) {
278 for ( String method : DEFINALIZE_LIST ) {
279 if ( name.equals(method) ) {
280 access &= ~ACC_FINAL;
281 break;
282 }
283 }
284 return super.visitMethod(access, name, desc, signature, exceptions);
285 }
286 };
287
288 new ClassReader(bytecode).accept(cv, 0);
289 return cw.toByteArray();
290 }
291
292 static byte[] transformMappedAPI(final String className, byte[] bytecode) {
293 final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES) {
294
295 @Override
296 protected String getCommonSuperClass(String a, String b) {
297 // HACK: prevent user-code static-initialization-blocks to be executed
298 if ( is_currently_computing_frames && !a.startsWith("java/") || !b.startsWith("java/") )
299 return "java/lang/Object";
300
301 return super.getCommonSuperClass(a, b);
302 }
303
304 };
305
306 final TransformationAdapter ta = new TransformationAdapter(cw, className);
307
308 ClassVisitor cv = ta;
309 if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters
310 cv = getMethodGenAdapter(className, cv);
311
312 new ClassReader(bytecode).accept(cv, ClassReader.SKIP_FRAMES);
313
314 if ( !ta.transformed )
315 return bytecode;
316
317 bytecode = cw.toByteArray();
318 if ( PRINT_BYTECODE )
319 printBytecode(bytecode);
320
321 return bytecode;
322 }
323
324 private static ClassAdapter getMethodGenAdapter(final String className, final ClassVisitor cv) {
325 return new ClassAdapter(cv) {
326
327 @Override
328 public void visitEnd() {
329 final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
330
331 generateViewAddressGetter();
332 generateCapacity();
333 generateAlignGetter(mappedSubtype);
334 generateSizeofGetter();
335 generateNext();
336
337 for ( String fieldName : mappedSubtype.fields.keySet() ) {
338 final FieldInfo field = mappedSubtype.fields.get(fieldName);
339
340 if ( field.type.getDescriptor().length() > 1 ) { // ByteBuffer, getter only
341 generateByteBufferGetter(fieldName, field);
342 } else {
343 generateFieldGetter(fieldName, field);
344 generateFieldSetter(fieldName, field);
345 }
346 }
347
348 super.visitEnd();
349 }
350
351 private void generateViewAddressGetter() {
352 MethodVisitor mv = super.visitMethod(ACC_PUBLIC, VIEWADDRESS_METHOD_NAME, "(I)J", null, null);
353 mv.visitCode();
354 mv.visitVarInsn(ALOAD, 0);
355 mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "baseAddress", "J");
356 mv.visitVarInsn(ILOAD, 1);
357 mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
358 mv.visitInsn(IMUL);
359 mv.visitInsn(I2L);
360 mv.visitInsn(LADD);
361 if ( MappedObject.CHECKS ) {
362 mv.visitInsn(DUP2);
363 mv.visitVarInsn(ALOAD, 0);
364 mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "checkAddress", "(JL" + MAPPED_OBJECT_JVM + ";)V");
365 }
366 mv.visitInsn(LRETURN);
367 mv.visitMaxs(3, 2);
368 mv.visitEnd();
369 }
370
371 private void generateCapacity() {
372 // return (backingByteBuffer().capacity() + (int)(MemoryUtil.getAddress0(backingByteBuffer()) - baseAddress)) / SIZEOF;
373 MethodVisitor mv = super.visitMethod(ACC_PUBLIC, CAPACITY_METHOD_NAME, "()I", null, null);
374 mv.visitCode();
375 mv.visitVarInsn(ALOAD, 0);
376 mv.visitMethodInsn(INVOKEVIRTUAL, MAPPED_OBJECT_JVM, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";");
377 mv.visitInsn(DUP);
378 mv.visitMethodInsn(INVOKEVIRTUAL, jvmClassName(ByteBuffer.class), "capacity", "()I");
379 mv.visitInsn(SWAP);
380 mv.visitMethodInsn(INVOKESTATIC, jvmClassName(MemoryUtil.class), "getAddress0", "(L" + jvmClassName(Buffer.class) + ";)J");
381 mv.visitVarInsn(ALOAD, 0);
382 mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "baseAddress", "J");
383 mv.visitInsn(LSUB);
384 mv.visitInsn(L2I);
385 mv.visitInsn(IADD);
386 mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
387 mv.visitInsn(IDIV);
388 mv.visitInsn(IRETURN);
389 mv.visitMaxs(3, 1);
390 mv.visitEnd();
391 }
392
393 private void generateAlignGetter(final MappedSubtypeInfo mappedSubtype) {
394 MethodVisitor mv = super.visitMethod(ACC_PUBLIC, ALIGN_METHOD_NAME, "()I", null, null);
395 mv.visitCode();
396 visitIntNode(mv, mappedSubtype.sizeof);
397 mv.visitInsn(IRETURN);
398 mv.visitMaxs(1, 1);
399 mv.visitEnd();
400 }
401
402 private void generateSizeofGetter() {
403 MethodVisitor mv = super.visitMethod(ACC_PUBLIC, SIZEOF_METHOD_NAME, "()I", null, null);
404 mv.visitCode();
405 mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
406 mv.visitInsn(IRETURN);
407 mv.visitMaxs(1, 1);
408 mv.visitEnd();
409 }
410
411 private void generateNext() {
412 MethodVisitor mv = super.visitMethod(ACC_PUBLIC, NEXT_METHOD_NAME, "()V", null, null);
413 mv.visitCode();
414 mv.visitVarInsn(ALOAD, 0);
415 mv.visitInsn(DUP);
416 mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "viewAddress", "J");
417 mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
418 mv.visitInsn(I2L);
419 mv.visitInsn(LADD);
420 mv.visitMethodInsn(INVOKEVIRTUAL, className, "setViewAddress", "(J)V");
421 mv.visitInsn(RETURN);
422 mv.visitMaxs(3, 1);
423 mv.visitEnd();
424 }
425
426 private void generateByteBufferGetter(final String fieldName, final FieldInfo field) {
427 MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null);
428 mv.visitCode();
429 mv.visitVarInsn(ALOAD, 0);
430 mv.visitVarInsn(ILOAD, 1);
431 mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
432 visitIntNode(mv, (int)field.offset);
433 mv.visitInsn(I2L);
434 mv.visitInsn(LADD);
435 visitIntNode(mv, (int)field.length);
436 mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
437 mv.visitInsn(ARETURN);
438 mv.visitMaxs(3, 2);
439 mv.visitEnd();
440 }
441
442 private void generateFieldGetter(final String fieldName, final FieldInfo field) {
443 MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null);
444 mv.visitCode();
445 mv.visitVarInsn(ALOAD, 0);
446 mv.visitVarInsn(ILOAD, 1);
447 mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
448 visitIntNode(mv, (int)field.offset);
449 mv.visitInsn(I2L);
450 mv.visitInsn(LADD);
451 mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(J)" + field.type.getDescriptor());
452 mv.visitInsn(field.type.getOpcode(IRETURN));
453 mv.visitMaxs(3, 2);
454 mv.visitEnd();
455 }
456
457 private void generateFieldSetter(final String fieldName, final FieldInfo field) {
458 MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, setterName(fieldName), "(L" + className + ";I" + field.type.getDescriptor() + ")V", null, null);
459 mv.visitCode();
460 int load = 0;
461 switch ( field.type.getSort() ) {
462 case Type.BOOLEAN:
463 case Type.CHAR:
464 case Type.BYTE:
465 case Type.SHORT:
466 case Type.INT:
467 load = ILOAD;
468 break;
469 case Type.FLOAT:
470 load = FLOAD;
471 break;
472 case Type.LONG:
473 load = LLOAD;
474 break;
475 case Type.DOUBLE:
476 load = DLOAD;
477 break;
478 }
479 mv.visitVarInsn(load, 2);
480 mv.visitVarInsn(ALOAD, 0);
481 mv.visitVarInsn(ILOAD, 1);
482 mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
483 visitIntNode(mv, (int)field.offset);
484 mv.visitInsn(I2L);
485 mv.visitInsn(LADD);
486 mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(" + field.type.getDescriptor() + "J)V");
487 mv.visitInsn(RETURN);
488 mv.visitMaxs(4, 4);
489 mv.visitEnd();
490 }
491
492 };
493 }
494
495 private static class TransformationAdapter extends ClassAdapter {
496
497 final String className;
498
499 boolean transformed;
500
501 TransformationAdapter(final ClassVisitor cv, final String className) {
502 super(cv);
503 this.className = className;
504 }
505
506 @Override
507 public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
508 // remove redirected fields
509 final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
510 if ( mappedSubtype != null && mappedSubtype.fields.containsKey(name) ) {
511 if ( PRINT_ACTIVITY )
512 LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc);
513 return null;
514 }
515
516 if ( (access & ACC_STATIC) == 0 ) {
517 return new FieldNode(access, name, desc, signature, value) {
518 public void visitEnd() {
519 if ( visibleAnnotations == null ) { // early-out
520 accept(cv);
521 return;
522 }
523
524 boolean before = false;
525 boolean after = false;
526 int byteLength = 0;
527 for ( AnnotationNode pad : visibleAnnotations ) {
528 if ( CACHE_LINE_PAD_JVM.equals(pad.desc) ) {
529 if ( "J".equals(desc) || "D".equals(desc) )
530 byteLength = 8;
531 else if ( "I".equals(desc) || "F".equals(desc) )
532 byteLength = 4;
533 else if ( "S".equals(desc) || "C".equals(desc) )
534 byteLength = 2;
535 else if ( "B".equals(desc) || "Z".equals(desc) )
536 byteLength = 1;
537 else
538 throw new ClassFormatError("The @CacheLinePad annotation cannot be used on non-primitive fields: " + className + "." + name);
539
540 transformed = true;
541
542 after = true;
543 if ( pad.values != null ) {
544 for ( int i = 0; i < pad.values.size(); i += 2 ) {
545 final boolean value = pad.values.get(i + 1).equals(Boolean.TRUE);
546 if ( "before".equals(pad.values.get(i)) )
547 before = value;
548 else
549 after = value;
550 }
551 }
552 break;
553 }
554 }
555
556 /*
557 We make the fields public to force the JVM to keep the fields in the object.
558 Instead of using only longs or integers, we use the same type as the original
559 field. That's because modern JVMs usually reorder fields by type:
560 longs, then doubles, then integers, then booleans, etc. This way it's more
561 likely that the padding will work as expected.
562 */
563
564 if ( before ) {
565 final int count = CacheUtil.getCacheLineSize() / byteLength - 1;
566 for ( int i = count; i >= 1; i-- )
567 cv.visitField(access | ACC_PUBLIC | ACC_SYNTHETIC, name + "$PAD_" + i, desc, signature, null);
568 }
569
570 accept(cv);
571
572 if ( after ) {
573 final int count = CacheUtil.getCacheLineSize() / byteLength - 1;
574 for ( int i = 1; i <= count; i++ )
575 cv.visitField(access | ACC_PUBLIC | ACC_SYNTHETIC, name + "$PAD" + i, desc, signature, null);
576 }
577 }
578 };
579 } else
580 return super.visitField(access, name, desc, signature, value);
581 }
582
583 @Override
584 public MethodVisitor visitMethod(final int access, String name, final String desc, final String signature, final String[] exceptions) {
585 // Move MappedSubtype constructors to another method
586 if ( "<init>".equals(name) ) {
587 final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
588 if ( mappedSubtype != null ) {
589 if ( !"()V".equals(desc) )
590 throw new ClassFormatError(className + " can only have a default constructor, found: " + desc);
591
592 final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
593 mv.visitVarInsn(ALOAD, 0);
594 mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V");
595 mv.visitInsn(RETURN);
596 mv.visitMaxs(0, 0);
597
598 // put the method body in another method
599 name = VIEW_CONSTRUCTOR_NAME;
600 }
601 }
602
603 final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
604 return new MethodNode(access, name, desc, signature, exceptions) {
605
606 /** When true, the method has touched a mapped object and needs to be transformed. We track this
607 * so we can skip the expensive frame analysis and tree API usage. */
608 boolean needsTransformation;
609
610 @Override
611 public void visitMaxs(int a, int b) {
612 try {
613 is_currently_computing_frames = true;
614 super.visitMaxs(a, b);
615 } finally {
616 is_currently_computing_frames = false;
617 }
618 }
619
620 @Override
621 public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
622 if ( className_to_subtype.containsKey(owner) || owner.startsWith(MAPPEDSET_PREFIX) )
623 needsTransformation = true;
624
625 super.visitFieldInsn(opcode, owner, name, desc);
626 }
627
628 @Override
629 public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
630 if ( className_to_subtype.containsKey(owner) )
631 needsTransformation = true;
632
633 super.visitMethodInsn(opcode, owner, name, desc);
634 }
635
636 @Override
637 public void visitEnd() {
638 if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object.
639 //System.err.println("\nTRANSFORMING: " + className + "." + name + desc);
640 transformed = true;
641 try {
642 transformMethod(analyse());
643 } catch (Exception e) {
644 throw new RuntimeException(e);
645 }
646 }
647
648 // Pass the instruction stream to the adapter's MethodVisitor
649 accept(mv);
650 }
651
652 private Frame<BasicValue>[] analyse() throws AnalyzerException {
653 final Analyzer<BasicValue> a = new Analyzer<BasicValue>(new SimpleVerifier());
654 a.analyze(className, this);
655 return a.getFrames();
656 }
657
658 private void transformMethod(final Frame<BasicValue>[] frames) {
659 final InsnList instructions = this.instructions;
660
661 final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
662
663 /*
664 We need this map because we insert/remove instructions from the stream and we need a way
665 to match each original instruction with the corresponding frame.
666 TODO: Can we keep track of everything more efficiently without a map?
667 */
668 final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>();
669 for ( int i = 0; i < frames.length; i++ )
670 frameMap.put(instructions.get(i), frames[i]);
671
672 for ( int i = 0; i < instructions.size(); i++ ) { // f is a separate cursor for frames
673 final AbstractInsnNode instruction = instructions.get(i);
674
675 //System.out.println("MAIN LOOP #" + i + " - " + getOpcodeName(instruction));
676
677 switch ( instruction.getType() ) {
678 case AbstractInsnNode.VAR_INSN:
679 if ( instruction.getOpcode() == ALOAD ) {
680 VarInsnNode varInsn = (VarInsnNode)instruction;
681 final MappedSubtypeInfo mappedSubtype = arrayVars.get(varInsn.var);
682 if ( mappedSubtype != null )
683 i = transformArrayAccess(instructions, i, frameMap, varInsn, mappedSubtype, varInsn.var);
684 }
685 break;
686 case AbstractInsnNode.FIELD_INSN:
687 FieldInsnNode fieldInsn = (FieldInsnNode)instruction;
688
689 final InsnList list = transformFieldAccess(fieldInsn);
690 if ( list != null )
691 i = replace(instructions, i, instruction, list);
692
693 break;
694 case AbstractInsnNode.METHOD_INSN:
695 MethodInsnNode methodInsn = (MethodInsnNode)instruction;
696 final MappedSubtypeInfo mappedType = className_to_subtype.get(methodInsn.owner);
697 if ( mappedType != null )
698 i = transformMethodCall(instructions, i, frameMap, methodInsn, mappedType, arrayVars);
699 break;
700 }
701 }
702 }
703 };
704 }
705 }
706
707 static int transformMethodCall(final InsnList instructions, int i, final Map<AbstractInsnNode, Frame<BasicValue>> frameMap, final MethodInsnNode methodInsn, final MappedSubtypeInfo mappedType, final Map<Integer, MappedSubtypeInfo> arrayVars) {
708 switch ( methodInsn.getOpcode() ) {
709 case INVOKEVIRTUAL:
710 if ( "asArray".equals(methodInsn.name) && methodInsn.desc.equals("()[L" + MAPPED_OBJECT_JVM + ";") ) {
711 // Go forward and store the local variable index.
712 // We only allow this pattern: INVOKEVIRTUAL -> CHECKCAST -> ASTORE.
713 // We remove the first two and store the target MappedSubtype in the ASTORE variable
714 AbstractInsnNode nextInstruction;
715 checkInsnAfterIsArray(nextInstruction = methodInsn.getNext(), CHECKCAST);
716 checkInsnAfterIsArray(nextInstruction = nextInstruction.getNext(), ASTORE);
717
718 final Frame<BasicValue> frame = frameMap.get(nextInstruction);
719 final String targetType = frame.getStack(frame.getStackSize() - 1).getType().getElementType().getInternalName();
720 if ( !methodInsn.owner.equals(targetType) ) {
721 /*
722 This may happen with the current API, like so:
723 MappedA foo = MappedA.malloc(...);
724 MappedB[] cursor = foo.asArray();
725 We have to parameterize MappedObject to avoid this.
726 */
727 throw new ClassCastException("Source: " + methodInsn.owner + " - Target: " + targetType);
728 }
729
730 final VarInsnNode varInstruction = (VarInsnNode)nextInstruction;
731
732 arrayVars.put(varInstruction.var, mappedType);
733
734 instructions.remove(methodInsn.getNext()); // Remove CHECKCAST
735 instructions.remove(methodInsn); // Remove INVOKEVIRTUAL
736 }
737
738 if ( "dup".equals(methodInsn.name) && methodInsn.desc.equals("()L" + MAPPED_OBJECT_JVM + ";") ) {
739 i = replace(instructions, i, methodInsn, generateDupInstructions(methodInsn));
740 break;
741 }
742
743 if ( "slice".equals(methodInsn.name) && methodInsn.desc.equals("()L" + MAPPED_OBJECT_JVM + ";") ) {
744 i = replace(instructions, i, methodInsn, generateSliceInstructions(methodInsn));
745 break;
746 }
747
748 if ( "runViewConstructor".equals(methodInsn.name) && "()V".equals(methodInsn.desc) ) {
749 i = replace(instructions, i, methodInsn, generateRunViewConstructorInstructions(methodInsn));
750 break;
751 }
752
753 if ( "copyTo".equals(methodInsn.name) && methodInsn.desc.equals("(L" + MAPPED_OBJECT_JVM + ";)V") ) {
754 i = replace(instructions, i, methodInsn, generateCopyToInstructions(mappedType));
755 break;
756 }
757
758 if ( "copyRange".equals(methodInsn.name) && methodInsn.desc.equals("(L" + MAPPED_OBJECT_JVM + ";I)V") ) {
759 i = replace(instructions, i, methodInsn, generateCopyRangeInstructions(mappedType));
760 break;
761 }
762
763 break;
764 case INVOKESPECIAL:
765 // super() in VIEW_CONSTRUCTOR_NAME, remove
766 if ( methodInsn.owner.equals(MAPPED_OBJECT_JVM) && "<init>".equals(methodInsn.name) && "()V".equals(methodInsn.desc) ) {
767 instructions.remove(methodInsn.getPrevious()); // ALOAD
768 instructions.remove(methodInsn); // INVOKESPECIAL
769
770 i -= 2;
771 }
772 break;
773 case INVOKESTATIC:
774 boolean isMapDirectMethod = "map".equals(methodInsn.name) && methodInsn.desc.equals("(JI)L" + MAPPED_OBJECT_JVM + ";");
775 boolean isMapBufferMethod = "map".equals(methodInsn.name) && methodInsn.desc.equals("(Ljava/nio/ByteBuffer;)L" + MAPPED_OBJECT_JVM + ";");
776 boolean isMallocMethod = "malloc".equals(methodInsn.name) && methodInsn.desc.equals("(I)L" + MAPPED_OBJECT_JVM + ";");
777
778 if ( (isMapDirectMethod || isMapBufferMethod) || isMallocMethod )
779 i = replace(instructions, i, methodInsn, generateMapInstructions(mappedType, methodInsn.owner, isMapDirectMethod, isMallocMethod));
780 break;
781 }
782
783 return i;
784 }
785
786 private static InsnList generateCopyRangeInstructions(final MappedSubtypeInfo mappedType) {
787 final InsnList list = new InsnList();
788
789 // stack: instances, target, this
790 list.add(getIntNode(mappedType.sizeof));
791 // stack: sizeof, instances, target, this
792 list.add(new InsnNode(IMUL));
793 // stack: bytes, target, this
794 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V"));
795 // stack: -
796
797 return list;
798 }
799
800 private static InsnList generateCopyToInstructions(final MappedSubtypeInfo mappedType) {
801 final InsnList list = new InsnList();
802
803 // stack: target, this
804 list.add(getIntNode(mappedType.sizeof - mappedType.padding));
805 // stack: sizeof, target, this
806 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V"));
807 // stack: -
808
809 return list;
810 }
811
812 private static InsnList generateRunViewConstructorInstructions(final MethodInsnNode methodInsn) {
813 final InsnList list = new InsnList();
814
815 // stack: this
816 list.add(new InsnNode(DUP));
817 // stack: this, this
818 list.add(new MethodInsnNode(INVOKEVIRTUAL, methodInsn.owner, VIEW_CONSTRUCTOR_NAME, "()V"));
819 // stack: this
820
821 return list;
822 }
823
824 private static InsnList generateSliceInstructions(final MethodInsnNode methodInsn) {
825 final InsnList list = new InsnList();
826
827 // stack: this
828 list.add(new TypeInsnNode(NEW, methodInsn.owner));
829 // stack: new, this
830 list.add(new InsnNode(DUP));
831 // stack: new, new, this
832 list.add(new MethodInsnNode(INVOKESPECIAL, methodInsn.owner, "<init>", "()V"));
833 // stack: new, this
834 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "slice", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";)L" + MAPPED_OBJECT_JVM + ";"));
835 // stack: new
836
837 return list;
838 }
839
840 private static InsnList generateDupInstructions(final MethodInsnNode methodInsn) {
841 final InsnList list = new InsnList();
842
843 // stack: this
844 list.add(new TypeInsnNode(NEW, methodInsn.owner));
845 // stack: new, this
846 list.add(new InsnNode(DUP));
847 // stack: new, new, this
848 list.add(new MethodInsnNode(INVOKESPECIAL, methodInsn.owner, "<init>", "()V"));
849 // stack: new, this
850 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "dup", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";)L" + MAPPED_OBJECT_JVM + ";"));
851 // stack: new
852
853 return list;
854 }
855
856 private static InsnList generateMapInstructions(final MappedSubtypeInfo mappedType, final String className, final boolean mapDirectMethod, final boolean mallocMethod) {
857 final InsnList trg = new InsnList();
858
859 if ( mallocMethod ) {
860 // stack: count
861 trg.add(getIntNode(mappedType.sizeof));
862 // stack: sizeof, count
863 trg.add(new InsnNode(IMUL));
864 // stack: bytes
865 trg.add(new MethodInsnNode(INVOKESTATIC, mappedType.cacheLinePadded ? jvmClassName(CacheUtil.class) : jvmClassName(BufferUtils.class), "createByteBuffer", "(I)L" + jvmClassName(ByteBuffer.class) + ";"));
866 // stack: buffer
867 } else if ( mapDirectMethod ) {
868 // stack: capacity, address
869 trg.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";"));
870 // stack: buffer
871 }
872
873 // stack: buffer
874 trg.add(new TypeInsnNode(NEW, className));
875 // stack: new, buffer
876 trg.add(new InsnNode(DUP));
877 // stack: new, new, buffer
878 trg.add(new MethodInsnNode(INVOKESPECIAL, className, "<init>", "()V"));
879 // stack: new, buffer
880 trg.add(new InsnNode(DUP_X1));
881 // stack: new, buffer, new
882 trg.add(new InsnNode(SWAP));
883 // stack: buffer, new, new
884 trg.add(getIntNode(mappedType.align));
885 // stack: int, buffer, new, new
886 trg.add(getIntNode(mappedType.sizeof));
887 // stack: int, int, buffer, new, new
888 trg.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "setup", "(L" + MAPPED_OBJECT_JVM + ";Ljava/nio/ByteBuffer;II)V"));
889 // stack: new
890
891 return trg;
892 }
893
894 static InsnList transformFieldAccess(final FieldInsnNode fieldInsn) {
895 final MappedSubtypeInfo mappedSubtype;
896 mappedSubtype = className_to_subtype.get(fieldInsn.owner);
897 if ( mappedSubtype == null ) { // early out
898 // MappedSet.view
899 outer:
900 if ( "view".equals(fieldInsn.name) && fieldInsn.owner.startsWith(MAPPEDSET_PREFIX) )
901 return generateSetViewInstructions(fieldInsn);
902
903 return null; // early out
904 }
905
906 if ( "SIZEOF".equals(fieldInsn.name) )
907 return generateSIZEOFInstructions(fieldInsn, mappedSubtype);
908
909 if ( "view".equals(fieldInsn.name) )
910 return generateViewInstructions(fieldInsn, mappedSubtype);
911
912 if ( "baseAddress".equals(fieldInsn.name) || "viewAddress".equals(fieldInsn.name) ) {
913 return generateAddressInstructions(fieldInsn);
914 }
915
916 final FieldInfo field = mappedSubtype.fields.get(fieldInsn.name);
917 if ( field == null ) // early out
918 return null;
919
920 // now we're going to transform ByteBuffer-typed field access
921 if ( fieldInsn.desc.equals("L" + jvmClassName(ByteBuffer.class) + ";") )
922 return generateByteBufferInstructions(fieldInsn, mappedSubtype, field.offset);
923
924 // we're now going to transform the field access
925 return generateFieldInstructions(fieldInsn, field);
926 }
927
928 private static InsnList generateSetViewInstructions(final FieldInsnNode fieldInsn) {
929 if ( fieldInsn.getOpcode() == GETFIELD )
930 throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
931 if ( fieldInsn.getOpcode() != PUTFIELD )
932 throw new InternalError();
933
934 final InsnList list = new InsnList();
935
936 // stack: index, this
937 if ( MAPPED_SET2_JVM.equals(fieldInsn.owner) )
938 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET2_JVM + ";I)V"));
939 else if ( MAPPED_SET3_JVM.equals(fieldInsn.owner) )
940 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET3_JVM + ";I)V"));
941 else if ( MAPPED_SET4_JVM.equals(fieldInsn.owner) )
942 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + MAPPED_SET4_JVM + ";I)V"));
943 else
944 throw new InternalError();
945 // stack: -
946
947 return list;
948 }
949
950 private static InsnList generateSIZEOFInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype) {
951 if ( !"I".equals(fieldInsn.desc) )
952 throw new InternalError();
953
954 final InsnList list = new InsnList();
955
956 if ( fieldInsn.getOpcode() == GETSTATIC ) {
957 list.add(getIntNode(mappedSubtype.sizeof));
958 return list;
959 }
960
961 if ( fieldInsn.getOpcode() == PUTSTATIC )
962 throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
963
964 throw new InternalError();
965 }
966
967 private static InsnList generateViewInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype) {
968 if ( !"I".equals(fieldInsn.desc) )
969 throw new InternalError();
970
971 final InsnList list = new InsnList();
972
973 if ( fieldInsn.getOpcode() == GETFIELD ) {
974 if ( mappedSubtype.sizeof_shift != 0 ) {
975 // stack: instance
976 list.add(getIntNode(mappedSubtype.sizeof_shift));
977 // stack: sizeof, instance
978 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "get_view_shift", "(L" + MAPPED_OBJECT_JVM + ";I)I"));
979 // stack: view
980 } else {
981 // stack: instance
982 list.add(getIntNode(mappedSubtype.sizeof));
983 // stack: sizeof, instance
984 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "get_view", "(L" + MAPPED_OBJECT_JVM + ";I)I"));
985 // stack: view
986 }
987 return list;
988 }
989
990 if ( fieldInsn.getOpcode() == PUTFIELD ) {
991 if ( mappedSubtype.sizeof_shift != 0 ) {
992 // stack: view, instance
993 list.add(getIntNode(mappedSubtype.sizeof_shift));
994 // stack: sizeof, view, instance
995 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view_shift", "(L" + MAPPED_OBJECT_JVM + ";II)V"));
996 // stack: -
997 } else {
998 // stack: view, instance
999 list.add(getIntNode(mappedSubtype.sizeof));
1000 // stack: sizeof, view, instance
1001 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view", "(L" + MAPPED_OBJECT_JVM + ";II)V"));
1002 // stack: -
1003 }
1004 return list;
1005 }
1006
1007 throw new InternalError();
1008 }
1009
1010 private static InsnList generateAddressInstructions(final FieldInsnNode fieldInsn) {
1011 if ( !"J".equals(fieldInsn.desc) )
1012 throw new IllegalStateException();
1013
1014 if ( fieldInsn.getOpcode() == GETFIELD ) // do not change a thing
1015 return null;
1016
1017 if ( fieldInsn.getOpcode() == PUTFIELD )
1018 throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
1019
1020 throw new InternalError();
1021 }
1022
1023 private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final long fieldOffset) {
1024 if ( fieldInsn.getOpcode() == PUTFIELD )
1025 throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
1026
1027 if ( fieldInsn.getOpcode() == GETFIELD ) {
1028 final InsnList list = new InsnList();
1029
1030 // stack: ref
1031 list.add(new FieldInsnNode(GETFIELD, mappedSubtype.className, "viewAddress", "J"));
1032 // stack: long
1033 list.add(new LdcInsnNode(fieldOffset));
1034 // stack: long, long
1035 list.add(new InsnNode(LADD));
1036 // stack: long
1037 list.add(new LdcInsnNode(mappedSubtype.fields.get(fieldInsn.name).length));
1038 // stack: long, long
1039 list.add(new InsnNode(L2I));
1040 // stack: int, long
1041 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";"));
1042 // stack: buffer
1043
1044 return list;
1045 }
1046
1047 throw new InternalError();
1048 }
1049
1050 private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) {
1051 final InsnList list = new InsnList();
1052
1053 if ( fieldInsn.getOpcode() == PUTFIELD ) {
1054 // stack: value, ref
1055 list.add(getIntNode((int)field.offset));
1056 // stack: fieldOffset, value, ref
1057 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
1058 // stack -
1059 return list;
1060 }
1061
1062 if ( fieldInsn.getOpcode() == GETFIELD ) {
1063 // stack: ref
1064 list.add(getIntNode((int)field.offset));
1065 // stack: fieldOffset, ref
1066 list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
1067 // stack: -
1068 return list;
1069 }
1070
1071 throw new InternalError();
1072 }
1073
1074 static int transformArrayAccess(final InsnList instructions, int i, final Map<AbstractInsnNode, Frame<BasicValue>> frameMap, final VarInsnNode loadInsn, final MappedSubtypeInfo mappedSubtype, final int var) {
1075 // We need to go forward in time to find how we use the array var
1076 final int loadStackSize = frameMap.get(loadInsn).getStackSize() + 1;
1077
1078 AbstractInsnNode nextInsn = loadInsn;
1079
1080 while ( true ) {
1081 nextInsn = nextInsn.getNext();
1082 if ( nextInsn == null )
1083 throw new InternalError();
1084
1085 Frame<BasicValue> frame = frameMap.get(nextInsn);
1086 if ( frame == null )
1087 continue;
1088
1089 int stackSize = frame.getStackSize();
1090
1091 if ( stackSize == loadStackSize + 1 && nextInsn.getOpcode() == AALOAD ) {
1092 final AbstractInsnNode aaLoadInsn = nextInsn;
1093
1094 while ( true ) {
1095 nextInsn = nextInsn.getNext();
1096 if ( nextInsn == null )
1097 break;
1098
1099 frame = frameMap.get(nextInsn);
1100 if ( frame == null )
1101 continue;
1102 stackSize = frame.getStackSize();
1103
1104 if ( stackSize == loadStackSize + 1 && nextInsn.getOpcode() == PUTFIELD ) {
1105 final FieldInsnNode fieldInsn = (FieldInsnNode)nextInsn;
1106
1107 // stack: value, view, ref
1108 instructions.insert(nextInsn, new MethodInsnNode(INVOKESTATIC, mappedSubtype.className, setterName(fieldInsn.name), "(L" + mappedSubtype.className + ";I" + fieldInsn.desc + ")V"));
1109 // stack: -
1110 instructions.remove(nextInsn);
1111
1112 break;
1113 } else if ( stackSize == loadStackSize && nextInsn.getOpcode() == GETFIELD ) {
1114 final FieldInsnNode fieldInsn = (FieldInsnNode)nextInsn;
1115
1116 // stack: view, ref
1117 instructions.insert(nextInsn, new MethodInsnNode(INVOKESTATIC, mappedSubtype.className, getterName(fieldInsn.name), "(L" + mappedSubtype.className + ";I)" + fieldInsn.desc));
1118 // stack: value
1119 instructions.remove(nextInsn);
1120
1121 break;
1122 } else if ( stackSize == loadStackSize && nextInsn.getOpcode() == DUP && nextInsn.getNext().getOpcode() == GETFIELD ) {
1123 // May happen with operator+assignment (e.g. cursor[i].value += 10)
1124 final FieldInsnNode fieldInsn = (FieldInsnNode)nextInsn.getNext();
1125
1126 final MethodInsnNode getter = new MethodInsnNode(INVOKESTATIC, mappedSubtype.className, getterName(fieldInsn.name), "(L" + mappedSubtype.className + ";I)" + fieldInsn.desc);
1127
1128 // stack: view, ref
1129 instructions.insert(nextInsn, new InsnNode(DUP2));
1130 // stack: view, ref, view, ref
1131 instructions.insert(nextInsn.getNext(), getter);
1132 // stack: value, view, ref
1133
1134 instructions.remove(nextInsn);
1135 instructions.remove(fieldInsn);
1136
1137 nextInsn = getter;
1138 continue;
1139 } else if ( stackSize < loadStackSize )
1140 throw new ClassFormatError("Invalid " + mappedSubtype.className + " view array usage detected: " + getOpcodeName(nextInsn));
1141 }
1142
1143 instructions.remove(aaLoadInsn);
1144
1145 return i;
1146 } else if ( stackSize == loadStackSize && nextInsn.getOpcode() == ARRAYLENGTH ) {
1147 if ( LWJGLUtil.DEBUG && loadInsn.getNext() != nextInsn )
1148 throw new InternalError();
1149
1150 instructions.remove(nextInsn);
1151 loadInsn.var = var;
1152 instructions.insert(loadInsn, new MethodInsnNode(INVOKEVIRTUAL, mappedSubtype.className, CAPACITY_METHOD_NAME, "()I"));
1153
1154 return i + 1;
1155 } else if ( stackSize < loadStackSize ) // Consumed by something other than AALOAD or ARRAYLENGTH
1156 throw new ClassFormatError("Invalid " + mappedSubtype.className + " view array usage detected: " + getOpcodeName(nextInsn));
1157 }
1158 }
1159
1160 private static class FieldInfo {
1161
1162 final long offset;
1163 final long length;
1164 final long lengthPadded;
1165 final Type type;
1166 final boolean isVolatile;
1167 final boolean isPointer;
1168
1169 FieldInfo(final long offset, final long length, final long lengthPadded, final Type type, final boolean isVolatile, final boolean isPointer) {
1170 this.offset = offset;
1171 this.length = length;
1172 this.lengthPadded = lengthPadded;
1173 this.type = type;
1174 this.isVolatile = isVolatile;
1175 this.isPointer = isPointer;
1176 }
1177
1178 String getAccessType() {
1179 return isPointer ? "a" : type.getDescriptor().toLowerCase() + (isVolatile ? "v" : "");
1180 }
1181
1182 }
1183
1184 private static class MappedSubtypeInfo {
1185
1186 final String className;
1187
1188 final int sizeof;
1189 final int sizeof_shift;
1190 final int align;
1191 final int padding;
1192 final boolean cacheLinePadded;
1193
1194 final Map<String, FieldInfo> fields;
1195
1196 MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align, int padding, final boolean cacheLinePadded) {
1197 this.className = className;
1198
1199 this.sizeof = sizeof;
1200 if ( ((sizeof - 1) & sizeof) == 0 )
1201 this.sizeof_shift = getPoT(sizeof);
1202 else
1203 this.sizeof_shift = 0;
1204 this.align = align;
1205 this.padding = padding;
1206 this.cacheLinePadded = cacheLinePadded;
1207
1208 this.fields = fields;
1209 }
1210
1211 private static int getPoT(int value) {
1212 int pot = -1;
1213 while ( value > 0 ) {
1214 pot++;
1215 value >>= 1;
1216 }
1217 return pot;
1218 }
1219
1220 }
1221
1222 // -------------------------------------------------------
1223 // -------------------[ MACROS & UTILS ]------------------
1224 // -------------------------------------------------------
1225
1226 private static void getClassEnums(final Class clazz, final Map<Integer, String> map, final String... prefixFilters) {
1227 try {
1228 OUTER:
1229 for ( Field field : clazz.getFields() ) {
1230 if ( !Modifier.isStatic(field.getModifiers()) || field.getType() != int.class )
1231 continue;
1232
1233 for ( String filter : prefixFilters ) {
1234 if ( field.getName().startsWith(filter) )
1235 continue OUTER;
1236 }
1237
1238 if ( map.put((Integer)field.get(null), field.getName()) != null )
1239 throw new IllegalStateException();
1240 }
1241 } catch (Exception e) {
1242 e.printStackTrace();
1243 }
1244 }
1245
1246 static String getOpcodeName(final AbstractInsnNode insn) {
1247 final String op = OPCODE_TO_NAME.get(insn.getOpcode());
1248 return INSNTYPE_TO_NAME.get(insn.getType()) + ": " + insn.getOpcode() + (op == null ? "" : " [" + OPCODE_TO_NAME.get(insn.getOpcode()) + "]");
1249 }
1250
1251 static String jvmClassName(Class<?> type) {
1252 return type.getName().replace('.', '/');
1253 }
1254
1255 static String getterName(final String fieldName) {
1256 return "get$" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1) + "$LWJGL";
1257 }
1258
1259 static String setterName(final String fieldName) {
1260 return "set$" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1) + "$LWJGL";
1261 }
1262
1263 private static void checkInsnAfterIsArray(final AbstractInsnNode instruction, final int opcode) {
1264 if ( instruction == null )
1265 throw new ClassFormatError("Unexpected end of instructions after .asArray() method.");
1266
1267 if ( instruction.getOpcode() != opcode )
1268 throw new ClassFormatError("The result of .asArray() must be stored to a local variable. Found: " + getOpcodeName(instruction));
1269 }
1270
1271 static AbstractInsnNode getIntNode(final int value) {
1272 if ( value <= 5 && -1 <= value )
1273 return new InsnNode(ICONST_M1 + value + 1);
1274
1275 if ( value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE )
1276 return new IntInsnNode(BIPUSH, value);
1277
1278 if ( value >= Short.MIN_VALUE && value <= Short.MAX_VALUE )
1279 return new IntInsnNode(SIPUSH, value);
1280
1281 return new LdcInsnNode(value);
1282 }
1283
1284 static void visitIntNode(final MethodVisitor mv, final int value) {
1285 if ( value <= 5 && -1 <= value )
1286 mv.visitInsn(ICONST_M1 + value + 1);
1287 else if ( value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE )
1288 mv.visitIntInsn(BIPUSH, value);
1289 else if ( value >= Short.MIN_VALUE && value <= Short.MAX_VALUE )
1290 mv.visitIntInsn(SIPUSH, value);
1291 else
1292 mv.visitLdcInsn(value);
1293 }
1294
1295 /** Replace an instruction with a list of instructions. */
1296 static int replace(final InsnList instructions, final int i, final AbstractInsnNode location, final InsnList list) {
1297 final int size = list.size();
1298
1299 instructions.insert(location, list);
1300 instructions.remove(location);
1301
1302 return i + (size - 1);
1303 }
1304
1305 private static void throwAccessErrorOnReadOnlyField(String className, String fieldName) {
1306 throw new IllegalAccessError("The " + className + "." + fieldName + " field is final.");
1307 }
1308
1309 private static void printBytecode(byte[] bytecode) {
1310 StringWriter sw = new StringWriter();
1311 ClassVisitor tracer = new TraceClassVisitor(new ClassWriter(0), new PrintWriter(sw));
1312 new ClassReader(bytecode).accept(tracer, 0);
1313 String dump = sw.toString();
1314
1315 LWJGLUtil.log(dump);
1316 }
1317
1318 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.lang.reflect.Field;
34 import java.lang.reflect.Modifier;
35 import java.nio.ByteBuffer;
36 import java.nio.ByteOrder;
37
38 import sun.misc.Unsafe;
39
40 /**
41 * [INTERNAL USE ONLY]
42 *
43 * @author Riven
44 */
45 final class MappedObjectUnsafe {
46
47 static final Unsafe INSTANCE = getUnsafeInstance();
48
49 private static final long BUFFER_ADDRESS_OFFSET = getObjectFieldOffset(ByteBuffer.class, "address");
50 private static final long BUFFER_CAPACITY_OFFSET = getObjectFieldOffset(ByteBuffer.class, "capacity");
51
52 private static final ByteBuffer global = ByteBuffer.allocateDirect(4 * 1024);
53
54 static ByteBuffer newBuffer(long address, int capacity) {
55 if ( address <= 0L || capacity < 0 )
56 throw new IllegalStateException("you almost crashed the jvm");
57
58 ByteBuffer buffer = global.duplicate().order(ByteOrder.nativeOrder());
59 INSTANCE.putLong(buffer, BUFFER_ADDRESS_OFFSET, address);
60 INSTANCE.putInt(buffer, BUFFER_CAPACITY_OFFSET, capacity);
61 buffer.position(0);
62 buffer.limit(capacity);
63 return buffer;
64 }
65
66 private static long getObjectFieldOffset(Class<?> type, String fieldName) {
67 while ( type != null ) {
68 try {
69 return INSTANCE.objectFieldOffset(type.getDeclaredField(fieldName));
70 } catch (Throwable t) {
71 type = type.getSuperclass();
72 }
73 }
74
75 throw new UnsupportedOperationException();
76 }
77
78 private static Unsafe getUnsafeInstance() {
79 final Field[] fields = Unsafe.class.getDeclaredFields();
80
81 /*
82 Different runtimes use different names for the Unsafe singleton,
83 so we cannot use .getDeclaredField and we scan instead. For example:
84
85 Oracle: theUnsafe
86 PERC : m_unsafe_instance
87 Android: THE_ONE
88 */
89 for ( Field field : fields ) {
90 if ( !field.getType().equals(Unsafe.class) )
91 continue;
92
93 final int modifiers = field.getModifiers();
94 if ( !(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) )
95 continue;
96
97 field.setAccessible(true);
98 try {
99 return (Unsafe)field.get(null);
100 } catch (IllegalAccessException e) {
101 // ignore
102 }
103 break;
104 }
105
106 throw new UnsupportedOperationException();
107 }
108
109 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 /**
34 * Factory for mapped sets. A mapped set can be used as a Structure of Arrays by
35 * linking together the view of two or more mapped objects. Changing the view
36 * of the mapped set, changes the corresponding view of all the mapped objects in
37 * the set.
38 */
39 public class MappedSet {
40
41 /**
42 * Creates a <code>MappedSet</code> by linking the specified <code>MappedObject</code>s.
43 *
44 * @return the mapped set.
45 */
46 public static MappedSet2 create(MappedObject a, MappedObject b) {
47 return new MappedSet2(a, b);
48 }
49
50 /**
51 * Creates a <code>MappedSet</code> by linking the specified <code>MappedObject</code>s.
52 *
53 * @return the mapped set.
54 */
55 public static MappedSet3 create(MappedObject a, MappedObject b, MappedObject c) {
56 return new MappedSet3(a, b, c);
57 }
58
59 /**
60 * Creates a <code>MappedSet</code> by linking the specified <code>MappedObject</code>s.
61 *
62 * @return the mapped set.
63 */
64 public static MappedSet4 create(MappedObject a, MappedObject b, MappedObject c, MappedObject d) {
65 return new MappedSet4(a, b, c, d);
66 }
67
68 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 /** <code>MappedSet</code> implementation for two <code>MappedObject</code>s. */
34 public class MappedSet2 {
35
36 private final MappedObject a, b;
37
38 MappedSet2(MappedObject a, MappedObject b) {
39 this.a = a;
40 this.b = b;
41 }
42
43 public int view;
44
45 void view(int view) {
46 a.setViewAddress(a.getViewAddress(view));
47 b.setViewAddress(b.getViewAddress(view));
48 }
49
50 public void next() {
51 this.a.next();
52 this.b.next();
53 }
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 /** <code>MappedSet</code> implementation for three <code>MappedObject</code>s. */
34 public class MappedSet3 {
35
36 private final MappedObject a, b, c;
37
38 MappedSet3(MappedObject a, MappedObject b, MappedObject c) {
39 this.a = a;
40 this.b = b;
41 this.c = c;
42 }
43
44 public int view;
45
46 void view(int view) {
47 a.setViewAddress(a.getViewAddress(view));
48 b.setViewAddress(b.getViewAddress(view));
49 c.setViewAddress(c.getViewAddress(view));
50 }
51
52 public void next() {
53 this.a.next();
54 this.b.next();
55 this.c.next();
56 }
57
58 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 /** <code>MappedSet</code> implementation for four <code>MappedObject</code>s. */
34 public class MappedSet4 {
35
36 private final MappedObject a, b, c, d;
37
38 MappedSet4(MappedObject a, MappedObject b, MappedObject c, MappedObject d) {
39 this.a = a;
40 this.b = b;
41 this.c = c;
42 this.d = d;
43 }
44
45 public int view;
46
47 void view(int view) {
48 a.setViewAddress(a.getViewAddress(view));
49 b.setViewAddress(b.getViewAddress(view));
50 c.setViewAddress(c.getViewAddress(view));
51 d.setViewAddress(d.getViewAddress(view));
52 }
53
54 public void next() {
55 this.a.next();
56 this.b.next();
57 this.c.next();
58 this.d.next();
59 }
60 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Retention;
35 import java.lang.annotation.RetentionPolicy;
36 import java.lang.annotation.Target;
37
38 /**
39 * This annotation marks a class as a mapped object, which will go under bytecode
40 * transformation at runtime. Mapped objects cannot be instantiated directly; a data
41 * buffer must be mapped first and the mapped object instance will then be used as a
42 * view on top of the buffer. Instead of a separate instance per "element" in the buffer,
43 * only a single instance is used to manage everything. See {@link MappedObject}
44 * for API details and {@link org.lwjgl.test.mapped.TestMappedObject} for examples.
45 * <p/>
46 * The instance fields of the annotated class should only be limited to primitive types or
47 * {@link java.nio.ByteBuffer}. Static fields are supported and they can have any type.
48 * <p/>
49 * The purpose of mapped objects is to reduce the memory requirements required for the type
50 * of data that are often used in OpenGL/OpenCL programming, while at the same time enabling
51 * clean Java code. There are also performance benefits related to not having to copy data
52 * between buffers and Java objects and the removal of bounds checking when accessing
53 * buffer data.
54 *
55 * @author Riven
56 */
57 @Retention(RetentionPolicy.RUNTIME)
58 @Target(ElementType.TYPE)
59 public @interface MappedType {
60
61 /**
62 * The number of bytes to add to the total byte size.
63 * SIZEOF will be calculated as <code>SIZEOF = max(field_offset + field_length) + padding</code>.
64 * <p/>
65 * Cannot be used with {@link #cacheLinePadding()}.
66 *
67 * @return the padding amount
68 */
69 int padding() default 0;
70
71 /**
72 * When true, SIZEOF will be increased (if necessary) so that it's a multiple of the CPU cache line size.
73 * Additionally, {@link MappedObject#malloc(int)} on the mapped object type will automatically use
74 * {@link CacheUtil#createByteBuffer(int)} instead of the unaligned {@link org.lwjgl.BufferUtils#createByteBuffer(int)}.
75 * <p/>
76 * Cannot be used with {@link #padding()}.
77 *
78 * @return if cache-line padding should be applied
79 *
80 * @see CacheUtil
81 */
82 boolean cacheLinePadding() default false;
83
84 /**
85 * The mapped data memory alignment, in bytes.
86 *
87 * @return the memory alignment
88 */
89 int align() default 4;
90
91 /**
92 * When autoGenerateOffsets is true, byte offsets of the mapped fields will
93 * be generated automatically. This is convenient for packed data. For manually
94 * aligned data, autoGenerateOffsets must be set to false and the user needs
95 * to manually specify byte offsets using the {@link MappedField} annotation.
96 *
97 * @return true if automatic byte offset generation is required.
98 */
99 boolean autoGenerateOffsets() default true;
100
101 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN 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.mapped;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Retention;
35 import java.lang.annotation.RetentionPolicy;
36 import java.lang.annotation.Target;
37
38 /**
39 * This annotation can be used on long fields of {@link MappedObject} subclasses,
40 * to specify that the long value should be interpreted as a pointer. This
41 * will determine the actual byte size of the field at runtime (4 or 8 bytes).
42 *
43 * @author Spasi
44 */
45 @Retention(RetentionPolicy.RUNTIME)
46 @Target(ElementType.FIELD)
47 public @interface Pointer {
48
49 }
3939 * matrix unless otherwise stated.
4040 *
4141 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3418 $
43 * $Id: Matrix.java 3418 2010-09-28 21:11:35Z spasi $
42 * @version $Revision$
43 * $Id$
4444 */
4545 public abstract class Matrix implements Serializable {
4646
3838 * Holds a 2x2 matrix
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: Matrix2f.java 3418 2010-09-28 21:11:35Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444
4545 public class Matrix2f extends Matrix implements Serializable {
332332 * @return the negated matrix
333333 */
334334 public Matrix2f negate(Matrix2f dest) {
335 return negate(this, this);
335 return negate(this, dest);
336336 }
337337
338338 /**
3838 * Holds a 3x3 matrix.
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: Matrix3f.java 3418 2010-09-28 21:11:35Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444
4545 public class Matrix3f extends Matrix implements Serializable {
430430 * @return the negated matrix
431431 */
432432 public Matrix3f negate(Matrix3f dest) {
433 return negate(this, this);
433 return negate(this, dest);
434434 }
435435
436436 /**
5151 setIdentity();
5252 }
5353
54 public Matrix4f(final Matrix4f src) {
55 super();
56 load(src);
57 }
58
5459 /**
5560 * Returns a string representation of this matrix
5661 */
277282 return this;
278283 }
279284
285 /**
286 * Store the rotation portion of this matrix in a float buffer. The matrix is stored in column
287 * major (openGL) order.
288 * @param buf The buffer to store this matrix in
289 */
290 public Matrix store3f(FloatBuffer buf) {
291 buf.put(m00);
292 buf.put(m01);
293 buf.put(m02);
294 buf.put(m10);
295 buf.put(m11);
296 buf.put(m12);
297 buf.put(m20);
298 buf.put(m21);
299 buf.put(m22);
300 return this;
301 }
280302
281303 /**
282304 * Add two matrices together and place the result in a third matrix.
791813 * @return the negated matrix
792814 */
793815 public Matrix4f negate(Matrix4f dest) {
794 return negate(this, this);
816 return negate(this, dest);
795817 }
796818
797819 /**
3535 * Quaternions for LWJGL!
3636 *
3737 * @author fbi
38 * @version $Revision: 3418 $
39 * $Id: Quaternion.java 3418 2010-09-28 21:11:35Z spasi $
38 * @version $Revision$
39 * $Id$
4040 */
4141
4242 import java.nio.FloatBuffer;
3838 * Base class for vectors.
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: Vector.java 3418 2010-09-28 21:11:35Z spasi $
41 * @version $Revision$
42 * $Id$
4343 */
4444 public abstract class Vector implements Serializable, ReadableVector {
4545
3333 import java.io.Serializable;
3434 import java.nio.FloatBuffer;
3535
36 import org.lwjgl.util.vector.Vector2f;
37
3638 /**
3739 *
3840 * Holds a 2-tuple vector.
3941 *
4042 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: Vector2f.java 3418 2010-09-28 21:11:35Z spasi $
43 * @version $Revision$
44 * $Id$
4345 */
4446
4547 public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f {
284286 */
285287 public final void setY(float y) {
286288 this.y = y;
287 }
288
289 }
290
291 public boolean equals(Object obj) {
292 if (this == obj) return true;
293 if (obj == null) return false;
294 if (getClass() != obj.getClass()) return false;
295 Vector2f other = (Vector2f)obj;
296
297 if (x == other.x && y == other.y) return true;
298
299 return false;
300 }
301
289302 }
3333 import java.io.Serializable;
3434 import java.nio.FloatBuffer;
3535
36 import org.lwjgl.util.vector.Vector3f;
37
3638 /**
3739 *
3840 * Holds a 3-tuple vector.
3941 *
4042 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3418 $
42 * $Id: Vector3f.java 3418 2010-09-28 21:11:35Z spasi $
43 * @version $Revision$
44 * $Id$
4345 */
4446
4547 public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f {
343345 public float getZ() {
344346 return z;
345347 }
348
349 public boolean equals(Object obj) {
350 if (this == obj) return true;
351 if (obj == null) return false;
352 if (getClass() != obj.getClass()) return false;
353 Vector3f other = (Vector3f)obj;
354
355 if (x == other.x && y == other.y && z == other.z) return true;
356
357 return false;
358 }
346359 }
3333 import java.io.Serializable;
3434 import java.nio.FloatBuffer;
3535
36 import org.lwjgl.util.vector.Vector4f;
37
3638 /**
3739 *
3840 * Holds a 4-tuple vector.
3941 *
4042 * @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 * @version $Revision$
44 * $Id$
4345 */
4446
4547 public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f {
335337 return w;
336338 }
337339
338
340 public boolean equals(Object obj) {
341 if (this == obj) return true;
342 if (obj == null) return false;
343 if (getClass() != obj.getClass()) return false;
344 Vector4f other = (Vector4f)obj;
345
346 if (x == other.x && y == other.y && z == other.z && w == other.w) return true;
347
348 return false;
349 }
339350 }
3434 * Writable interface to Vector2fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector2f.java 3418 2010-09-28 21:11:35Z spasi $
37 * $Id$
3838 */
3939 public interface WritableVector2f {
4040
3434 * Writable interface to Vector3fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector3f.java 3418 2010-09-28 21:11:35Z spasi $
37 * $Id$
3838 */
3939 public interface WritableVector3f extends WritableVector2f {
4040
3434 * Writable interface to Vector4fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector4f.java 3418 2010-09-28 21:11:35Z spasi $
37 * $Id$
3838 */
3939 public interface WritableVector4f extends WritableVector3f {
4040
0 /* -*- mode: c; tab-width: 8; -*- */
1 /* vi: set sw=4 ts=8: */
2 /* Reference version of egl.h for EGL 1.4.
3 * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
4 */
5
6 /*
7 ** Copyright (c) 2007-2009 The Khronos Group Inc.
8 **
9 ** Permission is hereby granted, free of charge, to any person obtaining a
10 ** copy of this software and/or associated documentation files (the
11 ** "Materials"), to deal in the Materials without restriction, including
12 ** without limitation the rights to use, copy, modify, merge, publish,
13 ** distribute, sublicense, and/or sell copies of the Materials, and to
14 ** permit persons to whom the Materials are furnished to do so, subject to
15 ** the following conditions:
16 **
17 ** The above copyright notice and this permission notice shall be included
18 ** in all copies or substantial portions of the Materials.
19 **
20 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
27 */
28
29 #ifndef __egl_h_
30 #define __egl_h_
31
32 /* All platform-dependent types and macro boilerplate (such as EGLAPI
33 * and EGLAPIENTRY) should go in eglplatform.h.
34 */
35 #include <EGL/eglplatform.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /* EGL Types */
42 /* EGLint is defined in eglplatform.h */
43 typedef unsigned int EGLBoolean;
44 typedef unsigned int EGLenum;
45 typedef void *EGLConfig;
46 typedef void *EGLContext;
47 typedef void *EGLDisplay;
48 typedef void *EGLSurface;
49 typedef void *EGLClientBuffer;
50
51 /* EGL Versioning */
52 #define EGL_VERSION_1_0 1
53 #define EGL_VERSION_1_1 1
54 #define EGL_VERSION_1_2 1
55 #define EGL_VERSION_1_3 1
56 #define EGL_VERSION_1_4 1
57
58 /* EGL Enumerants. Bitmasks and other exceptional cases aside, most
59 * enums are assigned unique values starting at 0x3000.
60 */
61
62 /* EGL aliases */
63 #define EGL_FALSE 0
64 #define EGL_TRUE 1
65
66 /* Out-of-band handle values */
67 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
68 #define EGL_NO_CONTEXT ((EGLContext)0)
69 #define EGL_NO_DISPLAY ((EGLDisplay)0)
70 #define EGL_NO_SURFACE ((EGLSurface)0)
71
72 /* Out-of-band attribute value */
73 #define EGL_DONT_CARE ((EGLint)-1)
74
75 /* Errors / GetError return values */
76 #define EGL_SUCCESS 0x3000
77 #define EGL_NOT_INITIALIZED 0x3001
78 #define EGL_BAD_ACCESS 0x3002
79 #define EGL_BAD_ALLOC 0x3003
80 #define EGL_BAD_ATTRIBUTE 0x3004
81 #define EGL_BAD_CONFIG 0x3005
82 #define EGL_BAD_CONTEXT 0x3006
83 #define EGL_BAD_CURRENT_SURFACE 0x3007
84 #define EGL_BAD_DISPLAY 0x3008
85 #define EGL_BAD_MATCH 0x3009
86 #define EGL_BAD_NATIVE_PIXMAP 0x300A
87 #define EGL_BAD_NATIVE_WINDOW 0x300B
88 #define EGL_BAD_PARAMETER 0x300C
89 #define EGL_BAD_SURFACE 0x300D
90 #define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
91
92 /* Reserved 0x300F-0x301F for additional errors */
93
94 /* Config attributes */
95 #define EGL_BUFFER_SIZE 0x3020
96 #define EGL_ALPHA_SIZE 0x3021
97 #define EGL_BLUE_SIZE 0x3022
98 #define EGL_GREEN_SIZE 0x3023
99 #define EGL_RED_SIZE 0x3024
100 #define EGL_DEPTH_SIZE 0x3025
101 #define EGL_STENCIL_SIZE 0x3026
102 #define EGL_CONFIG_CAVEAT 0x3027
103 #define EGL_CONFIG_ID 0x3028
104 #define EGL_LEVEL 0x3029
105 #define EGL_MAX_PBUFFER_HEIGHT 0x302A
106 #define EGL_MAX_PBUFFER_PIXELS 0x302B
107 #define EGL_MAX_PBUFFER_WIDTH 0x302C
108 #define EGL_NATIVE_RENDERABLE 0x302D
109 #define EGL_NATIVE_VISUAL_ID 0x302E
110 #define EGL_NATIVE_VISUAL_TYPE 0x302F
111 #define EGL_SAMPLES 0x3031
112 #define EGL_SAMPLE_BUFFERS 0x3032
113 #define EGL_SURFACE_TYPE 0x3033
114 #define EGL_TRANSPARENT_TYPE 0x3034
115 #define EGL_TRANSPARENT_BLUE_VALUE 0x3035
116 #define EGL_TRANSPARENT_GREEN_VALUE 0x3036
117 #define EGL_TRANSPARENT_RED_VALUE 0x3037
118 #define EGL_NONE 0x3038 /* Attrib list terminator */
119 #define EGL_BIND_TO_TEXTURE_RGB 0x3039
120 #define EGL_BIND_TO_TEXTURE_RGBA 0x303A
121 #define EGL_MIN_SWAP_INTERVAL 0x303B
122 #define EGL_MAX_SWAP_INTERVAL 0x303C
123 #define EGL_LUMINANCE_SIZE 0x303D
124 #define EGL_ALPHA_MASK_SIZE 0x303E
125 #define EGL_COLOR_BUFFER_TYPE 0x303F
126 #define EGL_RENDERABLE_TYPE 0x3040
127 #define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
128 #define EGL_CONFORMANT 0x3042
129
130 /* Reserved 0x3041-0x304F for additional config attributes */
131
132 /* Config attribute values */
133 #define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
134 #define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
135 #define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
136 #define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
137 #define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
138
139 /* More config attribute values, for EGL_TEXTURE_FORMAT */
140 #define EGL_NO_TEXTURE 0x305C
141 #define EGL_TEXTURE_RGB 0x305D
142 #define EGL_TEXTURE_RGBA 0x305E
143 #define EGL_TEXTURE_2D 0x305F
144
145 /* Config attribute mask bits */
146 #define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
147 #define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
148 #define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
149 #define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
150 #define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
151 #define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
152 #define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
153
154 #define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
155 #define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
156 #define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
157 #define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
158
159 /* QueryString targets */
160 #define EGL_VENDOR 0x3053
161 #define EGL_VERSION 0x3054
162 #define EGL_EXTENSIONS 0x3055
163 #define EGL_CLIENT_APIS 0x308D
164
165 /* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
166 #define EGL_HEIGHT 0x3056
167 #define EGL_WIDTH 0x3057
168 #define EGL_LARGEST_PBUFFER 0x3058
169 #define EGL_TEXTURE_FORMAT 0x3080
170 #define EGL_TEXTURE_TARGET 0x3081
171 #define EGL_MIPMAP_TEXTURE 0x3082
172 #define EGL_MIPMAP_LEVEL 0x3083
173 #define EGL_RENDER_BUFFER 0x3086
174 #define EGL_VG_COLORSPACE 0x3087
175 #define EGL_VG_ALPHA_FORMAT 0x3088
176 #define EGL_HORIZONTAL_RESOLUTION 0x3090
177 #define EGL_VERTICAL_RESOLUTION 0x3091
178 #define EGL_PIXEL_ASPECT_RATIO 0x3092
179 #define EGL_SWAP_BEHAVIOR 0x3093
180 #define EGL_MULTISAMPLE_RESOLVE 0x3099
181
182 /* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
183 #define EGL_BACK_BUFFER 0x3084
184 #define EGL_SINGLE_BUFFER 0x3085
185
186 /* OpenVG color spaces */
187 #define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
188 #define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
189
190 /* OpenVG alpha formats */
191 #define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
192 #define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
193
194 /* Constant scale factor by which fractional display resolutions &
195 * aspect ratio are scaled when queried as integer values.
196 */
197 #define EGL_DISPLAY_SCALING 10000
198
199 /* Unknown display resolution/aspect ratio */
200 #define EGL_UNKNOWN ((EGLint)-1)
201
202 /* Back buffer swap behaviors */
203 #define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
204 #define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
205
206 /* CreatePbufferFromClientBuffer buffer types */
207 #define EGL_OPENVG_IMAGE 0x3096
208
209 /* QueryContext targets */
210 #define EGL_CONTEXT_CLIENT_TYPE 0x3097
211
212 /* CreateContext attributes */
213 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
214
215 /* Multisample resolution behaviors */
216 #define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
217 #define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
218
219 /* BindAPI/QueryAPI targets */
220 #define EGL_OPENGL_ES_API 0x30A0
221 #define EGL_OPENVG_API 0x30A1
222 #define EGL_OPENGL_API 0x30A2
223
224 /* GetCurrentSurface targets */
225 #define EGL_DRAW 0x3059
226 #define EGL_READ 0x305A
227
228 /* WaitNative engines */
229 #define EGL_CORE_NATIVE_ENGINE 0x305B
230
231 /* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
232 #define EGL_COLORSPACE EGL_VG_COLORSPACE
233 #define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
234 #define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
235 #define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
236 #define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
237 #define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
238
239 /* EGL extensions must request enum blocks from the Khronos
240 * API Registrar, who maintains the enumerant registry. Submit
241 * a bug in Khronos Bugzilla against task "Registry".
242 */
243
244
245
246 /* EGL Functions */
247
248 EGLAPI EGLint EGLAPIENTRY eglGetError(void);
249
250 EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
251 EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
252 EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
253
254 EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
255
256 EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
257 EGLint config_size, EGLint *num_config);
258 EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
259 EGLConfig *configs, EGLint config_size,
260 EGLint *num_config);
261 EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
262 EGLint attribute, EGLint *value);
263
264 EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
265 EGLNativeWindowType win,
266 const EGLint *attrib_list);
267 EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
268 const EGLint *attrib_list);
269 EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
270 EGLNativePixmapType pixmap,
271 const EGLint *attrib_list);
272 EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
273 EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
274 EGLint attribute, EGLint *value);
275
276 EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
277 EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
278
279 EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
280
281 EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
282
283 EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
284 EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
285 EGLConfig config, const EGLint *attrib_list);
286
287 EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
288 EGLint attribute, EGLint value);
289 EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
290 EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
291
292
293 EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
294
295
296 EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
297 EGLContext share_context,
298 const EGLint *attrib_list);
299 EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
300 EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
301 EGLSurface read, EGLContext ctx);
302
303 EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
304 EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
305 EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
306 EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
307 EGLint attribute, EGLint *value);
308
309 EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
310 EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
311 EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
312 EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
313 EGLNativePixmapType target);
314
315 /* This is a generic function pointer type, whose name indicates it must
316 * be cast to the proper type *and calling convention* before use.
317 */
318 typedef void (*__eglMustCastToProperFunctionPointerType)(void);
319
320 /* Now, define eglGetProcAddress using the generic function ptr. type */
321 EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
322 eglGetProcAddress(const char *procname);
323
324 #ifdef __cplusplus
325 }
326 #endif
327
328 #endif /* __egl_h_ */
0 #ifndef __eglext_h_
1 #define __eglext_h_
2
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 /*
8 ** Copyright (c) 2007-2010 The Khronos Group Inc.
9 **
10 ** Permission is hereby granted, free of charge, to any person obtaining a
11 ** copy of this software and/or associated documentation files (the
12 ** "Materials"), to deal in the Materials without restriction, including
13 ** without limitation the rights to use, copy, modify, merge, publish,
14 ** distribute, sublicense, and/or sell copies of the Materials, and to
15 ** permit persons to whom the Materials are furnished to do so, subject to
16 ** the following conditions:
17 **
18 ** The above copyright notice and this permission notice shall be included
19 ** in all copies or substantial portions of the Materials.
20 **
21 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28 */
29
30 #include <EGL/eglplatform.h>
31
32 /*************************************************************/
33
34 /* Header file version number */
35 /* Current version at http://www.khronos.org/registry/egl/ */
36 /* $Revision: 11249 $ on $Date: 2010-05-05 09:54:28 -0700 (Wed, 05 May 2010) $ */
37 #define EGL_EGLEXT_VERSION 5
38
39 #ifndef EGL_KHR_config_attribs
40 #define EGL_KHR_config_attribs 1
41 #define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */
42 #define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */
43 #define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */
44 #endif
45
46 #ifndef EGL_KHR_lock_surface
47 #define EGL_KHR_lock_surface 1
48 #define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
49 #define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
50 #define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */
51 #define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */
52 #define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */
53 #define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */
54 #define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */
55 #define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */
56 #define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */
57 #define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */
58 #define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */
59 #define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */
60 #define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */
61 #define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */
62 #define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */
63 #define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */
64 #define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */
65 #define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */
66 #define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */
67 #define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */
68 #define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */
69 #ifdef EGL_EGLEXT_PROTOTYPES
70 EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
71 EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
72 #endif /* EGL_EGLEXT_PROTOTYPES */
73 typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
74 typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
75 #endif
76
77 #ifndef EGL_KHR_image
78 #define EGL_KHR_image 1
79 #define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
80 typedef void *EGLImageKHR;
81 #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
82 #ifdef EGL_EGLEXT_PROTOTYPES
83 EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
84 EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
85 #endif /* EGL_EGLEXT_PROTOTYPES */
86 typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
87 typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
88 #endif
89
90 #ifndef EGL_KHR_vg_parent_image
91 #define EGL_KHR_vg_parent_image 1
92 #define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */
93 #endif
94
95 #ifndef EGL_KHR_gl_texture_2D_image
96 #define EGL_KHR_gl_texture_2D_image 1
97 #define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */
98 #define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */
99 #endif
100
101 #ifndef EGL_KHR_gl_texture_cubemap_image
102 #define EGL_KHR_gl_texture_cubemap_image 1
103 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */
104 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */
105 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */
106 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */
107 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */
108 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */
109 #endif
110
111 #ifndef EGL_KHR_gl_texture_3D_image
112 #define EGL_KHR_gl_texture_3D_image 1
113 #define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */
114 #define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
115 #endif
116
117 #ifndef EGL_KHR_gl_renderbuffer_image
118 #define EGL_KHR_gl_renderbuffer_image 1
119 #define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
120 #endif
121
122 #ifndef EGL_KHR_reusable_sync
123 #define EGL_KHR_reusable_sync 1
124
125 typedef void* EGLSyncKHR;
126 typedef khronos_utime_nanoseconds_t EGLTimeKHR;
127
128 #define EGL_SYNC_STATUS_KHR 0x30F1
129 #define EGL_SIGNALED_KHR 0x30F2
130 #define EGL_UNSIGNALED_KHR 0x30F3
131 #define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
132 #define EGL_CONDITION_SATISFIED_KHR 0x30F6
133 #define EGL_SYNC_TYPE_KHR 0x30F7
134 #define EGL_SYNC_REUSABLE_KHR 0x30FA
135 #define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
136 #define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
137 #define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
138 #ifdef EGL_EGLEXT_PROTOTYPES
139 EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
140 EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
141 EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
142 EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
143 EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
144 #endif /* EGL_EGLEXT_PROTOTYPES */
145 typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
146 typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
147 typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
148 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
149 typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
150 #endif
151
152 #ifndef EGL_KHR_image_base
153 #define EGL_KHR_image_base 1
154 /* Most interfaces defined by EGL_KHR_image_pixmap above */
155 #define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
156 #endif
157
158 #ifndef EGL_KHR_image_pixmap
159 #define EGL_KHR_image_pixmap 1
160 /* Interfaces defined by EGL_KHR_image above */
161 #endif
162
163 #ifndef EGL_IMG_context_priority
164 #define EGL_IMG_context_priority 1
165 #define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
166 #define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
167 #define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
168 #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
169 #endif
170
171 #ifndef EGL_NV_coverage_sample
172 #define EGL_NV_coverage_sample 1
173 #define EGL_COVERAGE_BUFFERS_NV 0x30E0
174 #define EGL_COVERAGE_SAMPLES_NV 0x30E1
175 #endif
176
177 #ifndef EGL_NV_depth_nonlinear
178 #define EGL_NV_depth_nonlinear 1
179 #define EGL_DEPTH_ENCODING_NV 0x30E2
180 #define EGL_DEPTH_ENCODING_NONE_NV 0
181 #define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
182 #endif
183
184 #ifndef EGL_NV_sync
185 #define EGL_NV_sync 1
186 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
187 #define EGL_SYNC_STATUS_NV 0x30E7
188 #define EGL_SIGNALED_NV 0x30E8
189 #define EGL_UNSIGNALED_NV 0x30E9
190 #define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001
191 #define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull
192 #define EGL_ALREADY_SIGNALED_NV 0x30EA
193 #define EGL_TIMEOUT_EXPIRED_NV 0x30EB
194 #define EGL_CONDITION_SATISFIED_NV 0x30EC
195 #define EGL_SYNC_TYPE_NV 0x30ED
196 #define EGL_SYNC_CONDITION_NV 0x30EE
197 #define EGL_SYNC_FENCE_NV 0x30EF
198 #define EGL_NO_SYNC_NV ((EGLSyncNV)0)
199 typedef void* EGLSyncNV;
200 typedef unsigned long long EGLTimeNV;
201 #ifdef EGL_EGLEXT_PROTOTYPES
202 EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
203 EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
204 EGLBoolean eglFenceNV (EGLSyncNV sync);
205 EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
206 EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
207 EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
208 #endif /* EGL_EGLEXT_PROTOTYPES */
209 typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
210 typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
211 typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
212 typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
213 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
214 typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
215 #endif
216
217 #ifndef EGL_KHR_fence_sync
218 #define EGL_KHR_fence_sync 1
219 /* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
220 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
221 #define EGL_SYNC_CONDITION_KHR 0x30F8
222 #define EGL_SYNC_FENCE_KHR 0x30F9
223 #endif
224
225 #ifdef __cplusplus
226 }
227 #endif
228
229 #endif
0 #ifndef __eglplatform_h_
1 #define __eglplatform_h_
2
3 /*
4 ** Copyright (c) 2007-2009 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 /* Platform-specific types and definitions for egl.h
27 * $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $
28 *
29 * Adopters may modify khrplatform.h and this file to suit their platform.
30 * You are encouraged to submit all modifications to the Khronos group so that
31 * they can be included in future versions of this file. Please submit changes
32 * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
33 * by filing a bug against product "EGL" component "Registry".
34 */
35
36 #include <KHR/khrplatform.h>
37
38 /* Macros used in EGL function prototype declarations.
39 *
40 * EGL functions should be prototyped as:
41 *
42 * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
43 * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
44 *
45 * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
46 */
47
48 #ifndef EGLAPI
49 #define EGLAPI KHRONOS_APICALL
50 #endif
51
52 #ifndef EGLAPIENTRY
53 #define EGLAPIENTRY KHRONOS_APIENTRY
54 #endif
55 #define EGLAPIENTRYP EGLAPIENTRY*
56
57 /* The types NativeDisplayType, NativeWindowType, and NativePixmapType
58 * are aliases of window-system-dependent types, such as X Display * or
59 * Windows Device Context. They must be defined in platform-specific
60 * code below. The EGL-prefixed versions of Native*Type are the same
61 * types, renamed in EGL 1.3 so all types in the API start with "EGL".
62 */
63
64 #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
65 #ifndef WIN32_LEAN_AND_MEAN
66 #define WIN32_LEAN_AND_MEAN 1
67 #endif
68 #include <windows.h>
69
70 typedef HDC EGLNativeDisplayType;
71 typedef HBITMAP EGLNativePixmapType;
72 typedef HWND EGLNativeWindowType;
73
74 #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
75
76 typedef int EGLNativeDisplayType;
77 typedef void *EGLNativeWindowType;
78 typedef void *EGLNativePixmapType;
79
80 #elif defined(__unix__)
81
82 /* X11 (tentative) */
83 #include <X11/Xlib.h>
84 #include <X11/Xutil.h>
85
86 typedef Display *EGLNativeDisplayType;
87 typedef Pixmap EGLNativePixmapType;
88 typedef Window EGLNativeWindowType;
89
90 #else
91 #error "Platform not recognized"
92 #endif
93
94 /* EGL 1.2 types, renamed for consistency in EGL 1.3 */
95 typedef EGLNativeDisplayType NativeDisplayType;
96 typedef EGLNativePixmapType NativePixmapType;
97 typedef EGLNativeWindowType NativeWindowType;
98
99
100 /* Define EGLint. This must be a signed integral type large enough to contain
101 * all legal attribute names and values passed into and out of EGL, whether
102 * their type is boolean, bitmask, enumerant (symbolic constant), integer,
103 * handle, or other. While in general a 32-bit integer will suffice, if
104 * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
105 * integer type.
106 */
107 typedef khronos_int32_t EGLint;
108
109 #endif /* __eglplatform_h */
0 #ifndef __gl2_h_
1 #define __gl2_h_
2
3 /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
4
5 #include <GLES2/gl2platform.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /*
12 * This document is licensed under the SGI Free Software B License Version
13 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
14 */
15
16 /*-------------------------------------------------------------------------
17 * Data type definitions
18 *-----------------------------------------------------------------------*/
19
20 typedef void GLvoid;
21 typedef char GLchar;
22 typedef unsigned int GLenum;
23 typedef unsigned char GLboolean;
24 typedef unsigned int GLbitfield;
25 typedef khronos_int8_t GLbyte;
26 typedef short GLshort;
27 typedef int GLint;
28 typedef int GLsizei;
29 typedef khronos_uint8_t GLubyte;
30 typedef unsigned short GLushort;
31 typedef unsigned int GLuint;
32 typedef khronos_float_t GLfloat;
33 typedef khronos_float_t GLclampf;
34 typedef khronos_int32_t GLfixed;
35
36 /* GL types for handling large vertex buffer objects */
37 typedef khronos_intptr_t GLintptr;
38 typedef khronos_ssize_t GLsizeiptr;
39
40 /* OpenGL ES core versions */
41 #define GL_ES_VERSION_2_0 1
42
43 /* ClearBufferMask */
44 #define GL_DEPTH_BUFFER_BIT 0x00000100
45 #define GL_STENCIL_BUFFER_BIT 0x00000400
46 #define GL_COLOR_BUFFER_BIT 0x00004000
47
48 /* Boolean */
49 #define GL_FALSE 0
50 #define GL_TRUE 1
51
52 /* BeginMode */
53 #define GL_POINTS 0x0000
54 #define GL_LINES 0x0001
55 #define GL_LINE_LOOP 0x0002
56 #define GL_LINE_STRIP 0x0003
57 #define GL_TRIANGLES 0x0004
58 #define GL_TRIANGLE_STRIP 0x0005
59 #define GL_TRIANGLE_FAN 0x0006
60
61 /* AlphaFunction (not supported in ES20) */
62 /* GL_NEVER */
63 /* GL_LESS */
64 /* GL_EQUAL */
65 /* GL_LEQUAL */
66 /* GL_GREATER */
67 /* GL_NOTEQUAL */
68 /* GL_GEQUAL */
69 /* GL_ALWAYS */
70
71 /* BlendingFactorDest */
72 #define GL_ZERO 0
73 #define GL_ONE 1
74 #define GL_SRC_COLOR 0x0300
75 #define GL_ONE_MINUS_SRC_COLOR 0x0301
76 #define GL_SRC_ALPHA 0x0302
77 #define GL_ONE_MINUS_SRC_ALPHA 0x0303
78 #define GL_DST_ALPHA 0x0304
79 #define GL_ONE_MINUS_DST_ALPHA 0x0305
80
81 /* BlendingFactorSrc */
82 /* GL_ZERO */
83 /* GL_ONE */
84 #define GL_DST_COLOR 0x0306
85 #define GL_ONE_MINUS_DST_COLOR 0x0307
86 #define GL_SRC_ALPHA_SATURATE 0x0308
87 /* GL_SRC_ALPHA */
88 /* GL_ONE_MINUS_SRC_ALPHA */
89 /* GL_DST_ALPHA */
90 /* GL_ONE_MINUS_DST_ALPHA */
91
92 /* BlendEquationSeparate */
93 #define GL_FUNC_ADD 0x8006
94 #define GL_BLEND_EQUATION 0x8009
95 #define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
96 #define GL_BLEND_EQUATION_ALPHA 0x883D
97
98 /* BlendSubtract */
99 #define GL_FUNC_SUBTRACT 0x800A
100 #define GL_FUNC_REVERSE_SUBTRACT 0x800B
101
102 /* Separate Blend Functions */
103 #define GL_BLEND_DST_RGB 0x80C8
104 #define GL_BLEND_SRC_RGB 0x80C9
105 #define GL_BLEND_DST_ALPHA 0x80CA
106 #define GL_BLEND_SRC_ALPHA 0x80CB
107 #define GL_CONSTANT_COLOR 0x8001
108 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
109 #define GL_CONSTANT_ALPHA 0x8003
110 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
111 #define GL_BLEND_COLOR 0x8005
112
113 /* Buffer Objects */
114 #define GL_ARRAY_BUFFER 0x8892
115 #define GL_ELEMENT_ARRAY_BUFFER 0x8893
116 #define GL_ARRAY_BUFFER_BINDING 0x8894
117 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
118
119 #define GL_STREAM_DRAW 0x88E0
120 #define GL_STATIC_DRAW 0x88E4
121 #define GL_DYNAMIC_DRAW 0x88E8
122
123 #define GL_BUFFER_SIZE 0x8764
124 #define GL_BUFFER_USAGE 0x8765
125
126 #define GL_CURRENT_VERTEX_ATTRIB 0x8626
127
128 /* CullFaceMode */
129 #define GL_FRONT 0x0404
130 #define GL_BACK 0x0405
131 #define GL_FRONT_AND_BACK 0x0408
132
133 /* DepthFunction */
134 /* GL_NEVER */
135 /* GL_LESS */
136 /* GL_EQUAL */
137 /* GL_LEQUAL */
138 /* GL_GREATER */
139 /* GL_NOTEQUAL */
140 /* GL_GEQUAL */
141 /* GL_ALWAYS */
142
143 /* EnableCap */
144 #define GL_TEXTURE_2D 0x0DE1
145 #define GL_CULL_FACE 0x0B44
146 #define GL_BLEND 0x0BE2
147 #define GL_DITHER 0x0BD0
148 #define GL_STENCIL_TEST 0x0B90
149 #define GL_DEPTH_TEST 0x0B71
150 #define GL_SCISSOR_TEST 0x0C11
151 #define GL_POLYGON_OFFSET_FILL 0x8037
152 #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
153 #define GL_SAMPLE_COVERAGE 0x80A0
154
155 /* ErrorCode */
156 #define GL_NO_ERROR 0
157 #define GL_INVALID_ENUM 0x0500
158 #define GL_INVALID_VALUE 0x0501
159 #define GL_INVALID_OPERATION 0x0502
160 #define GL_OUT_OF_MEMORY 0x0505
161
162 /* FrontFaceDirection */
163 #define GL_CW 0x0900
164 #define GL_CCW 0x0901
165
166 /* GetPName */
167 #define GL_LINE_WIDTH 0x0B21
168 #define GL_ALIASED_POINT_SIZE_RANGE 0x846D
169 #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
170 #define GL_CULL_FACE_MODE 0x0B45
171 #define GL_FRONT_FACE 0x0B46
172 #define GL_DEPTH_RANGE 0x0B70
173 #define GL_DEPTH_WRITEMASK 0x0B72
174 #define GL_DEPTH_CLEAR_VALUE 0x0B73
175 #define GL_DEPTH_FUNC 0x0B74
176 #define GL_STENCIL_CLEAR_VALUE 0x0B91
177 #define GL_STENCIL_FUNC 0x0B92
178 #define GL_STENCIL_FAIL 0x0B94
179 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
180 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
181 #define GL_STENCIL_REF 0x0B97
182 #define GL_STENCIL_VALUE_MASK 0x0B93
183 #define GL_STENCIL_WRITEMASK 0x0B98
184 #define GL_STENCIL_BACK_FUNC 0x8800
185 #define GL_STENCIL_BACK_FAIL 0x8801
186 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
187 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
188 #define GL_STENCIL_BACK_REF 0x8CA3
189 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
190 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5
191 #define GL_VIEWPORT 0x0BA2
192 #define GL_SCISSOR_BOX 0x0C10
193 /* GL_SCISSOR_TEST */
194 #define GL_COLOR_CLEAR_VALUE 0x0C22
195 #define GL_COLOR_WRITEMASK 0x0C23
196 #define GL_UNPACK_ALIGNMENT 0x0CF5
197 #define GL_PACK_ALIGNMENT 0x0D05
198 #define GL_MAX_TEXTURE_SIZE 0x0D33
199 #define GL_MAX_VIEWPORT_DIMS 0x0D3A
200 #define GL_SUBPIXEL_BITS 0x0D50
201 #define GL_RED_BITS 0x0D52
202 #define GL_GREEN_BITS 0x0D53
203 #define GL_BLUE_BITS 0x0D54
204 #define GL_ALPHA_BITS 0x0D55
205 #define GL_DEPTH_BITS 0x0D56
206 #define GL_STENCIL_BITS 0x0D57
207 #define GL_POLYGON_OFFSET_UNITS 0x2A00
208 /* GL_POLYGON_OFFSET_FILL */
209 #define GL_POLYGON_OFFSET_FACTOR 0x8038
210 #define GL_TEXTURE_BINDING_2D 0x8069
211 #define GL_SAMPLE_BUFFERS 0x80A8
212 #define GL_SAMPLES 0x80A9
213 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA
214 #define GL_SAMPLE_COVERAGE_INVERT 0x80AB
215
216 /* GetTextureParameter */
217 /* GL_TEXTURE_MAG_FILTER */
218 /* GL_TEXTURE_MIN_FILTER */
219 /* GL_TEXTURE_WRAP_S */
220 /* GL_TEXTURE_WRAP_T */
221
222 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
223 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
224
225 /* HintMode */
226 #define GL_DONT_CARE 0x1100
227 #define GL_FASTEST 0x1101
228 #define GL_NICEST 0x1102
229
230 /* HintTarget */
231 #define GL_GENERATE_MIPMAP_HINT 0x8192
232
233 /* DataType */
234 #define GL_BYTE 0x1400
235 #define GL_UNSIGNED_BYTE 0x1401
236 #define GL_SHORT 0x1402
237 #define GL_UNSIGNED_SHORT 0x1403
238 #define GL_INT 0x1404
239 #define GL_UNSIGNED_INT 0x1405
240 #define GL_FLOAT 0x1406
241 #define GL_FIXED 0x140C
242
243 /* PixelFormat */
244 #define GL_DEPTH_COMPONENT 0x1902
245 #define GL_ALPHA 0x1906
246 #define GL_RGB 0x1907
247 #define GL_RGBA 0x1908
248 #define GL_LUMINANCE 0x1909
249 #define GL_LUMINANCE_ALPHA 0x190A
250
251 /* PixelType */
252 /* GL_UNSIGNED_BYTE */
253 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
254 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
255 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
256
257 /* Shaders */
258 #define GL_FRAGMENT_SHADER 0x8B30
259 #define GL_VERTEX_SHADER 0x8B31
260 #define GL_MAX_VERTEX_ATTRIBS 0x8869
261 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
262 #define GL_MAX_VARYING_VECTORS 0x8DFC
263 #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
264 #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
265 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
266 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
267 #define GL_SHADER_TYPE 0x8B4F
268 #define GL_DELETE_STATUS 0x8B80
269 #define GL_LINK_STATUS 0x8B82
270 #define GL_VALIDATE_STATUS 0x8B83
271 #define GL_ATTACHED_SHADERS 0x8B85
272 #define GL_ACTIVE_UNIFORMS 0x8B86
273 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
274 #define GL_ACTIVE_ATTRIBUTES 0x8B89
275 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
276 #define GL_SHADING_LANGUAGE_VERSION 0x8B8C
277 #define GL_CURRENT_PROGRAM 0x8B8D
278
279 /* StencilFunction */
280 #define GL_NEVER 0x0200
281 #define GL_LESS 0x0201
282 #define GL_EQUAL 0x0202
283 #define GL_LEQUAL 0x0203
284 #define GL_GREATER 0x0204
285 #define GL_NOTEQUAL 0x0205
286 #define GL_GEQUAL 0x0206
287 #define GL_ALWAYS 0x0207
288
289 /* StencilOp */
290 /* GL_ZERO */
291 #define GL_KEEP 0x1E00
292 #define GL_REPLACE 0x1E01
293 #define GL_INCR 0x1E02
294 #define GL_DECR 0x1E03
295 #define GL_INVERT 0x150A
296 #define GL_INCR_WRAP 0x8507
297 #define GL_DECR_WRAP 0x8508
298
299 /* StringName */
300 #define GL_VENDOR 0x1F00
301 #define GL_RENDERER 0x1F01
302 #define GL_VERSION 0x1F02
303 #define GL_EXTENSIONS 0x1F03
304
305 /* TextureMagFilter */
306 #define GL_NEAREST 0x2600
307 #define GL_LINEAR 0x2601
308
309 /* TextureMinFilter */
310 /* GL_NEAREST */
311 /* GL_LINEAR */
312 #define GL_NEAREST_MIPMAP_NEAREST 0x2700
313 #define GL_LINEAR_MIPMAP_NEAREST 0x2701
314 #define GL_NEAREST_MIPMAP_LINEAR 0x2702
315 #define GL_LINEAR_MIPMAP_LINEAR 0x2703
316
317 /* TextureParameterName */
318 #define GL_TEXTURE_MAG_FILTER 0x2800
319 #define GL_TEXTURE_MIN_FILTER 0x2801
320 #define GL_TEXTURE_WRAP_S 0x2802
321 #define GL_TEXTURE_WRAP_T 0x2803
322
323 /* TextureTarget */
324 /* GL_TEXTURE_2D */
325 #define GL_TEXTURE 0x1702
326
327 #define GL_TEXTURE_CUBE_MAP 0x8513
328 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
329 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
330 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
331 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
332 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
333 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
334 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
335 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
336
337 /* TextureUnit */
338 #define GL_TEXTURE0 0x84C0
339 #define GL_TEXTURE1 0x84C1
340 #define GL_TEXTURE2 0x84C2
341 #define GL_TEXTURE3 0x84C3
342 #define GL_TEXTURE4 0x84C4
343 #define GL_TEXTURE5 0x84C5
344 #define GL_TEXTURE6 0x84C6
345 #define GL_TEXTURE7 0x84C7
346 #define GL_TEXTURE8 0x84C8
347 #define GL_TEXTURE9 0x84C9
348 #define GL_TEXTURE10 0x84CA
349 #define GL_TEXTURE11 0x84CB
350 #define GL_TEXTURE12 0x84CC
351 #define GL_TEXTURE13 0x84CD
352 #define GL_TEXTURE14 0x84CE
353 #define GL_TEXTURE15 0x84CF
354 #define GL_TEXTURE16 0x84D0
355 #define GL_TEXTURE17 0x84D1
356 #define GL_TEXTURE18 0x84D2
357 #define GL_TEXTURE19 0x84D3
358 #define GL_TEXTURE20 0x84D4
359 #define GL_TEXTURE21 0x84D5
360 #define GL_TEXTURE22 0x84D6
361 #define GL_TEXTURE23 0x84D7
362 #define GL_TEXTURE24 0x84D8
363 #define GL_TEXTURE25 0x84D9
364 #define GL_TEXTURE26 0x84DA
365 #define GL_TEXTURE27 0x84DB
366 #define GL_TEXTURE28 0x84DC
367 #define GL_TEXTURE29 0x84DD
368 #define GL_TEXTURE30 0x84DE
369 #define GL_TEXTURE31 0x84DF
370 #define GL_ACTIVE_TEXTURE 0x84E0
371
372 /* TextureWrapMode */
373 #define GL_REPEAT 0x2901
374 #define GL_CLAMP_TO_EDGE 0x812F
375 #define GL_MIRRORED_REPEAT 0x8370
376
377 /* Uniform Types */
378 #define GL_FLOAT_VEC2 0x8B50
379 #define GL_FLOAT_VEC3 0x8B51
380 #define GL_FLOAT_VEC4 0x8B52
381 #define GL_INT_VEC2 0x8B53
382 #define GL_INT_VEC3 0x8B54
383 #define GL_INT_VEC4 0x8B55
384 #define GL_BOOL 0x8B56
385 #define GL_BOOL_VEC2 0x8B57
386 #define GL_BOOL_VEC3 0x8B58
387 #define GL_BOOL_VEC4 0x8B59
388 #define GL_FLOAT_MAT2 0x8B5A
389 #define GL_FLOAT_MAT3 0x8B5B
390 #define GL_FLOAT_MAT4 0x8B5C
391 #define GL_SAMPLER_2D 0x8B5E
392 #define GL_SAMPLER_CUBE 0x8B60
393
394 /* Vertex Arrays */
395 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
396 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
397 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
398 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
399 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
400 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
401 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
402
403 /* Read Format */
404 #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
405 #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
406
407 /* Shader Source */
408 #define GL_COMPILE_STATUS 0x8B81
409 #define GL_INFO_LOG_LENGTH 0x8B84
410 #define GL_SHADER_SOURCE_LENGTH 0x8B88
411 #define GL_SHADER_COMPILER 0x8DFA
412
413 /* Shader Binary */
414 #define GL_SHADER_BINARY_FORMATS 0x8DF8
415 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
416
417 /* Shader Precision-Specified Types */
418 #define GL_LOW_FLOAT 0x8DF0
419 #define GL_MEDIUM_FLOAT 0x8DF1
420 #define GL_HIGH_FLOAT 0x8DF2
421 #define GL_LOW_INT 0x8DF3
422 #define GL_MEDIUM_INT 0x8DF4
423 #define GL_HIGH_INT 0x8DF5
424
425 /* Framebuffer Object. */
426 #define GL_FRAMEBUFFER 0x8D40
427 #define GL_RENDERBUFFER 0x8D41
428
429 #define GL_RGBA4 0x8056
430 #define GL_RGB5_A1 0x8057
431 #define GL_RGB565 0x8D62
432 #define GL_DEPTH_COMPONENT16 0x81A5
433 #define GL_STENCIL_INDEX 0x1901
434 #define GL_STENCIL_INDEX8 0x8D48
435
436 #define GL_RENDERBUFFER_WIDTH 0x8D42
437 #define GL_RENDERBUFFER_HEIGHT 0x8D43
438 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
439 #define GL_RENDERBUFFER_RED_SIZE 0x8D50
440 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
441 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
442 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
443 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
444 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
445
446 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
447 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
448 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
449 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
450
451 #define GL_COLOR_ATTACHMENT0 0x8CE0
452 #define GL_DEPTH_ATTACHMENT 0x8D00
453 #define GL_STENCIL_ATTACHMENT 0x8D20
454
455 #define GL_NONE 0
456
457 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5
458 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
459 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
460 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
461 #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
462
463 #define GL_FRAMEBUFFER_BINDING 0x8CA6
464 #define GL_RENDERBUFFER_BINDING 0x8CA7
465 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8
466
467 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
468
469 /*-------------------------------------------------------------------------
470 * GL core functions.
471 *-----------------------------------------------------------------------*/
472
473 GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
474 GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
475 GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
476 GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
477 GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
478 GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
479 GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
480 GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
481 GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
482 GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
483 GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
484 GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
485 GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
486 GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
487 GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
488 GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
489 GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
490 GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
491 GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
492 GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
493 GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
494 GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
495 GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
496 GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
497 GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
498 GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
499 GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
500 GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
501 GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
502 GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
503 GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
504 GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
505 GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
506 GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
507 GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
508 GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
509 GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
510 GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
511 GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
512 GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
513 GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
514 GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
515 GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
516 GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
517 GL_APICALL void GL_APIENTRY glFinish (void);
518 GL_APICALL void GL_APIENTRY glFlush (void);
519 GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
520 GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
521 GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
522 GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
523 GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
524 GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
525 GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
526 GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
527 GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
528 GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
529 GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
530 GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
531 GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
532 GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
533 GL_APICALL GLenum GL_APIENTRY glGetError (void);
534 GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
535 GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
536 GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
537 GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
538 GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
539 GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
540 GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
541 GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
542 GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
543 GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
544 GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
545 GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
546 GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
547 GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
548 GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
549 GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
550 GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
551 GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
552 GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
553 GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
554 GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
555 GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
556 GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
557 GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
558 GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
559 GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
560 GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
561 GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
562 GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
563 GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
564 GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
565 GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
566 GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
567 GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
568 GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
569 GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
570 GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
571 GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
572 GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
573 GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
574 GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
575 GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
576 GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
577 GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
578 GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
579 GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
580 GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
581 GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
582 GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
583 GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
584 GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
585 GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
586 GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
587 GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
588 GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
589 GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
590 GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
591 GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
592 GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
593 GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
594 GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
595 GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
596 GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
597 GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
598 GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
599 GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
600 GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
601 GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
602 GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
603 GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
604 GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
605 GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
606 GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
607 GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
608 GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
609 GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
610 GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
611 GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
612 GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
613 GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
614 GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
615
616 #ifdef __cplusplus
617 }
618 #endif
619
620 #endif /* __gl2_h_ */
0 #ifndef __gl2ext_h_
1 #define __gl2ext_h_
2
3 /* $Revision: 10969 $ on $Date:: 2010-04-09 02:27:15 -0700 #$ */
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 /*
10 * This document is licensed under the SGI Free Software B License Version
11 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
12 */
13
14 #ifndef GL_APIENTRYP
15 # define GL_APIENTRYP GL_APIENTRY*
16 #endif
17
18 /*------------------------------------------------------------------------*
19 * OES extension tokens
20 *------------------------------------------------------------------------*/
21
22 /* GL_OES_compressed_ETC1_RGB8_texture */
23 #ifndef GL_OES_compressed_ETC1_RGB8_texture
24 #define GL_ETC1_RGB8_OES 0x8D64
25 #endif
26
27 /* GL_OES_compressed_paletted_texture */
28 #ifndef GL_OES_compressed_paletted_texture
29 #define GL_PALETTE4_RGB8_OES 0x8B90
30 #define GL_PALETTE4_RGBA8_OES 0x8B91
31 #define GL_PALETTE4_R5_G6_B5_OES 0x8B92
32 #define GL_PALETTE4_RGBA4_OES 0x8B93
33 #define GL_PALETTE4_RGB5_A1_OES 0x8B94
34 #define GL_PALETTE8_RGB8_OES 0x8B95
35 #define GL_PALETTE8_RGBA8_OES 0x8B96
36 #define GL_PALETTE8_R5_G6_B5_OES 0x8B97
37 #define GL_PALETTE8_RGBA4_OES 0x8B98
38 #define GL_PALETTE8_RGB5_A1_OES 0x8B99
39 #endif
40
41 /* GL_OES_depth24 */
42 #ifndef GL_OES_depth24
43 #define GL_DEPTH_COMPONENT24_OES 0x81A6
44 #endif
45
46 /* GL_OES_depth32 */
47 #ifndef GL_OES_depth32
48 #define GL_DEPTH_COMPONENT32_OES 0x81A7
49 #endif
50
51 /* GL_OES_depth_texture */
52 /* No new tokens introduced by this extension. */
53
54 /* GL_OES_EGL_image */
55 #ifndef GL_OES_EGL_image
56 typedef void* GLeglImageOES;
57 #endif
58
59 /* GL_OES_element_index_uint */
60 #ifndef GL_OES_element_index_uint
61 #define GL_UNSIGNED_INT 0x1405
62 #endif
63
64 /* GL_OES_get_program_binary */
65 #ifndef GL_OES_get_program_binary
66 #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
67 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
68 #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
69 #endif
70
71 /* GL_OES_mapbuffer */
72 #ifndef GL_OES_mapbuffer
73 #define GL_WRITE_ONLY_OES 0x88B9
74 #define GL_BUFFER_ACCESS_OES 0x88BB
75 #define GL_BUFFER_MAPPED_OES 0x88BC
76 #define GL_BUFFER_MAP_POINTER_OES 0x88BD
77 #endif
78
79 /* GL_OES_packed_depth_stencil */
80 #ifndef GL_OES_packed_depth_stencil
81 #define GL_DEPTH_STENCIL_OES 0x84F9
82 #define GL_UNSIGNED_INT_24_8_OES 0x84FA
83 #define GL_DEPTH24_STENCIL8_OES 0x88F0
84 #endif
85
86 /* GL_OES_rgb8_rgba8 */
87 #ifndef GL_OES_rgb8_rgba8
88 #define GL_RGB8_OES 0x8051
89 #define GL_RGBA8_OES 0x8058
90 #endif
91
92 /* GL_OES_standard_derivatives */
93 #ifndef GL_OES_standard_derivatives
94 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
95 #endif
96
97 /* GL_OES_stencil1 */
98 #ifndef GL_OES_stencil1
99 #define GL_STENCIL_INDEX1_OES 0x8D46
100 #endif
101
102 /* GL_OES_stencil4 */
103 #ifndef GL_OES_stencil4
104 #define GL_STENCIL_INDEX4_OES 0x8D47
105 #endif
106
107 /* GL_OES_texture_3D */
108 #ifndef GL_OES_texture_3D
109 #define GL_TEXTURE_WRAP_R_OES 0x8072
110 #define GL_TEXTURE_3D_OES 0x806F
111 #define GL_TEXTURE_BINDING_3D_OES 0x806A
112 #define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
113 #define GL_SAMPLER_3D_OES 0x8B5F
114 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
115 #endif
116
117 /* GL_OES_texture_float */
118 /* No new tokens introduced by this extension. */
119
120 /* GL_OES_texture_float_linear */
121 /* No new tokens introduced by this extension. */
122
123 /* GL_OES_texture_half_float */
124 #ifndef GL_OES_texture_half_float
125 #define GL_HALF_FLOAT_OES 0x8D61
126 #endif
127
128 /* GL_OES_texture_half_float_linear */
129 /* No new tokens introduced by this extension. */
130
131 /* GL_OES_texture_npot */
132 /* No new tokens introduced by this extension. */
133
134 /* GL_OES_vertex_array_object */
135 #ifndef GL_OES_vertex_array_object
136 #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
137 #endif
138
139 /* GL_OES_vertex_half_float */
140 /* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
141
142 /* GL_OES_vertex_type_10_10_10_2 */
143 #ifndef GL_OES_vertex_type_10_10_10_2
144 #define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
145 #define GL_INT_10_10_10_2_OES 0x8DF7
146 #endif
147
148 /*------------------------------------------------------------------------*
149 * AMD extension tokens
150 *------------------------------------------------------------------------*/
151
152 /* GL_AMD_compressed_3DC_texture */
153 #ifndef GL_AMD_compressed_3DC_texture
154 #define GL_3DC_X_AMD 0x87F9
155 #define GL_3DC_XY_AMD 0x87FA
156 #endif
157
158 /* GL_AMD_compressed_ATC_texture */
159 #ifndef GL_AMD_compressed_ATC_texture
160 #define GL_ATC_RGB_AMD 0x8C92
161 #define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
162 #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
163 #endif
164
165 /* GL_AMD_performance_monitor */
166 #ifndef GL_AMD_performance_monitor
167 #define GL_COUNTER_TYPE_AMD 0x8BC0
168 #define GL_COUNTER_RANGE_AMD 0x8BC1
169 #define GL_UNSIGNED_INT64_AMD 0x8BC2
170 #define GL_PERCENTAGE_AMD 0x8BC3
171 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
172 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
173 #define GL_PERFMON_RESULT_AMD 0x8BC6
174 #endif
175
176 /* GL_AMD_program_binary_Z400 */
177 #ifndef GL_AMD_program_binary_Z400
178 #define GL_Z400_BINARY_AMD 0x8740
179 #endif
180
181 /*------------------------------------------------------------------------*
182 * EXT extension tokens
183 *------------------------------------------------------------------------*/
184
185 /* GL_EXT_blend_minmax */
186 #ifndef GL_EXT_blend_minmax
187 #define GL_MIN_EXT 0x8007
188 #define GL_MAX_EXT 0x8008
189 #endif
190
191 /* GL_EXT_discard_framebuffer */
192 #ifndef GL_EXT_discard_framebuffer
193 #define GL_COLOR_EXT 0x1800
194 #define GL_DEPTH_EXT 0x1801
195 #define GL_STENCIL_EXT 0x1802
196 #endif
197
198 /* GL_EXT_multi_draw_arrays */
199 /* No new tokens introduced by this extension. */
200
201 /* GL_EXT_read_format_bgra */
202 #ifndef GL_EXT_read_format_bgra
203 #define GL_BGRA_EXT 0x80E1
204 #define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
205 #define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
206 #endif
207
208 /* GL_EXT_texture_filter_anisotropic */
209 #ifndef GL_EXT_texture_filter_anisotropic
210 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
211 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
212 #endif
213
214 /* GL_EXT_texture_format_BGRA8888 */
215 #ifndef GL_EXT_texture_format_BGRA8888
216 #define GL_BGRA_EXT 0x80E1
217 #endif
218
219 /* GL_EXT_texture_type_2_10_10_10_REV */
220 #ifndef GL_EXT_texture_type_2_10_10_10_REV
221 #define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
222 #endif
223
224 /* GL_EXT_texture_compression_dxt1 */
225 #ifndef GL_EXT_texture_compression_dxt1
226 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
227 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
228 #endif
229
230 /*------------------------------------------------------------------------*
231 * IMG extension tokens
232 *------------------------------------------------------------------------*/
233
234 /* GL_IMG_program_binary */
235 #ifndef GL_IMG_program_binary
236 #define GL_SGX_PROGRAM_BINARY_IMG 0x9130
237 #endif
238
239 /* GL_IMG_read_format */
240 #ifndef GL_IMG_read_format
241 #define GL_BGRA_IMG 0x80E1
242 #define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
243 #endif
244
245 /* GL_IMG_shader_binary */
246 #ifndef GL_IMG_shader_binary
247 #define GL_SGX_BINARY_IMG 0x8C0A
248 #endif
249
250 /* GL_IMG_texture_compression_pvrtc */
251 #ifndef GL_IMG_texture_compression_pvrtc
252 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
253 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
254 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
255 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
256 #endif
257
258 /* GL_IMG_multisampled_render_to_texture */
259 #ifndef GL_IMG_multisampled_render_to_texture
260 #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
261 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
262 #define GL_MAX_SAMPLES_IMG 0x9135
263 #define GL_TEXTURE_SAMPLES_IMG 0x9136
264 #endif
265
266 /*------------------------------------------------------------------------*
267 * NV extension tokens
268 *------------------------------------------------------------------------*/
269
270 /* GL_NV_fence */
271 #ifndef GL_NV_fence
272 #define GL_ALL_COMPLETED_NV 0x84F2
273 #define GL_FENCE_STATUS_NV 0x84F3
274 #define GL_FENCE_CONDITION_NV 0x84F4
275 #endif
276
277 /* GL_NV_coverage_sample */
278 #ifndef GL_NV_coverage_sample
279 #define GL_COVERAGE_COMPONENT_NV 0x8ED0
280 #define GL_COVERAGE_COMPONENT4_NV 0x8ED1
281 #define GL_COVERAGE_ATTACHMENT_NV 0x8ED2
282 #define GL_COVERAGE_BUFFERS_NV 0x8ED3
283 #define GL_COVERAGE_SAMPLES_NV 0x8ED4
284 #define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
285 #define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
286 #define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
287 #define GL_COVERAGE_BUFFER_BIT_NV 0x8000
288 #endif
289
290 /* GL_NV_depth_nonlinear */
291 #ifndef GL_NV_depth_nonlinear
292 #define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
293 #endif
294
295 /*------------------------------------------------------------------------*
296 * QCOM extension tokens
297 *------------------------------------------------------------------------*/
298
299 /* GL_QCOM_driver_control */
300 /* No new tokens introduced by this extension. */
301
302 /* GL_QCOM_extended_get */
303 #ifndef GL_QCOM_extended_get
304 #define GL_TEXTURE_WIDTH_QCOM 0x8BD2
305 #define GL_TEXTURE_HEIGHT_QCOM 0x8BD3
306 #define GL_TEXTURE_DEPTH_QCOM 0x8BD4
307 #define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5
308 #define GL_TEXTURE_FORMAT_QCOM 0x8BD6
309 #define GL_TEXTURE_TYPE_QCOM 0x8BD7
310 #define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8
311 #define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9
312 #define GL_TEXTURE_TARGET_QCOM 0x8BDA
313 #define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB
314 #define GL_STATE_RESTORE 0x8BDC
315 #endif
316
317 /* GL_QCOM_extended_get2 */
318 /* No new tokens introduced by this extension. */
319
320 /* GL_QCOM_perfmon_global_mode */
321 #ifndef GL_QCOM_perfmon_global_mode
322 #define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0
323 #endif
324
325 /* GL_QCOM_writeonly_rendering */
326 #ifndef GL_QCOM_writeonly_rendering
327 #define GL_WRITEONLY_RENDERING_QCOM 0x8823
328 #endif
329
330 /* GL_QCOM_tiled_rendering */
331 #ifndef GL_QCOM_tiled_rendering
332 #define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001
333 #define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002
334 #define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004
335 #define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008
336 #define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010
337 #define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020
338 #define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040
339 #define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080
340 #define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100
341 #define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200
342 #define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400
343 #define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800
344 #define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000
345 #define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000
346 #define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000
347 #define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000
348 #define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000
349 #define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000
350 #define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000
351 #define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000
352 #define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000
353 #define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000
354 #define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000
355 #define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000
356 #define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000
357 #define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000
358 #define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000
359 #define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000
360 #define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000
361 #define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000
362 #define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000
363 #define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000
364 #endif
365
366 /*------------------------------------------------------------------------*
367 * End of extension tokens, start of corresponding extension functions
368 *------------------------------------------------------------------------*/
369
370 /*------------------------------------------------------------------------*
371 * OES extension functions
372 *------------------------------------------------------------------------*/
373
374 /* GL_OES_compressed_ETC1_RGB8_texture */
375 #ifndef GL_OES_compressed_ETC1_RGB8_texture
376 #define GL_OES_compressed_ETC1_RGB8_texture 1
377 #endif
378
379 /* GL_OES_compressed_paletted_texture */
380 #ifndef GL_OES_compressed_paletted_texture
381 #define GL_OES_compressed_paletted_texture 1
382 #endif
383
384 /* GL_OES_depth24 */
385 #ifndef GL_OES_depth24
386 #define GL_OES_depth24 1
387 #endif
388
389 /* GL_OES_depth32 */
390 #ifndef GL_OES_depth32
391 #define GL_OES_depth32 1
392 #endif
393
394 /* GL_OES_depth_texture */
395 #ifndef GL_OES_depth_texture
396 #define GL_OES_depth_texture 1
397 #endif
398
399 /* GL_OES_EGL_image */
400 #ifndef GL_OES_EGL_image
401 #define GL_OES_EGL_image 1
402 #ifdef GL_GLEXT_PROTOTYPES
403 GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
404 GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
405 #endif
406 typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
407 typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
408 #endif
409
410 /* GL_OES_element_index_uint */
411 #ifndef GL_OES_element_index_uint
412 #define GL_OES_element_index_uint 1
413 #endif
414
415 /* GL_OES_fbo_render_mipmap */
416 #ifndef GL_OES_fbo_render_mipmap
417 #define GL_OES_fbo_render_mipmap 1
418 #endif
419
420 /* GL_OES_fragment_precision_high */
421 #ifndef GL_OES_fragment_precision_high
422 #define GL_OES_fragment_precision_high 1
423 #endif
424
425 /* GL_OES_get_program_binary */
426 #ifndef GL_OES_get_program_binary
427 #define GL_OES_get_program_binary 1
428 #ifdef GL_GLEXT_PROTOTYPES
429 GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
430 GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
431 #endif
432 typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
433 typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
434 #endif
435
436 /* GL_OES_mapbuffer */
437 #ifndef GL_OES_mapbuffer
438 #define GL_OES_mapbuffer 1
439 #ifdef GL_GLEXT_PROTOTYPES
440 GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
441 GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
442 GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);
443 #endif
444 typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
445 typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
446 typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
447 #endif
448
449 /* GL_OES_packed_depth_stencil */
450 #ifndef GL_OES_packed_depth_stencil
451 #define GL_OES_packed_depth_stencil 1
452 #endif
453
454 /* GL_OES_rgb8_rgba8 */
455 #ifndef GL_OES_rgb8_rgba8
456 #define GL_OES_rgb8_rgba8 1
457 #endif
458
459 /* GL_OES_standard_derivatives */
460 #ifndef GL_OES_standard_derivatives
461 #define GL_OES_standard_derivatives 1
462 #endif
463
464 /* GL_OES_stencil1 */
465 #ifndef GL_OES_stencil1
466 #define GL_OES_stencil1 1
467 #endif
468
469 /* GL_OES_stencil4 */
470 #ifndef GL_OES_stencil4
471 #define GL_OES_stencil4 1
472 #endif
473
474 /* GL_OES_texture_3D */
475 #ifndef GL_OES_texture_3D
476 #define GL_OES_texture_3D 1
477 #ifdef GL_GLEXT_PROTOTYPES
478 GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
479 GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
480 GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
481 GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
482 GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
483 GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
484 #endif
485 typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
486 typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
487 typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
488 typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
489 typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
490 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
491 #endif
492
493 /* GL_OES_texture_float */
494 #ifndef GL_OES_texture_float
495 #define GL_OES_texture_float 1
496 #endif
497
498 /* GL_OES_texture_float_linear */
499 #ifndef GL_OES_texture_float_linear
500 #define GL_OES_texture_float_linear 1
501 #endif
502
503 /* GL_OES_texture_half_float */
504 #ifndef GL_OES_texture_half_float
505 #define GL_OES_texture_half_float 1
506 #endif
507
508 /* GL_OES_texture_half_float_linear */
509 #ifndef GL_OES_texture_half_float_linear
510 #define GL_OES_texture_half_float_linear 1
511 #endif
512
513 /* GL_OES_texture_npot */
514 #ifndef GL_OES_texture_npot
515 #define GL_OES_texture_npot 1
516 #endif
517
518 /* GL_OES_vertex_array_object */
519 #ifndef GL_OES_vertex_array_object
520 #define GL_OES_vertex_array_object 1
521 #ifdef GL_GLEXT_PROTOTYPES
522 GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);
523 GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
524 GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
525 GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
526 #endif
527 typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
528 typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
529 typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
530 typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
531 #endif
532
533 /* GL_OES_vertex_half_float */
534 #ifndef GL_OES_vertex_half_float
535 #define GL_OES_vertex_half_float 1
536 #endif
537
538 /* GL_OES_vertex_type_10_10_10_2 */
539 #ifndef GL_OES_vertex_type_10_10_10_2
540 #define GL_OES_vertex_type_10_10_10_2 1
541 #endif
542
543 /*------------------------------------------------------------------------*
544 * AMD extension functions
545 *------------------------------------------------------------------------*/
546
547 /* GL_AMD_compressed_3DC_texture */
548 #ifndef GL_AMD_compressed_3DC_texture
549 #define GL_AMD_compressed_3DC_texture 1
550 #endif
551
552 /* GL_AMD_compressed_ATC_texture */
553 #ifndef GL_AMD_compressed_ATC_texture
554 #define GL_AMD_compressed_ATC_texture 1
555 #endif
556
557 /* AMD_performance_monitor */
558 #ifndef GL_AMD_performance_monitor
559 #define GL_AMD_performance_monitor 1
560 #ifdef GL_GLEXT_PROTOTYPES
561 GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
562 GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
563 GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
564 GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
565 GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
566 GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
567 GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
568 GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
569 GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
570 GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);
571 GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
572 #endif
573 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
574 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
575 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
576 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
577 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
578 typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
579 typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
580 typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
581 typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
582 typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
583 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
584 #endif
585
586 /* GL_AMD_program_binary_Z400 */
587 #ifndef GL_AMD_program_binary_Z400
588 #define GL_AMD_program_binary_Z400 1
589 #endif
590
591 /*------------------------------------------------------------------------*
592 * EXT extension functions
593 *------------------------------------------------------------------------*/
594
595 /* GL_EXT_blend_minmax */
596 #ifndef GL_EXT_blend_minmax
597 #define GL_EXT_blend_minmax 1
598 #endif
599
600 /* GL_EXT_discard_framebuffer */
601 #ifndef GL_EXT_discard_framebuffer
602 #define GL_EXT_discard_framebuffer 1
603 #ifdef GL_GLEXT_PROTOTYPES
604 GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
605 #endif
606 typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
607 #endif
608
609 #ifndef GL_EXT_multi_draw_arrays
610 #define GL_EXT_multi_draw_arrays 1
611 #ifdef GL_GLEXT_PROTOTYPES
612 GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
613 GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
614 #endif /* GL_GLEXT_PROTOTYPES */
615 typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
616 typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
617 #endif
618
619 /* GL_EXT_read_format_bgra */
620 #ifndef GL_EXT_read_format_bgra
621 #define GL_EXT_read_format_bgra 1
622 #endif
623
624 /* GL_EXT_texture_filter_anisotropic */
625 #ifndef GL_EXT_texture_filter_anisotropic
626 #define GL_EXT_texture_filter_anisotropic 1
627 #endif
628
629 /* GL_EXT_texture_format_BGRA8888 */
630 #ifndef GL_EXT_texture_format_BGRA8888
631 #define GL_EXT_texture_format_BGRA8888 1
632 #endif
633
634 /* GL_EXT_texture_type_2_10_10_10_REV */
635 #ifndef GL_EXT_texture_type_2_10_10_10_REV
636 #define GL_EXT_texture_type_2_10_10_10_REV 1
637 #endif
638
639 /* GL_EXT_texture_compression_dxt1 */
640 #ifndef GL_EXT_texture_compression_dxt1
641 #define GL_EXT_texture_compression_dxt1 1
642 #endif
643
644 /*------------------------------------------------------------------------*
645 * IMG extension functions
646 *------------------------------------------------------------------------*/
647
648 /* GL_IMG_program_binary */
649 #ifndef GL_IMG_program_binary
650 #define GL_IMG_program_binary 1
651 #endif
652
653 /* GL_IMG_read_format */
654 #ifndef GL_IMG_read_format
655 #define GL_IMG_read_format 1
656 #endif
657
658 /* GL_IMG_shader_binary */
659 #ifndef GL_IMG_shader_binary
660 #define GL_IMG_shader_binary 1
661 #endif
662
663 /* GL_IMG_texture_compression_pvrtc */
664 #ifndef GL_IMG_texture_compression_pvrtc
665 #define GL_IMG_texture_compression_pvrtc 1
666 #endif
667
668 /* GL_IMG_multisampled_render_to_texture */
669 #ifndef GL_IMG_multisampled_render_to_texture
670 #define GL_IMG_multisampled_render_to_texture 1
671 #ifdef GL_GLEXT_PROTOTYPES
672 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
673 GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
674 #endif
675 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
676 typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
677 #endif
678
679 /*------------------------------------------------------------------------*
680 * NV extension functions
681 *------------------------------------------------------------------------*/
682
683 /* GL_NV_fence */
684 #ifndef GL_NV_fence
685 #define GL_NV_fence 1
686 #ifdef GL_GLEXT_PROTOTYPES
687 GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
688 GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
689 GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);
690 GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);
691 GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
692 GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);
693 GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
694 #endif
695 typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
696 typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
697 typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
698 typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
699 typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
700 typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
701 typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
702 #endif
703
704 /* GL_NV_coverage_sample */
705 #ifndef GL_NV_coverage_sample
706 #define GL_NV_coverage_sample 1
707 #ifdef GL_GLEXT_PROTOTYPES
708 GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
709 GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
710 #endif
711 typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
712 typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
713 #endif
714
715 /* GL_NV_depth_nonlinear */
716 #ifndef GL_NV_depth_nonlinear
717 #define GL_NV_depth_nonlinear 1
718 #endif
719
720 /*------------------------------------------------------------------------*
721 * QCOM extension functions
722 *------------------------------------------------------------------------*/
723
724 /* GL_QCOM_driver_control */
725 #ifndef GL_QCOM_driver_control
726 #define GL_QCOM_driver_control 1
727 #ifdef GL_GLEXT_PROTOTYPES
728 GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
729 GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
730 GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
731 GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
732 #endif
733 typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
734 typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
735 typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
736 typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
737 #endif
738
739 /* GL_QCOM_extended_get */
740 #ifndef GL_QCOM_extended_get
741 #define GL_QCOM_extended_get 1
742 #ifdef GL_GLEXT_PROTOTYPES
743 GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
744 GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
745 GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
746 GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
747 GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
748 GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
749 GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
750 GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
751 #endif
752 typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
753 typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
754 typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
755 typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
756 typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
757 typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
758 typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
759 typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
760 #endif
761
762 /* GL_QCOM_extended_get2 */
763 #ifndef GL_QCOM_extended_get2
764 #define GL_QCOM_extended_get2 1
765 #ifdef GL_GLEXT_PROTOTYPES
766 GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
767 GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
768 GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
769 GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
770 #endif
771 typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
772 typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
773 typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
774 typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
775 #endif
776
777 /* GL_QCOM_perfmon_global_mode */
778 #ifndef GL_QCOM_perfmon_global_mode
779 #define GL_QCOM_perfmon_global_mode 1
780 #endif
781
782 /* GL_QCOM_writeonly_rendering */
783 #ifndef GL_QCOM_writeonly_rendering
784 #define GL_QCOM_writeonly_rendering 1
785 #endif
786
787 /* GL_QCOM_tiled_rendering */
788 #ifndef GL_QCOM_tiled_rendering
789 #define GL_QCOM_tiled_rendering 1
790 #ifdef GL_GLEXT_PROTOTYPES
791 GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
792 GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
793 #endif
794 typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
795 typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
796 #endif
797
798 #ifdef __cplusplus
799 }
800 #endif
801
802 #endif /* __gl2ext_h_ */
0 #ifndef __gl2extimg_h_
1 #define __gl2extimg_h_
2
3 #include <GLES2/gl2.h>
4 #include <GLES2/gl2ext.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 /*------------------------------------------------------------------------*
11 * IMG extension tokens
12 *------------------------------------------------------------------------*/
13
14 /* GL_IMG_binary_shader */
15 #ifndef GL_IMG_binary_shader
16 #define GL_SGX_BINARY_IMG 0x8C0A
17 #endif
18
19 /* GL_IMG_texture_compression_pvrtc */
20 #ifndef GL_IMG_texture_compression_pvrtc
21 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
22 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
23 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
24 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
25 #endif
26
27
28 /* GL_IMG_texture_format_BGRA8888 */
29 #define GL_BGRA 0x80E1
30
31
32 /*------------------------------------------------------------------------*
33 * IMG extension functions
34 *------------------------------------------------------------------------*/
35
36 /* GL_IMG_binary_shader */
37 #ifndef GL_IMG_binary_shader
38 #define GL_IMG_binary_shader 1
39 #endif
40
41 /* GL_IMG_texture_compression_pvrtc */
42 #ifndef GL_IMG_texture_compression_pvrtc
43 #define GL_IMG_texture_compression_pvrtc 1
44 #endif
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif /* __gl2extimg_h_ */
0 #ifndef __gl2platform_h_
1 #define __gl2platform_h_
2
3 /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
4
5 /*
6 * This document is licensed under the SGI Free Software B License Version
7 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
8 */
9
10 /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h
11 *
12 * Adopters may modify khrplatform.h and this file to suit their platform.
13 * You are encouraged to submit all modifications to the Khronos group so that
14 * they can be included in future versions of this file. Please submit changes
15 * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
16 * by filing a bug against product "OpenGL-ES" component "Registry".
17 */
18
19 #include <KHR/khrplatform.h>
20
21 #ifndef GL_APICALL
22 #define GL_APICALL KHRONOS_APICALL
23 #endif
24
25 #ifndef GL_APIENTRY
26 #define GL_APIENTRY KHRONOS_APIENTRY
27 #endif
28
29 #endif /* __gl2platform_h_ */
0 #ifndef __khrplatform_h_
1 #define __khrplatform_h_
2
3 /*
4 ** Copyright (c) 2008-2009 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 /* Khronos platform-specific types and definitions.
27 *
28 * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
29 *
30 * Adopters may modify this file to suit their platform. Adopters are
31 * encouraged to submit platform specific modifications to the Khronos
32 * group so that they can be included in future versions of this file.
33 * Please submit changes by sending them to the public Khronos Bugzilla
34 * (http://khronos.org/bugzilla) by filing a bug against product
35 * "Khronos (general)" component "Registry".
36 *
37 * A predefined template which fills in some of the bug fields can be
38 * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
39 * must create a Bugzilla login first.
40 *
41 *
42 * See the Implementer's Guidelines for information about where this file
43 * should be located on your system and for more details of its use:
44 * http://www.khronos.org/registry/implementers_guide.pdf
45 *
46 * This file should be included as
47 * #include <KHR/khrplatform.h>
48 * by Khronos client API header files that use its types and defines.
49 *
50 * The types in khrplatform.h should only be used to define API-specific types.
51 *
52 * Types defined in khrplatform.h:
53 * khronos_int8_t signed 8 bit
54 * khronos_uint8_t unsigned 8 bit
55 * khronos_int16_t signed 16 bit
56 * khronos_uint16_t unsigned 16 bit
57 * khronos_int32_t signed 32 bit
58 * khronos_uint32_t unsigned 32 bit
59 * khronos_int64_t signed 64 bit
60 * khronos_uint64_t unsigned 64 bit
61 * khronos_intptr_t signed same number of bits as a pointer
62 * khronos_uintptr_t unsigned same number of bits as a pointer
63 * khronos_ssize_t signed size
64 * khronos_usize_t unsigned size
65 * khronos_float_t signed 32 bit floating point
66 * khronos_time_ns_t unsigned 64 bit time in nanoseconds
67 * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
68 * nanoseconds
69 * khronos_stime_nanoseconds_t signed time interval in nanoseconds
70 * khronos_boolean_enum_t enumerated boolean type. This should
71 * only be used as a base type when a client API's boolean type is
72 * an enum. Client APIs which use an integer or other type for
73 * booleans cannot use this as the base type for their boolean.
74 *
75 * Tokens defined in khrplatform.h:
76 *
77 * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
78 *
79 * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
80 * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
81 *
82 * Calling convention macros defined in this file:
83 * KHRONOS_APICALL
84 * KHRONOS_APIENTRY
85 * KHRONOS_APIATTRIBUTES
86 *
87 * These may be used in function prototypes as:
88 *
89 * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
90 * int arg1,
91 * int arg2) KHRONOS_APIATTRIBUTES;
92 */
93
94 /*-------------------------------------------------------------------------
95 * Definition of KHRONOS_APICALL
96 *-------------------------------------------------------------------------
97 * This precedes the return type of the function in the function prototype.
98 */
99 #if defined(_WIN32) && !defined(__SCITECH_SNAP__)
100 # define KHRONOS_APICALL __declspec(dllimport)
101 #elif defined (__SYMBIAN32__)
102 # define KHRONOS_APICALL IMPORT_C
103 #else
104 # define KHRONOS_APICALL
105 #endif
106
107 /*-------------------------------------------------------------------------
108 * Definition of KHRONOS_APIENTRY
109 *-------------------------------------------------------------------------
110 * This follows the return type of the function and precedes the function
111 * name in the function prototype.
112 */
113 #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
114 /* Win32 but not WinCE */
115 # define KHRONOS_APIENTRY __stdcall
116 #else
117 # define KHRONOS_APIENTRY
118 #endif
119
120 /*-------------------------------------------------------------------------
121 * Definition of KHRONOS_APIATTRIBUTES
122 *-------------------------------------------------------------------------
123 * This follows the closing parenthesis of the function prototype arguments.
124 */
125 #if defined (__ARMCC_2__)
126 #define KHRONOS_APIATTRIBUTES __softfp
127 #else
128 #define KHRONOS_APIATTRIBUTES
129 #endif
130
131 /*-------------------------------------------------------------------------
132 * basic type definitions
133 *-----------------------------------------------------------------------*/
134 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
135
136
137 /*
138 * Using <stdint.h>
139 */
140 #include <stdint.h>
141 typedef int32_t khronos_int32_t;
142 typedef uint32_t khronos_uint32_t;
143 typedef int64_t khronos_int64_t;
144 typedef uint64_t khronos_uint64_t;
145 #define KHRONOS_SUPPORT_INT64 1
146 #define KHRONOS_SUPPORT_FLOAT 1
147
148 #elif defined(__VMS ) || defined(__sgi)
149
150 /*
151 * Using <inttypes.h>
152 */
153 #include <inttypes.h>
154 typedef int32_t khronos_int32_t;
155 typedef uint32_t khronos_uint32_t;
156 typedef int64_t khronos_int64_t;
157 typedef uint64_t khronos_uint64_t;
158 #define KHRONOS_SUPPORT_INT64 1
159 #define KHRONOS_SUPPORT_FLOAT 1
160
161 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
162
163 /*
164 * Win32
165 */
166 typedef __int32 khronos_int32_t;
167 typedef unsigned __int32 khronos_uint32_t;
168 typedef __int64 khronos_int64_t;
169 typedef unsigned __int64 khronos_uint64_t;
170 #define KHRONOS_SUPPORT_INT64 1
171 #define KHRONOS_SUPPORT_FLOAT 1
172
173 #elif defined(__sun__) || defined(__digital__)
174
175 /*
176 * Sun or Digital
177 */
178 typedef int khronos_int32_t;
179 typedef unsigned int khronos_uint32_t;
180 #if defined(__arch64__) || defined(_LP64)
181 typedef long int khronos_int64_t;
182 typedef unsigned long int khronos_uint64_t;
183 #else
184 typedef long long int khronos_int64_t;
185 typedef unsigned long long int khronos_uint64_t;
186 #endif /* __arch64__ */
187 #define KHRONOS_SUPPORT_INT64 1
188 #define KHRONOS_SUPPORT_FLOAT 1
189
190 #elif 0
191
192 /*
193 * Hypothetical platform with no float or int64 support
194 */
195 typedef int khronos_int32_t;
196 typedef unsigned int khronos_uint32_t;
197 #define KHRONOS_SUPPORT_INT64 0
198 #define KHRONOS_SUPPORT_FLOAT 0
199
200 #else
201
202 /*
203 * Generic fallback
204 */
205 #include <stdint.h>
206 typedef int32_t khronos_int32_t;
207 typedef uint32_t khronos_uint32_t;
208 typedef int64_t khronos_int64_t;
209 typedef uint64_t khronos_uint64_t;
210 #define KHRONOS_SUPPORT_INT64 1
211 #define KHRONOS_SUPPORT_FLOAT 1
212
213 #endif
214
215
216 /*
217 * Types that are (so far) the same on all platforms
218 */
219 typedef signed char khronos_int8_t;
220 typedef unsigned char khronos_uint8_t;
221 typedef signed short int khronos_int16_t;
222 typedef unsigned short int khronos_uint16_t;
223 typedef signed long int khronos_intptr_t;
224 typedef unsigned long int khronos_uintptr_t;
225 typedef signed long int khronos_ssize_t;
226 typedef unsigned long int khronos_usize_t;
227
228 #if KHRONOS_SUPPORT_FLOAT
229 /*
230 * Float type
231 */
232 typedef float khronos_float_t;
233 #endif
234
235 #if KHRONOS_SUPPORT_INT64
236 /* Time types
237 *
238 * These types can be used to represent a time interval in nanoseconds or
239 * an absolute Unadjusted System Time. Unadjusted System Time is the number
240 * of nanoseconds since some arbitrary system event (e.g. since the last
241 * time the system booted). The Unadjusted System Time is an unsigned
242 * 64 bit value that wraps back to 0 every 584 years. Time intervals
243 * may be either signed or unsigned.
244 */
245 typedef khronos_uint64_t khronos_utime_nanoseconds_t;
246 typedef khronos_int64_t khronos_stime_nanoseconds_t;
247 #endif
248
249 /*
250 * Dummy value used to pad enum types to 32 bits.
251 */
252 #ifndef KHRONOS_MAX_ENUM
253 #define KHRONOS_MAX_ENUM 0x7FFFFFFF
254 #endif
255
256 /*
257 * Enumerated boolean type
258 *
259 * Values other than zero should be considered to be true. Therefore
260 * comparisons should not be made against KHRONOS_TRUE.
261 */
262 typedef enum {
263 KHRONOS_FALSE = 0,
264 KHRONOS_TRUE = 1,
265 KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
266 } khronos_boolean_enum_t;
267
268 #endif /* __khrplatform_h_ */
3030 */
3131
3232 /**
33 * $Id: awt_tools.h 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision$
3737 */
3838
3939 #ifndef __LWJGL_AWT_TOOLS_H
3030 */
3131
3232 /**
33 * $Id: common_tools.c 3449 2010-10-14 19:58:32Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3449 $
36 * @version $Revision$
3737 */
3838
3939 #include <jni.h>
119119 org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil");
120120 if (org_lwjgl_LWJGLUtil_class == NULL)
121121 return;
122 log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V");
122 log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/CharSequence;)V");
123123 if (log_method == NULL)
124124 return;
125125 (*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str);
226226 const char *str = (const char *)ustr;
227227 if (str == NULL)
228228 return NULL;
229 return NewStringNativeWithLength(env, str, strlen(str));
229 return NewStringNativeWithLength(env, str, (jsize)strlen(str));
230230 }
231231
232232 // creates locale specific string
233 jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
233 jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length) {
234234 jclass jcls_str;
235235 jmethodID jmethod_str;
236236 jstring result;
296296 void *ext_func_pointer;
297297 void **ext_function_pointer_pointer;
298298 JNINativeMethod *method;
299 int i;
299 int i, num_natives = 0;
300300 if (clazz == NULL) {
301301 throwException(env, "Null class");
302302 return;
307307 if (function->ext_function_name != NULL) {
308308 ext_func_pointer = gpa(function->ext_function_name);
309309 if (ext_func_pointer == NULL) {
310 if ( function->optional )
311 continue;
312
310313 free(methods);
311314 throwException(env, "Missing driver symbols");
312315 return;
314317 ext_function_pointer_pointer = function->ext_function_pointer;
315318 *ext_function_pointer_pointer = ext_func_pointer;
316319 }
317 method = methods + i;
320 method = methods + num_natives;
318321 method->name = function->method_name;
319322 method->signature = function->signature;
320323 method->fnPtr = function->method_pointer;
321 }
322 (*env)->RegisterNatives(env, clazz, methods, num_functions);
324
325 num_natives++;
326 }
327 (*env)->RegisterNatives(env, clazz, methods, num_natives);
323328 free(methods);
324329 }
325330
326331 bool getBooleanProperty(JNIEnv *env, const char* propertyName) {
327 jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName));
332 jstring property = NewStringNativeWithLength(env, propertyName, (jsize)strlen(propertyName));
328333 jclass org_lwjgl_LWJGLUtil_class;
329334 jmethodID getBoolean;
330335 if (property == NULL)
3030 */
3131
3232 /**
33 * $Id: common_tools.h 3412 2010-09-26 23:43:24Z spasi $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
36 * @version $Revision$
3737 */
3838
3939 #ifndef _COMMON_TOOLS_H
7474 return NULL;
7575 }
7676
77 static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) {
77 static inline jobject safeNewBuffer(JNIEnv *env, void *p, jlong capacity) {
7878 if (p != NULL) {
7979 #ifdef __cplusplus
80 return env->NewDirectByteBuffer(p, size);
80 return env->NewDirectByteBuffer(p, capacity);
8181 #else
82 return (*env)->NewDirectByteBuffer(env, p, size);
82 return (*env)->NewDirectByteBuffer(env, p, capacity);
8383 #endif
8484 } else
8585 return NULL;
8686 }
8787
88 static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) {
88 static inline jobject safeNewBufferCached(JNIEnv *env, void *p, jlong size, jobject old_buffer) {
8989 if (old_buffer != NULL) {
9090 void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer);
9191 jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer);
108108
109109 char *ext_function_name;
110110 void **ext_function_pointer;
111 bool optional;
111112 } JavaMethodAndExtFunction;
112113
113114 typedef struct {
139140 extern void printfDebug(const char *format, ...);
140141 extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
141142 extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
142 extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length);
143 extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length);
143144 extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
144145 extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity);
145146 extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
5858 ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions);
5959 }
6060
61 int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) {
61 size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) {
6262 if ( slice_pitch == 0 )
6363 return region[1] * row_pitch;
6464 else
5858 #define CL_CALLBACK
5959 #endif
6060
61 // TODO: This is a bug in current CL implementations (AMD's only?), remove when fixed. (used for cl_native_kernel_func)
62 #if defined(_WIN32)
63 #define CL_USER_FUNC_CALLBACK __cdecl
64 #else
65 #define CL_USER_FUNC_CALLBACK CL_CALLBACK
66 #endif
67
6861 typedef void (CL_CALLBACK * cl_create_context_callback)(const char *errinfo, const void *private_info, size_t cb, void *user_data);
6962 typedef void (CL_CALLBACK * cl_mem_object_destructor_callback)(cl_mem memobj, void *user_data);
70 typedef void (CL_CALLBACK * cl_build_program_callback)(cl_program program, void *user_data);
63 typedef void (CL_CALLBACK * cl_program_callback)(cl_program program, void *user_data);
7164 typedef void (CL_CALLBACK * cl_event_callback)(cl_event event, cl_int event_command_exec_status, void *user_data);
72 typedef void (CL_USER_FUNC_CALLBACK * cl_native_kernel_func)(void *args);
65 typedef void (CL_CALLBACK * cl_native_kernel_func)(void *args);
66 typedef void (CL_CALLBACK * cl_printf_callback)(cl_context context, cl_uint printf_data_len, char *printf_data_ptr, void *user_data);
7367
7468 // -----------------[ Cross-platform functions ]-----------------
7569
7670 void* extcl_GetProcAddress(const char* function);
7771 void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
78 int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch);
72 size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch);
7973
8074 // -----------------[ Platform dependent functions ]-----------------
8175
1919 typedef cl_uint cl_device_local_mem_type;
2020 typedef cl_bitfield cl_device_exec_capabilities;
2121 typedef cl_bitfield cl_command_queue_properties;
22 typedef intptr_t cl_device_partition_property;
23 typedef cl_bitfield cl_device_affinity_domain;
2224
23 typedef intptr_t cl_context_properties;
25 typedef intptr_t cl_context_properties;
2426 typedef cl_uint cl_context_info;
2527 typedef cl_uint cl_command_queue_info;
2628 typedef cl_uint cl_channel_order;
2830 typedef cl_bitfield cl_mem_flags;
2931 typedef cl_uint cl_mem_object_type;
3032 typedef cl_uint cl_mem_info;
33 typedef cl_bitfield cl_mem_migration_flags;
3134 typedef cl_uint cl_image_info;
3235 typedef cl_uint cl_buffer_create_type;
3336 typedef cl_uint cl_addressing_mode;
3639 typedef cl_bitfield cl_map_flags;
3740 typedef cl_uint cl_program_info;
3841 typedef cl_uint cl_program_build_info;
42 typedef cl_uint cl_program_binary_type;
3943 typedef cl_int cl_build_status;
4044 typedef cl_uint cl_kernel_info;
45 typedef cl_uint cl_kernel_arg_info;
46 typedef cl_uint cl_kernel_arg_address_qualifier;
47 typedef cl_uint cl_kernel_arg_access_qualifier;
4148 typedef cl_uint cl_kernel_work_group_info;
4249 typedef cl_uint cl_event_info;
4350 typedef cl_uint cl_command_type;
4754 cl_channel_order image_channel_order;
4855 cl_channel_type image_channel_data_type;
4956 } cl_image_format;
57
58 typedef struct _cl_image_desc {
59 cl_mem_object_type image_type;
60 size_t image_width;
61 size_t image_height;
62 size_t image_depth;
63 size_t image_array_size;
64 size_t image_row_pitch;
65 size_t image_slice_pitch;
66 cl_uint num_mip_levels;
67 cl_uint num_samples;
68 cl_mem buffer;
69 } cl_image_desc;
5070
5171 typedef struct _cl_buffer_region {
5272 size_t origin;
6282 // -----------------[ Extension typedefs ]-----------------
6383
6484 // EXT_device_fission
65 typedef cl_bitfield cl_device_partition_property_ext;
85 typedef cl_ulong cl_device_partition_property_ext;
6686 // EXT_migrate_memobject
6787 typedef cl_bitfield cl_mem_migration_flags_ext;
88
89 // KHR_subgroups
90 typedef cl_uint cl_kernel_sub_group_info;
6891
6992 // -----------------[ Convenience typedefs ]-----------------
7093
+0
-83
src/native/common/extgl.c less more
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
-106
src/native/common/extgl.h less more
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 #ifdef __APPLE__
73 #include <OpenCL/cl_platform.h>
74 #else
75 #include <CL/cl_platform.h>
76 #endif
77
78 #include "common_tools.h"
79
80 #if defined(_WIN32) || defined(_WIN64)
81 #include <windows.h> // fix APIENTRY macro redefinition
82 #endif
83
84 #ifndef APIENTRY
85 #define APIENTRY
86 #endif
87
88 #include "extcl_types.h"
89 #include "extgl_types.h"
90
91 /* AMD_debug_output callback function pointer. */
92 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
93
94 /* ARB_debug_output callback function pointer. */
95 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
96
97 /* initializes everything, call this right after the rc is created. the function returns true if successful */
98 extern bool extgl_Open(JNIEnv *env);
99 extern void extgl_Close(void);
100 extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
101 extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions);
102 extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name);
103 extern void *extgl_GetProcAddress(const char *name);
104
105 #endif /* __EXTGL_H__ */
+0
-55
src/native/common/extgl_types.h less more
0 #if defined(_WIN32) || defined(_WIN64)
1 #define int64_t __int64
2 #define uint64_t unsigned __int64
3 #endif
4
5 #ifdef _MACOSX
6 typedef unsigned long GLenum;
7 typedef unsigned char GLboolean;
8 typedef unsigned long GLbitfield;
9 typedef signed char GLbyte;
10 typedef short GLshort;
11 typedef long GLint;
12 typedef long GLsizei;
13 typedef unsigned char GLubyte;
14 typedef unsigned short GLushort;
15 typedef unsigned long GLuint;
16 typedef float GLfloat;
17 typedef float GLclampf;
18 typedef double GLdouble;
19 typedef double GLclampd;
20 typedef void GLvoid;
21 #else
22 typedef unsigned int GLenum;
23 typedef unsigned char GLboolean;
24 typedef unsigned int GLbitfield;
25 typedef void GLvoid;
26 typedef signed char GLbyte; /* 1-byte signed */
27 typedef short GLshort; /* 2-byte signed */
28 typedef int GLint; /* 4-byte signed */
29 typedef unsigned char GLubyte; /* 1-byte unsigned */
30 typedef unsigned short GLushort; /* 2-byte unsigned */
31 typedef unsigned int GLuint; /* 4-byte unsigned */
32 typedef int GLsizei; /* 4-byte signed */
33 typedef float GLfloat; /* single precision float */
34 typedef float GLclampf; /* single precision float in [0,1] */
35 typedef double GLdouble; /* double precision float */
36 typedef double GLclampd; /* double precision float in [0,1] */
37 #endif
38
39 typedef char GLchar; /* native character */
40
41 typedef ptrdiff_t GLintptr;
42 typedef ptrdiff_t GLsizeiptr;
43 typedef ptrdiff_t GLintptrARB;
44 typedef ptrdiff_t GLsizeiptrARB;
45 typedef char GLcharARB; /* native character */
46 typedef unsigned int GLhandleARB; /* shader object handle */
47 typedef unsigned short GLhalfARB;
48 typedef unsigned short GLhalfNV;
49 typedef unsigned short GLhalf;
50 typedef int64_t GLint64EXT;
51 typedef uint64_t GLuint64EXT;
52 typedef int64_t GLint64;
53 typedef uint64_t GLuint64;
54 typedef struct __GLsync * GLsync;
0 /* ----------------------------------------------------------------------------
1 Copyright (c) 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 #ifdef __APPLE__
73 #include <OpenCL/cl_platform.h>
74 #else
75 #include <CL/cl_platform.h>
76 #endif
77
78 #include "common_tools.h"
79
80 #if defined(_WIN32) || defined(_WIN64)
81 #include <windows.h> // fix APIENTRY macro redefinition
82 #endif
83
84 #ifndef APIENTRY
85 #define APIENTRY
86 #endif
87
88 #include "extcl_types.h"
89 #include "extgl_types.h"
90
91 /* AMD_debug_output callback function pointer. */
92 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
93
94 /* ARB_debug_output callback function pointer. */
95 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
96
97 /* KHR_debug callback function pointer. */
98 typedef void (APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
99
100 /* initializes everything, call this right after the rc is created. the function returns true if successful */
101 extern bool extgl_Open(JNIEnv *env);
102 extern void extgl_Close(void);
103 extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
104 extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions);
105 extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name);
106 extern void *extgl_GetProcAddress(const char *name);
107
108
109 #ifndef __APPLE__
110 /* NV_present_video functions (GLX & WGL only) */
111 extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
112 extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position);
113 extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position);
114
115 /* NV_video_capture functions (GLX & WGL only) */
116 extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device);
117 extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
118 extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
119 extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position);
120 extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
121 #endif
122
123 #endif /* __EXTGL_H__ */
0 #if defined(_WIN32) || defined(_WIN64)
1 #define int64_t __int64
2 #define uint64_t unsigned __int64
3 #endif
4
5 #ifdef _MACOSX
6 typedef unsigned long GLenum;
7 typedef unsigned char GLboolean;
8 typedef unsigned long GLbitfield;
9 typedef signed char GLbyte;
10 typedef short GLshort;
11 typedef long GLint;
12 typedef long GLsizei;
13 typedef unsigned char GLubyte;
14 typedef unsigned short GLushort;
15 typedef unsigned long GLuint;
16 typedef float GLfloat;
17 typedef float GLclampf;
18 typedef double GLdouble;
19 typedef double GLclampd;
20 typedef void GLvoid;
21 #else
22 typedef unsigned int GLenum;
23 typedef unsigned char GLboolean;
24 typedef unsigned int GLbitfield;
25 typedef void GLvoid;
26 typedef signed char GLbyte; /* 1-byte signed */
27 typedef short GLshort; /* 2-byte signed */
28 typedef int GLint; /* 4-byte signed */
29 typedef unsigned char GLubyte; /* 1-byte unsigned */
30 typedef unsigned short GLushort; /* 2-byte unsigned */
31 typedef unsigned int GLuint; /* 4-byte unsigned */
32 typedef int GLsizei; /* 4-byte signed */
33 typedef float GLfloat; /* single precision float */
34 typedef float GLclampf; /* single precision float in [0,1] */
35 typedef double GLdouble; /* double precision float */
36 typedef double GLclampd; /* double precision float in [0,1] */
37 #endif
38
39 typedef char GLchar; /* native character */
40
41 typedef ptrdiff_t GLintptr;
42 typedef ptrdiff_t GLsizeiptr;
43 typedef ptrdiff_t GLintptrARB;
44 typedef ptrdiff_t GLsizeiptrARB;
45 typedef char GLcharARB; /* native character */
46 typedef unsigned int GLhandleARB; /* shader object handle */
47 typedef unsigned short GLhalfARB;
48 typedef unsigned short GLhalfNV;
49 typedef unsigned short GLhalf;
50 typedef int64_t GLint64EXT;
51 typedef uint64_t GLuint64EXT;
52 typedef int64_t GLint64;
53 typedef uint64_t GLuint64;
54 typedef struct __GLsync * GLsync;
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /**
33 * JNI implementation of the ARB/AMD_debug_output & KHR_debug function callbacks.
34 *
35 * @author Spasi
36 */
37
38 #include <jni.h>
39 #include "common_tools.h"
40 #include "extgl.h"
41 #include "org_lwjgl_opengl_CallbackUtil.h"
42
43 static jmethodID debugOutputCallbackARBJ;
44 static jmethodID debugOutputCallbackAMDJ;
45 static jmethodID debugCallbackKHRJ;
46
47 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
48 return (jlong)(intptr_t)(*env)->NewGlobalRef(env, obj);
49 }
50
51 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
52 (*env)->DeleteGlobalRef(env, (jobject)(intptr_t)globalRef);
53 }
54
55 // ----------------- [ ARB_debug_output ] -----------------
56
57 static void APIENTRY debugOutputCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
58 JNIEnv *env = attachCurrentThread();
59
60 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackARBJ != NULL ) {
61 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackARBJ,
62 (jint)source,
63 (jint)type,
64 (jint)id,
65 (jint)severity,
66 NewStringNativeWithLength(env, message, length)
67 );
68 }
69
70 detachCurrentThread();
71 }
72
73 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB(JNIEnv *env, jclass clazz) {
74 // Cache the callback methodID
75 jclass callbackClass;
76 if ( debugOutputCallbackARBJ == NULL ) {
77 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/ARBDebugOutputCallback$Handler");
78 if ( callbackClass != NULL )
79 debugOutputCallbackARBJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V");
80 }
81
82 return (jlong)(intptr_t)&debugOutputCallbackARB;
83 }
84
85 // ----------------- [ AMD_debug_output ] -----------------
86
87 static void APIENTRY debugOutputCallbackAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
88 JNIEnv *env = attachCurrentThread();
89
90 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackAMDJ != NULL ) {
91 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackAMDJ,
92 (jint)id,
93 (jint)category,
94 (jint)severity,
95 NewStringNativeWithLength(env, message, length)
96 );
97 }
98
99 detachCurrentThread();
100 }
101
102 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD(JNIEnv *env, jclass clazz) {
103 // Cache the callback methodID
104 jclass callbackClass;
105 if ( debugOutputCallbackAMDJ == NULL ) {
106 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputCallback$Handler");
107 if ( callbackClass != NULL )
108 debugOutputCallbackAMDJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIILjava/lang/String;)V");
109 }
110
111 return (jlong)(intptr_t)&debugOutputCallbackAMD;
112 }
113
114 // ----------------- [ KHR_debug ] -----------------
115
116 static void APIENTRY debugCallbackKHR(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
117 JNIEnv *env = attachCurrentThread();
118
119 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugCallbackKHRJ != NULL ) {
120 (*env)->CallVoidMethod(env, (jobject)userParam, debugCallbackKHRJ,
121 (jint)source,
122 (jint)type,
123 (jint)id,
124 (jint)severity,
125 NewStringNativeWithLength(env, message, length)
126 );
127 }
128
129 detachCurrentThread();
130 }
131
132 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugCallbackKHR(JNIEnv *env, jclass clazz) {
133 // Cache the callback methodID
134 jclass callbackClass;
135 if ( debugCallbackKHRJ == NULL ) {
136 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/KHRDebugCallback$Handler");
137 if ( callbackClass != NULL )
138 debugCallbackKHRJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V");
139 }
140
141 return (jlong)(intptr_t)&debugCallbackKHR;
142 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_CallbackUtil */
3
4 #ifndef _Included_org_lwjgl_opengl_CallbackUtil
5 #define _Included_org_lwjgl_opengl_CallbackUtil
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_CallbackUtil
11 * Method: ncreateGlobalRef
12 * Signature: (Ljava/lang/Object;)J
13 */
14 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef
15 (JNIEnv *, jclass, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_CallbackUtil
19 * Method: deleteGlobalRef
20 * Signature: (J)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef
23 (JNIEnv *, jclass, jlong);
24
25 /*
26 * Class: org_lwjgl_opengl_CallbackUtil
27 * Method: getDebugOutputCallbackARB
28 * Signature: ()J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB
31 (JNIEnv *, jclass);
32
33 /*
34 * Class: org_lwjgl_opengl_CallbackUtil
35 * Method: getDebugOutputCallbackAMD
36 * Signature: ()J
37 */
38 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD
39 (JNIEnv *, jclass);
40
41 /*
42 * Class: org_lwjgl_opengl_CallbackUtil
43 * Method: getDebugCallbackKHR
44 * Signature: ()J
45 */
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugCallbackKHR
47 (JNIEnv *, jclass);
48
49 #ifdef __cplusplus
50 }
51 #endif
52 #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 <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_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) {
38 return (jlong)(intptr_t)extgl_GetProcAddress((char *)(intptr_t)function_name);
39 }
40
41 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) {
42 extgl_Open(env);
43 }
44
45 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nUnloadOpenGLLibrary(JNIEnv * env, jclass clazz) {
46 extgl_Close();
47 }
48
49 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_resetNativeStubs(JNIEnv *env, jclass clazz, jclass gl_class) {
50 (*env)->UnregisterNatives(env, gl_class);
51 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_GLContext */
3
4 #ifndef _Included_org_lwjgl_opengl_GLContext
5 #define _Included_org_lwjgl_opengl_GLContext
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_GLContext
11 * Method: ngetFunctionAddress
12 * Signature: (J)J
13 */
14 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_ngetFunctionAddress
15 (JNIEnv *, jclass, jlong);
16
17 /*
18 * Class: org_lwjgl_opengl_GLContext
19 * Method: nLoadOpenGLLibrary
20 * Signature: ()V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary
23 (JNIEnv *, jclass);
24
25 /*
26 * Class: org_lwjgl_opengl_GLContext
27 * Method: nUnloadOpenGLLibrary
28 * Signature: ()V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nUnloadOpenGLLibrary
31 (JNIEnv *, jclass);
32
33 /*
34 * Class: org_lwjgl_opengl_GLContext
35 * Method: resetNativeStubs
36 * Signature: (Ljava/lang/Class;)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_resetNativeStubs
39 (JNIEnv *, jclass, jclass);
40
41 #ifdef __cplusplus
42 }
43 #endif
44 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_GLContext_CapabilitiesCacheEntry */
3
4 #ifndef _Included_org_lwjgl_opengl_GLContext_CapabilitiesCacheEntry
5 #define _Included_org_lwjgl_opengl_GLContext_CapabilitiesCacheEntry
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /**
33 * JNI implementation of the NVPresentVideoUtil class (GLX & WGL only).
34 *
35 * @author Spasi
36 */
37
38 #include <jni.h>
39 #include "common_tools.h"
40 #include "extgl.h"
41 #include "org_lwjgl_opengl_NVPresentVideoUtil.h"
42
43 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglEnumerateVideoDevicesNV(
44 JNIEnv *env, jclass clazz, jobject peer_info, jobject devices, jint devices_position
45 ) {
46 #ifdef __APPLE__
47 return 0;
48 #else
49 return extgl_EnumerateVideoDevicesNV(env, peer_info, devices, devices_position);
50 #endif
51 }
52
53 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglBindVideoDeviceNV(
54 JNIEnv *env, jclass clazz, jobject peer_info, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position
55 ) {
56 #ifdef __APPLE__
57 return false;
58 #else
59 return extgl_BindVideoDeviceNV(env, peer_info, video_slot, video_device, attrib_list, attrib_list_position);
60 #endif
61 }
62
63 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglQueryContextNV(JNIEnv *env, jclass clazz, jobject peer_info, jobject context_handle, jint attrib, jobject value, jint value_position) {
64 #ifdef __APPLE__
65 return false;
66 #else
67 return extgl_QueryContextNV(env, peer_info, context_handle, attrib, value, value_position);
68 #endif
69 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_NVPresentVideoUtil */
3
4 #ifndef _Included_org_lwjgl_opengl_NVPresentVideoUtil
5 #define _Included_org_lwjgl_opengl_NVPresentVideoUtil
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_NVPresentVideoUtil
11 * Method: nglEnumerateVideoDevicesNV
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/LongBuffer;I)I
13 */
14 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglEnumerateVideoDevicesNV
15 (JNIEnv *, jclass, jobject, jobject, jint);
16
17 /*
18 * Class: org_lwjgl_opengl_NVPresentVideoUtil
19 * Method: nglBindVideoDeviceNV
20 * Signature: (Ljava/nio/ByteBuffer;IJLjava/nio/IntBuffer;I)Z
21 */
22 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglBindVideoDeviceNV
23 (JNIEnv *, jclass, jobject, jint, jlong, jobject, jint);
24
25 /*
26 * Class: org_lwjgl_opengl_NVPresentVideoUtil
27 * Method: nglQueryContextNV
28 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;I)Z
29 */
30 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglQueryContextNV
31 (JNIEnv *, jclass, jobject, jobject, jint, jobject, jint);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /**
33 * JNI implementation of the NVVideoCaptureUtil class (GLX & WGL only).
34 *
35 * @author Spasi
36 */
37
38 #include <jni.h>
39 #include "common_tools.h"
40 #include "extgl.h"
41 #include "org_lwjgl_opengl_NVVideoCaptureUtil.h"
42
43 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglBindVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jint video_slot, jlong device) {
44 #ifdef __APPLE__
45 return false;
46 #else
47 return extgl_BindVideoCaptureDeviceNV(env, peer_info, video_slot, device);
48 #endif
49 }
50
51 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglEnumerateVideoCaptureDevicesNV(JNIEnv *env, jclass clazz, jobject peer_info, jobject devices, jint devices_position) {
52 #ifdef __APPLE__
53 return 0;
54 #else
55 return extgl_EnumerateVideoCaptureDevicesNV(env, peer_info, devices, devices_position);
56 #endif
57 }
58
59 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglLockVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device) {
60 #ifdef __APPLE__
61 return false;
62 #else
63 return extgl_LockVideoCaptureDeviceNV(env, peer_info, device);
64 #endif
65 }
66
67 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglQueryVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device, jint attribute, jobject value, jint value_position) {
68 #ifdef __APPLE__
69 return false;
70 #else
71 return extgl_QueryVideoCaptureDeviceNV(env, peer_info, device, attribute, value, value_position);
72 #endif
73 }
74
75 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglReleaseVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device) {
76 #ifdef __APPLE__
77 return false;
78 #else
79 return extgl_ReleaseVideoCaptureDeviceNV(env, peer_info, device);
80 #endif
81 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_NVVideoCaptureUtil */
3
4 #ifndef _Included_org_lwjgl_opengl_NVVideoCaptureUtil
5 #define _Included_org_lwjgl_opengl_NVVideoCaptureUtil
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_NVVideoCaptureUtil
11 * Method: nglBindVideoCaptureDeviceNV
12 * Signature: (Ljava/nio/ByteBuffer;IJ)Z
13 */
14 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglBindVideoCaptureDeviceNV
15 (JNIEnv *, jclass, jobject, jint, jlong);
16
17 /*
18 * Class: org_lwjgl_opengl_NVVideoCaptureUtil
19 * Method: nglEnumerateVideoCaptureDevicesNV
20 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/LongBuffer;I)I
21 */
22 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglEnumerateVideoCaptureDevicesNV
23 (JNIEnv *, jclass, jobject, jobject, jint);
24
25 /*
26 * Class: org_lwjgl_opengl_NVVideoCaptureUtil
27 * Method: nglLockVideoCaptureDeviceNV
28 * Signature: (Ljava/nio/ByteBuffer;J)Z
29 */
30 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglLockVideoCaptureDeviceNV
31 (JNIEnv *, jclass, jobject, jlong);
32
33 /*
34 * Class: org_lwjgl_opengl_NVVideoCaptureUtil
35 * Method: nglQueryVideoCaptureDeviceNV
36 * Signature: (Ljava/nio/ByteBuffer;JILjava/nio/IntBuffer;I)Z
37 */
38 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglQueryVideoCaptureDeviceNV
39 (JNIEnv *, jclass, jobject, jlong, jint, jobject, jint);
40
41 /*
42 * Class: org_lwjgl_opengl_NVVideoCaptureUtil
43 * Method: nglReleaseVideoCaptureDeviceNV
44 * Signature: (Ljava/nio/ByteBuffer;J)Z
45 */
46 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglReleaseVideoCaptureDeviceNV
47 (JNIEnv *, jclass, jobject, jlong);
48
49 #ifdef __cplusplus
50 }
51 #endif
52 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_Pbuffer */
3
4 #ifndef _Included_org_lwjgl_opengl_Pbuffer
5 #define _Included_org_lwjgl_opengl_Pbuffer
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED
10 #define org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED 1L
11 #undef org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED
12 #define org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED 2L
13 #undef org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED
14 #define org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED 4L
15 #undef org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED
16 #define org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED 8L
17 #undef org_lwjgl_opengl_Pbuffer_MIPMAP_LEVEL
18 #define org_lwjgl_opengl_Pbuffer_MIPMAP_LEVEL 8315L
19 #undef org_lwjgl_opengl_Pbuffer_CUBE_MAP_FACE
20 #define org_lwjgl_opengl_Pbuffer_CUBE_MAP_FACE 8316L
21 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_X
22 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_X 8317L
23 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_X
24 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_X 8318L
25 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_Y
26 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_Y 8319L
27 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_Y
28 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_Y 8320L
29 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_Z
30 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_POSITIVE_Z 8321L
31 #undef org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_Z
32 #define org_lwjgl_opengl_Pbuffer_TEXTURE_CUBE_MAP_NEGATIVE_Z 8322L
33 #undef org_lwjgl_opengl_Pbuffer_FRONT_LEFT_BUFFER
34 #define org_lwjgl_opengl_Pbuffer_FRONT_LEFT_BUFFER 8323L
35 #undef org_lwjgl_opengl_Pbuffer_FRONT_RIGHT_BUFFER
36 #define org_lwjgl_opengl_Pbuffer_FRONT_RIGHT_BUFFER 8324L
37 #undef org_lwjgl_opengl_Pbuffer_BACK_LEFT_BUFFER
38 #define org_lwjgl_opengl_Pbuffer_BACK_LEFT_BUFFER 8325L
39 #undef org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER
40 #define org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER 8326L
41 #undef org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER
42 #define org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER 8359L
43 #ifdef __cplusplus
44 }
45 #endif
46 #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 char *extensions, const char *name)
49 {
50 const char *start;
51 char *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 = (char *) 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 = (char *) 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 #include <EGL/egl.h>
75 //#include <GLES2/gl2.h>
76 #include <GLES2/gl2platform.h>
77
78 #include "extgl_types.h"
79
80 /* KHR_debug callback function pointer. */
81 typedef void (GL_APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
82
83 /* initializes everything, call this right after the rc is created. the function returns true if successful */
84 extern bool extgl_Open(JNIEnv *env);
85 extern void extgl_Close(void);
86 extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
87 extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions);
88 extern bool extgl_QueryExtension(const char *extensions, const char *name);
89 extern void *extgl_GetProcAddress(const char *name);
90
91 #endif /* __EXTGL_H__ */
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 "extgl_egl.h"
32
33 static void extgl_InitEGLKHRLockSurface(EGLExtensions *extensions) {
34 ExtFunction functions[] = {
35 { "eglLockSurfaceKHR", (void *)&extensions->eglLockSurfaceKHR },
36 { "eglUnlockSurfaceKHR", (void *)&extensions->eglUnlockSurfaceKHR }
37 };
38 if ( extensions->EGLKHRLockSurface )
39 extensions->EGLKHRLockSurface = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
40 }
41
42 static void extgl_InitEGLKHRImageBase(EGLExtensions *extensions) {
43 ExtFunction functions[] = {
44 { "eglCreateImageKHR", (void *)&extensions->eglCreateImageKHR },
45 { "eglDestroyImageKHR", (void *)&extensions->eglDestroyImageKHR }
46 };
47 if ( extensions->EGLKHRImageBase )
48 extensions->EGLKHRImageBase = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
49 }
50
51 static void extgl_InitEGLKHRFenceSync(EGLExtensions *extensions) {
52 ExtFunction functions[] = {
53 { "eglCreateSyncKHR", (void *)&extensions->eglCreateSyncKHR },
54 { "eglDestroySyncKHR", (void *)&extensions->eglDestroySyncKHR },
55 { "eglClientWaitSyncKHR", (void *)&extensions->eglClientWaitSyncKHR },
56 { "eglSignalSyncKHR", (void *)&extensions->eglSignalSyncKHR },
57 { "eglGetSyncAttribKHR", (void *)&extensions->eglGetSyncAttribKHR }
58 };
59 if (extensions->EGLKHRFenceSync)
60 extensions->EGLKHRFenceSync = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
61 }
62
63 static void extgl_InitEGLNVSync(EGLExtensions *extensions) {
64 ExtFunction functions[] = {
65 { "eglCreateFenceSyncNV", (void *)&extensions->eglCreateFenceSyncNV },
66 { "eglDestroySyncNV", (void *)&extensions->eglDestroySyncNV },
67 { "eglFenceNV", (void *)&extensions->eglFenceNV },
68 { "eglClientWaitSyncNV", (void *)&extensions->eglClientWaitSyncNV },
69 { "eglSignalSyncNV", (void *)&extensions->eglSignalSyncNV },
70 { "eglGetSyncAttribNV", (void *)&extensions->eglGetSyncAttribNV }
71
72 };
73 if (extensions->EGLNVSync)
74 extensions->EGLNVSync = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
75 }
76
77 static void extgl_InitSupportedEGLExtensions(EGLDisplay dpy, EGLExtensions *extensions) {
78 const char *extension_string = eglQueryString(dpy, EGL_EXTENSIONS);
79
80 extensions->EGLKHRConfigAttribs = extgl_QueryExtension(extension_string, "EGL_KHR_config_attribs");
81 extensions->EGLKHRLockSurface = extgl_QueryExtension(extension_string, "EGL_KHR_lock_surface");
82 extensions->EGLKHRImage = extgl_QueryExtension(extension_string, "EGL_KHR_image");
83 extensions->EGLKHRVGParentImage = extgl_QueryExtension(extension_string, "EGL_KHR_vg_parent_image");
84 extensions->EGLKHRGLTexture2DImage = extgl_QueryExtension(extension_string, "EGL_KHR_gl_texture_2D_image");
85 extensions->EGLKHRGLTextureCubemapImage = extgl_QueryExtension(extension_string, "EGL_KHR_gl_texture_cubemap_image");
86 extensions->EGLKHRGLTexture3DImage = extgl_QueryExtension(extension_string, "EGL_KHR_gl_texture_3D_image");
87 extensions->EGLKHRGLRenderbufferImage = extgl_QueryExtension(extension_string, "EGL_KHR_gl_renderbuffer_image");
88 extensions->EGLKHRReusableSync = extgl_QueryExtension(extension_string, "EGL_KHR_reusable_sync");
89 extensions->EGLKHRImageBase = extgl_QueryExtension(extension_string, "EGL_KHR_image_base");
90 extensions->EGLKHRImagePixmap = extgl_QueryExtension(extension_string, "EGL_KHR_image_pixmap");
91 extensions->EGLIMGContextPriority = extgl_QueryExtension(extension_string, "EGL_IMG_context_priority");
92 extensions->EGLNVCoverageSample = extgl_QueryExtension(extension_string, "EGL_NV_coverage_sample");
93 extensions->EGLNVDepthNonlinear = extgl_QueryExtension(extension_string, "EGL_NV_depth_nonlinear");
94 extensions->EGLNVSync = extgl_QueryExtension(extension_string, "EGL_NV_sync");
95 extensions->EGLKHRFenceSync = extgl_QueryExtension(extension_string, "EGL_KHR_fence_sync");
96 }
97
98 void extgl_InitEGL(EGLDisplay dpy, EGLExtensions *extensions) {
99 extgl_InitSupportedEGLExtensions(dpy, extensions);
100
101 extgl_InitEGLKHRLockSurface(extensions);
102 extgl_InitEGLKHRImageBase(extensions);
103 extgl_InitEGLKHRFenceSync(extensions);
104 extgl_InitEGLNVSync(extensions);
105 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 #ifndef _EXTGL_EGL_H
32 #define _EXTGL_EGL_H
33
34 #include "extgl.h"
35 #include "common_tools.h"
36
37 #include <EGL/eglext.h>
38
39 typedef struct {
40 bool EGLKHRConfigAttribs;
41 bool EGLKHRLockSurface;
42 bool EGLKHRImage;
43 bool EGLKHRVGParentImage;
44 bool EGLKHRGLTexture2DImage;
45 bool EGLKHRGLTextureCubemapImage;
46 bool EGLKHRGLTexture3DImage;
47 bool EGLKHRGLRenderbufferImage;
48 bool EGLKHRFenceSync;
49 bool EGLKHRReusableSync;
50 bool EGLKHRImageBase;
51 bool EGLKHRImagePixmap;
52 bool EGLIMGContextPriority;
53 bool EGLNVCoverageSample;
54 bool EGLNVDepthNonlinear;
55 bool EGLNVSync;
56
57 PFNEGLLOCKSURFACEKHRPROC eglLockSurfaceKHR;
58 PFNEGLUNLOCKSURFACEKHRPROC eglUnlockSurfaceKHR;
59
60 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
61 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
62
63 PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
64 PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
65 PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
66 PFNEGLSIGNALSYNCKHRPROC eglSignalSyncKHR;
67 PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
68
69 PFNEGLCREATEFENCESYNCNVPROC eglCreateFenceSyncNV;
70 PFNEGLDESTROYSYNCNVPROC eglDestroySyncNV;
71 PFNEGLFENCENVPROC eglFenceNV;
72 PFNEGLCLIENTWAITSYNCNVPROC eglClientWaitSyncNV;
73 PFNEGLSIGNALSYNCNVPROC eglSignalSyncNV;
74 PFNEGLGETSYNCATTRIBNVPROC eglGetSyncAttribNV;
75 } EGLExtensions;
76
77 extern void extgl_InitEGL(EGLDisplay dpy, EGLExtensions *extensions);
78
79 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 #ifndef _EXTGL_TYPES_H
32 #define _EXTGL_TYPES_H
33
34 #include <KHR/khrplatform.h>
35
36 /*-------------------------------------------------------------------------
37 * Data type definitions
38 *-----------------------------------------------------------------------*/
39
40 typedef void GLvoid;
41 typedef char GLchar;
42 typedef unsigned int GLenum;
43 typedef unsigned char GLboolean;
44 typedef unsigned int GLbitfield;
45 typedef khronos_int8_t GLbyte;
46 typedef short GLshort;
47 typedef int GLint;
48 typedef int GLsizei;
49 typedef khronos_uint8_t GLubyte;
50 typedef unsigned short GLushort;
51 typedef unsigned int GLuint;
52 typedef khronos_float_t GLfloat;
53 typedef khronos_float_t GLclampf;
54 typedef khronos_int32_t GLfixed;
55
56 // OpenGL ES 3.0
57 typedef unsigned short GLhalf;
58 typedef khronos_int64_t GLint64;
59 typedef khronos_uint64_t GLuint64;
60 typedef struct __GLsync *GLsync;
61
62 /* GL types for handling large vertex buffer objects */
63 typedef khronos_intptr_t GLintptr;
64 typedef khronos_ssize_t GLsizeiptr;
65
66 typedef khronos_int64_t EGLint64NV;
67 typedef khronos_uint64_t EGLuint64NV;
68
69 // EGL_image_OES
70 typedef void* GLeglImageOES;
71
72 #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 * JNI implementation of the ARB/AMD_debug_output & KHR_debug function callbacks.
34 *
35 * @author Spasi
36 */
37
38 #include <jni.h>
39 #include "common_tools.h"
40 #include "extgl.h"
41 #include "org_lwjgl_opengles_CallbackUtil.h"
42
43 static jmethodID debugCallbackKHRJ;
44
45 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
46 return (jlong)(intptr_t)(*env)->NewGlobalRef(env, obj);
47 }
48
49 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
50 (*env)->DeleteGlobalRef(env, (jobject)(intptr_t)globalRef);
51 }
52
53 // ----------------- [ KHR_debug ] -----------------
54
55 static void EGLAPIENTRY debugCallbackKHR(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
56 JNIEnv *env = attachCurrentThread();
57
58 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugCallbackKHRJ != NULL ) {
59 (*env)->CallVoidMethod(env, (jobject)userParam, debugCallbackKHRJ,
60 (jint)source,
61 (jint)type,
62 (jint)id,
63 (jint)severity,
64 NewStringNativeWithLength(env, message, length)
65 );
66 }
67
68 detachCurrentThread();
69 }
70
71 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugCallbackKHR(JNIEnv *env, jclass clazz) {
72 // Cache the callback methodID
73 jclass callbackClass;
74 if ( debugCallbackKHRJ == NULL ) {
75 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengles/KHRDebugCallback$Handler");
76 if ( callbackClass != NULL )
77 debugCallbackKHRJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V");
78 }
79
80 return (jlong)(intptr_t)&debugCallbackKHR;
81 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_CallbackUtil */
3
4 #ifndef _Included_org_lwjgl_opengles_CallbackUtil
5 #define _Included_org_lwjgl_opengles_CallbackUtil
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengles_CallbackUtil
11 * Method: ncreateGlobalRef
12 * Signature: (Ljava/lang/Object;)J
13 */
14 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_CallbackUtil_ncreateGlobalRef
15 (JNIEnv *, jclass, jobject);
16
17 /*
18 * Class: org_lwjgl_opengles_CallbackUtil
19 * Method: deleteGlobalRef
20 * Signature: (J)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_CallbackUtil_deleteGlobalRef
23 (JNIEnv *, jclass, jlong);
24
25 /*
26 * Class: org_lwjgl_opengles_CallbackUtil
27 * Method: getDebugCallbackKHR
28 * Signature: ()J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_CallbackUtil_getDebugCallbackKHR
31 (JNIEnv *, jclass);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_opengles_EGL.h"
35 #include "extgl_egl.h"
36
37 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGL_eglGetError(JNIEnv *env, jclass clazz) {
38 return eglGetError();
39 }
40
41 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetDisplay(JNIEnv *env, jclass clazz, jlong display_id) {
42 return (intptr_t)eglGetDisplay((EGLNativeDisplayType)(intptr_t)display_id);
43 }
44
45 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglInitialize(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong version) {
46 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
47 EGLint *version_address = (EGLint *)(intptr_t)version;
48
49 return eglInitialize(dpy, version_address, version_address + 1);
50 }
51
52 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglTerminate(JNIEnv *env, jclass clazz, jlong dpy_ptr) {
53 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
54
55 return eglTerminate(dpy);
56 }
57
58 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengles_EGL_neglQueryString(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint name) {
59 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
60 const char * __result = eglQueryString(dpy, name);
61 if ( __result == NULL )
62 return NULL;
63
64 return NewStringNativeWithLength(env, __result, (jsize)strlen(__result));
65 }
66
67 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigs(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong configs, jint config_size, jlong num_config) {
68 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
69 EGLConfig *configs_address = (EGLConfig *)(intptr_t)configs;
70 EGLint *num_config_address = (EGLint *)(intptr_t)num_config;
71
72 return eglGetConfigs(dpy, configs_address, config_size, num_config_address);
73 }
74
75 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglChooseConfig(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong attrib_list, jlong configs, jint config_size, jlong num_config) {
76 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
77 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
78 EGLConfig *configs_address = (EGLConfig *)(intptr_t)configs;
79 EGLint *num_config_address = (EGLint *)(intptr_t)num_config;
80
81 return eglChooseConfig(dpy, attrib_list_address, configs_address, config_size, num_config_address);
82 }
83
84 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigAttrib(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jint attribute, jlong value) {
85 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
86 EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
87 EGLint *value_address = (EGLint *)(intptr_t)value;
88
89 return eglGetConfigAttrib(dpy, config, attribute, value_address);
90 }
91
92 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong win, jlong attrib_list) {
93 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
94 EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
95 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
96
97 return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)win, attrib_list_address);
98 }
99
100 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreatePbufferSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong attrib_list) {
101 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
102 EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
103 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
104
105 return (intptr_t)eglCreatePbufferSurface(dpy, config, attrib_list_address);
106 }
107
108 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglDestroySurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr) {
109 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
110 EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
111
112 return eglDestroySurface(dpy, surface);
113 }
114
115 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSurfaceAttrib(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr, jint attribute, jint value) {
116 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
117 EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
118
119 return eglSurfaceAttrib(dpy, surface, attribute, value);
120 }
121
122 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQuerySurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr, jint attribute, jlong value) {
123 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
124 EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
125 EGLint *value_address = (EGLint *)(intptr_t)value;
126
127 return eglQuerySurface(dpy, surface, attribute, value_address);
128 }
129
130 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglBindAPI(JNIEnv *env, jclass clazz, jint api) {
131 return eglBindAPI(api);
132 }
133
134 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGL_eglQueryAPI(JNIEnv *env, jclass clazz) {
135 return eglQueryAPI();
136 }
137
138 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglReleaseThread(JNIEnv *env, jclass clazz) {
139 return eglReleaseThread();
140 }
141
142 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSwapInterval(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint interval) {
143 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
144 return eglSwapInterval(dpy, interval);
145 }
146
147 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong share_context_ptr, jlong attrib_list) {
148 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
149 EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
150 EGLContext share_context = (EGLContext)(intptr_t)share_context_ptr;
151 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
152
153 return (intptr_t)eglCreateContext(dpy, config, share_context, attrib_list_address);
154 }
155
156 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglDestroyContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong ctx_ptr) {
157 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
158 EGLContext ctx = (EGLContext)(intptr_t)ctx_ptr;
159
160 return eglDestroyContext(dpy, ctx);
161 }
162
163 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglMakeCurrent(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong draw_ptr, jlong read_ptr, jlong ctx_ptr) {
164 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
165 EGLSurface draw = (EGLSurface)(intptr_t)draw_ptr;
166 EGLSurface read = (EGLSurface)(intptr_t)read_ptr;
167 EGLContext ctx = (EGLContext)(intptr_t)ctx_ptr;
168
169 return eglMakeCurrent(dpy, draw, read, ctx);
170 }
171
172 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentContext(JNIEnv *env, jclass clazz) {
173 return (intptr_t)eglGetCurrentContext();
174 }
175
176 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentSurface(JNIEnv *env, jclass clazz, jint readdraw) {
177 return (intptr_t)eglGetCurrentSurface(readdraw);
178 }
179
180 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentDisplay(JNIEnv *env, jclass clazz) {
181 return (intptr_t)eglGetCurrentDisplay();
182 }
183
184 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQueryContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong ctx_ptr, jint attribute, jlong value) {
185 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
186 EGLContext ctx = (EGLContext)(intptr_t)ctx_ptr;
187 EGLint *value_address = (EGLint *)(intptr_t)value;
188
189 return eglQueryContext(dpy, ctx, attribute, value_address);
190
191 }
192
193 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitClient(JNIEnv *env, jclass clazz) {
194 return eglWaitClient();
195 }
196
197 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitGL(JNIEnv *env, jclass clazz) {
198 return eglWaitGL();
199 }
200
201 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitNative(JNIEnv *env, jclass clazz, jint engine) {
202 return eglWaitNative(engine);
203 }
204
205 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSwapBuffers(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr) {
206 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
207 EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
208
209 return eglSwapBuffers(dpy, surface);
210 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_EGL */
3
4 #ifndef _Included_org_lwjgl_opengles_EGL
5 #define _Included_org_lwjgl_opengles_EGL
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengles_EGL_EGL_FALSE
10 #define org_lwjgl_opengles_EGL_EGL_FALSE 0L
11 #undef org_lwjgl_opengles_EGL_EGL_TRUE
12 #define org_lwjgl_opengles_EGL_EGL_TRUE 1L
13 #undef org_lwjgl_opengles_EGL_EGL_DEFAULT_DISPLAY
14 #define org_lwjgl_opengles_EGL_EGL_DEFAULT_DISPLAY 0L
15 #undef org_lwjgl_opengles_EGL_EGL_NO_CONTEXT
16 #define org_lwjgl_opengles_EGL_EGL_NO_CONTEXT 0L
17 #undef org_lwjgl_opengles_EGL_EGL_NO_DISPLAY
18 #define org_lwjgl_opengles_EGL_EGL_NO_DISPLAY 0L
19 #undef org_lwjgl_opengles_EGL_EGL_NO_SURFACE
20 #define org_lwjgl_opengles_EGL_EGL_NO_SURFACE 0L
21 #undef org_lwjgl_opengles_EGL_EGL_DONT_CARE
22 #define org_lwjgl_opengles_EGL_EGL_DONT_CARE -1L
23 #undef org_lwjgl_opengles_EGL_EGL_SUCCESS
24 #define org_lwjgl_opengles_EGL_EGL_SUCCESS 12288L
25 #undef org_lwjgl_opengles_EGL_EGL_NOT_INITIALIZED
26 #define org_lwjgl_opengles_EGL_EGL_NOT_INITIALIZED 12289L
27 #undef org_lwjgl_opengles_EGL_EGL_BAD_ACCESS
28 #define org_lwjgl_opengles_EGL_EGL_BAD_ACCESS 12290L
29 #undef org_lwjgl_opengles_EGL_EGL_BAD_ALLOC
30 #define org_lwjgl_opengles_EGL_EGL_BAD_ALLOC 12291L
31 #undef org_lwjgl_opengles_EGL_EGL_BAD_ATTRIBUTE
32 #define org_lwjgl_opengles_EGL_EGL_BAD_ATTRIBUTE 12292L
33 #undef org_lwjgl_opengles_EGL_EGL_BAD_CONFIG
34 #define org_lwjgl_opengles_EGL_EGL_BAD_CONFIG 12293L
35 #undef org_lwjgl_opengles_EGL_EGL_BAD_CONTEXT
36 #define org_lwjgl_opengles_EGL_EGL_BAD_CONTEXT 12294L
37 #undef org_lwjgl_opengles_EGL_EGL_BAD_CURRENT_SURFACE
38 #define org_lwjgl_opengles_EGL_EGL_BAD_CURRENT_SURFACE 12295L
39 #undef org_lwjgl_opengles_EGL_EGL_BAD_DISPLAY
40 #define org_lwjgl_opengles_EGL_EGL_BAD_DISPLAY 12296L
41 #undef org_lwjgl_opengles_EGL_EGL_BAD_MATCH
42 #define org_lwjgl_opengles_EGL_EGL_BAD_MATCH 12297L
43 #undef org_lwjgl_opengles_EGL_EGL_BAD_NATIVE_PIXMAP
44 #define org_lwjgl_opengles_EGL_EGL_BAD_NATIVE_PIXMAP 12298L
45 #undef org_lwjgl_opengles_EGL_EGL_BAD_NATIVE_WINDOW
46 #define org_lwjgl_opengles_EGL_EGL_BAD_NATIVE_WINDOW 12299L
47 #undef org_lwjgl_opengles_EGL_EGL_BAD_PARAMETER
48 #define org_lwjgl_opengles_EGL_EGL_BAD_PARAMETER 12300L
49 #undef org_lwjgl_opengles_EGL_EGL_BAD_SURFACE
50 #define org_lwjgl_opengles_EGL_EGL_BAD_SURFACE 12301L
51 #undef org_lwjgl_opengles_EGL_EGL_CONTEXT_LOST
52 #define org_lwjgl_opengles_EGL_EGL_CONTEXT_LOST 12302L
53 #undef org_lwjgl_opengles_EGL_EGL_BUFFER_SIZE
54 #define org_lwjgl_opengles_EGL_EGL_BUFFER_SIZE 12320L
55 #undef org_lwjgl_opengles_EGL_EGL_ALPHA_SIZE
56 #define org_lwjgl_opengles_EGL_EGL_ALPHA_SIZE 12321L
57 #undef org_lwjgl_opengles_EGL_EGL_BLUE_SIZE
58 #define org_lwjgl_opengles_EGL_EGL_BLUE_SIZE 12322L
59 #undef org_lwjgl_opengles_EGL_EGL_GREEN_SIZE
60 #define org_lwjgl_opengles_EGL_EGL_GREEN_SIZE 12323L
61 #undef org_lwjgl_opengles_EGL_EGL_RED_SIZE
62 #define org_lwjgl_opengles_EGL_EGL_RED_SIZE 12324L
63 #undef org_lwjgl_opengles_EGL_EGL_DEPTH_SIZE
64 #define org_lwjgl_opengles_EGL_EGL_DEPTH_SIZE 12325L
65 #undef org_lwjgl_opengles_EGL_EGL_STENCIL_SIZE
66 #define org_lwjgl_opengles_EGL_EGL_STENCIL_SIZE 12326L
67 #undef org_lwjgl_opengles_EGL_EGL_CONFIG_CAVEAT
68 #define org_lwjgl_opengles_EGL_EGL_CONFIG_CAVEAT 12327L
69 #undef org_lwjgl_opengles_EGL_EGL_CONFIG_ID
70 #define org_lwjgl_opengles_EGL_EGL_CONFIG_ID 12328L
71 #undef org_lwjgl_opengles_EGL_EGL_LEVEL
72 #define org_lwjgl_opengles_EGL_EGL_LEVEL 12329L
73 #undef org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_HEIGHT
74 #define org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_HEIGHT 12330L
75 #undef org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_PIXELS
76 #define org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_PIXELS 12331L
77 #undef org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_WIDTH
78 #define org_lwjgl_opengles_EGL_EGL_MAX_PBUFFER_WIDTH 12332L
79 #undef org_lwjgl_opengles_EGL_EGL_NATIVE_RENDERABLE
80 #define org_lwjgl_opengles_EGL_EGL_NATIVE_RENDERABLE 12333L
81 #undef org_lwjgl_opengles_EGL_EGL_NATIVE_VISUAL_ID
82 #define org_lwjgl_opengles_EGL_EGL_NATIVE_VISUAL_ID 12334L
83 #undef org_lwjgl_opengles_EGL_EGL_NATIVE_VISUAL_TYPE
84 #define org_lwjgl_opengles_EGL_EGL_NATIVE_VISUAL_TYPE 12335L
85 #undef org_lwjgl_opengles_EGL_EGL_SAMPLES
86 #define org_lwjgl_opengles_EGL_EGL_SAMPLES 12337L
87 #undef org_lwjgl_opengles_EGL_EGL_SAMPLE_BUFFERS
88 #define org_lwjgl_opengles_EGL_EGL_SAMPLE_BUFFERS 12338L
89 #undef org_lwjgl_opengles_EGL_EGL_SURFACE_TYPE
90 #define org_lwjgl_opengles_EGL_EGL_SURFACE_TYPE 12339L
91 #undef org_lwjgl_opengles_EGL_EGL_TRANSPARENT_TYPE
92 #define org_lwjgl_opengles_EGL_EGL_TRANSPARENT_TYPE 12340L
93 #undef org_lwjgl_opengles_EGL_EGL_TRANSPARENT_BLUE_VALUE
94 #define org_lwjgl_opengles_EGL_EGL_TRANSPARENT_BLUE_VALUE 12341L
95 #undef org_lwjgl_opengles_EGL_EGL_TRANSPARENT_GREEN_VALUE
96 #define org_lwjgl_opengles_EGL_EGL_TRANSPARENT_GREEN_VALUE 12342L
97 #undef org_lwjgl_opengles_EGL_EGL_TRANSPARENT_RED_VALUE
98 #define org_lwjgl_opengles_EGL_EGL_TRANSPARENT_RED_VALUE 12343L
99 #undef org_lwjgl_opengles_EGL_EGL_NONE
100 #define org_lwjgl_opengles_EGL_EGL_NONE 12344L
101 #undef org_lwjgl_opengles_EGL_EGL_BIND_TO_TEXTURE_RGB
102 #define org_lwjgl_opengles_EGL_EGL_BIND_TO_TEXTURE_RGB 12345L
103 #undef org_lwjgl_opengles_EGL_EGL_BIND_TO_TEXTURE_RGBA
104 #define org_lwjgl_opengles_EGL_EGL_BIND_TO_TEXTURE_RGBA 12346L
105 #undef org_lwjgl_opengles_EGL_EGL_MIN_SWAP_INTERVAL
106 #define org_lwjgl_opengles_EGL_EGL_MIN_SWAP_INTERVAL 12347L
107 #undef org_lwjgl_opengles_EGL_EGL_MAX_SWAP_INTERVAL
108 #define org_lwjgl_opengles_EGL_EGL_MAX_SWAP_INTERVAL 12348L
109 #undef org_lwjgl_opengles_EGL_EGL_LUMINANCE_SIZE
110 #define org_lwjgl_opengles_EGL_EGL_LUMINANCE_SIZE 12349L
111 #undef org_lwjgl_opengles_EGL_EGL_ALPHA_MASK_SIZE
112 #define org_lwjgl_opengles_EGL_EGL_ALPHA_MASK_SIZE 12350L
113 #undef org_lwjgl_opengles_EGL_EGL_COLOR_BUFFER_TYPE
114 #define org_lwjgl_opengles_EGL_EGL_COLOR_BUFFER_TYPE 12351L
115 #undef org_lwjgl_opengles_EGL_EGL_RENDERABLE_TYPE
116 #define org_lwjgl_opengles_EGL_EGL_RENDERABLE_TYPE 12352L
117 #undef org_lwjgl_opengles_EGL_EGL_MATCH_NATIVE_PIXMAP
118 #define org_lwjgl_opengles_EGL_EGL_MATCH_NATIVE_PIXMAP 12353L
119 #undef org_lwjgl_opengles_EGL_EGL_CONFORMANT
120 #define org_lwjgl_opengles_EGL_EGL_CONFORMANT 12354L
121 #undef org_lwjgl_opengles_EGL_EGL_SLOW_CONFIG
122 #define org_lwjgl_opengles_EGL_EGL_SLOW_CONFIG 12368L
123 #undef org_lwjgl_opengles_EGL_EGL_NON_CONFORMANT_CONFIG
124 #define org_lwjgl_opengles_EGL_EGL_NON_CONFORMANT_CONFIG 12369L
125 #undef org_lwjgl_opengles_EGL_EGL_TRANSPARENT_RGB
126 #define org_lwjgl_opengles_EGL_EGL_TRANSPARENT_RGB 12370L
127 #undef org_lwjgl_opengles_EGL_EGL_RGB_BUFFER
128 #define org_lwjgl_opengles_EGL_EGL_RGB_BUFFER 12430L
129 #undef org_lwjgl_opengles_EGL_EGL_LUMINANCE_BUFFER
130 #define org_lwjgl_opengles_EGL_EGL_LUMINANCE_BUFFER 12431L
131 #undef org_lwjgl_opengles_EGL_EGL_NO_TEXTURE
132 #define org_lwjgl_opengles_EGL_EGL_NO_TEXTURE 12380L
133 #undef org_lwjgl_opengles_EGL_EGL_TEXTURE_RGB
134 #define org_lwjgl_opengles_EGL_EGL_TEXTURE_RGB 12381L
135 #undef org_lwjgl_opengles_EGL_EGL_TEXTURE_RGBA
136 #define org_lwjgl_opengles_EGL_EGL_TEXTURE_RGBA 12382L
137 #undef org_lwjgl_opengles_EGL_EGL_TEXTURE_2D
138 #define org_lwjgl_opengles_EGL_EGL_TEXTURE_2D 12383L
139 #undef org_lwjgl_opengles_EGL_EGL_PBUFFER_BIT
140 #define org_lwjgl_opengles_EGL_EGL_PBUFFER_BIT 1L
141 #undef org_lwjgl_opengles_EGL_EGL_PIXMAP_BIT
142 #define org_lwjgl_opengles_EGL_EGL_PIXMAP_BIT 2L
143 #undef org_lwjgl_opengles_EGL_EGL_WINDOW_BIT
144 #define org_lwjgl_opengles_EGL_EGL_WINDOW_BIT 4L
145 #undef org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_LINEAR_BIT
146 #define org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_LINEAR_BIT 32L
147 #undef org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_PRE_BIT
148 #define org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_PRE_BIT 64L
149 #undef org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_BOX_BIT
150 #define org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_BOX_BIT 512L
151 #undef org_lwjgl_opengles_EGL_EGL_SWAP_BEHAVIOR_PRESERVED_BIT
152 #define org_lwjgl_opengles_EGL_EGL_SWAP_BEHAVIOR_PRESERVED_BIT 1024L
153 #undef org_lwjgl_opengles_EGL_EGL_OPENGL_ES_BIT
154 #define org_lwjgl_opengles_EGL_EGL_OPENGL_ES_BIT 1L
155 #undef org_lwjgl_opengles_EGL_EGL_OPENVG_BIT
156 #define org_lwjgl_opengles_EGL_EGL_OPENVG_BIT 2L
157 #undef org_lwjgl_opengles_EGL_EGL_OPENGL_ES2_BIT
158 #define org_lwjgl_opengles_EGL_EGL_OPENGL_ES2_BIT 4L
159 #undef org_lwjgl_opengles_EGL_EGL_OPENGL_BIT
160 #define org_lwjgl_opengles_EGL_EGL_OPENGL_BIT 8L
161 #undef org_lwjgl_opengles_EGL_EGL_VENDOR
162 #define org_lwjgl_opengles_EGL_EGL_VENDOR 12371L
163 #undef org_lwjgl_opengles_EGL_EGL_VERSION
164 #define org_lwjgl_opengles_EGL_EGL_VERSION 12372L
165 #undef org_lwjgl_opengles_EGL_EGL_EXTENSIONS
166 #define org_lwjgl_opengles_EGL_EGL_EXTENSIONS 12373L
167 #undef org_lwjgl_opengles_EGL_EGL_CLIENT_APIS
168 #define org_lwjgl_opengles_EGL_EGL_CLIENT_APIS 12429L
169 #undef org_lwjgl_opengles_EGL_EGL_HEIGHT
170 #define org_lwjgl_opengles_EGL_EGL_HEIGHT 12374L
171 #undef org_lwjgl_opengles_EGL_EGL_WIDTH
172 #define org_lwjgl_opengles_EGL_EGL_WIDTH 12375L
173 #undef org_lwjgl_opengles_EGL_EGL_LARGEST_PBUFFER
174 #define org_lwjgl_opengles_EGL_EGL_LARGEST_PBUFFER 12376L
175 #undef org_lwjgl_opengles_EGL_EGL_TEXTURE_FORMAT
176 #define org_lwjgl_opengles_EGL_EGL_TEXTURE_FORMAT 12416L
177 #undef org_lwjgl_opengles_EGL_EGL_TEXTURE_TARGET
178 #define org_lwjgl_opengles_EGL_EGL_TEXTURE_TARGET 12417L
179 #undef org_lwjgl_opengles_EGL_EGL_MIPMAP_TEXTURE
180 #define org_lwjgl_opengles_EGL_EGL_MIPMAP_TEXTURE 12418L
181 #undef org_lwjgl_opengles_EGL_EGL_MIPMAP_LEVEL
182 #define org_lwjgl_opengles_EGL_EGL_MIPMAP_LEVEL 12419L
183 #undef org_lwjgl_opengles_EGL_EGL_RENDER_BUFFER
184 #define org_lwjgl_opengles_EGL_EGL_RENDER_BUFFER 12422L
185 #undef org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE
186 #define org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE 12423L
187 #undef org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT
188 #define org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT 12424L
189 #undef org_lwjgl_opengles_EGL_EGL_HORIZONTAL_RESOLUTION
190 #define org_lwjgl_opengles_EGL_EGL_HORIZONTAL_RESOLUTION 12432L
191 #undef org_lwjgl_opengles_EGL_EGL_VERTICAL_RESOLUTION
192 #define org_lwjgl_opengles_EGL_EGL_VERTICAL_RESOLUTION 12433L
193 #undef org_lwjgl_opengles_EGL_EGL_PIXEL_ASPECT_RATIO
194 #define org_lwjgl_opengles_EGL_EGL_PIXEL_ASPECT_RATIO 12434L
195 #undef org_lwjgl_opengles_EGL_EGL_SWAP_BEHAVIOR
196 #define org_lwjgl_opengles_EGL_EGL_SWAP_BEHAVIOR 12435L
197 #undef org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE
198 #define org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE 12441L
199 #undef org_lwjgl_opengles_EGL_EGL_BACK_BUFFER
200 #define org_lwjgl_opengles_EGL_EGL_BACK_BUFFER 12420L
201 #undef org_lwjgl_opengles_EGL_EGL_SINGLE_BUFFER
202 #define org_lwjgl_opengles_EGL_EGL_SINGLE_BUFFER 12421L
203 #undef org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_sRGB
204 #define org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_sRGB 12425L
205 #undef org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_LINEAR
206 #define org_lwjgl_opengles_EGL_EGL_VG_COLORSPACE_LINEAR 12426L
207 #undef org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_NONPRE
208 #define org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_NONPRE 12427L
209 #undef org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_PRE
210 #define org_lwjgl_opengles_EGL_EGL_VG_ALPHA_FORMAT_PRE 12428L
211 #undef org_lwjgl_opengles_EGL_EGL_DISPLAY_SCALING
212 #define org_lwjgl_opengles_EGL_EGL_DISPLAY_SCALING 10000L
213 #undef org_lwjgl_opengles_EGL_EGL_UNKNOWN
214 #define org_lwjgl_opengles_EGL_EGL_UNKNOWN -1L
215 #undef org_lwjgl_opengles_EGL_EGL_BUFFER_PRESERVED
216 #define org_lwjgl_opengles_EGL_EGL_BUFFER_PRESERVED 12436L
217 #undef org_lwjgl_opengles_EGL_EGL_BUFFER_DESTROYED
218 #define org_lwjgl_opengles_EGL_EGL_BUFFER_DESTROYED 12437L
219 #undef org_lwjgl_opengles_EGL_EGL_OPENVG_IMAGE
220 #define org_lwjgl_opengles_EGL_EGL_OPENVG_IMAGE 12438L
221 #undef org_lwjgl_opengles_EGL_EGL_CONTEXT_CLIENT_TYPE
222 #define org_lwjgl_opengles_EGL_EGL_CONTEXT_CLIENT_TYPE 12439L
223 #undef org_lwjgl_opengles_EGL_EGL_CONTEXT_CLIENT_VERSION
224 #define org_lwjgl_opengles_EGL_EGL_CONTEXT_CLIENT_VERSION 12440L
225 #undef org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_DEFAULT
226 #define org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_DEFAULT 12442L
227 #undef org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_BOX
228 #define org_lwjgl_opengles_EGL_EGL_MULTISAMPLE_RESOLVE_BOX 12443L
229 #undef org_lwjgl_opengles_EGL_EGL_OPENGL_ES_API
230 #define org_lwjgl_opengles_EGL_EGL_OPENGL_ES_API 12448L
231 #undef org_lwjgl_opengles_EGL_EGL_OPENVG_API
232 #define org_lwjgl_opengles_EGL_EGL_OPENVG_API 12449L
233 #undef org_lwjgl_opengles_EGL_EGL_OPENGL_API
234 #define org_lwjgl_opengles_EGL_EGL_OPENGL_API 12450L
235 #undef org_lwjgl_opengles_EGL_EGL_DRAW
236 #define org_lwjgl_opengles_EGL_EGL_DRAW 12377L
237 #undef org_lwjgl_opengles_EGL_EGL_READ
238 #define org_lwjgl_opengles_EGL_EGL_READ 12378L
239 #undef org_lwjgl_opengles_EGL_EGL_CORE_NATIVE_ENGINE
240 #define org_lwjgl_opengles_EGL_EGL_CORE_NATIVE_ENGINE 12379L
241 /*
242 * Class: org_lwjgl_opengles_EGL
243 * Method: eglGetError
244 * Signature: ()I
245 */
246 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGL_eglGetError
247 (JNIEnv *, jclass);
248
249 /*
250 * Class: org_lwjgl_opengles_EGL
251 * Method: neglGetDisplay
252 * Signature: (J)J
253 */
254 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetDisplay
255 (JNIEnv *, jclass, jlong);
256
257 /*
258 * Class: org_lwjgl_opengles_EGL
259 * Method: neglInitialize
260 * Signature: (JJ)Z
261 */
262 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglInitialize
263 (JNIEnv *, jclass, jlong, jlong);
264
265 /*
266 * Class: org_lwjgl_opengles_EGL
267 * Method: neglTerminate
268 * Signature: (J)Z
269 */
270 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglTerminate
271 (JNIEnv *, jclass, jlong);
272
273 /*
274 * Class: org_lwjgl_opengles_EGL
275 * Method: neglQueryString
276 * Signature: (JI)Ljava/lang/String;
277 */
278 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengles_EGL_neglQueryString
279 (JNIEnv *, jclass, jlong, jint);
280
281 /*
282 * Class: org_lwjgl_opengles_EGL
283 * Method: neglGetConfigs
284 * Signature: (JJIJ)Z
285 */
286 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigs
287 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
288
289 /*
290 * Class: org_lwjgl_opengles_EGL
291 * Method: neglChooseConfig
292 * Signature: (JJJIJ)Z
293 */
294 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglChooseConfig
295 (JNIEnv *, jclass, jlong, jlong, jlong, jint, jlong);
296
297 /*
298 * Class: org_lwjgl_opengles_EGL
299 * Method: neglGetConfigAttrib
300 * Signature: (JJIJ)Z
301 */
302 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigAttrib
303 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
304
305 /*
306 * Class: org_lwjgl_opengles_EGL
307 * Method: neglCreateWindowSurface
308 * Signature: (JJJJ)J
309 */
310 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface
311 (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
312
313 /*
314 * Class: org_lwjgl_opengles_EGL
315 * Method: neglCreatePbufferSurface
316 * Signature: (JJJ)J
317 */
318 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreatePbufferSurface
319 (JNIEnv *, jclass, jlong, jlong, jlong);
320
321 /*
322 * Class: org_lwjgl_opengles_EGL
323 * Method: neglSurfaceAttrib
324 * Signature: (JJII)Z
325 */
326 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSurfaceAttrib
327 (JNIEnv *, jclass, jlong, jlong, jint, jint);
328
329 /*
330 * Class: org_lwjgl_opengles_EGL
331 * Method: neglDestroySurface
332 * Signature: (JJ)Z
333 */
334 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglDestroySurface
335 (JNIEnv *, jclass, jlong, jlong);
336
337 /*
338 * Class: org_lwjgl_opengles_EGL
339 * Method: neglQuerySurface
340 * Signature: (JJIJ)Z
341 */
342 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQuerySurface
343 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
344
345 /*
346 * Class: org_lwjgl_opengles_EGL
347 * Method: eglBindAPI
348 * Signature: (I)Z
349 */
350 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglBindAPI
351 (JNIEnv *, jclass, jint);
352
353 /*
354 * Class: org_lwjgl_opengles_EGL
355 * Method: eglQueryAPI
356 * Signature: ()I
357 */
358 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGL_eglQueryAPI
359 (JNIEnv *, jclass);
360
361 /*
362 * Class: org_lwjgl_opengles_EGL
363 * Method: eglReleaseThread
364 * Signature: ()Z
365 */
366 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglReleaseThread
367 (JNIEnv *, jclass);
368
369 /*
370 * Class: org_lwjgl_opengles_EGL
371 * Method: neglSwapInterval
372 * Signature: (JI)Z
373 */
374 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSwapInterval
375 (JNIEnv *, jclass, jlong, jint);
376
377 /*
378 * Class: org_lwjgl_opengles_EGL
379 * Method: neglCreateContext
380 * Signature: (JJJJ)J
381 */
382 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateContext
383 (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
384
385 /*
386 * Class: org_lwjgl_opengles_EGL
387 * Method: neglDestroyContext
388 * Signature: (JJ)Z
389 */
390 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglDestroyContext
391 (JNIEnv *, jclass, jlong, jlong);
392
393 /*
394 * Class: org_lwjgl_opengles_EGL
395 * Method: neglMakeCurrent
396 * Signature: (JJJJ)Z
397 */
398 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglMakeCurrent
399 (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
400
401 /*
402 * Class: org_lwjgl_opengles_EGL
403 * Method: neglGetCurrentContext
404 * Signature: ()J
405 */
406 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentContext
407 (JNIEnv *, jclass);
408
409 /*
410 * Class: org_lwjgl_opengles_EGL
411 * Method: neglGetCurrentSurface
412 * Signature: (I)J
413 */
414 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentSurface
415 (JNIEnv *, jclass, jint);
416
417 /*
418 * Class: org_lwjgl_opengles_EGL
419 * Method: neglGetCurrentDisplay
420 * Signature: ()J
421 */
422 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglGetCurrentDisplay
423 (JNIEnv *, jclass);
424
425 /*
426 * Class: org_lwjgl_opengles_EGL
427 * Method: neglQueryContext
428 * Signature: (JJIJ)Z
429 */
430 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQueryContext
431 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
432
433 /*
434 * Class: org_lwjgl_opengles_EGL
435 * Method: eglWaitClient
436 * Signature: ()Z
437 */
438 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitClient
439 (JNIEnv *, jclass);
440
441 /*
442 * Class: org_lwjgl_opengles_EGL
443 * Method: eglWaitGL
444 * Signature: ()Z
445 */
446 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitGL
447 (JNIEnv *, jclass);
448
449 /*
450 * Class: org_lwjgl_opengles_EGL
451 * Method: eglWaitNative
452 * Signature: (I)Z
453 */
454 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_eglWaitNative
455 (JNIEnv *, jclass, jint);
456
457 /*
458 * Class: org_lwjgl_opengles_EGL
459 * Method: neglSwapBuffers
460 * Signature: (JJ)Z
461 */
462 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSwapBuffers
463 (JNIEnv *, jclass, jlong, jlong);
464
465 #ifdef __cplusplus
466 }
467 #endif
468 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_opengles_EGLKHRFenceSync.h"
35 #include "extgl_egl.h"
36
37 static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
38 static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
39 static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
40 static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
41
42 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint type, jlong attrib_list) {
43 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
44 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
45
46 return (intptr_t)eglCreateSyncKHR(dpy, type, attrib_list_address);
47 }
48
49 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglDestroySyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr) {
50 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
51 EGLSyncKHR sync = (EGLSyncKHR)(intptr_t)sync_ptr;
52
53 return eglDestroySyncKHR(dpy, sync);
54 }
55
56 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglClientWaitSyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr, jint flags, jlong timeout) {
57 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
58 EGLSyncKHR sync = (EGLSyncKHR)(intptr_t)sync_ptr;
59
60 return eglClientWaitSyncKHR(dpy, sync, flags, timeout);
61 }
62
63 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr, jint attribute, jlong value) {
64 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
65 EGLSyncKHR sync = (EGLSyncKHR)(intptr_t)sync_ptr;
66 EGLint *value_address = (EGLint *)(intptr_t)value;
67
68 return eglGetSyncAttribKHR(dpy, sync, attribute, value_address);
69 }
70
71 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_initNativeStubs(JNIEnv *env, jclass clazz) {
72 JavaMethodAndExtFunction functions[] = {
73 {"neglCreateSyncKHR", "(JIJ)J", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR, "eglCreateSyncKHR", (void *)&eglCreateSyncKHR, false},
74 {"neglDestroySyncKHR", "(JJ)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglDestroySyncKHR, "eglDestroySyncKHR", (void *)&eglDestroySyncKHR, false},
75 {"neglClientWaitSyncKHR", "(JJIJ)I", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglClientWaitSyncKHR, "eglClientWaitSyncKHR", (void *)&eglClientWaitSyncKHR, false},
76 {"neglGetSyncAttribKHR", "(JJIJ)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR, "eglGetSyncAttribKHR", (void *)&eglGetSyncAttribKHR, false}
77 };
78 int num_functions = NUMFUNCTIONS(functions);
79 extgl_InitializeClass(env, clazz, num_functions, functions);
80 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_EGLKHRFenceSync */
3
4 #ifndef _Included_org_lwjgl_opengles_EGLKHRFenceSync
5 #define _Included_org_lwjgl_opengles_EGLKHRFenceSync
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_FENCE_KHR
10 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_FENCE_KHR 12537L
11 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_TYPE_KHR
12 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_TYPE_KHR 12535L
13 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_STATUS_KHR
14 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_STATUS_KHR 12529L
15 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_CONDITION_KHR
16 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_CONDITION_KHR 12536L
17 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SIGNALED_KHR
18 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SIGNALED_KHR 12530L
19 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_UNSIGNALED_KHR
20 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_UNSIGNALED_KHR 12531L
21 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR
22 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 12528L
23 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_FLUSH_COMMANDS_BIT_KHR
24 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 1L
25 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_FOREVER_KHR
26 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_FOREVER_KHR -1i64
27 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_TIMEOUT_EXPIRED_KHR
28 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_TIMEOUT_EXPIRED_KHR 12533L
29 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_CONDITION_SATISFIED_KHR
30 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_CONDITION_SATISFIED_KHR 12534L
31 #undef org_lwjgl_opengles_EGLKHRFenceSync_EGL_NO_SYNC_KHR
32 #define org_lwjgl_opengles_EGLKHRFenceSync_EGL_NO_SYNC_KHR 0i64
33 /*
34 * Class: org_lwjgl_opengles_EGLKHRFenceSync
35 * Method: initNativeStubs
36 * Signature: ()V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_initNativeStubs
39 (JNIEnv *, jclass);
40
41 /*
42 * Class: org_lwjgl_opengles_EGLKHRFenceSync
43 * Method: neglCreateSyncKHR
44 * Signature: (JIJ)J
45 */
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR
47 (JNIEnv *, jclass, jlong, jint, jlong);
48
49 /*
50 * Class: org_lwjgl_opengles_EGLKHRFenceSync
51 * Method: neglDestroySyncKHR
52 * Signature: (JJ)Z
53 */
54 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglDestroySyncKHR
55 (JNIEnv *, jclass, jlong, jlong);
56
57 /*
58 * Class: org_lwjgl_opengles_EGLKHRFenceSync
59 * Method: neglClientWaitSyncKHR
60 * Signature: (JJIJ)I
61 */
62 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglClientWaitSyncKHR
63 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
64
65 /*
66 * Class: org_lwjgl_opengles_EGLKHRFenceSync
67 * Method: neglGetSyncAttribKHR
68 * Signature: (JJIJ)Z
69 */
70 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR
71 (JNIEnv *, jclass, jlong, jlong, jint, jlong);
72
73 #ifdef __cplusplus
74 }
75 #endif
76 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_opengles_EGLKHRReusableSync.h"
35 #include "extgl_egl.h"
36
37 static PFNEGLSIGNALSYNCKHRPROC eglSignalSyncKHR;
38
39 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRReusableSync_neglSignalSyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr, jint mode) {
40 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
41 EGLSyncKHR sync = (EGLSyncKHR)(intptr_t)sync_ptr;
42 return eglSignalSyncKHR(dpy, sync, mode);
43 }
44
45 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLKHRReusableSync_initNativeStubs(JNIEnv *env, jclass clazz) {
46 JavaMethodAndExtFunction functions[] = {
47 {"neglSignalSyncKHR", "(JJI)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRReusableSync_neglSignalSyncKHR, "eglSignalSyncKHR", (void *)&eglSignalSyncKHR, false}
48 };
49 int num_functions = NUMFUNCTIONS(functions);
50 extgl_InitializeClass(env, clazz, num_functions, functions);
51 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_EGLKHRReusableSync */
3
4 #ifndef _Included_org_lwjgl_opengles_EGLKHRReusableSync
5 #define _Included_org_lwjgl_opengles_EGLKHRReusableSync
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_REUSABLE_KHR
10 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_REUSABLE_KHR 12538L
11 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_TYPE_KHR
12 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_TYPE_KHR 12535L
13 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_STATUS_KHR
14 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_STATUS_KHR 12529L
15 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_SIGNALED_KHR
16 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_SIGNALED_KHR 12530L
17 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_UNSIGNALED_KHR
18 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_UNSIGNALED_KHR 12531L
19 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_FLUSH_COMMANDS_BIT_KHR
20 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 1L
21 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_FOREVER_KHR
22 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_FOREVER_KHR -1i64
23 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_TIMEOUT_EXPIRED_KHR
24 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_TIMEOUT_EXPIRED_KHR 12533L
25 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_CONDITION_SATISFIED_KHR
26 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_CONDITION_SATISFIED_KHR 12534L
27 #undef org_lwjgl_opengles_EGLKHRReusableSync_EGL_NO_SYNC_KHR
28 #define org_lwjgl_opengles_EGLKHRReusableSync_EGL_NO_SYNC_KHR 0i64
29 /*
30 * Class: org_lwjgl_opengles_EGLKHRReusableSync
31 * Method: initNativeStubs
32 * Signature: ()V
33 */
34 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLKHRReusableSync_initNativeStubs
35 (JNIEnv *, jclass);
36
37 /*
38 * Class: org_lwjgl_opengles_EGLKHRReusableSync
39 * Method: neglSignalSyncKHR
40 * Signature: (JJI)Z
41 */
42 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRReusableSync_neglSignalSyncKHR
43 (JNIEnv *, jclass, jlong, jlong, jint);
44
45 #ifdef __cplusplus
46 }
47 #endif
48 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_opengles_EGLNVSync.h"
35 #include "extgl_egl.h"
36
37 static PFNEGLCREATEFENCESYNCNVPROC eglCreateFenceSyncNV;
38 static PFNEGLDESTROYSYNCNVPROC eglDestroySyncNV;
39 static PFNEGLFENCENVPROC eglFenceNV;
40 static PFNEGLCLIENTWAITSYNCNVPROC eglClientWaitSyncNV;
41 static PFNEGLSIGNALSYNCNVPROC eglSignalSyncNV;
42 static PFNEGLGETSYNCATTRIBNVPROC eglGetSyncAttribNV;
43
44 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint condition, jlong attrib_list) {
45 EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
46 const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
47
48 return (intptr_t)eglCreateFenceSyncNV(dpy, condition, attrib_list_address);
49 }
50
51 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglDestroySyncNV(JNIEnv *env, jclass clazz, jlong sync_ptr) {
52 EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
53
54 return eglDestroySyncNV(sync);
55 }
56
57 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglFenceNV(JNIEnv *env, jclass clazz, jlong sync_ptr) {
58 EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
59
60 return eglFenceNV(sync);
61 }
62
63 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglClientWaitSyncNV(JNIEnv *env, jclass clazz, jlong sync_ptr, jint flags, jlong timeout) {
64 EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
65
66 return eglClientWaitSyncNV(sync, flags, timeout);
67 }
68
69 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglSignalSyncNV(JNIEnv *env, jclass clazz, jlong sync_ptr, jint mode) {
70 EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
71
72 return eglSignalSyncNV(sync, mode);
73 }
74
75 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV(JNIEnv *env, jclass clazz, jlong sync_ptr, jint attribute, jlong value) {
76 EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
77 EGLint *value_address = (EGLint *)(intptr_t)value;
78
79 return eglGetSyncAttribNV(sync, attribute, value_address);
80 }
81
82 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLNVSync_initNativeStubs(JNIEnv *env, jclass clazz) {
83 JavaMethodAndExtFunction functions[] = {
84 {"neglCreateFenceSyncNV", "(JIJ)J", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV, "eglCreateFenceSyncNV", (void *)&eglCreateFenceSyncNV, false},
85 {"neglDestroySyncNV", "(J)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglDestroySyncNV, "eglDestroySyncNV", (void *)&eglDestroySyncNV, false},
86 {"neglFenceNV", "(J)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglFenceNV, "eglFenceNV", (void *)&eglFenceNV, false},
87 {"neglClientWaitSyncNV", "(JIJ)I", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglClientWaitSyncNV, "eglClientWaitSyncNV", (void *)&eglClientWaitSyncNV, false},
88 {"neglSignalSyncNV", "(JI)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglSignalSyncNV, "eglSignalSyncNV", (void *)&eglSignalSyncNV, false},
89 {"neglGetSyncAttribNV", "(JIJ)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV, "eglGetSyncAttribNV", (void *)&eglGetSyncAttribNV, false}
90 };
91 int num_functions = NUMFUNCTIONS(functions);
92 extgl_InitializeClass(env, clazz, num_functions, functions);
93 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_EGLNVSync */
3
4 #ifndef _Included_org_lwjgl_opengles_EGLNVSync
5 #define _Included_org_lwjgl_opengles_EGLNVSync
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV
10 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 12518L
11 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_STATUS_NV
12 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_STATUS_NV 12519L
13 #undef org_lwjgl_opengles_EGLNVSync_EGL_SIGNALED_NV
14 #define org_lwjgl_opengles_EGLNVSync_EGL_SIGNALED_NV 12520L
15 #undef org_lwjgl_opengles_EGLNVSync_EGL_UNSIGNALED_NV
16 #define org_lwjgl_opengles_EGLNVSync_EGL_UNSIGNALED_NV 12521L
17 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_FLUSH_COMMANDS_BIT_NV
18 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_FLUSH_COMMANDS_BIT_NV 1L
19 #undef org_lwjgl_opengles_EGLNVSync_EGL_FOREVER_NV
20 #define org_lwjgl_opengles_EGLNVSync_EGL_FOREVER_NV -1i64
21 #undef org_lwjgl_opengles_EGLNVSync_EGL_ALREADY_SIGNALED_NV
22 #define org_lwjgl_opengles_EGLNVSync_EGL_ALREADY_SIGNALED_NV 12522L
23 #undef org_lwjgl_opengles_EGLNVSync_EGL_TIMEOUT_EXPIRED_NV
24 #define org_lwjgl_opengles_EGLNVSync_EGL_TIMEOUT_EXPIRED_NV 12523L
25 #undef org_lwjgl_opengles_EGLNVSync_EGL_CONDITION_SATISFIED_NV
26 #define org_lwjgl_opengles_EGLNVSync_EGL_CONDITION_SATISFIED_NV 12524L
27 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_TYPE_NV
28 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_TYPE_NV 12525L
29 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_CONDITION_NV
30 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_CONDITION_NV 12526L
31 #undef org_lwjgl_opengles_EGLNVSync_EGL_SYNC_FENCE_NV
32 #define org_lwjgl_opengles_EGLNVSync_EGL_SYNC_FENCE_NV 12527L
33 #undef org_lwjgl_opengles_EGLNVSync_EGL_NO_SYNC_NV
34 #define org_lwjgl_opengles_EGLNVSync_EGL_NO_SYNC_NV 0i64
35 /*
36 * Class: org_lwjgl_opengles_EGLNVSync
37 * Method: initNativeStubs
38 * Signature: ()V
39 */
40 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLNVSync_initNativeStubs
41 (JNIEnv *, jclass);
42
43 /*
44 * Class: org_lwjgl_opengles_EGLNVSync
45 * Method: neglCreateFenceSyncNV
46 * Signature: (JIJ)J
47 */
48 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV
49 (JNIEnv *, jclass, jlong, jint, jlong);
50
51 /*
52 * Class: org_lwjgl_opengles_EGLNVSync
53 * Method: neglDestroySyncNV
54 * Signature: (J)Z
55 */
56 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglDestroySyncNV
57 (JNIEnv *, jclass, jlong);
58
59 /*
60 * Class: org_lwjgl_opengles_EGLNVSync
61 * Method: neglFenceNV
62 * Signature: (J)Z
63 */
64 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglFenceNV
65 (JNIEnv *, jclass, jlong);
66
67 /*
68 * Class: org_lwjgl_opengles_EGLNVSync
69 * Method: neglClientWaitSyncNV
70 * Signature: (JIJ)I
71 */
72 JNIEXPORT jint JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglClientWaitSyncNV
73 (JNIEnv *, jclass, jlong, jint, jlong);
74
75 /*
76 * Class: org_lwjgl_opengles_EGLNVSync
77 * Method: neglSignalSyncNV
78 * Signature: (JI)Z
79 */
80 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglSignalSyncNV
81 (JNIEnv *, jclass, jlong, jint);
82
83 /*
84 * Class: org_lwjgl_opengles_EGLNVSync
85 * Method: neglGetSyncAttribNV
86 * Signature: (JIJ)Z
87 */
88 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV
89 (JNIEnv *, jclass, jlong, jint, jlong);
90
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_opengles_GLContext.h"
35 #include "extgl.h"
36
37 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) {
38 extgl_Open(env);
39 }
40
41 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_nUnloadOpenGLLibrary(JNIEnv * env, jclass clazz) {
42 extgl_Close();
43 }
44
45 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_resetNativeStubs(JNIEnv *env, jclass clazz, jclass gl_class) {
46 //(*env)->UnregisterNatives(env, gl_class);
47 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_GLContext */
3
4 #ifndef _Included_org_lwjgl_opengles_GLContext
5 #define _Included_org_lwjgl_opengles_GLContext
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengles_GLContext
11 * Method: nLoadOpenGLLibrary
12 * Signature: ()V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_nLoadOpenGLLibrary
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengles_GLContext
19 * Method: nUnloadOpenGLLibrary
20 * Signature: ()V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_nUnloadOpenGLLibrary
23 (JNIEnv *, jclass);
24
25 /*
26 * Class: org_lwjgl_opengles_GLContext
27 * Method: resetNativeStubs
28 * Signature: (Ljava/lang/Class;)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLContext_resetNativeStubs
31 (JNIEnv *, jclass, jclass);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengles_GLContext_CapabilitiesCacheEntry */
3
4 #ifndef _Included_org_lwjgl_opengles_GLContext_CapabilitiesCacheEntry
5 #define _Included_org_lwjgl_opengles_GLContext_CapabilitiesCacheEntry
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
00 #include "org_lwjgl_BufferUtils.h"
1 #include "common_tools.h"
12
23 JNIEXPORT void JNICALL Java_org_lwjgl_BufferUtils_zeroBuffer0(JNIEnv *env, jclass clazz, jobject buffer, jlong offset, jlong size) {
34 memset((char*)(*env)->GetDirectBufferAddress(env, buffer) + (size_t)offset, 0, (size_t)size);
4 }
5 }
6
7 JNIEXPORT jlong JNICALL Java_org_lwjgl_BufferUtils_getBufferAddress(JNIEnv *env, jclass clazz, jobject buffer) {
8 return (intptr_t)(*env)->GetDirectBufferAddress(env, buffer);
9 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_BufferUtils */
3
4 #ifndef _Included_org_lwjgl_BufferUtils
5 #define _Included_org_lwjgl_BufferUtils
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_BufferUtils
11 * Method: zeroBuffer0
12 * Signature: (Ljava/nio/Buffer;JJ)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_BufferUtils_zeroBuffer0
15 (JNIEnv *, jclass, jobject, jlong, jlong);
16
17 /*
18 * Class: org_lwjgl_BufferUtils
19 * Method: getBufferAddress
20 * Signature: (Ljava/nio/Buffer;)J
21 */
22 JNIEXPORT jlong JNICALL Java_org_lwjgl_BufferUtils_getBufferAddress
23 (JNIEnv *, jclass, jobject);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_DefaultSysImplementation */
3
4 #ifndef _Included_org_lwjgl_DefaultSysImplementation
5 #define _Included_org_lwjgl_DefaultSysImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_DefaultSysImplementation
11 * Method: getJNIVersion
12 * Signature: ()I
13 */
14 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
15 (JNIEnv *, jobject);
16
17 /*
18 * Class: org_lwjgl_DefaultSysImplementation
19 * Method: getPointerSize
20 * Signature: ()I
21 */
22 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getPointerSize
23 (JNIEnv *, jobject);
24
25 /*
26 * Class: org_lwjgl_DefaultSysImplementation
27 * Method: setDebug
28 * Signature: (Z)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
31 (JNIEnv *, jobject, jboolean);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_input_Cursor */
3
4 #ifndef _Included_org_lwjgl_input_Cursor
5 #define _Included_org_lwjgl_input_Cursor
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_input_Cursor_CURSOR_ONE_BIT_TRANSPARENCY
10 #define org_lwjgl_input_Cursor_CURSOR_ONE_BIT_TRANSPARENCY 1L
11 #undef org_lwjgl_input_Cursor_CURSOR_8_BIT_ALPHA
12 #define org_lwjgl_input_Cursor_CURSOR_8_BIT_ALPHA 2L
13 #undef org_lwjgl_input_Cursor_CURSOR_ANIMATION
14 #define org_lwjgl_input_Cursor_CURSOR_ANIMATION 4L
15 #ifdef __cplusplus
16 }
17 #endif
18 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_input_Cursor_CursorElement */
3
4 #ifndef _Included_org_lwjgl_input_Cursor_CursorElement
5 #define _Included_org_lwjgl_input_Cursor_CursorElement
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_input_Keyboard */
3
4 #ifndef _Included_org_lwjgl_input_Keyboard
5 #define _Included_org_lwjgl_input_Keyboard
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_input_Keyboard_EVENT_SIZE
10 #define org_lwjgl_input_Keyboard_EVENT_SIZE 18L
11 #undef org_lwjgl_input_Keyboard_CHAR_NONE
12 #define org_lwjgl_input_Keyboard_CHAR_NONE 0L
13 #undef org_lwjgl_input_Keyboard_KEY_NONE
14 #define org_lwjgl_input_Keyboard_KEY_NONE 0L
15 #undef org_lwjgl_input_Keyboard_KEY_ESCAPE
16 #define org_lwjgl_input_Keyboard_KEY_ESCAPE 1L
17 #undef org_lwjgl_input_Keyboard_KEY_1
18 #define org_lwjgl_input_Keyboard_KEY_1 2L
19 #undef org_lwjgl_input_Keyboard_KEY_2
20 #define org_lwjgl_input_Keyboard_KEY_2 3L
21 #undef org_lwjgl_input_Keyboard_KEY_3
22 #define org_lwjgl_input_Keyboard_KEY_3 4L
23 #undef org_lwjgl_input_Keyboard_KEY_4
24 #define org_lwjgl_input_Keyboard_KEY_4 5L
25 #undef org_lwjgl_input_Keyboard_KEY_5
26 #define org_lwjgl_input_Keyboard_KEY_5 6L
27 #undef org_lwjgl_input_Keyboard_KEY_6
28 #define org_lwjgl_input_Keyboard_KEY_6 7L
29 #undef org_lwjgl_input_Keyboard_KEY_7
30 #define org_lwjgl_input_Keyboard_KEY_7 8L
31 #undef org_lwjgl_input_Keyboard_KEY_8
32 #define org_lwjgl_input_Keyboard_KEY_8 9L
33 #undef org_lwjgl_input_Keyboard_KEY_9
34 #define org_lwjgl_input_Keyboard_KEY_9 10L
35 #undef org_lwjgl_input_Keyboard_KEY_0
36 #define org_lwjgl_input_Keyboard_KEY_0 11L
37 #undef org_lwjgl_input_Keyboard_KEY_MINUS
38 #define org_lwjgl_input_Keyboard_KEY_MINUS 12L
39 #undef org_lwjgl_input_Keyboard_KEY_EQUALS
40 #define org_lwjgl_input_Keyboard_KEY_EQUALS 13L
41 #undef org_lwjgl_input_Keyboard_KEY_BACK
42 #define org_lwjgl_input_Keyboard_KEY_BACK 14L
43 #undef org_lwjgl_input_Keyboard_KEY_TAB
44 #define org_lwjgl_input_Keyboard_KEY_TAB 15L
45 #undef org_lwjgl_input_Keyboard_KEY_Q
46 #define org_lwjgl_input_Keyboard_KEY_Q 16L
47 #undef org_lwjgl_input_Keyboard_KEY_W
48 #define org_lwjgl_input_Keyboard_KEY_W 17L
49 #undef org_lwjgl_input_Keyboard_KEY_E
50 #define org_lwjgl_input_Keyboard_KEY_E 18L
51 #undef org_lwjgl_input_Keyboard_KEY_R
52 #define org_lwjgl_input_Keyboard_KEY_R 19L
53 #undef org_lwjgl_input_Keyboard_KEY_T
54 #define org_lwjgl_input_Keyboard_KEY_T 20L
55 #undef org_lwjgl_input_Keyboard_KEY_Y
56 #define org_lwjgl_input_Keyboard_KEY_Y 21L
57 #undef org_lwjgl_input_Keyboard_KEY_U
58 #define org_lwjgl_input_Keyboard_KEY_U 22L
59 #undef org_lwjgl_input_Keyboard_KEY_I
60 #define org_lwjgl_input_Keyboard_KEY_I 23L
61 #undef org_lwjgl_input_Keyboard_KEY_O
62 #define org_lwjgl_input_Keyboard_KEY_O 24L
63 #undef org_lwjgl_input_Keyboard_KEY_P
64 #define org_lwjgl_input_Keyboard_KEY_P 25L
65 #undef org_lwjgl_input_Keyboard_KEY_LBRACKET
66 #define org_lwjgl_input_Keyboard_KEY_LBRACKET 26L
67 #undef org_lwjgl_input_Keyboard_KEY_RBRACKET
68 #define org_lwjgl_input_Keyboard_KEY_RBRACKET 27L
69 #undef org_lwjgl_input_Keyboard_KEY_RETURN
70 #define org_lwjgl_input_Keyboard_KEY_RETURN 28L
71 #undef org_lwjgl_input_Keyboard_KEY_LCONTROL
72 #define org_lwjgl_input_Keyboard_KEY_LCONTROL 29L
73 #undef org_lwjgl_input_Keyboard_KEY_A
74 #define org_lwjgl_input_Keyboard_KEY_A 30L
75 #undef org_lwjgl_input_Keyboard_KEY_S
76 #define org_lwjgl_input_Keyboard_KEY_S 31L
77 #undef org_lwjgl_input_Keyboard_KEY_D
78 #define org_lwjgl_input_Keyboard_KEY_D 32L
79 #undef org_lwjgl_input_Keyboard_KEY_F
80 #define org_lwjgl_input_Keyboard_KEY_F 33L
81 #undef org_lwjgl_input_Keyboard_KEY_G
82 #define org_lwjgl_input_Keyboard_KEY_G 34L
83 #undef org_lwjgl_input_Keyboard_KEY_H
84 #define org_lwjgl_input_Keyboard_KEY_H 35L
85 #undef org_lwjgl_input_Keyboard_KEY_J
86 #define org_lwjgl_input_Keyboard_KEY_J 36L
87 #undef org_lwjgl_input_Keyboard_KEY_K
88 #define org_lwjgl_input_Keyboard_KEY_K 37L
89 #undef org_lwjgl_input_Keyboard_KEY_L
90 #define org_lwjgl_input_Keyboard_KEY_L 38L
91 #undef org_lwjgl_input_Keyboard_KEY_SEMICOLON
92 #define org_lwjgl_input_Keyboard_KEY_SEMICOLON 39L
93 #undef org_lwjgl_input_Keyboard_KEY_APOSTROPHE
94 #define org_lwjgl_input_Keyboard_KEY_APOSTROPHE 40L
95 #undef org_lwjgl_input_Keyboard_KEY_GRAVE
96 #define org_lwjgl_input_Keyboard_KEY_GRAVE 41L
97 #undef org_lwjgl_input_Keyboard_KEY_LSHIFT
98 #define org_lwjgl_input_Keyboard_KEY_LSHIFT 42L
99 #undef org_lwjgl_input_Keyboard_KEY_BACKSLASH
100 #define org_lwjgl_input_Keyboard_KEY_BACKSLASH 43L
101 #undef org_lwjgl_input_Keyboard_KEY_Z
102 #define org_lwjgl_input_Keyboard_KEY_Z 44L
103 #undef org_lwjgl_input_Keyboard_KEY_X
104 #define org_lwjgl_input_Keyboard_KEY_X 45L
105 #undef org_lwjgl_input_Keyboard_KEY_C
106 #define org_lwjgl_input_Keyboard_KEY_C 46L
107 #undef org_lwjgl_input_Keyboard_KEY_V
108 #define org_lwjgl_input_Keyboard_KEY_V 47L
109 #undef org_lwjgl_input_Keyboard_KEY_B
110 #define org_lwjgl_input_Keyboard_KEY_B 48L
111 #undef org_lwjgl_input_Keyboard_KEY_N
112 #define org_lwjgl_input_Keyboard_KEY_N 49L
113 #undef org_lwjgl_input_Keyboard_KEY_M
114 #define org_lwjgl_input_Keyboard_KEY_M 50L
115 #undef org_lwjgl_input_Keyboard_KEY_COMMA
116 #define org_lwjgl_input_Keyboard_KEY_COMMA 51L
117 #undef org_lwjgl_input_Keyboard_KEY_PERIOD
118 #define org_lwjgl_input_Keyboard_KEY_PERIOD 52L
119 #undef org_lwjgl_input_Keyboard_KEY_SLASH
120 #define org_lwjgl_input_Keyboard_KEY_SLASH 53L
121 #undef org_lwjgl_input_Keyboard_KEY_RSHIFT
122 #define org_lwjgl_input_Keyboard_KEY_RSHIFT 54L
123 #undef org_lwjgl_input_Keyboard_KEY_MULTIPLY
124 #define org_lwjgl_input_Keyboard_KEY_MULTIPLY 55L
125 #undef org_lwjgl_input_Keyboard_KEY_LMENU
126 #define org_lwjgl_input_Keyboard_KEY_LMENU 56L
127 #undef org_lwjgl_input_Keyboard_KEY_SPACE
128 #define org_lwjgl_input_Keyboard_KEY_SPACE 57L
129 #undef org_lwjgl_input_Keyboard_KEY_CAPITAL
130 #define org_lwjgl_input_Keyboard_KEY_CAPITAL 58L
131 #undef org_lwjgl_input_Keyboard_KEY_F1
132 #define org_lwjgl_input_Keyboard_KEY_F1 59L
133 #undef org_lwjgl_input_Keyboard_KEY_F2
134 #define org_lwjgl_input_Keyboard_KEY_F2 60L
135 #undef org_lwjgl_input_Keyboard_KEY_F3
136 #define org_lwjgl_input_Keyboard_KEY_F3 61L
137 #undef org_lwjgl_input_Keyboard_KEY_F4
138 #define org_lwjgl_input_Keyboard_KEY_F4 62L
139 #undef org_lwjgl_input_Keyboard_KEY_F5
140 #define org_lwjgl_input_Keyboard_KEY_F5 63L
141 #undef org_lwjgl_input_Keyboard_KEY_F6
142 #define org_lwjgl_input_Keyboard_KEY_F6 64L
143 #undef org_lwjgl_input_Keyboard_KEY_F7
144 #define org_lwjgl_input_Keyboard_KEY_F7 65L
145 #undef org_lwjgl_input_Keyboard_KEY_F8
146 #define org_lwjgl_input_Keyboard_KEY_F8 66L
147 #undef org_lwjgl_input_Keyboard_KEY_F9
148 #define org_lwjgl_input_Keyboard_KEY_F9 67L
149 #undef org_lwjgl_input_Keyboard_KEY_F10
150 #define org_lwjgl_input_Keyboard_KEY_F10 68L
151 #undef org_lwjgl_input_Keyboard_KEY_NUMLOCK
152 #define org_lwjgl_input_Keyboard_KEY_NUMLOCK 69L
153 #undef org_lwjgl_input_Keyboard_KEY_SCROLL
154 #define org_lwjgl_input_Keyboard_KEY_SCROLL 70L
155 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD7
156 #define org_lwjgl_input_Keyboard_KEY_NUMPAD7 71L
157 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD8
158 #define org_lwjgl_input_Keyboard_KEY_NUMPAD8 72L
159 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD9
160 #define org_lwjgl_input_Keyboard_KEY_NUMPAD9 73L
161 #undef org_lwjgl_input_Keyboard_KEY_SUBTRACT
162 #define org_lwjgl_input_Keyboard_KEY_SUBTRACT 74L
163 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD4
164 #define org_lwjgl_input_Keyboard_KEY_NUMPAD4 75L
165 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD5
166 #define org_lwjgl_input_Keyboard_KEY_NUMPAD5 76L
167 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD6
168 #define org_lwjgl_input_Keyboard_KEY_NUMPAD6 77L
169 #undef org_lwjgl_input_Keyboard_KEY_ADD
170 #define org_lwjgl_input_Keyboard_KEY_ADD 78L
171 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD1
172 #define org_lwjgl_input_Keyboard_KEY_NUMPAD1 79L
173 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD2
174 #define org_lwjgl_input_Keyboard_KEY_NUMPAD2 80L
175 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD3
176 #define org_lwjgl_input_Keyboard_KEY_NUMPAD3 81L
177 #undef org_lwjgl_input_Keyboard_KEY_NUMPAD0
178 #define org_lwjgl_input_Keyboard_KEY_NUMPAD0 82L
179 #undef org_lwjgl_input_Keyboard_KEY_DECIMAL
180 #define org_lwjgl_input_Keyboard_KEY_DECIMAL 83L
181 #undef org_lwjgl_input_Keyboard_KEY_F11
182 #define org_lwjgl_input_Keyboard_KEY_F11 87L
183 #undef org_lwjgl_input_Keyboard_KEY_F12
184 #define org_lwjgl_input_Keyboard_KEY_F12 88L
185 #undef org_lwjgl_input_Keyboard_KEY_F13
186 #define org_lwjgl_input_Keyboard_KEY_F13 100L
187 #undef org_lwjgl_input_Keyboard_KEY_F14
188 #define org_lwjgl_input_Keyboard_KEY_F14 101L
189 #undef org_lwjgl_input_Keyboard_KEY_F15
190 #define org_lwjgl_input_Keyboard_KEY_F15 102L
191 #undef org_lwjgl_input_Keyboard_KEY_F16
192 #define org_lwjgl_input_Keyboard_KEY_F16 103L
193 #undef org_lwjgl_input_Keyboard_KEY_F17
194 #define org_lwjgl_input_Keyboard_KEY_F17 104L
195 #undef org_lwjgl_input_Keyboard_KEY_F18
196 #define org_lwjgl_input_Keyboard_KEY_F18 105L
197 #undef org_lwjgl_input_Keyboard_KEY_KANA
198 #define org_lwjgl_input_Keyboard_KEY_KANA 112L
199 #undef org_lwjgl_input_Keyboard_KEY_F19
200 #define org_lwjgl_input_Keyboard_KEY_F19 113L
201 #undef org_lwjgl_input_Keyboard_KEY_CONVERT
202 #define org_lwjgl_input_Keyboard_KEY_CONVERT 121L
203 #undef org_lwjgl_input_Keyboard_KEY_NOCONVERT
204 #define org_lwjgl_input_Keyboard_KEY_NOCONVERT 123L
205 #undef org_lwjgl_input_Keyboard_KEY_YEN
206 #define org_lwjgl_input_Keyboard_KEY_YEN 125L
207 #undef org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS
208 #define org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS 141L
209 #undef org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX
210 #define org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX 144L
211 #undef org_lwjgl_input_Keyboard_KEY_AT
212 #define org_lwjgl_input_Keyboard_KEY_AT 145L
213 #undef org_lwjgl_input_Keyboard_KEY_COLON
214 #define org_lwjgl_input_Keyboard_KEY_COLON 146L
215 #undef org_lwjgl_input_Keyboard_KEY_UNDERLINE
216 #define org_lwjgl_input_Keyboard_KEY_UNDERLINE 147L
217 #undef org_lwjgl_input_Keyboard_KEY_KANJI
218 #define org_lwjgl_input_Keyboard_KEY_KANJI 148L
219 #undef org_lwjgl_input_Keyboard_KEY_STOP
220 #define org_lwjgl_input_Keyboard_KEY_STOP 149L
221 #undef org_lwjgl_input_Keyboard_KEY_AX
222 #define org_lwjgl_input_Keyboard_KEY_AX 150L
223 #undef org_lwjgl_input_Keyboard_KEY_UNLABELED
224 #define org_lwjgl_input_Keyboard_KEY_UNLABELED 151L
225 #undef org_lwjgl_input_Keyboard_KEY_NUMPADENTER
226 #define org_lwjgl_input_Keyboard_KEY_NUMPADENTER 156L
227 #undef org_lwjgl_input_Keyboard_KEY_RCONTROL
228 #define org_lwjgl_input_Keyboard_KEY_RCONTROL 157L
229 #undef org_lwjgl_input_Keyboard_KEY_SECTION
230 #define org_lwjgl_input_Keyboard_KEY_SECTION 167L
231 #undef org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA
232 #define org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA 179L
233 #undef org_lwjgl_input_Keyboard_KEY_DIVIDE
234 #define org_lwjgl_input_Keyboard_KEY_DIVIDE 181L
235 #undef org_lwjgl_input_Keyboard_KEY_SYSRQ
236 #define org_lwjgl_input_Keyboard_KEY_SYSRQ 183L
237 #undef org_lwjgl_input_Keyboard_KEY_RMENU
238 #define org_lwjgl_input_Keyboard_KEY_RMENU 184L
239 #undef org_lwjgl_input_Keyboard_KEY_FUNCTION
240 #define org_lwjgl_input_Keyboard_KEY_FUNCTION 196L
241 #undef org_lwjgl_input_Keyboard_KEY_PAUSE
242 #define org_lwjgl_input_Keyboard_KEY_PAUSE 197L
243 #undef org_lwjgl_input_Keyboard_KEY_HOME
244 #define org_lwjgl_input_Keyboard_KEY_HOME 199L
245 #undef org_lwjgl_input_Keyboard_KEY_UP
246 #define org_lwjgl_input_Keyboard_KEY_UP 200L
247 #undef org_lwjgl_input_Keyboard_KEY_PRIOR
248 #define org_lwjgl_input_Keyboard_KEY_PRIOR 201L
249 #undef org_lwjgl_input_Keyboard_KEY_LEFT
250 #define org_lwjgl_input_Keyboard_KEY_LEFT 203L
251 #undef org_lwjgl_input_Keyboard_KEY_RIGHT
252 #define org_lwjgl_input_Keyboard_KEY_RIGHT 205L
253 #undef org_lwjgl_input_Keyboard_KEY_END
254 #define org_lwjgl_input_Keyboard_KEY_END 207L
255 #undef org_lwjgl_input_Keyboard_KEY_DOWN
256 #define org_lwjgl_input_Keyboard_KEY_DOWN 208L
257 #undef org_lwjgl_input_Keyboard_KEY_NEXT
258 #define org_lwjgl_input_Keyboard_KEY_NEXT 209L
259 #undef org_lwjgl_input_Keyboard_KEY_INSERT
260 #define org_lwjgl_input_Keyboard_KEY_INSERT 210L
261 #undef org_lwjgl_input_Keyboard_KEY_DELETE
262 #define org_lwjgl_input_Keyboard_KEY_DELETE 211L
263 #undef org_lwjgl_input_Keyboard_KEY_CLEAR
264 #define org_lwjgl_input_Keyboard_KEY_CLEAR 218L
265 #undef org_lwjgl_input_Keyboard_KEY_LMETA
266 #define org_lwjgl_input_Keyboard_KEY_LMETA 219L
267 #undef org_lwjgl_input_Keyboard_KEY_LWIN
268 #define org_lwjgl_input_Keyboard_KEY_LWIN 219L
269 #undef org_lwjgl_input_Keyboard_KEY_RMETA
270 #define org_lwjgl_input_Keyboard_KEY_RMETA 220L
271 #undef org_lwjgl_input_Keyboard_KEY_RWIN
272 #define org_lwjgl_input_Keyboard_KEY_RWIN 220L
273 #undef org_lwjgl_input_Keyboard_KEY_APPS
274 #define org_lwjgl_input_Keyboard_KEY_APPS 221L
275 #undef org_lwjgl_input_Keyboard_KEY_POWER
276 #define org_lwjgl_input_Keyboard_KEY_POWER 222L
277 #undef org_lwjgl_input_Keyboard_KEY_SLEEP
278 #define org_lwjgl_input_Keyboard_KEY_SLEEP 223L
279 #undef org_lwjgl_input_Keyboard_KEYBOARD_SIZE
280 #define org_lwjgl_input_Keyboard_KEYBOARD_SIZE 256L
281 #undef org_lwjgl_input_Keyboard_BUFFER_SIZE
282 #define org_lwjgl_input_Keyboard_BUFFER_SIZE 50L
283 #ifdef __cplusplus
284 }
285 #endif
286 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_input_Keyboard_KeyEvent */
3
4 #ifndef _Included_org_lwjgl_input_Keyboard_KeyEvent
5 #define _Included_org_lwjgl_input_Keyboard_KeyEvent
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_input_Mouse */
3
4 #ifndef _Included_org_lwjgl_input_Mouse
5 #define _Included_org_lwjgl_input_Mouse
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_input_Mouse_EVENT_SIZE
10 #define org_lwjgl_input_Mouse_EVENT_SIZE 22L
11 #undef org_lwjgl_input_Mouse_BUFFER_SIZE
12 #define org_lwjgl_input_Mouse_BUFFER_SIZE 50L
13 #ifdef __cplusplus
14 }
15 #endif
16 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_openal_AL */
3
4 #ifndef _Included_org_lwjgl_openal_AL
5 #define _Included_org_lwjgl_openal_AL
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_openal_AL
11 * Method: nCreate
12 * Signature: (Ljava/lang/String;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate
15 (JNIEnv *, jclass, jstring);
16
17 /*
18 * Class: org_lwjgl_openal_AL
19 * Method: nCreateDefault
20 * Signature: ()V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreateDefault
23 (JNIEnv *, jclass);
24
25 /*
26 * Class: org_lwjgl_openal_AL
27 * Method: nDestroy
28 * Signature: ()V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy
31 (JNIEnv *, jclass);
32
33 /*
34 * Class: org_lwjgl_openal_AL
35 * Method: resetNativeStubs
36 * Signature: (Ljava/lang/Class;)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_resetNativeStubs
39 (JNIEnv *, jclass, jclass);
40
41 #ifdef __cplusplus
42 }
43 #endif
44 #endif
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
31
3232 /**
3333 * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
3434 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
3737 * @author Brian Matzon <brian@matzon.dk>
3838 * @version $Revision: 2279 $
3939 */
8080 * C Specification:
8181 * ALubyte * alcGetString(ALCdevice *device, ALenum token);
8282 */
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;
83 static jobject JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) {
84 char* alcString = (char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token);
85 size_t length;
8686 int i=1;
8787
8888 if (alcString == NULL) {
102102 break;
103103 }
104104 case 0x1013: // ALC_ALL_DEVICES_SPECIFIER
105 while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
106 i++;
105 while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
106 i++;
107107 }
108108 length = i + 1;
109109 break;
110110 default: // e.g. ALC_DEFAULT_ALL_DEVICES_SPECIFIER
111111 length = strlen(alcString);
112112 }
113 return NewStringNativeWithLength(env, alcString, length);
113 //return NewStringNativeWithLength(env, alcString, length);
114 return safeNewBuffer(env, alcString, length);
114115 }
115116
116117 /**
117118 * This function returns integers related to the context.
118 *
119 *
119120 * C Specification:
120121 * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest);
121122 */
122 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jobject dest, jint offset) {
123 ALint* address = NULL;
124 if (dest != NULL) {
125 address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest);
126 }
127 alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address);
123 static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jlong dest) {
124 ALint* dest_address = (ALint*)(intptr_t)dest;
125 alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, dest_address);
128126 }
129127
130128 /**
131129 * This function opens a device by name.
132 *
130 *
133131 * C Specification:
134132 * ALCdevice *alcOpenDevice( const ALubyte *tokstr );
135133 */
136 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) {
137 char * tokenstring;
138 ALCdevice* device;
139
140 if(tokstr != NULL) {
141 tokenstring = GetStringNativeChars(env, tokstr);
142 } else {
143 tokenstring = NULL;
144 }
145
146 /* get device */
147 device = alcOpenDevice((ALubyte *) tokenstring);
148
149 if(tokenstring != NULL) {
150 free(tokenstring);
151 }
152
153 return (jlong)((intptr_t)device);
134 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jlong tokstr) {
135 return (jlong)(intptr_t)alcOpenDevice((ALubyte *)(intptr_t)tokstr);
154136 }
155137
156138 /**
157139 * This function closes a device by name.
158 *
140 *
159141 * C Specification:
160142 * bool alcCloseDevice( ALCdevice *dev );
161143 */
165147
166148 /**
167149 * This function creates a context using a specified device.
168 *
150 *
169151 * C Specification:
170152 * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist );
171153 */
172 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) {
173 ALint* address = NULL;
154 static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong attrlist) {
155 ALint* attrlist_address = (ALint*)(intptr_t)attrlist;
174156 ALCcontext* context;
175157
176 if (attrlist != NULL) {
177 address = (ALint*) safeGetBufferAddress(env, attrlist);
178 }
179 context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address);
180
158 context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), attrlist_address);
159
181160 return (jlong)((intptr_t)context);
182161 }
183162
194173
195174 /**
196175 * This function tells a context to begin processing.
197 *
176 *
198177 * C Specification:
199178 * void alcProcessContext(ALCcontext *context);
200179 */
204183
205184 /**
206185 * This function retrieves the current context.
207 *
186 *
208187 * C Specification:
209188 * ALCcontext* alcGetCurrentContext( ALvoid );
210189 */
215194
216195 /**
217196 * This function retrieves the specified contexts device
218 *
197 *
219198 * C Specification:
220199 * ALCdevice* alcGetContextsDevice(ALCcontext *context);
221200 */
236215
237216 /**
238217 * This function destroys a context.
239 *
218 *
240219 * C Specification:
241220 * void alcDestroyContext(ALCcontext *context);
242221 */
246225
247226 /**
248227 * This function retrieves the specified devices context error state.
249 *
228 *
250229 * C Specification:
251230 * ALCenum alcGetError(ALCdevice *device);
252231 */
256235
257236 /**
258237 * This function queries if a specified context extension is available.
259 *
238 *
260239 * C Specification:
261240 * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName);
262241 */
263 static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) {
264 /* get extension */
265 ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
266
267 jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname);
268
269 free(functionname);
270
271 return result;
242 static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong extName) {
243 return (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)extName);
272244 }
273245
274246 /**
277249 * C Specification:
278250 * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName);
279251 */
280 static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) {
281 /* get extension */
282 ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
283
284 jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname);
285
286 free(enumerationname);
287
288 return result;
252 static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong enumName) {
253 return (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)enumName);
289254 }
290255
291256 /**
298263 #endif
299264 JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC10_initNativeStubs(JNIEnv *env, jclass clazz) {
300265 JavaMethodAndExtFunction functions[] = {
301 {"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString},
302 {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv},
303 {"nalcOpenDevice", "(Ljava/lang/String;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice},
304 {"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice},
305 {"nalcCreateContext", "(JLjava/nio/IntBuffer;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
306 {"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent},
307 {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext},
308 {"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext},
309 {"nalcGetContextsDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice, "alcGetContextsDevice", (void*)&alcGetContextsDevice},
310 {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext},
311 {"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext},
312 {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError},
313 {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent},
314 {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue}
266 {"nalcGetString", "(JI)Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString, false},
267 {"nalcGetIntegerv", "(JIIJ)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv, false},
268 {"nalcOpenDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice, false},
269 {"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice, false},
270 {"nalcCreateContext", "(JJ)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext, false},
271 {"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent, false},
272 {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext, false},
273 {"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext, false},
274 {"nalcGetContextsDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice, "alcGetContextsDevice", (void*)&alcGetContextsDevice, false},
275 {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext, false},
276 {"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext, false},
277 {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError, false},
278 {"nalcIsExtensionPresent", "(JJ)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent, false},
279 {"nalcGetEnumValue", "(JJ)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue, false}
315280 };
316281 int num_functions = NUMFUNCTIONS(functions);
317282 extal_InitializeClass(env, clazz, num_functions, functions);
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
31
3232 /**
3333 * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
3434 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
35 * This is the actual JNI implementation of the OpenAL context/device library.
36 *
3737 * @author Brian Matzon <brian@matzon.dk>
3838 * @version $Revision: 2279 $
3939 */
5959 * Method: nalcCaptureOpenDevice
6060 * Signature: (Ljava/lang/String;III)J
6161 */
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);
62 static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jlong devicename, jint frequency, jint format, jint buffersize) {
63 return (jlong)(intptr_t)alcCaptureOpenDevice((const char *)(intptr_t)devicename, (unsigned int) frequency, format, buffersize);
7464 }
7565
7666 /*
10595 * Method: nalcCaptureSamples
10696 * Signature: (JLjava/nio/ByteBuffer;I)V
10797 */
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));
98 static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jlong buffer, jint samples) {
99 ALvoid *buffer_address = (ALbyte *)(intptr_t)buffer;
110100 alcCaptureSamples((ALCdevice*) ((intptr_t)device), buffer_address, samples);
111101 }
112102
120110 #endif
121111 JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC11_initNativeStubs(JNIEnv *env, jclass clazz) {
122112 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}
113 {"nalcCaptureOpenDevice", "(JIII)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice, false},
114 {"nalcCaptureCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice, "alcCaptureCloseDevice", (void*)&alcCaptureCloseDevice, false},
115 {"nalcCaptureStart", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStart, "alcCaptureStart", (void*)&alcCaptureStart, false},
116 {"nalcCaptureStop", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStop, "alcCaptureStop", (void*)&alcCaptureStop, false},
117 {"nalcCaptureSamples", "(JJI)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples, false}
128118 };
129119 int num_functions = NUMFUNCTIONS(functions);
130120 extal_InitializeClass(env, clazz, num_functions, functions);
4141 extcl_UnloadLibrary();
4242 }
4343
44 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) {
45 jlong address_jlong;
46 char *function_name_pointer = GetStringNativeChars(env, function_name);
47 void *address = extcl_GetProcAddress(function_name_pointer);
48 free(function_name_pointer);
49 address_jlong = (jlong)(intptr_t)address;
50 return address_jlong;
44 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) {
45 return (jlong)(intptr_t)extcl_GetProcAddress((char *)(intptr_t)function_name);
5146 }
5247
5348 JNIEXPORT jobject JNICALL Java_org_lwjgl_opencl_CL_getHostBuffer(JNIEnv *env, jclass clazz, jlong address, jint size) {
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opencl_CL */
3
4 #ifndef _Included_org_lwjgl_opencl_CL
5 #define _Included_org_lwjgl_opencl_CL
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opencl_CL
11 * Method: nCreate
12 * Signature: (Ljava/lang/String;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreate
15 (JNIEnv *, jclass, jstring);
16
17 /*
18 * Class: org_lwjgl_opencl_CL
19 * Method: nCreateDefault
20 * Signature: ()V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreateDefault
23 (JNIEnv *, jclass);
24
25 /*
26 * Class: org_lwjgl_opencl_CL
27 * Method: nDestroy
28 * Signature: ()V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nDestroy
31 (JNIEnv *, jclass);
32
33 /*
34 * Class: org_lwjgl_opencl_CL
35 * Method: ngetFunctionAddress
36 * Signature: (J)J
37 */
38 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_ngetFunctionAddress
39 (JNIEnv *, jclass, jlong);
40
41 /*
42 * Class: org_lwjgl_opencl_CL
43 * Method: getHostBuffer
44 * Signature: (JI)Ljava/nio/ByteBuffer;
45 */
46 JNIEXPORT jobject JNICALL Java_org_lwjgl_opencl_CL_getHostBuffer
47 (JNIEnv *, jclass, jlong, jint);
48
49 /*
50 * Class: org_lwjgl_opencl_CL
51 * Method: resetNativeStubs
52 * Signature: (Ljava/lang/Class;)V
53 */
54 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_resetNativeStubs
55 (JNIEnv *, jclass, jclass);
56
57 #ifdef __cplusplus
58 }
59 #endif
60 #endif
3030 */
3131
3232 /**
33 * JNI implementation of the AMD_debug_output function callback.
33 * JNI implementation of the OpenCL function callbacks.
3434 *
3535 * @author Spasi
3636 */
4242
4343 static jmethodID contextCallbackJ;
4444 static jmethodID memObjectDestructorCallbackJ;
45 static jmethodID buildProgramCallbackJ;
45 static jmethodID programCallbackJ;
4646 static jmethodID nativeKernelCallbackJ;
4747 static jmethodID eventCallbackJ;
48 static jmethodID printfCallbackJ;
4849
4950 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
5051 return (intptr_t)(*env)->NewGlobalRef(env, obj);
6566 private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb);
6667
6768 (*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ,
68 NewStringNativeWithLength(env, errinfo, strlen(errinfo)),
69 NewStringNativeWithLength(env, errinfo, (jsize)strlen(errinfo)),
6970 private_info_buffer
7071 );
7172 }
112113 return (jlong)(intptr_t)&memObjectDestructorCallback;
113114 }
114115
115 // ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] -----------------
116
117 static void CL_CALLBACK buildProgramCallback(cl_program program, void *user_data) {
118 JNIEnv *env = attachCurrentThread();
119
120 if ( env != NULL && !(*env)->ExceptionOccurred(env) && buildProgramCallbackJ != NULL ) {
121 (*env)->CallVoidMethod(env, (jobject)user_data, buildProgramCallbackJ,
116 // ----------------- [ PROGRAM CALLBACK ] -----------------
117
118 static void CL_CALLBACK programCallback(cl_program program, void *user_data) {
119 JNIEnv *env = attachCurrentThread();
120
121 if ( env != NULL && !(*env)->ExceptionOccurred(env) && programCallbackJ != NULL ) {
122 (*env)->CallVoidMethod(env, (jobject)user_data, programCallbackJ,
122123 (jlong)(intptr_t)program
123124 );
124125 (*env)->DeleteGlobalRef(env, (jobject)user_data);
127128 detachCurrentThread();
128129 }
129130
130 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getBuildProgramCallback(JNIEnv *env, jclass clazz) {
131 // Cache the callback methodID
132 jclass callbackClass;
133 if ( buildProgramCallbackJ == NULL ) {
134 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLBuildProgramCallback");
135 if ( callbackClass != NULL )
136 buildProgramCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V");
137 }
138
139 return (jlong)(intptr_t)&buildProgramCallback;
131 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getProgramCallback(JNIEnv *env, jclass clazz) {
132 // Cache the callback methodID
133 jclass callbackClass;
134 if ( programCallbackJ == NULL ) {
135 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLProgramCallback");
136 if ( callbackClass != NULL )
137 programCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V");
138 }
139
140 return (jlong)(intptr_t)&programCallback;
140141 }
141142
142143 // ----------------- [ NATIVE KERNEL CALLBACK ] -----------------
143144
144 static void CL_USER_FUNC_CALLBACK nativeKernelCallback(void *args) {
145 static void CL_CALLBACK nativeKernelCallback(void *args) {
145146 JNIEnv *env = attachCurrentThread();
146147 jobject user_func = (jobject)(intptr_t)*(jlong *)args;
147 jint num_mem_objects = *(jint *)((char *)args + 8);
148 jsize num_mem_objects = *(jsize *)((char *)args + 8);
148149 jobjectArray memobjs = NULL;
149150 jobject buffer;
150 jint i;
151 jsize i;
151152
152153 if ( env != NULL && !(*env)->ExceptionOccurred(env) && nativeKernelCallbackJ != NULL ) {
153154 if ( num_mem_objects > 0 ) {
213214 return (jlong)(intptr_t)&eventCallback;
214215 }
215216
217 // ----------------- [ PRINTF CALLBACK ] -----------------
218
219 static void CL_CALLBACK printfCallback(cl_context context, cl_uint printf_data_len, char *printf_data_ptr, void *user_data) {
220 JNIEnv *env = attachCurrentThread();
221
222 if ( env != NULL && !(*env)->ExceptionOccurred(env) && printfCallbackJ != NULL ) {
223 (*env)->CallVoidMethod(env, (jobject)user_data, printfCallbackJ,
224 NewStringNativeWithLength(env, printf_data_ptr, printf_data_len)
225 );
226 }
227
228 detachCurrentThread();
229 }
230
231 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getPrintfCallback(JNIEnv *env, jclass clazz) {
232 // Cache the callback methodID
233 jclass callbackClass;
234 if ( printfCallbackJ == NULL ) {
235 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLPrintfCallback");
236 if ( callbackClass != NULL )
237 printfCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(Ljava/lang/String;)V");
238 }
239
240 return (jlong)(intptr_t)&printfCallback;
241 }
242
216243 // ----------------- [ APPLE_ContextLoggingFunctions CALLBACKS ] -----------------
217244
218245 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE(JNIEnv *env, jclass clazz) {
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opencl_CallbackUtil */
3
4 #ifndef _Included_org_lwjgl_opencl_CallbackUtil
5 #define _Included_org_lwjgl_opencl_CallbackUtil
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opencl_CallbackUtil
11 * Method: ncreateGlobalRef
12 * Signature: (Ljava/lang/Object;)J
13 */
14 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef
15 (JNIEnv *, jclass, jobject);
16
17 /*
18 * Class: org_lwjgl_opencl_CallbackUtil
19 * Method: deleteGlobalRef
20 * Signature: (J)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CallbackUtil_deleteGlobalRef
23 (JNIEnv *, jclass, jlong);
24
25 /*
26 * Class: org_lwjgl_opencl_CallbackUtil
27 * Method: getContextCallback
28 * Signature: ()J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getContextCallback
31 (JNIEnv *, jclass);
32
33 /*
34 * Class: org_lwjgl_opencl_CallbackUtil
35 * Method: getMemObjectDestructorCallback
36 * Signature: ()J
37 */
38 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getMemObjectDestructorCallback
39 (JNIEnv *, jclass);
40
41 /*
42 * Class: org_lwjgl_opencl_CallbackUtil
43 * Method: getProgramCallback
44 * Signature: ()J
45 */
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getProgramCallback
47 (JNIEnv *, jclass);
48
49 /*
50 * Class: org_lwjgl_opencl_CallbackUtil
51 * Method: getNativeKernelCallback
52 * Signature: ()J
53 */
54 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getNativeKernelCallback
55 (JNIEnv *, jclass);
56
57 /*
58 * Class: org_lwjgl_opencl_CallbackUtil
59 * Method: getEventCallback
60 * Signature: ()J
61 */
62 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getEventCallback
63 (JNIEnv *, jclass);
64
65 /*
66 * Class: org_lwjgl_opencl_CallbackUtil
67 * Method: getPrintfCallback
68 * Signature: ()J
69 */
70 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getPrintfCallback
71 (JNIEnv *, jclass);
72
73 /*
74 * Class: org_lwjgl_opencl_CallbackUtil
75 * Method: getLogMessageToSystemLogAPPLE
76 * Signature: ()J
77 */
78 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE
79 (JNIEnv *, jclass);
80
81 /*
82 * Class: org_lwjgl_opencl_CallbackUtil
83 * Method: getLogMessageToStdoutAPPLE
84 * Signature: ()J
85 */
86 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStdoutAPPLE
87 (JNIEnv *, jclass);
88
89 /*
90 * Class: org_lwjgl_opencl_CallbackUtil
91 * Method: getLogMessageToStderrAPPLE
92 * Signature: ()J
93 */
94 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStderrAPPLE
95 (JNIEnv *, jclass);
96
97 #ifdef __cplusplus
98 }
99 #endif
100 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_AWTSurfaceLock.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @author kappaOne <one.kappa@gmail.com>
37 * @version $Revision$
3738 */
3839
3940 #include <jni.h>
41 #ifdef __MACH__
42 #include <JavaVM/jawt_md.h>
43 #else
4044 #include <jawt_md.h>
45 #endif
4146 #include "org_lwjgl_opengl_AWTSurfaceLock.h"
4247 #include "awt_tools.h"
4348 #include "common_tools.h"
5358 JAWT_DrawingSurface* ds;
5459 JAWT_DrawingSurfaceInfo *dsi;
5560 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;
61
62 jboolean result = JNI_FALSE;
63
64 #ifdef __MACH__
65 // try get JAWT with JAWT_MACOSX_USE_CALAYER Opt In
66 awt.version = JAWT_VERSION_1_4 | 0x80000000;//JAWT_MACOSX_USE_CALAYER;
67 result = JAWT_GetAWT(env, &awt);
68 #endif
69
70 if (result == JNI_FALSE) {
71 // now try without CALAYER
72 awt.version = JAWT_VERSION_1_4;
73 if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
74 throwException(env, "Could not get the JAWT interface");
75 return JNI_FALSE;
76 }
6077 }
6178
6279 ds = awt.GetDrawingSurface(env, canvas);
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_AWTSurfaceLock */
3
4 #ifndef _Included_org_lwjgl_opengl_AWTSurfaceLock
5 #define _Included_org_lwjgl_opengl_AWTSurfaceLock
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_AWTSurfaceLock_WAIT_DELAY_MILLIS
10 #define org_lwjgl_opengl_AWTSurfaceLock_WAIT_DELAY_MILLIS 100L
11 /*
12 * Class: org_lwjgl_opengl_AWTSurfaceLock
13 * Method: createHandle
14 * Signature: ()Ljava/nio/ByteBuffer;
15 */
16 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_createHandle
17 (JNIEnv *, jclass);
18
19 /*
20 * Class: org_lwjgl_opengl_AWTSurfaceLock
21 * Method: lockAndInitHandle
22 * Signature: (Ljava/nio/ByteBuffer;Ljava/awt/Canvas;)Z
23 */
24 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_lockAndInitHandle
25 (JNIEnv *, jclass, jobject, jobject);
26
27 /*
28 * Class: org_lwjgl_opengl_AWTSurfaceLock
29 * Method: nUnlock
30 * Signature: (Ljava/nio/ByteBuffer;)V
31 */
32 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_nUnlock
33 (JNIEnv *, jclass, jobject);
34
35 #ifdef __cplusplus
36 }
37 #endif
38 #endif
+0
-112
src/native/common/org_lwjgl_opengl_CallbackUtil.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /**
33 * JNI implementation of the AMD_debug_output function callback.
34 *
35 * @author Spasi
36 */
37
38 #include <jni.h>
39 #include "common_tools.h"
40 #include "extgl.h"
41 #include "org_lwjgl_opengl_CallbackUtil.h"
42
43 static jmethodID debugOutputCallbackARBJ;
44 static jmethodID debugOutputCallbackAMDJ;
45
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
47 return (jlong)(*env)->NewGlobalRef(env, obj);
48 }
49
50 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
51 (*env)->DeleteGlobalRef(env, (jobject)globalRef);
52 }
53
54 // ----------------- [ ARB_debug_output ] -----------------
55
56 static void APIENTRY debugOutputCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
57 JNIEnv *env = attachCurrentThread();
58
59 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackARBJ != NULL ) {
60 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackARBJ,
61 (jint)source,
62 (jint)type,
63 (jint)id,
64 (jint)severity,
65 NewStringNativeWithLength(env, message, length)
66 );
67 }
68
69 detachCurrentThread();
70 }
71
72 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB(JNIEnv *env, jclass clazz) {
73 // Cache the callback methodID
74 jclass callbackClass;
75 if ( debugOutputCallbackARBJ == NULL ) {
76 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/ARBDebugOutputCallback$Handler");
77 if ( callbackClass != NULL )
78 debugOutputCallbackARBJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V");
79 }
80
81 return (jlong)(intptr_t)&debugOutputCallbackARB;
82 }
83
84 // ----------------- [ AMD_debug_output ] -----------------
85
86 static void APIENTRY debugOutputCallbackAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
87 JNIEnv *env = attachCurrentThread();
88
89 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackAMDJ != NULL ) {
90 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackAMDJ,
91 (jint)id,
92 (jint)category,
93 (jint)severity,
94 NewStringNativeWithLength(env, message, length)
95 );
96 }
97
98 detachCurrentThread();
99 }
100
101 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD(JNIEnv *env, jclass clazz) {
102 // Cache the callback methodID
103 jclass callbackClass;
104 if ( debugOutputCallbackAMDJ == NULL ) {
105 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputCallback$Handler");
106 if ( callbackClass != NULL )
107 debugOutputCallbackAMDJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIILjava/lang/String;)V");
108 }
109
110 return (jlong)(intptr_t)&debugOutputCallbackAMD;
111 }
+0
-57
src/native/common/org_lwjgl_opengl_GLContext.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
-359
src/native/linux/context.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3357 2010-06-02 23:35:38Z spasi $
34 *
35 * Include file to access public window features
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3357 $
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 colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
122 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
123 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
124 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
125
126 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
127 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
128 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
129 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
130
131 int bpe = convertToBPE(bpp);
132 int accum_bpe = convertToBPE(accum_bpp);
133 attrib_list_t attrib_list;
134 initAttribList(&attrib_list);
135 int render_type;
136
137 if ( floating_point )
138 render_type = GLX_RGBA_FLOAT_BIT;
139 else if ( floating_point_packed )
140 render_type = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
141 else
142 render_type = GLX_RGBA_BIT;
143
144 putAttrib(&attrib_list, GLX_RENDER_TYPE); putAttrib(&attrib_list, render_type);
145 putAttrib(&attrib_list, GLX_DOUBLEBUFFER); putAttrib(&attrib_list, double_buffer ? True : False);
146 putAttrib(&attrib_list, GLX_DRAWABLE_TYPE); putAttrib(&attrib_list, drawable_type);
147 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
148 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
149 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
150 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
151 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
152 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
153 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
154 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
155 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
156 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
157 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
158 if (stereo) {
159 putAttrib(&attrib_list, GLX_STEREO); putAttrib(&attrib_list, True);
160 }
161 // Assume the caller has checked support for multisample
162 if (samples > 0) {
163 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
164 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0
165 if ( colorSamples > 0 ) {
166 putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
167 }
168 }
169 if (sRGB) {
170 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True);
171 }
172 putAttrib(&attrib_list, None); putAttrib(&attrib_list, None);
173 int num_formats = 0;
174 GLXFBConfig* configs = lwjgl_glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats);
175 if (num_formats > 0) {
176 return configs;
177 } else {
178 if (configs != NULL)
179 XFree(configs);
180 return NULL;
181 }
182 }
183
184 GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer) {
185 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
186 int bpp;
187 if (use_display_bpp) {
188 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
189 GLXFBConfig *configs = chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
190 if (configs != NULL)
191 return configs;
192 else
193 bpp = 16;
194 } else
195 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
196 return chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
197 }
198
199 static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, bool double_buffer) {
200 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
201 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
202 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
203 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
204 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
205 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
206 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
207 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
208 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
209
210 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
211 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
212
213 int bpe = convertToBPE(bpp);
214 int accum_bpe = convertToBPE(accum_bpp);
215 attrib_list_t attrib_list;
216 initAttribList(&attrib_list);
217 putAttrib(&attrib_list, GLX_RGBA);
218 putAttrib(&attrib_list, GLX_DOUBLEBUFFER);
219 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
220 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
221 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
222 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
223 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
224 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
225 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
226 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
227 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
228 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
229 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
230 if (stereo)
231 putAttrib(&attrib_list, GLX_STEREO);
232 // Assume the caller has checked support for multisample
233 if (samples > 0) {
234 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
235 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0
236 if ( colorSamples > 0 )
237 putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
238 }
239 if (sRGB)
240 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
241 putAttrib(&attrib_list, None);
242 return lwjgl_glXChooseVisual(disp, screen, attrib_list.attribs);
243 }
244
245 XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer) {
246 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
247 int bpp;
248 if (use_display_bpp) {
249 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
250 XVisualInfo *vis_info = chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
251 if (vis_info != NULL)
252 return vis_info;
253 else
254 bpp = 16;
255 } else
256 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
257 return chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
258 }
259
260 static void dumpVisualInfo(JNIEnv *env, Display *display, GLXExtensions *extension_flags, XVisualInfo *vis_info) {
261 int alpha, depth, stencil, r, g, b;
262 int sample_buffers = 0;
263 int samples = 0;
264 lwjgl_glXGetConfig(display, vis_info, GLX_RED_SIZE, &r);
265 lwjgl_glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g);
266 lwjgl_glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b);
267 lwjgl_glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha);
268 lwjgl_glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth);
269 lwjgl_glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil);
270 if (extension_flags->GLX_ARB_multisample) {
271 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers);
272 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples);
273 }
274 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);
275 }
276
277 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) {
278 if ((*env)->GetDirectBufferCapacity(env, peer_info_handle) < sizeof(X11PeerInfo)) {
279 throwException(env, "Handle too small");
280 return false;
281 }
282 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
283 GLXExtensions extension_flags;
284 if (!extgl_InitGLX(display, screen, &extension_flags)) {
285 throwException(env, "Could not init GLX");
286 return false;
287 }
288 if (!extension_flags.GLX13 && force_glx13) {
289 throwException(env, "GLX13 is required, but is not available");
290 return false;
291 }
292 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
293 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
294 if (samples > 0 && !extension_flags.GLX_ARB_multisample) {
295 throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample");
296 return false;
297 }
298 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
299 if (colorSamples > 0 && !extension_flags.GLX_NV_multisample_coverage) {
300 throwException(env, "Color samples > 0 specified but there's no support for GLX_NV_multisample_coverage");
301 return false;
302 }
303 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
304 if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point
305 throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float");
306 return false;
307 }
308 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
309 if (floating_point_packed && !(extension_flags.GLX13 && extension_flags.GLX_EXT_fbconfig_packed_float)) { // We need GLX13 to support packed floating point
310 throwException(env, "Packed floating point specified but there's no support for GLX_EXT_fbconfig_packed_float");
311 return false;
312 }
313 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
314 if (sRGB && !extension_flags.GLX_ARB_framebuffer_sRGB) {
315 throwException(env, "sRGB specified but there's no support for GLX_ARB_framebuffer_sRGB");
316 return false;
317 }
318
319 peer_info->glx13 = extension_flags.GLX13;
320 if (peer_info->glx13) {
321 GLXFBConfig *configs = chooseVisualGLX13(env, display, screen, pixel_format, use_display_bpp, drawable_type, double_buffered);
322 if (configs == NULL) {
323 throwException(env, "Could not choose GLX13 config");
324 return false;
325 }
326 if (isDebugEnabled()) {
327 XVisualInfo *vis_info = lwjgl_glXGetVisualFromFBConfig(display, configs[0]);
328 if (vis_info != NULL) {
329 dumpVisualInfo(env, display, &extension_flags, vis_info);
330 XFree(vis_info);
331 }
332 }
333 int config_id;
334 int result = lwjgl_glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id);
335 XFree(configs);
336 if (result != Success) {
337 throwException(env, "Could not get GLX_FBCONFIG_ID from GLXFBConfig");
338 return false;
339 }
340 peer_info->config.glx13_config.config_id = config_id;
341 } else {
342 XVisualInfo *vis_info = chooseVisualGLX(env, display, screen, pixel_format, use_display_bpp, double_buffered);
343 if (vis_info == NULL) {
344 throwException(env, "Could not choose visual");
345 return false;
346 }
347 peer_info->config.glx_config.visualid = vis_info->visualid;
348 peer_info->config.glx_config.depth = vis_info->depth;
349 peer_info->screen = vis_info->screen;
350 if (isDebugEnabled())
351 dumpVisualInfo(env, display, &extension_flags, vis_info);
352 XFree(vis_info);
353 }
354 peer_info->display = display;
355 peer_info->screen = screen;
356 peer_info->drawable = None;
357 return true;
358 }
+0
-83
src/native/linux/context.h less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
-411
src/native/linux/display.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
-232
src/native/linux/extgl_glx.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 extension_flags->GLX_NV_multisample_coverage = GLXQueryExtension(disp, screen, "GLX_NV_multisample_coverage");
163 }
164
165 bool extgl_Open(JNIEnv *env) {
166 if (lib_gl_handle != NULL)
167 return true;
168 /*
169 * Actually we don't need the RTLD_GLOBAL flag, since the symbols
170 * we load should be private to us. However, according to the
171 * documentation at
172 *
173 * http://dri.sourceforge.net/doc/DRIuserguide.html
174 *
175 * DRI drivers need this flag to work properly
176 */
177 lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
178 if (lib_gl_handle == NULL) {
179 throwFormattedException(env, "Error loading libGL.so.1: %s", dlerror());
180 return false;
181 }
182 lwjgl_glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB");
183 if (lwjgl_glXGetProcAddressARB == NULL) {
184 extgl_Close();
185 throwException(env, "Could not get address of glXGetProcAddressARB");
186 return false;
187 }
188 /* Unlike Windows, GLX function addresses are context-independent
189 * so we only have to initialize the addresses once at load
190 */
191 extgl_InitGLX12();
192 extgl_InitGLX13();
193 extgl_InitGLXSGISwapControl();
194 extgl_InitGLXARBCreateContext();
195 return true;
196 }
197
198 void *extgl_GetProcAddress(const char *name) {
199 void *t = (void*)lwjgl_glXGetProcAddressARB((const GLubyte*)name);
200 if (t == NULL) {
201 t = dlsym(lib_gl_handle, name);
202 if (t == NULL) {
203 printfDebug("Could not locate symbol %s\n", name);
204 }
205 }
206 return t;
207 }
208
209 void extgl_Close(void) {
210 dlclose(lib_gl_handle);
211 lib_gl_handle = NULL;
212 }
213
214 bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags) {
215 int major, minor;
216 /* Assume glx ver >= 1.2 */
217 // Check GLX 1.2 symbols available
218 if (!symbols_flags.GLX12)
219 return false;
220 if (lwjgl_glXQueryVersion(disp, &major, &minor) != True)
221 return false;
222 bool glx12 = major > 1 || (major == 1 && minor >= 2);
223 // Check GLX 1.2 version
224 if (!glx12)
225 return false;
226 extension_flags->GLX12 = glx12;
227 extension_flags->GLX13 = major > 1 || (major == 1 && minor >= 3);
228 extension_flags->GLX14 = major > 1 || (major == 1 && minor >= 4);
229 extgl_InitGLXSupportedExtensions(disp, screen, extension_flags);
230 return true;
231 }
+0
-404
src/native/linux/extgl_glx.h less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 /* GLX_NV_multisample_coverage */
274 #define GLX_COVERAGE_SAMPLES_NV 100001
275 #define GLX_COLOR_SAMPLES_NV 0x20B3
276
277
278 typedef XID GLXContextID;
279 typedef XID GLXPixmap;
280 typedef XID GLXDrawable;
281 typedef XID GLXPbuffer;
282 typedef XID GLXWindow;
283 typedef XID GLXFBConfigID;
284
285 typedef struct __GLXcontextRec *GLXContext;
286
287 typedef struct __GLXFBConfigRec *GLXFBConfig;
288
289 typedef GLXFBConfig * (APIENTRY * glXGetFBConfigsPROC) (Display *dpy, int screen, int *nelements);
290 typedef GLXFBConfig * (APIENTRY * glXChooseFBConfigPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
291 typedef int (APIENTRY * glXGetFBConfigAttribPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
292 typedef XVisualInfo * (APIENTRY * glXGetVisualFromFBConfigPROC) (Display *dpy, GLXFBConfig config);
293 typedef GLXWindow (APIENTRY * glXCreateWindowPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
294 typedef void (APIENTRY * glXDestroyWindowPROC) (Display *dpy, GLXWindow win);
295 typedef GLXPixmap (APIENTRY * glXCreatePixmapPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
296 typedef void (APIENTRY * glXDestroyPixmapPROC) (Display *dpy, GLXPixmap pixmap);
297 typedef GLXPbuffer (APIENTRY * glXCreatePbufferPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
298 typedef void (APIENTRY * glXDestroyPbufferPROC) (Display *dpy, GLXPbuffer pbuf);
299 typedef void (APIENTRY * glXQueryDrawablePROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
300 typedef GLXContext (APIENTRY * glXCreateNewContextPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
301 typedef Bool (APIENTRY * glXMakeContextCurrentPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
302 typedef GLXDrawable (APIENTRY * glXGetCurrentReadDrawablePROC) (void);
303 typedef Display * (APIENTRY * glXGetCurrentDisplayPROC) (void);
304 typedef int (APIENTRY * glXQueryContextPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
305 typedef void (APIENTRY * glXSelectEventPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
306 typedef void (APIENTRY * glXGetSelectedEventPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
307
308 typedef GLXContextID (APIENTRY * glXGetContextIDEXTPROC) (const GLXContext ctx);
309 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawableEXTPROC) (void);
310 typedef GLXContext (APIENTRY * glXImportContextEXTPROC) (Display *dpy, GLXContextID contextID);
311 typedef void (APIENTRY * glXFreeContextEXTPROC) (Display *dpy, GLXContext ctx);
312 typedef int (APIENTRY * glXQueryContextInfoEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
313
314 typedef XVisualInfo* (APIENTRY * glXChooseVisualPROC) (Display *dpy, int screen, int *attribList);
315 typedef void (APIENTRY * glXCopyContextPROC) (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
316 typedef GLXContext (APIENTRY * glXCreateContextPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
317 typedef GLXPixmap (APIENTRY * glXCreateGLXPixmapPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
318 typedef void (APIENTRY * glXDestroyContextPROC) (Display *dpy, GLXContext ctx);
319 typedef void (APIENTRY * glXDestroyGLXPixmapPROC) (Display *dpy, GLXPixmap pix);
320 typedef int (APIENTRY * glXGetConfigPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
321 typedef GLXContext (APIENTRY * glXGetCurrentContextPROC) (void);
322 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawablePROC) (void);
323 typedef Bool (APIENTRY * glXIsDirectPROC) (Display *dpy, GLXContext ctx);
324 typedef Bool (APIENTRY * glXMakeCurrentPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
325 typedef Bool (APIENTRY * glXQueryExtensionPROC) (Display *dpy, int *errorBase, int *eventBase);
326 typedef Bool (APIENTRY * glXQueryVersionPROC) (Display *dpy, int *major, int *minor);
327 typedef void (APIENTRY * glXSwapBuffersPROC) (Display *dpy, GLXDrawable drawable);
328 typedef void (APIENTRY * glXUseXFontPROC) (Font font, int first, int count, int listBase);
329 typedef void (APIENTRY * glXWaitGLPROC) (void);
330 typedef void (APIENTRY * glXWaitXPROC) (void);
331 typedef const char * (APIENTRY * glXGetClientStringPROC) (Display *dpy, int name );
332 typedef const char * (APIENTRY * glXQueryServerStringPROC) (Display *dpy, int screen, int name );
333 typedef const char * (APIENTRY * glXQueryExtensionsStringPROC) (Display *dpy, int screen );
334
335 /* GLX_SGI_swap_control */
336 typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval);
337
338 /* GLX_ARB_create_context */
339 typedef GLXContext (APIENTRY * glXCreateContextAttribsARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
340
341 typedef struct {
342 bool GLX12;
343 bool GLX13;
344 bool GLX14;
345 /* bool GLX_EXT_visual_info;
346 bool GLX_EXT_visual_rating;*/
347 bool GLX_SGI_swap_control;
348 bool GLX_ARB_multisample;
349 bool GLX_ARB_fbconfig_float;
350 bool GLX_EXT_fbconfig_packed_float;
351 bool GLX_ARB_framebuffer_sRGB;
352 bool GLX_ARB_create_context;
353 bool GLX_NV_multisample_coverage;
354 } GLXExtensions;
355
356 /* Add _ to global symbols to avoid symbol clash with the OpenGL library */
357 extern glXGetFBConfigsPROC lwjgl_glXGetFBConfigs;
358 extern glXChooseFBConfigPROC lwjgl_glXChooseFBConfig;
359 extern glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib;
360 extern glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig;
361 extern glXCreateWindowPROC lwjgl_glXCreateWindow;
362 extern glXDestroyWindowPROC lwjgl_glXDestroyWindow;
363 extern glXCreatePixmapPROC lwjgl_glXCreatePixmap;
364 extern glXDestroyPixmapPROC lwjgl_glXDestroyPixmap;
365 extern glXCreatePbufferPROC lwjgl_glXCreatePbuffer;
366 extern glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer;
367 extern glXQueryDrawablePROC lwjgl_glXQueryDrawable;
368 extern glXCreateNewContextPROC lwjgl_glXCreateNewContext;
369 extern glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent;
370 extern glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable;
371 extern glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay;
372 extern glXQueryContextPROC lwjgl_glXQueryContext;
373 extern glXSelectEventPROC lwjgl_glXSelectEvent;
374 extern glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent;
375
376 extern glXChooseVisualPROC lwjgl_glXChooseVisual;
377 extern glXCopyContextPROC lwjgl_glXCopyContext;
378 extern glXCreateContextPROC lwjgl_glXCreateContext;
379 extern glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap;
380 extern glXDestroyContextPROC lwjgl_glXDestroyContext;
381 extern glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap;
382 extern glXGetConfigPROC lwjgl_glXGetConfig;
383 extern glXGetCurrentContextPROC lwjgl_glXGetCurrentContext;
384 extern glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable;
385 extern glXIsDirectPROC lwjgl_glXIsDirect;
386 extern glXMakeCurrentPROC lwjgl_glXMakeCurrent;
387 extern glXQueryExtensionPROC lwjgl_glXQueryExtension;
388 extern glXQueryVersionPROC lwjgl_glXQueryVersion;
389 extern glXSwapBuffersPROC lwjgl_glXSwapBuffers;
390 extern glXUseXFontPROC lwjgl_glXUseXFont;
391 extern glXWaitGLPROC lwjgl_glXWaitGL;
392 extern glXWaitXPROC lwjgl_glXWaitX;
393 extern glXGetClientStringPROC lwjgl_glXGetClientString;
394 extern glXQueryServerStringPROC lwjgl_glXQueryServerString;
395 extern glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString;
396
397 extern glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI;
398
399 extern glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB;
400
401 extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags);
402
403 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 * GLX extension implementations.
34 *
35 * @author Spasi
36 */
37 #include "GLX.h"
38
39 /* NV_present_video functions */
40
41 typedef struct {
42 GLXExtensions extension_flags;
43 GLXContext context;
44 } X11Context;
45
46 jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) {
47 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
48 jlong *devices_address = ((jlong *)safeGetBufferAddress(env, devices)) + devices_position;
49 unsigned int *result;
50 int i, elements;
51
52 result = lwjgl_glXEnumerateVideoDevicesNV(peer_info->display, peer_info->screen, &elements);
53 if ( devices_address != NULL ) {
54 for ( i = 0; i < elements; i++ )
55 devices_address[i] = (jlong)result[i];
56 }
57 XFree(result);
58
59 return elements;
60 }
61
62 jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position) {
63 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
64 const int *attrib_list_address = ((const int *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
65
66 return lwjgl_glXBindVideoDeviceNV(peer_info->display, video_slot, (unsigned int)video_device, attrib_list_address);
67 }
68
69 jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position) {
70 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
71 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
72 int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
73
74 return lwjgl_glXQueryContext(peer_info->display, context_info->context, attrib, value_address) == GLX_BAD_ATTRIBUTE ? 0 : 1;
75 }
76
77 /* NV_video_capture functions */
78
79 jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device) {
80 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
81
82 return lwjgl_glXBindVideoCaptureDeviceNV(peer_info->display, video_slot, (GLXVideoCaptureDeviceNV)device);
83 }
84
85 jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) {
86 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
87 jlong *devices_address = ((jlong *)safeGetBufferAddress(env, devices)) + devices_position;
88 GLXVideoCaptureDeviceNV *result;
89 int i, elements;
90
91 result = lwjgl_glXEnumerateVideoCaptureDevicesNV(peer_info->display, peer_info->screen, &elements);
92 if ( devices_address != NULL ) {
93 for ( i = 0; i < elements; i++ )
94 devices_address[i] = (jlong)result[i];
95 }
96 XFree(devices);
97
98 return elements;
99 }
100
101 jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) {
102 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
103
104 lwjgl_glXLockVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device);
105 return true;
106 }
107
108 jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position) {
109 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
110 int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
111
112 return lwjgl_glXQueryVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device, attribute, value_address);
113 }
114
115 jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) {
116 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
117
118 lwjgl_glXReleaseVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device);
119 return true;
120 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 * GLX extension implementations.
34 *
35 * @author Spasi
36 */
37 #ifndef __LWJGL_GLX_H
38 #define __LWJGL_GLX_H
39
40 #include <jni.h>
41 #include "common_tools.h"
42 #include "context.h"
43
44 #include "extgl.h"
45 #include "extgl_glx.h"
46
47 /* NV_present_video functions */
48 extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
49 extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position);
50 extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position);
51
52 /* NV_video_capture functions */
53 extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device);
54 extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
55 extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
56 extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position);
57 extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
58
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$
34 *
35 * Include file to access public window features
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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 colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
122 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
123 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
124 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
125
126 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
127 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
128 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
129 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
130
131 int bpe = convertToBPE(bpp);
132 int accum_bpe = convertToBPE(accum_bpp);
133 attrib_list_t attrib_list;
134 initAttribList(&attrib_list);
135 int render_type;
136
137 if ( floating_point )
138 render_type = GLX_RGBA_FLOAT_BIT;
139 else if ( floating_point_packed )
140 render_type = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
141 else
142 render_type = GLX_RGBA_BIT;
143
144 putAttrib(&attrib_list, GLX_RENDER_TYPE); putAttrib(&attrib_list, render_type);
145 putAttrib(&attrib_list, GLX_DOUBLEBUFFER); putAttrib(&attrib_list, double_buffer ? True : False);
146 putAttrib(&attrib_list, GLX_DRAWABLE_TYPE); putAttrib(&attrib_list, drawable_type);
147 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
148 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
149 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
150 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
151 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
152 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
153 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
154 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
155 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
156 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
157 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
158 if (stereo) {
159 putAttrib(&attrib_list, GLX_STEREO); putAttrib(&attrib_list, True);
160 }
161 // Assume the caller has checked support for multisample
162 if (samples > 0) {
163 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
164 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0
165 if ( colorSamples > 0 ) {
166 putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
167 }
168 }
169 if (sRGB) {
170 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True);
171 }
172 putAttrib(&attrib_list, None); putAttrib(&attrib_list, None);
173 int num_formats = 0;
174 GLXFBConfig* configs = lwjgl_glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats);
175 if (num_formats > 0) {
176 return configs;
177 } else {
178 if (configs != NULL)
179 XFree(configs);
180 return NULL;
181 }
182 }
183
184 GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer) {
185 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
186 int bpp;
187 if (use_display_bpp) {
188 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
189 GLXFBConfig *configs = chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
190 if (configs != NULL)
191 return configs;
192 else
193 bpp = 16;
194 } else
195 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
196 return chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer);
197 }
198
199 static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, bool double_buffer) {
200 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
201 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
202 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
203 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
204 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
205 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
206 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
207 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
208 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
209
210 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
211 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
212
213 int bpe = convertToBPE(bpp);
214 int accum_bpe = convertToBPE(accum_bpp);
215 attrib_list_t attrib_list;
216 initAttribList(&attrib_list);
217 putAttrib(&attrib_list, GLX_RGBA);
218 putAttrib(&attrib_list, GLX_DOUBLEBUFFER);
219 putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth);
220 putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe);
221 putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe);
222 putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe);
223 putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha);
224 putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil);
225 putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers);
226 putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe);
227 putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe);
228 putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe);
229 putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha);
230 if (stereo)
231 putAttrib(&attrib_list, GLX_STEREO);
232 // Assume the caller has checked support for multisample
233 if (samples > 0) {
234 putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
235 putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0
236 if ( colorSamples > 0 )
237 putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
238 }
239 if (sRGB)
240 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
241 putAttrib(&attrib_list, None);
242 return lwjgl_glXChooseVisual(disp, screen, attrib_list.attribs);
243 }
244
245 XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer) {
246 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
247 int bpp;
248 if (use_display_bpp) {
249 bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen));
250 XVisualInfo *vis_info = chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
251 if (vis_info != NULL)
252 return vis_info;
253 else
254 bpp = 16;
255 } else
256 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
257 return chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer);
258 }
259
260 static void dumpVisualInfo(JNIEnv *env, Display *display, GLXExtensions *extension_flags, XVisualInfo *vis_info) {
261 int alpha, depth, stencil, r, g, b;
262 int sample_buffers = 0;
263 int samples = 0;
264 lwjgl_glXGetConfig(display, vis_info, GLX_RED_SIZE, &r);
265 lwjgl_glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g);
266 lwjgl_glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b);
267 lwjgl_glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha);
268 lwjgl_glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth);
269 lwjgl_glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil);
270 if (extension_flags->GLX_ARB_multisample) {
271 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers);
272 lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples);
273 }
274 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);
275 }
276
277 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) {
278 if ((*env)->GetDirectBufferCapacity(env, peer_info_handle) < sizeof(X11PeerInfo)) {
279 throwException(env, "Handle too small");
280 return false;
281 }
282 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
283 GLXExtensions extension_flags;
284 if (!extgl_InitGLX(display, screen, &extension_flags)) {
285 throwException(env, "Could not init GLX");
286 return false;
287 }
288 if (!extension_flags.GLX13 && force_glx13) {
289 throwException(env, "GLX13 is required, but is not available");
290 return false;
291 }
292 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
293 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
294 if (samples > 0 && !extension_flags.GLX_ARB_multisample) {
295 throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample");
296 return false;
297 }
298 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
299 if (colorSamples > 0 && !extension_flags.GLX_NV_multisample_coverage) {
300 throwException(env, "Color samples > 0 specified but there's no support for GLX_NV_multisample_coverage");
301 return false;
302 }
303 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
304 if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point
305 throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float");
306 return false;
307 }
308 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
309 if (floating_point_packed && !(extension_flags.GLX13 && extension_flags.GLX_EXT_fbconfig_packed_float)) { // We need GLX13 to support packed floating point
310 throwException(env, "Packed floating point specified but there's no support for GLX_EXT_fbconfig_packed_float");
311 return false;
312 }
313 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
314 if (sRGB && !extension_flags.GLX_ARB_framebuffer_sRGB) {
315 throwException(env, "sRGB specified but there's no support for GLX_ARB_framebuffer_sRGB");
316 return false;
317 }
318
319 peer_info->glx13 = extension_flags.GLX13;
320 if (peer_info->glx13) {
321 GLXFBConfig *configs = chooseVisualGLX13(env, display, screen, pixel_format, use_display_bpp, drawable_type, double_buffered);
322 if (configs == NULL) {
323 throwException(env, "Could not choose GLX13 config");
324 return false;
325 }
326 if (isDebugEnabled()) {
327 XVisualInfo *vis_info = lwjgl_glXGetVisualFromFBConfig(display, configs[0]);
328 if (vis_info != NULL) {
329 dumpVisualInfo(env, display, &extension_flags, vis_info);
330 XFree(vis_info);
331 }
332 }
333 int config_id;
334 int result = lwjgl_glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id);
335 XFree(configs);
336 if (result != Success) {
337 throwException(env, "Could not get GLX_FBCONFIG_ID from GLXFBConfig");
338 return false;
339 }
340 peer_info->config.glx13_config.config_id = config_id;
341 } else {
342 XVisualInfo *vis_info = chooseVisualGLX(env, display, screen, pixel_format, use_display_bpp, double_buffered);
343 if (vis_info == NULL) {
344 throwException(env, "Could not choose visual");
345 return false;
346 }
347 peer_info->config.glx_config.visualid = vis_info->visualid;
348 peer_info->config.glx_config.depth = vis_info->depth;
349 peer_info->screen = vis_info->screen;
350 if (isDebugEnabled())
351 dumpVisualInfo(env, display, &extension_flags, vis_info);
352 XFree(vis_info);
353 }
354 peer_info->display = display;
355 peer_info->screen = screen;
356 peer_info->drawable = None;
357 return true;
358 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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$
34 *
35 * Include file to access public window features
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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$
34 *
35 * Linux specific library for display handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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_EXT_swap_control */
77 glXSwapIntervalEXTPROC lwjgl_glXSwapIntervalEXT = NULL;
78
79 /* GLX_ARB_create_context */
80 glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB = NULL;
81
82 /* GLX_NV_present_video */
83 glXEnumerateVideoDevicesNVPROC lwjgl_glXEnumerateVideoDevicesNV = NULL;
84 glXBindVideoDeviceNVPROC lwjgl_glXBindVideoDeviceNV = NULL;
85
86 /* GLX_NV_video_capture */
87 glXBindVideoCaptureDeviceNVPROC lwjgl_glXBindVideoCaptureDeviceNV = NULL;
88 glXEnumerateVideoCaptureDevicesNVPROC lwjgl_glXEnumerateVideoCaptureDevicesNV = NULL;
89 glXLockVideoCaptureDeviceNVPROC lwjgl_glXLockVideoCaptureDeviceNV = NULL;
90 glXQueryVideoCaptureDeviceNVPROC lwjgl_glXQueryVideoCaptureDeviceNV = NULL;
91 glXReleaseVideoCaptureDeviceNVPROC lwjgl_glXReleaseVideoCaptureDeviceNV = NULL;
92
93 static void * lib_gl_handle = NULL;
94
95 typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName);
96
97 static glXGetProcAddressARBPROC lwjgl_glXGetProcAddressARB;
98
99 static GLXExtensions symbols_flags;
100
101 /** returns true if the extention is available */
102 static inline bool GLXQueryExtension(const GLubyte *exts, const char *name) {
103 return extgl_QueryExtension(exts, name);
104 }
105
106 static void extgl_InitGLX13() {
107 ExtFunction functions[] = {
108 {"glXGetFBConfigs", (void*)&lwjgl_glXGetFBConfigs},
109 {"glXChooseFBConfig", (void*)&lwjgl_glXChooseFBConfig},
110 {"glXGetFBConfigAttrib", (void*)&lwjgl_glXGetFBConfigAttrib},
111 {"glXGetVisualFromFBConfig", (void*)&lwjgl_glXGetVisualFromFBConfig},
112 {"glXCreateWindow", (void*)&lwjgl_glXCreateWindow},
113 {"glXDestroyWindow", (void*)&lwjgl_glXDestroyWindow},
114 {"glXCreatePixmap", (void*)&lwjgl_glXCreatePixmap},
115 {"glXDestroyPixmap", (void*)&lwjgl_glXDestroyPixmap},
116 {"glXCreatePbuffer", (void*)&lwjgl_glXCreatePbuffer},
117 {"glXDestroyPbuffer", (void*)&lwjgl_glXDestroyPbuffer},
118 {"glXQueryDrawable", (void*)&lwjgl_glXQueryDrawable},
119 {"glXCreateNewContext", (void*)&lwjgl_glXCreateNewContext},
120 {"glXMakeContextCurrent", (void*)&lwjgl_glXMakeContextCurrent},
121 {"glXGetCurrentReadDrawable", (void*)&lwjgl_glXGetCurrentReadDrawable},
122 {"glXGetCurrentDisplay", (void*)&lwjgl_glXGetCurrentDisplay},
123 {"glXQueryContext", (void*)&lwjgl_glXQueryContext},
124 {"glXSelectEvent", (void*)&lwjgl_glXSelectEvent},
125 {"glXGetSelectedEvent", (void*)&lwjgl_glXGetSelectedEvent}};
126 symbols_flags.GLX13 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
127 }
128
129 static void extgl_InitGLX12(void) {
130 ExtFunction functions[] = {
131 {"glXChooseVisual", (void*)&lwjgl_glXChooseVisual},
132 {"glXCopyContext", (void*)&lwjgl_glXCopyContext},
133 {"glXCreateContext", (void*)&lwjgl_glXCreateContext},
134 {"glXCreateGLXPixmap", (void*)&lwjgl_glXCreateGLXPixmap},
135 {"glXDestroyContext", (void*)&lwjgl_glXDestroyContext},
136 {"glXDestroyGLXPixmap", (void*)&lwjgl_glXDestroyGLXPixmap},
137 {"glXGetConfig", (void*)&lwjgl_glXGetConfig},
138 {"glXGetCurrentContext", (void*)&lwjgl_glXGetCurrentContext},
139 {"glXGetCurrentDrawable", (void*)&lwjgl_glXGetCurrentDrawable},
140 {"glXIsDirect", (void*)&lwjgl_glXIsDirect},
141 {"glXMakeCurrent", (void*)&lwjgl_glXMakeCurrent},
142 {"glXQueryExtension", (void*)&lwjgl_glXQueryExtension},
143 {"glXQueryVersion", (void*)&lwjgl_glXQueryVersion},
144 {"glXSwapBuffers", (void*)&lwjgl_glXSwapBuffers},
145 {"glXUseXFont", (void*)&lwjgl_glXUseXFont},
146 {"glXWaitGL", (void*)&lwjgl_glXWaitGL},
147 {"glXWaitX", (void*)&lwjgl_glXWaitX},
148 {"glXGetClientString", (void*)&lwjgl_glXGetClientString},
149 {"glXQueryServerString", (void*)&lwjgl_glXQueryServerString},
150 {"glXQueryExtensionsString", (void*)&lwjgl_glXQueryExtensionsString}};
151 symbols_flags.GLX12 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
152 }
153
154 static void extgl_InitGLXSGISwapControl() {
155 ExtFunction functions[] = {
156 {"glXSwapIntervalSGI", (void*)&lwjgl_glXSwapIntervalSGI}};
157 symbols_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
158 }
159
160 static void extgl_InitGLXEXTSwapControl() {
161 ExtFunction functions[] = {
162 {"glXSwapIntervalEXT", (void*)&lwjgl_glXSwapIntervalEXT}};
163 symbols_flags.GLX_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
164 }
165
166 static void extgl_InitGLXARBCreateContext() {
167 ExtFunction functions[] = {
168 {"glXCreateContextAttribsARB", (void*)&lwjgl_glXCreateContextAttribsARB}};
169 symbols_flags.GLX_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
170 }
171
172 static void extgl_InitGLXNVPresentVideo() {
173 ExtFunction functions[] = {
174 { "glXEnumerateVideoDevicesNV", (void*)&lwjgl_glXEnumerateVideoDevicesNV },
175 { "glXBindVideoDeviceNV", (void*)&lwjgl_glXBindVideoDeviceNV }
176 };
177
178 symbols_flags.GLX_NV_present_video = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
179 }
180
181 static void extgl_InitGLXNVVideoCapture() {
182 ExtFunction functions[] = {
183 { "glXBindVideoCaptureDeviceNV", (void*)&lwjgl_glXBindVideoCaptureDeviceNV },
184 { "glXEnumerateVideoCaptureDevicesNV", (void*)&lwjgl_glXEnumerateVideoCaptureDevicesNV },
185 { "glXLockVideoCaptureDeviceNV", (void*)&lwjgl_glXLockVideoCaptureDeviceNV },
186 { "glXQueryVideoCaptureDeviceNV", (void*)&lwjgl_glXQueryVideoCaptureDeviceNV },
187 { "glXReleaseVideoCaptureDeviceNV", (void*)&lwjgl_glXReleaseVideoCaptureDeviceNV }
188 };
189
190 symbols_flags.GLX_NV_video_capture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
191 }
192
193 static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExtensions *extension_flags) {
194 const GLubyte *exts = (const GLubyte *)lwjgl_glXQueryExtensionsString(disp, screen);
195
196 /* extension_flags.GLX_EXT_visual_info = GLXQueryExtension(exts, "GLX_EXT_visual_info");
197 extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(exts, "GLX_EXT_visual_rating");*/
198 extension_flags->GLX_SGI_swap_control = symbols_flags.GLX_SGI_swap_control && GLXQueryExtension(exts, "GLX_SGI_swap_control");
199 extension_flags->GLX_EXT_swap_control = symbols_flags.GLX_EXT_swap_control && GLXQueryExtension(exts, "GLX_EXT_swap_control");
200 extension_flags->GLX_ARB_multisample = GLXQueryExtension(exts, "GLX_ARB_multisample");
201 extension_flags->GLX_ARB_fbconfig_float = GLXQueryExtension(exts, "GLX_ARB_fbconfig_float");
202 extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(exts, "GLX_EXT_fbconfig_packed_float");
203 extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(exts, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(exts, "GLX_EXT_framebuffer_sRGB");
204 extension_flags->GLX_ARB_create_context = GLXQueryExtension(exts, "GLX_ARB_create_context");
205 extension_flags->GLX_NV_multisample_coverage = GLXQueryExtension(exts, "GLX_NV_multisample_coverage");
206 extension_flags->GLX_NV_present_video = GLXQueryExtension(exts, "GLX_NV_present_video");
207 extension_flags->GLX_NV_video_capture = GLXQueryExtension(exts, "GLX_NV_video_capture");
208 }
209
210 bool extgl_Open(JNIEnv *env) {
211 if (lib_gl_handle != NULL)
212 return true;
213 /*
214 * Actually we don't need the RTLD_GLOBAL flag, since the symbols
215 * we load should be private to us. However, according to the
216 * documentation at
217 *
218 * http://dri.sourceforge.net/doc/DRIuserguide.html
219 *
220 * DRI drivers need this flag to work properly
221 */
222 #ifdef __OpenBSD__
223 lib_gl_handle = dlopen("libGL.so", RTLD_LAZY | RTLD_GLOBAL);
224 #else
225 lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
226 #endif
227 if (lib_gl_handle == NULL) {
228 throwFormattedException(env, "Error loading libGL.so.1: %s", dlerror());
229 return false;
230 }
231 lwjgl_glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB");
232 if (lwjgl_glXGetProcAddressARB == NULL) {
233 extgl_Close();
234 throwException(env, "Could not get address of glXGetProcAddressARB");
235 return false;
236 }
237 /* Unlike Windows, GLX function addresses are context-independent
238 * so we only have to initialize the addresses once at load
239 */
240 extgl_InitGLX12();
241 extgl_InitGLX13();
242 extgl_InitGLXSGISwapControl();
243 extgl_InitGLXEXTSwapControl();
244 extgl_InitGLXARBCreateContext();
245 extgl_InitGLXNVPresentVideo();
246 extgl_InitGLXNVVideoCapture();
247 return true;
248 }
249
250 void *extgl_GetProcAddress(const char *name) {
251 void *t = (void*)lwjgl_glXGetProcAddressARB((const GLubyte*)name);
252 if (t == NULL) {
253 t = dlsym(lib_gl_handle, name);
254 if (t == NULL) {
255 printfDebug("Could not locate symbol %s\n", name);
256 }
257 }
258 return t;
259 }
260
261 void extgl_Close(void) {
262 dlclose(lib_gl_handle);
263 lib_gl_handle = NULL;
264 }
265
266 bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags) {
267 int major, minor;
268 /* Assume glx ver >= 1.2 */
269 // Check GLX 1.2 symbols available
270 if (!symbols_flags.GLX12)
271 return false;
272 if (lwjgl_glXQueryVersion(disp, &major, &minor) != True)
273 return false;
274 bool glx12 = major > 1 || (major == 1 && minor >= 2);
275 // Check GLX 1.2 version
276 if (!glx12)
277 return false;
278 extension_flags->GLX12 = glx12;
279 extension_flags->GLX13 = major > 1 || (major == 1 && minor >= 3);
280 extension_flags->GLX14 = major > 1 || (major == 1 && minor >= 4);
281 extgl_InitGLXSupportedExtensions(disp, screen, extension_flags);
282 return true;
283 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 /* GLX_NV_multisample_coverage */
274 #define GLX_COVERAGE_SAMPLES_NV 100001
275 #define GLX_COLOR_SAMPLES_NV 0x20B3
276
277 /* GLX_NV_present_video */
278 #define GLX_NUM_VIDEO_SLOTS_NV 0x20F0
279
280 /* GLX_NV_video_capture */
281 #define GLX_DEVICE_ID_NV 0x20CD
282 #define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
283 #define GLX_UNIQUE_ID_NV 0x20CE
284
285 typedef XID GLXContextID;
286 typedef XID GLXPixmap;
287 typedef XID GLXDrawable;
288 typedef XID GLXPbuffer;
289 typedef XID GLXWindow;
290 typedef XID GLXFBConfigID;
291
292 typedef struct __GLXcontextRec *GLXContext;
293
294 typedef struct __GLXFBConfigRec *GLXFBConfig;
295
296 typedef GLXFBConfig * (APIENTRY * glXGetFBConfigsPROC) (Display *dpy, int screen, int *nelements);
297 typedef GLXFBConfig * (APIENTRY * glXChooseFBConfigPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
298 typedef int (APIENTRY * glXGetFBConfigAttribPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
299 typedef XVisualInfo * (APIENTRY * glXGetVisualFromFBConfigPROC) (Display *dpy, GLXFBConfig config);
300 typedef GLXWindow (APIENTRY * glXCreateWindowPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
301 typedef void (APIENTRY * glXDestroyWindowPROC) (Display *dpy, GLXWindow win);
302 typedef GLXPixmap (APIENTRY * glXCreatePixmapPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
303 typedef void (APIENTRY * glXDestroyPixmapPROC) (Display *dpy, GLXPixmap pixmap);
304 typedef GLXPbuffer (APIENTRY * glXCreatePbufferPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
305 typedef void (APIENTRY * glXDestroyPbufferPROC) (Display *dpy, GLXPbuffer pbuf);
306 typedef void (APIENTRY * glXQueryDrawablePROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
307 typedef GLXContext (APIENTRY * glXCreateNewContextPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
308 typedef Bool (APIENTRY * glXMakeContextCurrentPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
309 typedef GLXDrawable (APIENTRY * glXGetCurrentReadDrawablePROC) (void);
310 typedef Display * (APIENTRY * glXGetCurrentDisplayPROC) (void);
311 typedef int (APIENTRY * glXQueryContextPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
312 typedef void (APIENTRY * glXSelectEventPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
313 typedef void (APIENTRY * glXGetSelectedEventPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
314
315 typedef GLXContextID (APIENTRY * glXGetContextIDEXTPROC) (const GLXContext ctx);
316 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawableEXTPROC) (void);
317 typedef GLXContext (APIENTRY * glXImportContextEXTPROC) (Display *dpy, GLXContextID contextID);
318 typedef void (APIENTRY * glXFreeContextEXTPROC) (Display *dpy, GLXContext ctx);
319 typedef int (APIENTRY * glXQueryContextInfoEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
320
321 typedef XVisualInfo* (APIENTRY * glXChooseVisualPROC) (Display *dpy, int screen, int *attribList);
322 typedef void (APIENTRY * glXCopyContextPROC) (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
323 typedef GLXContext (APIENTRY * glXCreateContextPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
324 typedef GLXPixmap (APIENTRY * glXCreateGLXPixmapPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
325 typedef void (APIENTRY * glXDestroyContextPROC) (Display *dpy, GLXContext ctx);
326 typedef void (APIENTRY * glXDestroyGLXPixmapPROC) (Display *dpy, GLXPixmap pix);
327 typedef int (APIENTRY * glXGetConfigPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
328 typedef GLXContext (APIENTRY * glXGetCurrentContextPROC) (void);
329 typedef GLXDrawable (APIENTRY * glXGetCurrentDrawablePROC) (void);
330 typedef Bool (APIENTRY * glXIsDirectPROC) (Display *dpy, GLXContext ctx);
331 typedef Bool (APIENTRY * glXMakeCurrentPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
332 typedef Bool (APIENTRY * glXQueryExtensionPROC) (Display *dpy, int *errorBase, int *eventBase);
333 typedef Bool (APIENTRY * glXQueryVersionPROC) (Display *dpy, int *major, int *minor);
334 typedef void (APIENTRY * glXSwapBuffersPROC) (Display *dpy, GLXDrawable drawable);
335 typedef void (APIENTRY * glXUseXFontPROC) (Font font, int first, int count, int listBase);
336 typedef void (APIENTRY * glXWaitGLPROC) (void);
337 typedef void (APIENTRY * glXWaitXPROC) (void);
338 typedef const char * (APIENTRY * glXGetClientStringPROC) (Display *dpy, int name );
339 typedef const char * (APIENTRY * glXQueryServerStringPROC) (Display *dpy, int screen, int name );
340 typedef const char * (APIENTRY * glXQueryExtensionsStringPROC) (Display *dpy, int screen );
341
342 /* GLX_SGI_swap_control */
343 typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval);
344
345 /* GLX_EXT_swap_control */
346 typedef void (APIENTRY * glXSwapIntervalEXTPROC)(Display *dpy, GLXDrawable drawable, int interval);
347
348 /* GLX_ARB_create_context */
349 typedef GLXContext (APIENTRY * glXCreateContextAttribsARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
350
351 /* GLX_NV_present_video */
352 typedef unsigned int * (APIENTRY * glXEnumerateVideoDevicesNVPROC) (Display *dpy, int screen, int *nelements);
353 typedef int (APIENTRY * glXBindVideoDeviceNVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
354
355 /* GLX_NV_video_capture */
356 typedef XID GLXVideoCaptureDeviceNV;
357 typedef int (APIENTRY * glXBindVideoCaptureDeviceNVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
358 typedef GLXVideoCaptureDeviceNV * (APIENTRY * glXEnumerateVideoCaptureDevicesNVPROC) (Display *dpy, int screen, int *nelements);
359 typedef void (APIENTRY * glXLockVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
360 typedef int (APIENTRY * glXQueryVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
361 typedef void (APIENTRY * glXReleaseVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
362
363 typedef struct {
364 bool GLX12;
365 bool GLX13;
366 bool GLX14;
367 /* bool GLX_EXT_visual_info;
368 bool GLX_EXT_visual_rating;*/
369 bool GLX_SGI_swap_control;
370 bool GLX_EXT_swap_control;
371 bool GLX_ARB_multisample;
372 bool GLX_ARB_fbconfig_float;
373 bool GLX_EXT_fbconfig_packed_float;
374 bool GLX_ARB_framebuffer_sRGB;
375 bool GLX_ARB_create_context;
376 bool GLX_NV_multisample_coverage;
377 bool GLX_NV_present_video;
378 bool GLX_NV_video_capture;
379 } GLXExtensions;
380
381 /* Add _ to global symbols to avoid symbol clash with the OpenGL library */
382 extern glXGetFBConfigsPROC lwjgl_glXGetFBConfigs;
383 extern glXChooseFBConfigPROC lwjgl_glXChooseFBConfig;
384 extern glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib;
385 extern glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig;
386 extern glXCreateWindowPROC lwjgl_glXCreateWindow;
387 extern glXDestroyWindowPROC lwjgl_glXDestroyWindow;
388 extern glXCreatePixmapPROC lwjgl_glXCreatePixmap;
389 extern glXDestroyPixmapPROC lwjgl_glXDestroyPixmap;
390 extern glXCreatePbufferPROC lwjgl_glXCreatePbuffer;
391 extern glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer;
392 extern glXQueryDrawablePROC lwjgl_glXQueryDrawable;
393 extern glXCreateNewContextPROC lwjgl_glXCreateNewContext;
394 extern glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent;
395 extern glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable;
396 extern glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay;
397 extern glXQueryContextPROC lwjgl_glXQueryContext;
398 extern glXSelectEventPROC lwjgl_glXSelectEvent;
399 extern glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent;
400
401 extern glXChooseVisualPROC lwjgl_glXChooseVisual;
402 extern glXCopyContextPROC lwjgl_glXCopyContext;
403 extern glXCreateContextPROC lwjgl_glXCreateContext;
404 extern glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap;
405 extern glXDestroyContextPROC lwjgl_glXDestroyContext;
406 extern glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap;
407 extern glXGetConfigPROC lwjgl_glXGetConfig;
408 extern glXGetCurrentContextPROC lwjgl_glXGetCurrentContext;
409 extern glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable;
410 extern glXIsDirectPROC lwjgl_glXIsDirect;
411 extern glXMakeCurrentPROC lwjgl_glXMakeCurrent;
412 extern glXQueryExtensionPROC lwjgl_glXQueryExtension;
413 extern glXQueryVersionPROC lwjgl_glXQueryVersion;
414 extern glXSwapBuffersPROC lwjgl_glXSwapBuffers;
415 extern glXUseXFontPROC lwjgl_glXUseXFont;
416 extern glXWaitGLPROC lwjgl_glXWaitGL;
417 extern glXWaitXPROC lwjgl_glXWaitX;
418 extern glXGetClientStringPROC lwjgl_glXGetClientString;
419 extern glXQueryServerStringPROC lwjgl_glXQueryServerString;
420 extern glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString;
421
422 extern glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI;
423 extern glXSwapIntervalEXTPROC lwjgl_glXSwapIntervalEXT;
424
425 extern glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB;
426
427 /* GLX_NV_present_video */
428 extern glXEnumerateVideoDevicesNVPROC lwjgl_glXEnumerateVideoDevicesNV;
429 extern glXBindVideoDeviceNVPROC lwjgl_glXBindVideoDeviceNV;
430
431 /* GLX_NV_video_capture */
432 extern glXBindVideoCaptureDeviceNVPROC lwjgl_glXBindVideoCaptureDeviceNV;
433 extern glXEnumerateVideoCaptureDevicesNVPROC lwjgl_glXEnumerateVideoCaptureDevicesNV;
434 extern glXLockVideoCaptureDeviceNVPROC lwjgl_glXLockVideoCaptureDeviceNV;
435 extern glXQueryVideoCaptureDeviceNVPROC lwjgl_glXQueryVideoCaptureDeviceNV;
436 extern glXReleaseVideoCaptureDeviceNVPROC lwjgl_glXReleaseVideoCaptureDeviceNV;
437
438 extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags);
439
440 #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$
34 *
35 * Linux specific display functions.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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
75 static Visual *current_visual;
76
77 static bool checkXError(JNIEnv *env, Display *disp) {
78 XSync(disp, False);
79 return (*env)->ExceptionCheck(env) == JNI_FALSE;
80 }
81
82 static int global_error_handler(Display *disp, XErrorEvent *error) {
83 JNIEnv *env = getThreadEnv();
84 if (env != NULL) {
85 jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay");
86 if (org_lwjgl_LinuxDisplay_class == NULL) {
87 // Don't propagate error
88 (*env)->ExceptionClear(env);
89 return 0;
90 }
91 jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I");
92 if (handler_method == NULL)
93 return 0;
94 return (*env)->CallStaticIntMethod(env, org_lwjgl_LinuxDisplay_class, handler_method, (jlong)(intptr_t)disp, (jlong)(intptr_t)error,
95 (jlong)(intptr_t)error->display, (jlong)error->serial, (jlong)error->error_code, (jlong)error->request_code, (jlong)error->minor_code);
96 } else
97 return 0;
98 }
99
100 static jlong openDisplay(JNIEnv *env) {
101 Display *display_connection = XOpenDisplay(NULL);
102 if (display_connection == NULL) {
103 throwException(env, "Could not open X display connection");
104 return (intptr_t)NULL;
105 }
106 return (intptr_t)display_connection;
107 }
108
109 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
110 (JNIEnv *env, jobject ignored) {
111 return org_lwjgl_LinuxSysImplementation_JNI_VERSION;
112 }
113
114 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) {
115 Display *disp = (Display *)(intptr_t)display_ptr;
116 char err_msg_buffer[ERR_MSG_SIZE];
117 XGetErrorText(disp, error_code, err_msg_buffer, ERR_MSG_SIZE);
118 err_msg_buffer[ERR_MSG_SIZE - 1] = '\0';
119 return NewStringNativeWithLength(env, err_msg_buffer, strlen(err_msg_buffer));
120 }
121
122 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr, jlong display_ptr, jlong event_ptr) {
123 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
124 Display *disp = (Display *)(intptr_t)display_ptr;
125 XErrorEvent *event = (XErrorEvent *)(intptr_t)event_ptr;
126 return (jint)handler(disp, event);
127 }
128
129 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler(JNIEnv *env, jclass unused) {
130 return (intptr_t)XSetErrorHandler(global_error_handler);
131 }
132
133 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr) {
134 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
135 return (intptr_t)XSetErrorHandler(handler);
136 }
137
138 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) {
139 Display *disp = (Display *)(intptr_t)display_ptr;
140 XSync(disp, throw_away_events ? True : False);
141 }
142
143 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_sync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) {
144 Display *disp = (Display *)(intptr_t)display_ptr;
145 XSync(disp, throw_away_events ? True : False);
146 }
147
148 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) {
149 Display *disp = (Display *)(intptr_t)display_ptr;
150 return XDefaultScreen(disp);
151 }
152
153 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom(JNIEnv *env, jclass unused, jlong display_ptr, jstring atom_name_obj, jboolean only_if_exists) {
154 Display *disp = (Display *)(intptr_t)display_ptr;
155 char *atom_name = GetStringNativeChars(env, atom_name_obj);
156 if (atom_name == NULL)
157 return 0;
158 Atom atom = XInternAtom(disp, atom_name, only_if_exists ? True : False);
159 free(atom_name);
160 return atom;
161 }
162
163 static void setDecorations(Display *disp, Window window, int dec) {
164 Atom motif_hints_atom = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
165 MotifWmHints motif_hints;
166 motif_hints.flags = MWM_HINTS_DECORATIONS;
167 motif_hints.decorations = dec;
168 XChangeProperty(disp, window, motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long));
169 }
170
171 static bool isLegacyFullscreen(jint window_mode) {
172 return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY;
173 }
174
175 static void setWindowTitle(Display *disp, Window window, jlong title, jint len) {
176 Atom UTF8_STRING = XInternAtom(disp, "UTF8_STRING", True);
177 Atom _NET_WM_NAME = XInternAtom(disp, "_NET_WM_NAME", True);
178 Atom _NET_WM_ICON_NAME = XInternAtom(disp, "_NET_WM_ICON_NAME", True);
179
180 // ASCII fallback if XChangeProperty fails.
181 XmbSetWMProperties(disp, window, (const char *)(intptr_t)title, (const char *)(intptr_t)title, NULL, 0, NULL, NULL, NULL);
182
183 // Set the UTF-8 encoded title
184 if ( _NET_WM_NAME )
185 XChangeProperty(
186 disp, window, _NET_WM_NAME, UTF8_STRING,
187 8, PropModeReplace, (const unsigned char *)(intptr_t)title, len
188 );
189
190 if ( _NET_WM_ICON_NAME )
191 XChangeProperty(
192 disp, window, _NET_WM_ICON_NAME, UTF8_STRING,
193 8, PropModeReplace, (const unsigned char *)(intptr_t)title, len
194 );
195 }
196
197 static void setClassHint(Display *disp, Window window, jlong wm_name, jlong wm_class) {
198 XClassHint* hint = XAllocClassHint();
199
200 hint->res_name = (char *)(intptr_t)wm_name;
201 hint->res_class = (char *)(intptr_t)wm_class;
202
203 XSetClassHint(disp, window, hint);
204
205 XFree(hint);
206 }
207
208 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
209 return openDisplay(env);
210 }
211
212 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz, jlong display) {
213 Display *disp = (Display *)(intptr_t)display;
214 XCloseDisplay(disp);
215 }
216
217 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jlong window, jobject peer_info_handle) {
218 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
219 if (peer_info->glx13)
220 peer_info->drawable = glx_window;
221 else
222 peer_info->drawable = window;
223 }
224
225 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject pixel_format) {
226 Display *disp = (Display *)(intptr_t)display;
227 initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, true, GLX_WINDOW_BIT, true, false);
228 }
229
230 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jlong title, jint len) {
231 Display *disp = (Display *)(intptr_t)display;
232 Window window = (Window)window_ptr;
233 setWindowTitle(disp, window, title, len);
234 }
235
236 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetClassHint(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jlong wm_name, jlong wm_class) {
237 Display *disp = (Display *)(intptr_t)display;
238 Window window = (Window)window_ptr;
239 setClassHint(disp, window, wm_name, wm_class);
240 }
241
242 static void destroyWindow(JNIEnv *env, Display *disp, Window window) {
243 if (glx_window != None) {
244 lwjgl_glXDestroyWindow(disp, glx_window);
245 glx_window = None;
246 }
247 XDestroyWindow(disp, window);
248 XFreeColormap(disp, cmap);
249 }
250
251 static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp, int screen) {
252 unsigned long nitems;
253 Atom actual_type;
254 int actual_format;
255 unsigned long bytes_after;
256 Atom *supported_list;
257 Atom netwm_supported_atom = XInternAtom(disp, "_NET_SUPPORTED", False);
258 int result = XGetWindowProperty(disp, RootWindow(disp, screen), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
259 if (result != Success) {
260 throwException(env, "Unable to query _NET_SUPPORTED window property");
261 return false;
262 }
263 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
264 bool supported = false;
265 unsigned long i;
266 for (i = 0; i < nitems; i++) {
267 if (fullscreen_atom == supported_list[i]) {
268 supported = true;
269 break;
270 }
271 }
272 XFree(supported_list);
273 return supported;
274 }
275
276 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display, jint screen) {
277 Display *disp = (Display *)(intptr_t)display;
278 return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE;
279 }
280
281 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) {
282 Display *disp = (Display *)(intptr_t)display;
283 Window window = (Window)window_ptr;
284 XMoveWindow(disp, window, x, y);
285 XResizeWindow(disp, window, width, height);
286 }
287
288 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize(JNIEnv *env, jclass clazz, jlong display, jboolean synchronize) {
289 Display *disp = (Display *)(intptr_t)display;
290 XSynchronize(disp, synchronize ? True : False);
291 }
292
293 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) {
294 Display *disp = (Display *)(intptr_t)display;
295 return RootWindow(disp, screen);
296 }
297
298 static Window getCurrentWindow(JNIEnv *env, jlong display_ptr, jlong window_ptr) {
299 Display *disp = (Display *)(intptr_t)display_ptr;
300
301 Window parent = (Window)window_ptr;
302 Window win, root;
303
304 Window *children;
305 unsigned int nchildren;
306
307 do {
308 win = parent;
309
310 if (XQueryTree(disp, win, &root, &parent, &children, &nchildren) == 0) {
311 throwException(env, "XQueryTree failed");
312 return 0;
313 }
314
315 if (children != NULL) XFree(children);
316 } while (parent != root);
317
318 return win;
319 }
320
321 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetX(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
322 Display *disp = (Display *)(intptr_t)display_ptr;
323 Window win = getCurrentWindow(env, display_ptr, window_ptr);
324
325 XWindowAttributes win_attribs;
326 XGetWindowAttributes(disp, win, &win_attribs);
327
328 return win_attribs.x;
329 }
330
331 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetY(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
332 Display *disp = (Display *)(intptr_t)display_ptr;
333 Window win = getCurrentWindow(env, display_ptr, window_ptr);
334
335 XWindowAttributes win_attribs;
336 XGetWindowAttributes(disp, win, &win_attribs);
337
338 return win_attribs.y;
339 }
340
341 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetWidth(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
342 Display *disp = (Display *)(intptr_t)display_ptr;
343 Window win = (Window)window_ptr;
344 XWindowAttributes win_attribs;
345
346 XGetWindowAttributes(disp, win, &win_attribs);
347
348 return win_attribs.width;
349 }
350
351 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetHeight(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
352 Display *disp = (Display *)(intptr_t)display_ptr;
353 Window win = (Window)window_ptr;
354 XWindowAttributes win_attribs;
355
356 XGetWindowAttributes(disp, win, &win_attribs);
357
358 return win_attribs.height;
359 }
360
361 static void updateWindowHints(JNIEnv *env, Display *disp, Window window) {
362 XWMHints* win_hints = XAllocWMHints();
363 if (win_hints == NULL) {
364 throwException(env, "XAllocWMHints failed");
365 return;
366 }
367
368 win_hints->flags = InputHint;
369 win_hints->input = True;
370
371 XSetWMHints(disp, window, win_hints);
372 XFree(win_hints);
373 XFlush(disp);
374 }
375
376 static void updateWindowBounds(Display *disp, Window win, int x, int y, int width, int height, jboolean position, jboolean resizable) {
377 XSizeHints *window_hints = XAllocSizeHints();
378
379 if (position) {
380 window_hints->flags |= PPosition;
381 window_hints->x = x;
382 window_hints->y = y;
383 }
384
385 if (!resizable) {
386 window_hints->flags |= PMinSize | PMaxSize;
387 window_hints->min_width = width;
388 window_hints->max_width = width;
389 window_hints->min_height = height;
390 window_hints->max_height = height;
391 }
392
393 XSetWMNormalHints(disp, win, window_hints);
394 XFree(window_hints);
395 }
396
397 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, jboolean resizable) {
398 Window parent = (Window)parent_handle;
399 Window win;
400 XSetWindowAttributes attribs;
401 int attribmask;
402
403 XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
404 if (vis_info == NULL)
405 return false;
406 cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone);
407 attribs.colormap = cmap;
408 attribs.border_pixel = 0;
409 attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask| EnterWindowMask | LeaveWindowMask;
410 attribmask = CWColormap | CWEventMask | CWBorderPixel;
411 if (isLegacyFullscreen(window_mode)) {
412 attribmask |= CWOverrideRedirect;
413 attribs.override_redirect = True;
414 }
415 win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
416
417 current_depth = vis_info->depth;
418 current_visual = vis_info->visual;
419
420 XFree(vis_info);
421 if (!checkXError(env, disp)) {
422 XFreeColormap(disp, cmap);
423 return false;
424 }
425 // printfDebugJava(env, "Created window");
426 if (undecorated) {
427 // Use Motif decoration hint property and hope the window manager respects them
428 setDecorations(disp, win, 0);
429 }
430
431 if (RootWindow(disp, screen) == parent_handle) { // only set hints when Display.setParent isn't used
432 updateWindowBounds(disp, win, x, y, width, height, JNI_TRUE, resizable);
433 updateWindowHints(env, disp, win);
434 }
435
436 #define NUM_ATOMS 1
437 Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/};
438 XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS);
439 if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
440 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
441 XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
442 XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
443 }
444 if (!checkXError(env, disp)) {
445 destroyWindow(env, disp, win);
446 return 0;
447 }
448 return win;
449 }
450
451 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) {
452 Display *disp = (Display *)(intptr_t)display;
453 Window window = (Window)window_ptr;
454 Window parent = (Window)parent_ptr;
455 XReparentWindow(disp, window, parent, x, y);
456 }
457
458 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
459 Display *disp = (Display *)(intptr_t)display;
460 Window window = (Window)window_ptr;
461 XMapRaised(disp, window);
462 }
463
464 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
465 Display *disp = (Display *)(intptr_t)display;
466 Window window = (Window)window_ptr;
467 Window root, parent;
468 Window *children;
469 unsigned int nchildren;
470 if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) {
471 throwException(env, "XQueryTree failed");
472 return None;
473 }
474 if (children != NULL)
475 XFree(children);
476 return parent;
477 }
478
479 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getChildCount(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
480 Display *disp = (Display *)(intptr_t)display;
481 Window window = (Window)window_ptr;
482 Window root, parent;
483 Window *children;
484 unsigned int nchildren;
485 if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) {
486 throwException(env, "XQueryTree failed");
487 return None;
488 }
489 if (children != NULL)
490 XFree(children);
491
492 return nchildren;
493 }
494
495 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty(JNIEnv *env, jclass unusued, jlong display, jlong window_ptr, jlong property_ptr) {
496 Display *disp = (Display *)(intptr_t)display;
497 Window window = (Window)window_ptr;
498 Atom property = (Atom)property_ptr;
499 int num_props;
500 Atom *properties = XListProperties(disp, window, &num_props);
501 if (properties == NULL)
502 return JNI_FALSE;
503 jboolean result = JNI_FALSE;
504 for (int i = 0; i < num_props; i++) {
505 if (properties[i] == property) {
506 result = JNI_TRUE;
507 break;
508 }
509 }
510 XFree(properties);
511 return result;
512 }
513
514 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
515 Display *disp = (Display *)(intptr_t)display_ptr;
516 int revert_mode;
517 Window win;
518 XGetInputFocus(disp, &win, &revert_mode);
519 return win;
520 }
521
522 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) {
523 Display *disp = (Display *)(intptr_t)display;
524 Window window = (Window)window_ptr;
525 XSetInputFocus(disp, window, RevertToParent, time);
526 }
527
528 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, jboolean resizable) {
529 Display *disp = (Display *)(intptr_t)display;
530 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
531 GLXFBConfig *fb_config = NULL;
532 if (peer_info->glx13) {
533 fb_config = getFBConfigFromPeerInfo(env, peer_info);
534 if (fb_config == NULL)
535 return 0;
536 }
537 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
538 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
539 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
540 int width = (*env)->GetIntField(env, mode, fid_width);
541 int height = (*env)->GetIntField(env, mode, fid_height);
542 Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle, resizable);
543 if ((*env)->ExceptionOccurred(env)) {
544 return 0;
545 }
546 if (peer_info->glx13) {
547 glx_window = lwjgl_glXCreateWindow(disp, *fb_config, win, NULL);
548 XFree(fb_config);
549 }
550 if (!checkXError(env, disp)) {
551 lwjgl_glXDestroyWindow(disp, glx_window);
552 destroyWindow(env, disp, win);
553 }
554 return win;
555 }
556
557 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowSize(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint width, jint height, jboolean resizable) {
558 Display *disp = (Display *)(intptr_t)display;
559 Window win = (Window)window_ptr;
560 updateWindowBounds(disp, win, 0, 0, width, height, JNI_FALSE, resizable);
561 }
562
563 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
564 Display *disp = (Display *)(intptr_t)display;
565 Window window = (Window)window_ptr;
566 destroyWindow(env, disp, window);
567 }
568
569 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
570 JAWT jawt;
571 jawt.version = JAWT_VERSION_1_4;
572 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
573 throwException(env, "GetAWT failed");
574 return;
575 }
576 jawt.Lock(env);
577 }
578
579 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT(JNIEnv *env, jclass clazz) {
580 JAWT jawt;
581 jawt.version = JAWT_VERSION_1_4;
582 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
583 throwException(env, "GetAWT failed");
584 return;
585 }
586 jawt.Unlock(env);
587 }
588
589 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
590 (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icons_buffer, jint icons_buffer_size)
591 {
592 Display *disp = (Display *)(intptr_t)display;
593 Window window = (Window)window_ptr;
594 const unsigned char *icons_char_buffer = (const unsigned char *)(*env)->GetDirectBufferAddress(env, icons_buffer);
595
596 int length = icons_buffer_size/4;
597 unsigned long icons_long_buffer[length];
598 int i = 0;
599
600 // copy byte array to long array
601 for (i = 0; i < icons_buffer_size; i += 4) {
602 unsigned long argb = (icons_char_buffer[i] << 24) |
603 (icons_char_buffer[i+1] << 16) |
604 (icons_char_buffer[i+2] << 8) |
605 (icons_char_buffer[i+3]);
606 icons_long_buffer[i/4] = argb;
607 }
608
609 XChangeProperty(disp, window,
610 XInternAtom(disp, "_NET_WM_ICON", False),
611 XInternAtom(disp, "CARDINAL", False),
612 32, PropModeReplace, (const unsigned char*) icons_long_buffer, length);
613 }
614
615 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
616 Display *disp = (Display *)(intptr_t)display_ptr;
617 return XUngrabKeyboard(disp, CurrentTime);
618 }
619
620 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
621 Display *disp = (Display *)(intptr_t)display_ptr;
622 Window win = (Window)window_ptr;
623 return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
624 }
625
626 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
627 Display *disp = (Display *)(intptr_t)display_ptr;
628 Window win = (Window)window_ptr;
629 Cursor cursor = (Cursor)cursor_ptr;
630 int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
631 return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime);
632 }
633
634 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
635 Display *disp = (Display *)(intptr_t)display_ptr;
636 Window win = (Window)window_ptr;
637 XWindowAttributes win_attribs;
638
639 XGetWindowAttributes(disp, win, &win_attribs);
640 XF86VidModeSetViewPort(disp, screen, win_attribs.x, win_attribs.y);
641 }
642
643 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer(JNIEnv *env, jclass unused, jlong display_ptr) {
644 Display *disp = (Display *)(intptr_t)display_ptr;
645 return XUngrabPointer(disp, CurrentTime);
646 }
647
648 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
649 Display *disp = (Display *)(intptr_t)display_ptr;
650 Window win = (Window)window_ptr;
651 Cursor cursor = (Cursor)cursor_ptr;
652 XDefineCursor(disp, win, cursor);
653 }
654
655 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
656 Display *disp = (Display *)(intptr_t)display_ptr;
657 Window win = (Window)window_ptr;
658 unsigned int best_width, best_height;
659 if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
660 throwException(env, "Could not query best cursor size");
661 return false;
662 }
663 Pixmap mask = XCreatePixmap(disp, win, best_width, best_height, 1);
664 XGCValues gc_values;
665 gc_values.foreground = 0;
666 GC gc = XCreateGC(disp, mask, GCForeground, &gc_values);
667 XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
668 XFreeGC(disp, gc);
669 XColor dummy_color;
670 Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
671 XFreePixmap(disp, mask);
672 return cursor;
673 }
674
675 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
676 Display *disp = (Display *)(intptr_t)display_ptr;
677 Window win = (Window)window_ptr;
678 XIconifyWindow(disp, win, screen);
679 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
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 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo
5 #define _Included_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo
11 * Method: getScreenFromSurfaceInfo
12 * Signature: (Ljava/nio/ByteBuffer;)I
13 */
14 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_getScreenFromSurfaceInfo
15 (JNIEnv *, jclass, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo
19 * Method: nInitHandle
20 * Signature: (ILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_nInitHandle
23 (JNIEnv *, jclass, jint, jobject, jobject);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
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 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxCanvasImplementation */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxCanvasImplementation
5 #define _Included_org_lwjgl_opengl_LinuxCanvasImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxCanvasImplementation
11 * Method: nFindVisualIDFromFormat
12 * Signature: (JILorg/lwjgl/opengl/PixelFormat;)I
13 */
14 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat
15 (JNIEnv *, jclass, jlong, jint, jobject);
16
17 #ifdef __cplusplus
18 }
19 #endif
20 #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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
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 jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getGLXContext(JNIEnv *env, jclass clazz, jobject context_handle) {
109 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
110 return (intptr_t)context_info->context;
111 }
112
113 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getDisplay(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
114 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
115 return (intptr_t)peer_info->display;
116 }
117
118 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval
119 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle, jint value)
120 {
121 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
122 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
123
124 if (context_info->extension_flags.GLX_EXT_swap_control) {
125 lwjgl_glXSwapIntervalEXT(peer_info->display, peer_info->drawable, value);
126 }
127 else if (context_info->extension_flags.GLX_SGI_swap_control) {
128 lwjgl_glXSwapIntervalSGI(value);
129 }
130 }
131
132 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate
133 (JNIEnv *env , jclass clazz, jobject peer_handle, jobject attribs, jobject shared_context_handle) {
134 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(X11Context));
135 if (context_handle == NULL) {
136 throwException(env, "Could not allocate handle buffer");
137 return NULL;
138 }
139 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
140 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
141 GLXExtensions extension_flags;
142 if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) {
143 throwException(env, "Could not initialize GLX");
144 return NULL;
145 }
146 GLXContext shared_context = NULL;
147 if (shared_context_handle != NULL) {
148 X11Context *shared_context_info = (*env)->GetDirectBufferAddress(env, shared_context_handle);
149 shared_context = shared_context_info->context;
150 }
151 if (peer_info->glx13) {
152 createContextGLX13(env, peer_info, context_info, extension_flags.GLX_ARB_create_context ? attribs : NULL, shared_context);
153 } else {
154 createContextGLX(env, peer_info, context_info, shared_context);
155 }
156 context_info->extension_flags = extension_flags;
157 return context_handle;
158 }
159
160 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy
161 (JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) {
162 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
163 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
164 lwjgl_glXDestroyContext(peer_info->display, context_info->context);
165 }
166
167 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext
168 (JNIEnv *env , jclass clazz, jobject peer_info_handle) {
169 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
170 Bool result;
171 if (peer_info->glx13) {
172 result = lwjgl_glXMakeContextCurrent(peer_info->display, None, None, NULL);
173 } else {
174 result = lwjgl_glXMakeCurrent(peer_info->display, None, NULL);
175 }
176 if (!result)
177 throwException(env, "Could not release current context");
178 }
179
180 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCurrent
181 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
182 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
183 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
184 Bool result;
185 if (peer_info->glx13) {
186 result = lwjgl_glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context);
187 } else {
188 result = lwjgl_glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context);
189 }
190 if (!result)
191 throwException(env, "Could not make context current");
192 }
193
194 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent
195 (JNIEnv *env, jclass clazz, jobject context_handle) {
196 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
197 return context_info->context == lwjgl_glXGetCurrentContext();
198 }
199
200 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers
201 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
202 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
203 lwjgl_glXSwapBuffers(peer_info->display, peer_info->drawable);
204 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxContextImplementation */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxContextImplementation
5 #define _Included_org_lwjgl_opengl_LinuxContextImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxContextImplementation
11 * Method: nCreate
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate
15 (JNIEnv *, jclass, jobject, jobject, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_LinuxContextImplementation
19 * Method: getGLXContext
20 * Signature: (Ljava/nio/ByteBuffer;)J
21 */
22 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getGLXContext
23 (JNIEnv *, jobject, jobject);
24
25 /*
26 * Class: org_lwjgl_opengl_LinuxContextImplementation
27 * Method: getDisplay
28 * Signature: (Ljava/nio/ByteBuffer;)J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getDisplay
31 (JNIEnv *, jobject, jobject);
32
33 /*
34 * Class: org_lwjgl_opengl_LinuxContextImplementation
35 * Method: nSwapBuffers
36 * Signature: (Ljava/nio/ByteBuffer;)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers
39 (JNIEnv *, jclass, jobject);
40
41 /*
42 * Class: org_lwjgl_opengl_LinuxContextImplementation
43 * Method: nReleaseCurrentContext
44 * Signature: (Ljava/nio/ByteBuffer;)V
45 */
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext
47 (JNIEnv *, jclass, jobject);
48
49 /*
50 * Class: org_lwjgl_opengl_LinuxContextImplementation
51 * Method: nMakeCurrent
52 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
53 */
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCurrent
55 (JNIEnv *, jclass, jobject, jobject);
56
57 /*
58 * Class: org_lwjgl_opengl_LinuxContextImplementation
59 * Method: nIsCurrent
60 * Signature: (Ljava/nio/ByteBuffer;)Z
61 */
62 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent
63 (JNIEnv *, jclass, jobject);
64
65 /*
66 * Class: org_lwjgl_opengl_LinuxContextImplementation
67 * Method: nSetSwapInterval
68 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;I)V
69 */
70 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval
71 (JNIEnv *, jclass, jobject, jobject, jint);
72
73 /*
74 * Class: org_lwjgl_opengl_LinuxContextImplementation
75 * Method: nDestroy
76 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
77 */
78 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy
79 (JNIEnv *, jclass, jobject, jobject);
80
81 #ifdef __cplusplus
82 }
83 #endif
84 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxDisplayPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxDisplayPeerInfo
5 #define _Included_org_lwjgl_opengl_LinuxDisplayPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxDisplayPeerInfo
11 * Method: initDefaultPeerInfo
12 * Signature: (JILjava/nio/ByteBuffer;Lorg/lwjgl/opengl/PixelFormat;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo
15 (JNIEnv *, jclass, jlong, jint, jobject, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_LinuxDisplayPeerInfo
19 * Method: initDrawable
20 * Signature: (JLjava/nio/ByteBuffer;)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable
23 (JNIEnv *, jclass, jlong, jobject);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxPbufferPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxPbufferPeerInfo
5 #define _Included_org_lwjgl_opengl_LinuxPbufferPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxPbufferPeerInfo
11 * Method: nInitHandle
12 * Signature: (JILjava/nio/ByteBuffer;IILorg/lwjgl/opengl/PixelFormat;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle
15 (JNIEnv *, jclass, jlong, jint, jobject, jint, jint, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_LinuxPbufferPeerInfo
19 * Method: nDestroy
20 * Signature: (Ljava/nio/ByteBuffer;)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nDestroy
23 (JNIEnv *, jclass, jobject);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #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$
34 *
35 * Linux Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 "context.h"
42
43 bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen) {
44 /*
45 if ((*env)->GetDirectBufferCapacity(env, peer_info_handle) < sizeof(X11PeerInfo)) {
46 throwException(env, "Handle too small");
47 return false;
48 }
49 */
50 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
51
52 peer_info->display = display;
53 peer_info->screen = screen;
54 return true;
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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/Xlib.h>
46 #include "extgl.h"
47
48 typedef struct {
49 Display *display;
50 int screen;
51 jlong drawable;
52 } X11PeerInfo;
53
54 extern bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen);
55
56 #endif /* _LWJGL_CONTEXT_H_INCLUDED_ */
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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, ramp + ramp_size, ramp + ramp_size*2)) {
299 throwException(env, "Could not get the current gamma ramp");
300 return NULL;
301 }
302 return ramp_buffer;
303 }
304
305 static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer) {
306 if (ramp_buffer == NULL)
307 return;
308 unsigned short *ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer);
309 jlong capacity = (*env)->GetDirectBufferCapacity(env, ramp_buffer);
310 int size = capacity/(sizeof(unsigned short)*3);
311 if (size == 0)
312 return;
313 if (XF86VidModeSetGammaRamp(disp, screen, size, ramp_ptr, ramp_ptr + size, ramp_ptr + size*2) == False) {
314 throwException(env, "Could not set gamma ramp.");
315 }
316 }
317
318 static bool switchDisplayMode(JNIEnv * env, Display *disp, int screen, jint extension, jobject mode) {
319 if (mode == NULL) {
320 throwException(env, "mode must be non-null");
321 return false;
322 }
323 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
324 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
325 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
326 jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I");
327 int width = (*env)->GetIntField(env, mode, fid_width);
328 int height = (*env)->GetIntField(env, mode, fid_height);
329 int freq = (*env)->GetIntField(env, mode, fid_freq);
330 if (!setMode(env, disp, screen, extension, width, height, freq)) {
331 throwException(env, "Could not switch mode.");
332 return false;
333 }
334 return true;
335 }
336
337 static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) {
338 int num_modes, i;
339 mode_info *avail_modes;
340 int bpp = XDefaultDepth(disp, screen);
341 avail_modes = getDisplayModes(disp, screen, extension, &num_modes);
342 if (avail_modes == NULL) {
343 printfDebugJava(env, "Could not get display modes");
344 return NULL;
345 }
346 // Allocate an array of DisplayModes big enough
347 jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
348 jobjectArray ret = (*env)->NewObjectArray(env, num_modes, displayModeClass, NULL);
349 jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
350
351 for (i = 0; i < num_modes; i++) {
352 jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, avail_modes[i].width, avail_modes[i].height, bpp, avail_modes[i].freq);
353 (*env)->SetObjectArrayElement(env, ret, i, displayMode);
354 }
355 free(avail_modes);
356 return ret;
357 }
358
359 static jobject getCurrentXRandrMode(JNIEnv * env, Display *disp, int screen) {
360 Drawable root_window = RootWindow(disp, screen);
361 XRRScreenConfiguration *config = XRRGetScreenInfo(disp, root_window);
362 if (config == NULL) {
363 throwException(env, "Could not get current screen configuration.");
364 return NULL;
365 }
366 short rate = XRRConfigCurrentRate(config);
367 Rotation current_rotation;
368 SizeID size_index = XRRConfigCurrentConfiguration(config, &current_rotation);
369 int n_sizes;
370 XRRScreenSize *sizes = XRRConfigSizes(config, &n_sizes);
371 if (size_index >= n_sizes) {
372 throwFormattedException(env, "Xrandr current index (%d) is larger than or equals to the number of sizes (%d).", size_index, n_sizes);
373 XRRFreeScreenConfigInfo(config);
374 return NULL;
375 }
376 XRRScreenSize current_size = sizes[size_index];
377 XRRFreeScreenConfigInfo(config);
378 int bpp = XDefaultDepth(disp, screen);
379 jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");
380 jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
381 jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, current_size.width, current_size.height, bpp, rate);
382 return displayMode;
383 }
384
385 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display, jint screen) {
386 Display *disp = (Display *)(intptr_t)display;
387 return getCurrentXRandrMode(env, disp, screen);
388 }
389
390 JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension) {
391 Display *disp = (Display *)(intptr_t)display;
392 return getAvailableDisplayModes(env, disp, screen, extension);
393 }
394
395 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) {
396 Display *disp = (Display *)(intptr_t)display;
397 switchDisplayMode(env, disp, screen, extension, mode);
398 }
399
400 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz, jlong display_ptr, jint screen) {
401 Display *disp = (Display *)(intptr_t)display_ptr;
402 return (jint)getGammaRampLengthOfDisplay(env, disp, screen);
403 }
404
405 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) {
406 Display *disp = (Display *)(intptr_t)display;
407 setGamma(env, disp, screen, gamma_buffer);
408 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 <stdio.h>
32 #include <string.h>
33 #include <dlfcn.h>
34 #include "extgl.h"
35
36 static void * lib_gl_handle = NULL;
37
38 bool extgl_Open(JNIEnv *env) {
39 if ( lib_gl_handle != NULL )
40 return true;
41
42 lib_gl_handle = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
43 if (lib_gl_handle == NULL) {
44 throwFormattedException(env, "Error loading libGLESv2.so: %s", dlerror());
45 return false;
46 }
47 return true;
48 }
49
50 void extgl_Close(void) {
51 dlclose(lib_gl_handle);
52 lib_gl_handle = NULL;
53 }
54
55 void *extgl_GetProcAddress(const char *name) {
56 void *t = eglGetProcAddress(name);
57
58 if ( t == NULL ) {
59 t = dlsym(lib_gl_handle, name);
60 if ( t == NULL )
61 printfDebug("Could not locate symbol %s\n", name);
62 }
63
64 //if ( t != NULL )
65 //printfDebug("Located symbol %s\n", name);
66
67 return t;
68 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3555 2011-07-02 20:50:27Z kappa1 $
34 *
35 * Linux specific display functions.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3555 $
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 "context.h"
53 #include "org_lwjgl_opengl_LinuxDisplay.h"
54 //#include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h"
55 #include "org_lwjgl_LinuxSysImplementation.h"
56
57 #define ERR_MSG_SIZE 1024
58
59 typedef struct {
60 unsigned long flags;
61 unsigned long functions;
62 unsigned long decorations;
63 long input_mode;
64 unsigned long status;
65 } MotifWmHints;
66
67 #define MWM_HINTS_DECORATIONS (1L << 1)
68
69 static Colormap cmap;
70 static int current_depth;
71
72 static Visual *current_visual;
73
74 static bool checkXError(JNIEnv *env, Display *disp) {
75 XSync(disp, False);
76 return (*env)->ExceptionCheck(env) == JNI_FALSE;
77 }
78
79 static int global_error_handler(Display *disp, XErrorEvent *error) {
80 JNIEnv *env = getThreadEnv();
81 if (env != NULL) {
82 jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay");
83 if (org_lwjgl_LinuxDisplay_class == NULL) {
84 // Don't propagate error
85 (*env)->ExceptionClear(env);
86 return 0;
87 }
88 jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I");
89 if (handler_method == NULL)
90 return 0;
91 return (*env)->CallStaticIntMethod(env, org_lwjgl_LinuxDisplay_class, handler_method, (jlong)(intptr_t)disp, (jlong)(intptr_t)error,
92 (jlong)(intptr_t)error->display, (jlong)error->serial, (jlong)error->error_code, (jlong)error->request_code, (jlong)error->minor_code);
93 } else
94 return 0;
95 }
96
97 static jlong openDisplay(JNIEnv *env) {
98 Display *display_connection = XOpenDisplay(NULL);
99 if (display_connection == NULL) {
100 throwException(env, "Could not open X display connection");
101 return (intptr_t)NULL;
102 }
103 return (intptr_t)display_connection;
104 }
105
106 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
107 (JNIEnv *env, jobject ignored) {
108 return org_lwjgl_LinuxSysImplementation_JNI_VERSION;
109 }
110
111 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) {
112 Display *disp = (Display *)(intptr_t)display_ptr;
113 char err_msg_buffer[ERR_MSG_SIZE];
114 XGetErrorText(disp, error_code, err_msg_buffer, ERR_MSG_SIZE);
115 err_msg_buffer[ERR_MSG_SIZE - 1] = '\0';
116 return NewStringNativeWithLength(env, err_msg_buffer, strlen(err_msg_buffer));
117 }
118
119 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr, jlong display_ptr, jlong event_ptr) {
120 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
121 Display *disp = (Display *)(intptr_t)display_ptr;
122 XErrorEvent *event = (XErrorEvent *)(intptr_t)event_ptr;
123 return (jint)handler(disp, event);
124 }
125
126 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler(JNIEnv *env, jclass unused) {
127 return (intptr_t)XSetErrorHandler(global_error_handler);
128 }
129
130 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr) {
131 XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr;
132 return (intptr_t)XSetErrorHandler(handler);
133 }
134
135 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) {
136 Display *disp = (Display *)(intptr_t)display_ptr;
137 XSync(disp, throw_away_events ? True : False);
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, jlong title, jint len) {
173 // ASCII fallback if XChangeProperty fails.
174 XStoreName(disp, window, (const char *)(intptr_t)title);
175
176 // Set the UTF-8 encoded title
177 XChangeProperty(disp, window,
178 XInternAtom(disp, "_NET_WM_NAME", False),
179 XInternAtom(disp, "UTF8_STRING", False),
180 8, PropModeReplace, (const unsigned char *)(intptr_t)title,
181 len);
182 }
183
184 static void setClassHint(Display *disp, Window window, jlong wm_name, jlong wm_class) {
185 XClassHint* hint = XAllocClassHint();
186
187 hint->res_name = (char *)(intptr_t)wm_name;
188 hint->res_class = (char *)(intptr_t)wm_class;
189
190 XSetClassHint(disp, window, hint);
191
192 XFree(hint);
193 }
194
195 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
196 return openDisplay(env);
197 }
198
199 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz, jlong display) {
200 Display *disp = (Display *)(intptr_t)display;
201 XCloseDisplay(disp);
202 }
203
204 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jlong window, jobject peer_info_handle) {
205 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
206 peer_info->drawable = window;
207 }
208
209 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle) {
210 //Display *disp = (Display *)(intptr_t)display;
211 //initPeerInfo(env, peer_info_handle, disp, screen);
212 }
213
214 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jlong title, jint len) {
215 Display *disp = (Display *)(intptr_t)display;
216 Window window = (Window)window_ptr;
217 setWindowTitle(disp, window, title, len);
218 }
219
220 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetClassHint(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jlong wm_name, jlong wm_class) {
221 Display *disp = (Display *)(intptr_t)display;
222 Window window = (Window)window_ptr;
223 setClassHint(disp, window, wm_name, wm_class);
224 }
225
226 static void destroyWindow(JNIEnv *env, Display *disp, Window window) {
227 XDestroyWindow(disp, window);
228 XFreeColormap(disp, cmap);
229 }
230
231 static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp, int screen) {
232 unsigned long nitems;
233 Atom actual_type;
234 int actual_format;
235 unsigned long bytes_after;
236 Atom *supported_list;
237 Atom netwm_supported_atom = XInternAtom(disp, "_NET_SUPPORTED", False);
238 int result = XGetWindowProperty(disp, RootWindow(disp, screen), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
239 if (result != Success) {
240 throwException(env, "Unable to query _NET_SUPPORTED window property");
241 return false;
242 }
243 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
244 bool supported = false;
245 unsigned long i;
246 for (i = 0; i < nitems; i++) {
247 if (fullscreen_atom == supported_list[i]) {
248 supported = true;
249 break;
250 }
251 }
252 XFree(supported_list);
253 return supported;
254 }
255
256 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display, jint screen) {
257 Display *disp = (Display *)(intptr_t)display;
258 return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE;
259 }
260
261 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) {
262 Display *disp = (Display *)(intptr_t)display;
263 Window window = (Window)window_ptr;
264 XMoveWindow(disp, window, x, y);
265 XResizeWindow(disp, window, width, height);
266 }
267
268 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize(JNIEnv *env, jclass clazz, jlong display, jboolean synchronize) {
269 Display *disp = (Display *)(intptr_t)display;
270 XSynchronize(disp, synchronize ? True : False);
271 }
272
273 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) {
274 Display *disp = (Display *)(intptr_t)display;
275 return RootWindow(disp, screen);
276 }
277
278 static Window getCurrentWindow(JNIEnv *env, jlong display_ptr, jlong window_ptr) {
279 Display *disp = (Display *)(intptr_t)display_ptr;
280
281 Window parent = (Window)window_ptr;
282 Window win, root;
283
284 Window *children;
285 unsigned int nchildren;
286
287 do {
288 win = parent;
289
290 if (XQueryTree(disp, win, &root, &parent, &children, &nchildren) == 0) {
291 throwException(env, "XQueryTree failed");
292 return 0;
293 }
294
295 if (children != NULL) XFree(children);
296 } while (parent != root);
297
298 return win;
299 }
300
301 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetX(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
302 Display *disp = (Display *)(intptr_t)display_ptr;
303 Window win = getCurrentWindow(env, display_ptr, window_ptr);
304
305 XWindowAttributes win_attribs;
306 XGetWindowAttributes(disp, win, &win_attribs);
307
308 return win_attribs.x;
309 }
310
311 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetY(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
312 Display *disp = (Display *)(intptr_t)display_ptr;
313 Window win = getCurrentWindow(env, display_ptr, window_ptr);
314
315 XWindowAttributes win_attribs;
316 XGetWindowAttributes(disp, win, &win_attribs);
317
318 return win_attribs.y;
319 }
320
321 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetWidth(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
322 Display *disp = (Display *)(intptr_t)display_ptr;
323 Window win = (Window)window_ptr;
324 XWindowAttributes win_attribs;
325
326 XGetWindowAttributes(disp, win, &win_attribs);
327
328 return win_attribs.width;
329 }
330
331 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetHeight(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
332 Display *disp = (Display *)(intptr_t)display_ptr;
333 Window win = (Window)window_ptr;
334 XWindowAttributes win_attribs;
335
336 XGetWindowAttributes(disp, win, &win_attribs);
337
338 return win_attribs.height;
339 }
340
341 static void updateWindowHints(JNIEnv *env, Display *disp, Window window) {
342 XWMHints* win_hints = XAllocWMHints();
343 if (win_hints == NULL) {
344 throwException(env, "XAllocWMHints failed");
345 return;
346 }
347
348 win_hints->flags = InputHint;
349 win_hints->input = True;
350
351 XSetWMHints(disp, window, win_hints);
352 XFree(win_hints);
353 XFlush(disp);
354 }
355
356 static void updateWindowBounds(Display *disp, Window win, int x, int y, int width, int height, jboolean position, jboolean resizable) {
357 XSizeHints *window_hints = XAllocSizeHints();
358
359 if (position) {
360 window_hints->flags |= PPosition;
361 window_hints->x = x;
362 window_hints->y = y;
363 }
364
365 if (!resizable) {
366 window_hints->flags |= PMinSize | PMaxSize;
367 window_hints->min_width = width;
368 window_hints->max_width = width;
369 window_hints->min_height = height;
370 window_hints->max_height = height;
371 }
372
373 XSetWMNormalHints(disp, win, window_hints);
374 XFree(window_hints);
375 }
376
377 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, jboolean resizable) {
378 Window parent = (Window)parent_handle;
379 Window win;
380 XSetWindowAttributes attribs;
381 unsigned int attribmask;
382
383 XVisualInfo vis_info;
384 if ( !XMatchVisualInfo(disp, screen, DefaultDepth(disp, screen), TrueColor, &vis_info) ) {
385 throwException(env, "Failed to acquire X visual.");
386 return false;
387 }
388
389 cmap = XCreateColormap(disp, parent, vis_info.visual, AllocNone);
390 if (!checkXError(env, disp)) {
391 return false;
392 }
393 attribs.colormap = cmap;
394 attribs.border_pixel = 0;
395 attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
396 attribmask = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel;
397 if (isLegacyFullscreen(window_mode)) {
398 attribmask |= CWOverrideRedirect;
399 attribs.override_redirect = True;
400 }
401 win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info.depth, InputOutput, vis_info.visual, attribmask, &attribs);
402
403 current_depth = vis_info.depth;
404 current_visual = vis_info.visual;
405
406 if (!checkXError(env, disp)) {
407 XFreeColormap(disp, cmap);
408 return false;
409 }
410 if (undecorated) {
411 // Use Motif decoration hint property and hope the window manager respects them
412 setDecorations(disp, win, 0);
413 }
414
415 if (RootWindow(disp, screen) == parent_handle) { // only set hints when Display.setParent isn't used
416 updateWindowBounds(disp, win, x, y, width, height, JNI_TRUE, resizable);
417 updateWindowHints(env, disp, win);
418 }
419
420 #define NUM_ATOMS 1
421 Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/};
422 XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS);
423 if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
424 Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
425 XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
426 XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
427 }
428 if (!checkXError(env, disp)) {
429 destroyWindow(env, disp, win);
430 return 0;
431 }
432 return win;
433 }
434
435 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) {
436 Display *disp = (Display *)(intptr_t)display;
437 Window window = (Window)window_ptr;
438 Window parent = (Window)parent_ptr;
439 XReparentWindow(disp, window, parent, x, y);
440 }
441
442 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
443 Display *disp = (Display *)(intptr_t)display;
444 Window window = (Window)window_ptr;
445 XMapRaised(disp, window);
446 }
447
448 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
449 Display *disp = (Display *)(intptr_t)display;
450 Window window = (Window)window_ptr;
451 Window root, parent;
452 Window *children;
453 unsigned int nchildren;
454 if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) {
455 throwException(env, "XQueryTree failed");
456 return None;
457 }
458 if (children != NULL)
459 XFree(children);
460 return parent;
461 }
462
463 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getChildCount(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) {
464 Display *disp = (Display *)(intptr_t)display;
465 Window window = (Window)window_ptr;
466 Window root, parent;
467 Window *children;
468 unsigned int nchildren;
469 if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) {
470 throwException(env, "XQueryTree failed");
471 return None;
472 }
473 if (children != NULL)
474 XFree(children);
475
476 return nchildren;
477 }
478
479 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty(JNIEnv *env, jclass unusued, jlong display, jlong window_ptr, jlong property_ptr) {
480 Display *disp = (Display *)(intptr_t)display;
481 Window window = (Window)window_ptr;
482 Atom property = (Atom)property_ptr;
483 int num_props;
484 Atom *properties = XListProperties(disp, window, &num_props);
485 if (properties == NULL)
486 return JNI_FALSE;
487 jboolean result = JNI_FALSE;
488 for (int i = 0; i < num_props; i++) {
489 if (properties[i] == property) {
490 result = JNI_TRUE;
491 break;
492 }
493 }
494 XFree(properties);
495 return result;
496 }
497
498 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
499 Display *disp = (Display *)(intptr_t)display_ptr;
500 int revert_mode;
501 Window win;
502 XGetInputFocus(disp, &win, &revert_mode);
503 return win;
504 }
505
506 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) {
507 Display *disp = (Display *)(intptr_t)display;
508 Window window = (Window)window_ptr;
509 XSetInputFocus(disp, window, RevertToParent, time);
510 }
511
512 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, jboolean resizable) {
513 Display *disp = (Display *)(intptr_t)display;
514 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
515
516 jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
517
518 jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
519 jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
520
521 int width = (*env)->GetIntField(env, mode, fid_width);
522 int height = (*env)->GetIntField(env, mode, fid_height);
523
524 Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle, resizable);
525
526 if ((*env)->ExceptionOccurred(env))
527 return 0;
528
529 if (!checkXError(env, disp))
530 destroyWindow(env, disp, win);
531
532 return win;
533 }
534
535 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowSize(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint width, jint height, jboolean resizable) {
536 Display *disp = (Display *)(intptr_t)display;
537 Window win = (Window)window_ptr;
538 updateWindowBounds(disp, win, 0, 0, width, height, JNI_FALSE, resizable);
539 }
540
541 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
542 Display *disp = (Display *)(intptr_t)display;
543 Window window = (Window)window_ptr;
544 destroyWindow(env, disp, window);
545 }
546
547 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
548 JAWT jawt;
549 jawt.version = JAWT_VERSION_1_4;
550 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
551 throwException(env, "GetAWT failed");
552 return;
553 }
554 jawt.Lock(env);
555 }
556
557 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT(JNIEnv *env, jclass clazz) {
558 JAWT jawt;
559 jawt.version = JAWT_VERSION_1_4;
560 if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
561 throwException(env, "GetAWT failed");
562 return;
563 }
564 jawt.Unlock(env);
565 }
566
567 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
568 (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icons_buffer, jint icons_buffer_size)
569 {
570 Display *disp = (Display *)(intptr_t)display;
571 Window window = (Window)window_ptr;
572 const unsigned char *icons_char_buffer = (const unsigned char *)(*env)->GetDirectBufferAddress(env, icons_buffer);
573
574 int length = icons_buffer_size/4;
575 unsigned long icons_long_buffer[length];
576 int i = 0;
577
578 // copy byte array to long array
579 for (i = 0; i < icons_buffer_size; i += 4) {
580 unsigned long argb = (icons_char_buffer[i] << 24) |
581 (icons_char_buffer[i+1] << 16) |
582 (icons_char_buffer[i+2] << 8) |
583 (icons_char_buffer[i+3]);
584 icons_long_buffer[i/4] = argb;
585 }
586
587 XChangeProperty(disp, window,
588 XInternAtom(disp, "_NET_WM_ICON", False),
589 XInternAtom(disp, "CARDINAL", False),
590 32, PropModeReplace, (const unsigned char*) icons_long_buffer, length);
591 }
592
593 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
594 Display *disp = (Display *)(intptr_t)display_ptr;
595 return XUngrabKeyboard(disp, CurrentTime);
596 }
597
598 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
599 Display *disp = (Display *)(intptr_t)display_ptr;
600 Window win = (Window)window_ptr;
601 return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
602 }
603
604 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
605 Display *disp = (Display *)(intptr_t)display_ptr;
606 Window win = (Window)window_ptr;
607 Cursor cursor = (Cursor)cursor_ptr;
608 int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
609 return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime);
610 }
611
612 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
613 Display *disp = (Display *)(intptr_t)display_ptr;
614 Window win = (Window)window_ptr;
615 XWindowAttributes win_attribs;
616
617 XGetWindowAttributes(disp, win, &win_attribs);
618 XF86VidModeSetViewPort(disp, screen, win_attribs.x, win_attribs.y);
619 }
620
621 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer(JNIEnv *env, jclass unused, jlong display_ptr) {
622 Display *disp = (Display *)(intptr_t)display_ptr;
623 return XUngrabPointer(disp, CurrentTime);
624 }
625
626 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
627 Display *disp = (Display *)(intptr_t)display_ptr;
628 Window win = (Window)window_ptr;
629 Cursor cursor = (Cursor)cursor_ptr;
630 XDefineCursor(disp, win, cursor);
631 }
632
633 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
634 Display *disp = (Display *)(intptr_t)display_ptr;
635 Window win = (Window)window_ptr;
636 unsigned int best_width, best_height;
637 if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
638 throwException(env, "Could not query best cursor size");
639 return false;
640 }
641 Pixmap mask = XCreatePixmap(disp, win, best_width, best_height, 1);
642 XGCValues gc_values;
643 gc_values.foreground = 0;
644 GC gc = XCreateGC(disp, mask, GCForeground, &gc_values);
645 XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
646 XFreeGC(disp, gc);
647 XColor dummy_color;
648 Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
649 XFreePixmap(disp, mask);
650 return cursor;
651 }
652
653 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
654 Display *disp = (Display *)(intptr_t)display_ptr;
655 Window win = (Window)window_ptr;
656 XIconifyWindow(disp, win, screen);
657 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_LinuxSysImplementation */
3
4 #ifndef _Included_org_lwjgl_LinuxSysImplementation
5 #define _Included_org_lwjgl_LinuxSysImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_LinuxSysImplementation_JNI_VERSION
10 #define org_lwjgl_LinuxSysImplementation_JNI_VERSION 19L
11 #ifdef __cplusplus
12 }
13 #endif
14 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_input_Cursor.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * Linux cursor handling.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @version $Revision$
3939 */
4040
4141 #include <X11/X.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 /**
33 * $Id: org_lwjgl_opengl_Display.c 3453 2010-10-28 21:39:55Z kappa1 $
34 *
35 * Linux specific display functions.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3453 $
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| EnterWindowMask | LeaveWindowMask;
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
-82
src/native/linux/org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
-65
src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
-200
src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3412 2010-09-26 23:43:24Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
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 jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getGLXContext(JNIEnv *env, jclass clazz, jobject context_handle) {
109 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
110 return (intptr_t)context_info->context;
111 }
112
113 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getDisplay(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
114 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
115 return (intptr_t)peer_info->display;
116 }
117
118 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval
119 (JNIEnv *env, jclass clazz, jobject context_handle, jint value)
120 {
121 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
122 if (context_info->extension_flags.GLX_SGI_swap_control) {
123 lwjgl_glXSwapIntervalSGI(value);
124 }
125 }
126
127 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate
128 (JNIEnv *env , jclass clazz, jobject peer_handle, jobject attribs, jobject shared_context_handle) {
129 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(X11Context));
130 if (context_handle == NULL) {
131 throwException(env, "Could not allocate handle buffer");
132 return NULL;
133 }
134 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
135 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
136 GLXExtensions extension_flags;
137 if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) {
138 throwException(env, "Could not initialize GLX");
139 return NULL;
140 }
141 GLXContext shared_context = NULL;
142 if (shared_context_handle != NULL) {
143 X11Context *shared_context_info = (*env)->GetDirectBufferAddress(env, shared_context_handle);
144 shared_context = shared_context_info->context;
145 }
146 if (peer_info->glx13) {
147 createContextGLX13(env, peer_info, context_info, extension_flags.GLX_ARB_create_context ? attribs : NULL, shared_context);
148 } else {
149 createContextGLX(env, peer_info, context_info, shared_context);
150 }
151 context_info->extension_flags = extension_flags;
152 return context_handle;
153 }
154
155 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy
156 (JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) {
157 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
158 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
159 lwjgl_glXDestroyContext(peer_info->display, context_info->context);
160 }
161
162 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext
163 (JNIEnv *env , jclass clazz, jobject peer_info_handle) {
164 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
165 Bool result;
166 if (peer_info->glx13) {
167 result = lwjgl_glXMakeContextCurrent(peer_info->display, None, None, NULL);
168 } else {
169 result = lwjgl_glXMakeCurrent(peer_info->display, None, NULL);
170 }
171 if (!result)
172 throwException(env, "Could not release current context");
173 }
174
175 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCurrent
176 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
177 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
178 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
179 Bool result;
180 if (peer_info->glx13) {
181 result = lwjgl_glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context);
182 } else {
183 result = lwjgl_glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context);
184 }
185 if (!result)
186 throwException(env, "Could not make context current");
187 }
188
189 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent
190 (JNIEnv *env, jclass clazz, jobject context_handle) {
191 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
192 return context_info->context == lwjgl_glXGetCurrentContext();
193 }
194
195 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers
196 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
197 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
198 lwjgl_glXSwapBuffers(peer_info->display, peer_info->drawable);
199 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxDisplay */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxDisplay
5 #define _Included_org_lwjgl_opengl_LinuxDisplay
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_LinuxDisplay_CurrentTime
10 #define org_lwjgl_opengl_LinuxDisplay_CurrentTime 0L
11 #undef org_lwjgl_opengl_LinuxDisplay_GrabSuccess
12 #define org_lwjgl_opengl_LinuxDisplay_GrabSuccess 0L
13 #undef org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeOff
14 #define org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeOff 0L
15 #undef org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeOn
16 #define org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeOn 1L
17 #undef org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeDefault
18 #define org_lwjgl_opengl_LinuxDisplay_AutoRepeatModeDefault 2L
19 #undef org_lwjgl_opengl_LinuxDisplay_None
20 #define org_lwjgl_opengl_LinuxDisplay_None 0L
21 #undef org_lwjgl_opengl_LinuxDisplay_KeyPressMask
22 #define org_lwjgl_opengl_LinuxDisplay_KeyPressMask 1L
23 #undef org_lwjgl_opengl_LinuxDisplay_KeyReleaseMask
24 #define org_lwjgl_opengl_LinuxDisplay_KeyReleaseMask 2L
25 #undef org_lwjgl_opengl_LinuxDisplay_ButtonPressMask
26 #define org_lwjgl_opengl_LinuxDisplay_ButtonPressMask 4L
27 #undef org_lwjgl_opengl_LinuxDisplay_ButtonReleaseMask
28 #define org_lwjgl_opengl_LinuxDisplay_ButtonReleaseMask 8L
29 #undef org_lwjgl_opengl_LinuxDisplay_NotifyAncestor
30 #define org_lwjgl_opengl_LinuxDisplay_NotifyAncestor 0L
31 #undef org_lwjgl_opengl_LinuxDisplay_NotifyNonlinear
32 #define org_lwjgl_opengl_LinuxDisplay_NotifyNonlinear 3L
33 #undef org_lwjgl_opengl_LinuxDisplay_NotifyPointer
34 #define org_lwjgl_opengl_LinuxDisplay_NotifyPointer 5L
35 #undef org_lwjgl_opengl_LinuxDisplay_NotifyPointerRoot
36 #define org_lwjgl_opengl_LinuxDisplay_NotifyPointerRoot 6L
37 #undef org_lwjgl_opengl_LinuxDisplay_NotifyDetailNone
38 #define org_lwjgl_opengl_LinuxDisplay_NotifyDetailNone 7L
39 #undef org_lwjgl_opengl_LinuxDisplay_SetModeInsert
40 #define org_lwjgl_opengl_LinuxDisplay_SetModeInsert 0L
41 #undef org_lwjgl_opengl_LinuxDisplay_SaveSetRoot
42 #define org_lwjgl_opengl_LinuxDisplay_SaveSetRoot 1L
43 #undef org_lwjgl_opengl_LinuxDisplay_SaveSetUnmap
44 #define org_lwjgl_opengl_LinuxDisplay_SaveSetUnmap 1L
45 #undef org_lwjgl_opengl_LinuxDisplay_X_SetInputFocus
46 #define org_lwjgl_opengl_LinuxDisplay_X_SetInputFocus 42L
47 #undef org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY
48 #define org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY 1L
49 #undef org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM
50 #define org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM 2L
51 #undef org_lwjgl_opengl_LinuxDisplay_WINDOWED
52 #define org_lwjgl_opengl_LinuxDisplay_WINDOWED 3L
53 #undef org_lwjgl_opengl_LinuxDisplay_XRANDR
54 #define org_lwjgl_opengl_LinuxDisplay_XRANDR 10L
55 #undef org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE
56 #define org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE 11L
57 #undef org_lwjgl_opengl_LinuxDisplay_NONE
58 #define org_lwjgl_opengl_LinuxDisplay_NONE 12L
59 /*
60 * Class: org_lwjgl_opengl_LinuxDisplay
61 * Method: nGetCurrentGammaRamp
62 * Signature: (JI)Ljava/nio/ByteBuffer;
63 */
64 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp
65 (JNIEnv *, jclass, jlong, jint);
66
67 /*
68 * Class: org_lwjgl_opengl_LinuxDisplay
69 * Method: nIsXrandrSupported
70 * Signature: (J)Z
71 */
72 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported
73 (JNIEnv *, jclass, jlong);
74
75 /*
76 * Class: org_lwjgl_opengl_LinuxDisplay
77 * Method: nIsXF86VidModeSupported
78 * Signature: (J)Z
79 */
80 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported
81 (JNIEnv *, jclass, jlong);
82
83 /*
84 * Class: org_lwjgl_opengl_LinuxDisplay
85 * Method: nIsNetWMFullscreenSupported
86 * Signature: (JI)Z
87 */
88 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported
89 (JNIEnv *, jclass, jlong, jint);
90
91 /*
92 * Class: org_lwjgl_opengl_LinuxDisplay
93 * Method: nLockAWT
94 * Signature: ()V
95 */
96 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT
97 (JNIEnv *, jclass);
98
99 /*
100 * Class: org_lwjgl_opengl_LinuxDisplay
101 * Method: nUnlockAWT
102 * Signature: ()V
103 */
104 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT
105 (JNIEnv *, jclass);
106
107 /*
108 * Class: org_lwjgl_opengl_LinuxDisplay
109 * Method: callErrorHandler
110 * Signature: (JJJ)I
111 */
112 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler
113 (JNIEnv *, jclass, jlong, jlong, jlong);
114
115 /*
116 * Class: org_lwjgl_opengl_LinuxDisplay
117 * Method: setErrorHandler
118 * Signature: ()J
119 */
120 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler
121 (JNIEnv *, jclass);
122
123 /*
124 * Class: org_lwjgl_opengl_LinuxDisplay
125 * Method: resetErrorHandler
126 * Signature: (J)J
127 */
128 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler
129 (JNIEnv *, jclass, jlong);
130
131 /*
132 * Class: org_lwjgl_opengl_LinuxDisplay
133 * Method: synchronize
134 * Signature: (JZ)V
135 */
136 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize
137 (JNIEnv *, jclass, jlong, jboolean);
138
139 /*
140 * Class: org_lwjgl_opengl_LinuxDisplay
141 * Method: getErrorText
142 * Signature: (JJ)Ljava/lang/String;
143 */
144 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText
145 (JNIEnv *, jclass, jlong, jlong);
146
147 /*
148 * Class: org_lwjgl_opengl_LinuxDisplay
149 * Method: openDisplay
150 * Signature: ()J
151 */
152 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay
153 (JNIEnv *, jclass);
154
155 /*
156 * Class: org_lwjgl_opengl_LinuxDisplay
157 * Method: closeDisplay
158 * Signature: (J)V
159 */
160 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay
161 (JNIEnv *, jclass, jlong);
162
163 /*
164 * Class: org_lwjgl_opengl_LinuxDisplay
165 * Method: nGetDefaultScreen
166 * Signature: (J)I
167 */
168 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen
169 (JNIEnv *, jclass, jlong);
170
171 /*
172 * Class: org_lwjgl_opengl_LinuxDisplay
173 * Method: nUngrabKeyboard
174 * Signature: (J)I
175 */
176 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard
177 (JNIEnv *, jclass, jlong);
178
179 /*
180 * Class: org_lwjgl_opengl_LinuxDisplay
181 * Method: nGrabKeyboard
182 * Signature: (JJ)I
183 */
184 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard
185 (JNIEnv *, jclass, jlong, jlong);
186
187 /*
188 * Class: org_lwjgl_opengl_LinuxDisplay
189 * Method: nGrabPointer
190 * Signature: (JJJ)I
191 */
192 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer
193 (JNIEnv *, jclass, jlong, jlong, jlong);
194
195 /*
196 * Class: org_lwjgl_opengl_LinuxDisplay
197 * Method: nSetViewPort
198 * Signature: (JJI)V
199 */
200 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort
201 (JNIEnv *, jclass, jlong, jlong, jint);
202
203 /*
204 * Class: org_lwjgl_opengl_LinuxDisplay
205 * Method: nUngrabPointer
206 * Signature: (J)I
207 */
208 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer
209 (JNIEnv *, jclass, jlong);
210
211 /*
212 * Class: org_lwjgl_opengl_LinuxDisplay
213 * Method: nDefineCursor
214 * Signature: (JJJ)V
215 */
216 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor
217 (JNIEnv *, jclass, jlong, jlong, jlong);
218
219 /*
220 * Class: org_lwjgl_opengl_LinuxDisplay
221 * Method: nCreateWindow
222 * Signature: (JILjava/nio/ByteBuffer;Lorg/lwjgl/opengl/DisplayMode;IIIZJZ)J
223 */
224 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow
225 (JNIEnv *, jclass, jlong, jint, jobject, jobject, jint, jint, jint, jboolean, jlong, jboolean);
226
227 /*
228 * Class: org_lwjgl_opengl_LinuxDisplay
229 * Method: getRootWindow
230 * Signature: (JI)J
231 */
232 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow
233 (JNIEnv *, jclass, jlong, jint);
234
235 /*
236 * Class: org_lwjgl_opengl_LinuxDisplay
237 * Method: hasProperty
238 * Signature: (JJJ)Z
239 */
240 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty
241 (JNIEnv *, jclass, jlong, jlong, jlong);
242
243 /*
244 * Class: org_lwjgl_opengl_LinuxDisplay
245 * Method: getParentWindow
246 * Signature: (JJ)J
247 */
248 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow
249 (JNIEnv *, jclass, jlong, jlong);
250
251 /*
252 * Class: org_lwjgl_opengl_LinuxDisplay
253 * Method: getChildCount
254 * Signature: (JJ)I
255 */
256 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getChildCount
257 (JNIEnv *, jclass, jlong, jlong);
258
259 /*
260 * Class: org_lwjgl_opengl_LinuxDisplay
261 * Method: mapRaised
262 * Signature: (JJ)V
263 */
264 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised
265 (JNIEnv *, jclass, jlong, jlong);
266
267 /*
268 * Class: org_lwjgl_opengl_LinuxDisplay
269 * Method: reparentWindow
270 * Signature: (JJJII)V
271 */
272 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_reparentWindow
273 (JNIEnv *, jclass, jlong, jlong, jlong, jint, jint);
274
275 /*
276 * Class: org_lwjgl_opengl_LinuxDisplay
277 * Method: nGetInputFocus
278 * Signature: (J)J
279 */
280 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus
281 (JNIEnv *, jclass, jlong);
282
283 /*
284 * Class: org_lwjgl_opengl_LinuxDisplay
285 * Method: nSetInputFocus
286 * Signature: (JJJ)V
287 */
288 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetInputFocus
289 (JNIEnv *, jclass, jlong, jlong, jlong);
290
291 /*
292 * Class: org_lwjgl_opengl_LinuxDisplay
293 * Method: nSetWindowSize
294 * Signature: (JJIIZ)V
295 */
296 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowSize
297 (JNIEnv *, jclass, jlong, jlong, jint, jint, jboolean);
298
299 /*
300 * Class: org_lwjgl_opengl_LinuxDisplay
301 * Method: nGetX
302 * Signature: (JJ)I
303 */
304 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetX
305 (JNIEnv *, jclass, jlong, jlong);
306
307 /*
308 * Class: org_lwjgl_opengl_LinuxDisplay
309 * Method: nGetY
310 * Signature: (JJ)I
311 */
312 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetY
313 (JNIEnv *, jclass, jlong, jlong);
314
315 /*
316 * Class: org_lwjgl_opengl_LinuxDisplay
317 * Method: nGetWidth
318 * Signature: (JJ)I
319 */
320 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetWidth
321 (JNIEnv *, jclass, jlong, jlong);
322
323 /*
324 * Class: org_lwjgl_opengl_LinuxDisplay
325 * Method: nGetHeight
326 * Signature: (JJ)I
327 */
328 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetHeight
329 (JNIEnv *, jclass, jlong, jlong);
330
331 /*
332 * Class: org_lwjgl_opengl_LinuxDisplay
333 * Method: nDestroyWindow
334 * Signature: (JJ)V
335 */
336 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow
337 (JNIEnv *, jclass, jlong, jlong);
338
339 /*
340 * Class: org_lwjgl_opengl_LinuxDisplay
341 * Method: nSwitchDisplayMode
342 * Signature: (JIILorg/lwjgl/opengl/DisplayMode;)V
343 */
344 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode
345 (JNIEnv *, jclass, jlong, jint, jint, jobject);
346
347 /*
348 * Class: org_lwjgl_opengl_LinuxDisplay
349 * Method: nInternAtom
350 * Signature: (JLjava/lang/String;Z)J
351 */
352 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom
353 (JNIEnv *, jclass, jlong, jstring, jboolean);
354
355 /*
356 * Class: org_lwjgl_opengl_LinuxDisplay
357 * Method: nGetGammaRampLength
358 * Signature: (JI)I
359 */
360 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength
361 (JNIEnv *, jclass, jlong, jint);
362
363 /*
364 * Class: org_lwjgl_opengl_LinuxDisplay
365 * Method: nSetGammaRamp
366 * Signature: (JILjava/nio/ByteBuffer;)V
367 */
368 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp
369 (JNIEnv *, jclass, jlong, jint, jobject);
370
371 /*
372 * Class: org_lwjgl_opengl_LinuxDisplay
373 * Method: nConvertToNativeRamp
374 * Signature: (Ljava/nio/FloatBuffer;II)Ljava/nio/ByteBuffer;
375 */
376 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nConvertToNativeRamp
377 (JNIEnv *, jclass, jobject, jint, jint);
378
379 /*
380 * Class: org_lwjgl_opengl_LinuxDisplay
381 * Method: nGetCurrentXRandrMode
382 * Signature: (JI)Lorg/lwjgl/opengl/DisplayMode;
383 */
384 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode
385 (JNIEnv *, jclass, jlong, jint);
386
387 /*
388 * Class: org_lwjgl_opengl_LinuxDisplay
389 * Method: nSetTitle
390 * Signature: (JJJI)V
391 */
392 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle
393 (JNIEnv *, jclass, jlong, jlong, jlong, jint);
394
395 /*
396 * Class: org_lwjgl_opengl_LinuxDisplay
397 * Method: nSetClassHint
398 * Signature: (JJJJ)V
399 */
400 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetClassHint
401 (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
402
403 /*
404 * Class: org_lwjgl_opengl_LinuxDisplay
405 * Method: nReshape
406 * Signature: (JJIIII)V
407 */
408 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape
409 (JNIEnv *, jclass, jlong, jlong, jint, jint, jint, jint);
410
411 /*
412 * Class: org_lwjgl_opengl_LinuxDisplay
413 * Method: nGetAvailableDisplayModes
414 * Signature: (JII)[Lorg/lwjgl/opengl/DisplayMode;
415 */
416 JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes
417 (JNIEnv *, jclass, jlong, jint, jint);
418
419 /*
420 * Class: org_lwjgl_opengl_LinuxDisplay
421 * Method: nSync
422 * Signature: (JZ)V
423 */
424 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSync
425 (JNIEnv *, jclass, jlong, jboolean);
426
427 /*
428 * Class: org_lwjgl_opengl_LinuxDisplay
429 * Method: nIconifyWindow
430 * Signature: (JJI)V
431 */
432 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow
433 (JNIEnv *, jclass, jlong, jlong, jint);
434
435 /*
436 * Class: org_lwjgl_opengl_LinuxDisplay
437 * Method: nGetNativeCursorCapabilities
438 * Signature: (J)I
439 */
440 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCapabilities
441 (JNIEnv *, jclass, jlong);
442
443 /*
444 * Class: org_lwjgl_opengl_LinuxDisplay
445 * Method: nGetMinCursorSize
446 * Signature: (JJ)I
447 */
448 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize
449 (JNIEnv *, jclass, jlong, jlong);
450
451 /*
452 * Class: org_lwjgl_opengl_LinuxDisplay
453 * Method: nGetMaxCursorSize
454 * Signature: (JJ)I
455 */
456 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize
457 (JNIEnv *, jclass, jlong, jlong);
458
459 /*
460 * Class: org_lwjgl_opengl_LinuxDisplay
461 * Method: nCreateCursor
462 * Signature: (JIIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)J
463 */
464 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
465 (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
466
467 /*
468 * Class: org_lwjgl_opengl_LinuxDisplay
469 * Method: nCreateBlankCursor
470 * Signature: (JJ)J
471 */
472 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor
473 (JNIEnv *, jclass, jlong, jlong);
474
475 /*
476 * Class: org_lwjgl_opengl_LinuxDisplay
477 * Method: nDestroyCursor
478 * Signature: (JJ)V
479 */
480 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
481 (JNIEnv *, jclass, jlong, jlong);
482
483 /*
484 * Class: org_lwjgl_opengl_LinuxDisplay
485 * Method: nGetPbufferCapabilities
486 * Signature: (JI)I
487 */
488 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
489 (JNIEnv *, jclass, jlong, jint);
490
491 /*
492 * Class: org_lwjgl_opengl_LinuxDisplay
493 * Method: nSetWindowIcon
494 * Signature: (JJLjava/nio/ByteBuffer;I)V
495 */
496 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
497 (JNIEnv *, jclass, jlong, jlong, jobject, jint);
498
499 #ifdef __cplusplus
500 }
501 #endif
502 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxDisplay_Compiz */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxDisplay_Compiz
5 #define _Included_org_lwjgl_opengl_LinuxDisplay_Compiz
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxDisplay_Compiz_Provider */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxDisplay_Compiz_Provider
5 #define _Included_org_lwjgl_opengl_LinuxDisplay_Compiz_Provider
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxEvent */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxEvent
5 #define _Included_org_lwjgl_opengl_LinuxEvent
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_LinuxEvent_FocusIn
10 #define org_lwjgl_opengl_LinuxEvent_FocusIn 9L
11 #undef org_lwjgl_opengl_LinuxEvent_FocusOut
12 #define org_lwjgl_opengl_LinuxEvent_FocusOut 10L
13 #undef org_lwjgl_opengl_LinuxEvent_KeyPress
14 #define org_lwjgl_opengl_LinuxEvent_KeyPress 2L
15 #undef org_lwjgl_opengl_LinuxEvent_KeyRelease
16 #define org_lwjgl_opengl_LinuxEvent_KeyRelease 3L
17 #undef org_lwjgl_opengl_LinuxEvent_ButtonPress
18 #define org_lwjgl_opengl_LinuxEvent_ButtonPress 4L
19 #undef org_lwjgl_opengl_LinuxEvent_ButtonRelease
20 #define org_lwjgl_opengl_LinuxEvent_ButtonRelease 5L
21 #undef org_lwjgl_opengl_LinuxEvent_MotionNotify
22 #define org_lwjgl_opengl_LinuxEvent_MotionNotify 6L
23 #undef org_lwjgl_opengl_LinuxEvent_EnterNotify
24 #define org_lwjgl_opengl_LinuxEvent_EnterNotify 7L
25 #undef org_lwjgl_opengl_LinuxEvent_LeaveNotify
26 #define org_lwjgl_opengl_LinuxEvent_LeaveNotify 8L
27 #undef org_lwjgl_opengl_LinuxEvent_UnmapNotify
28 #define org_lwjgl_opengl_LinuxEvent_UnmapNotify 18L
29 #undef org_lwjgl_opengl_LinuxEvent_MapNotify
30 #define org_lwjgl_opengl_LinuxEvent_MapNotify 19L
31 #undef org_lwjgl_opengl_LinuxEvent_Expose
32 #define org_lwjgl_opengl_LinuxEvent_Expose 12L
33 #undef org_lwjgl_opengl_LinuxEvent_ConfigureNotify
34 #define org_lwjgl_opengl_LinuxEvent_ConfigureNotify 22L
35 #undef org_lwjgl_opengl_LinuxEvent_ClientMessage
36 #define org_lwjgl_opengl_LinuxEvent_ClientMessage 33L
37 /*
38 * Class: org_lwjgl_opengl_LinuxEvent
39 * Method: createEventBuffer
40 * Signature: ()Ljava/nio/ByteBuffer;
41 */
42 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer
43 (JNIEnv *, jclass);
44
45 /*
46 * Class: org_lwjgl_opengl_LinuxEvent
47 * Method: getPending
48 * Signature: (J)I
49 */
50 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_getPending
51 (JNIEnv *, jclass, jlong);
52
53 /*
54 * Class: org_lwjgl_opengl_LinuxEvent
55 * Method: nSendEvent
56 * Signature: (Ljava/nio/ByteBuffer;JJZJ)V
57 */
58 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSendEvent
59 (JNIEnv *, jclass, jobject, jlong, jlong, jboolean, jlong);
60
61 /*
62 * Class: org_lwjgl_opengl_LinuxEvent
63 * Method: nFilterEvent
64 * Signature: (Ljava/nio/ByteBuffer;J)Z
65 */
66 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent
67 (JNIEnv *, jclass, jobject, jlong);
68
69 /*
70 * Class: org_lwjgl_opengl_LinuxEvent
71 * Method: nNextEvent
72 * Signature: (JLjava/nio/ByteBuffer;)V
73 */
74 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nNextEvent
75 (JNIEnv *, jclass, jlong, jobject);
76
77 /*
78 * Class: org_lwjgl_opengl_LinuxEvent
79 * Method: nGetType
80 * Signature: (Ljava/nio/ByteBuffer;)I
81 */
82 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetType
83 (JNIEnv *, jclass, jobject);
84
85 /*
86 * Class: org_lwjgl_opengl_LinuxEvent
87 * Method: nGetWindow
88 * Signature: (Ljava/nio/ByteBuffer;)J
89 */
90 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetWindow
91 (JNIEnv *, jclass, jobject);
92
93 /*
94 * Class: org_lwjgl_opengl_LinuxEvent
95 * Method: nSetWindow
96 * Signature: (Ljava/nio/ByteBuffer;J)V
97 */
98 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSetWindow
99 (JNIEnv *, jclass, jobject, jlong);
100
101 /*
102 * Class: org_lwjgl_opengl_LinuxEvent
103 * Method: nGetFocusMode
104 * Signature: (Ljava/nio/ByteBuffer;)I
105 */
106 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusMode
107 (JNIEnv *, jclass, jobject);
108
109 /*
110 * Class: org_lwjgl_opengl_LinuxEvent
111 * Method: nGetFocusDetail
112 * Signature: (Ljava/nio/ByteBuffer;)I
113 */
114 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusDetail
115 (JNIEnv *, jclass, jobject);
116
117 /*
118 * Class: org_lwjgl_opengl_LinuxEvent
119 * Method: nGetClientMessageType
120 * Signature: (Ljava/nio/ByteBuffer;)J
121 */
122 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientMessageType
123 (JNIEnv *, jclass, jobject);
124
125 /*
126 * Class: org_lwjgl_opengl_LinuxEvent
127 * Method: nGetClientData
128 * Signature: (Ljava/nio/ByteBuffer;I)I
129 */
130 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientData
131 (JNIEnv *, jclass, jobject, jint);
132
133 /*
134 * Class: org_lwjgl_opengl_LinuxEvent
135 * Method: nGetClientFormat
136 * Signature: (Ljava/nio/ByteBuffer;)I
137 */
138 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientFormat
139 (JNIEnv *, jclass, jobject);
140
141 /*
142 * Class: org_lwjgl_opengl_LinuxEvent
143 * Method: nGetButtonTime
144 * Signature: (Ljava/nio/ByteBuffer;)J
145 */
146 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime
147 (JNIEnv *, jclass, jobject);
148
149 /*
150 * Class: org_lwjgl_opengl_LinuxEvent
151 * Method: nGetButtonState
152 * Signature: (Ljava/nio/ByteBuffer;)I
153 */
154 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonState
155 (JNIEnv *, jclass, jobject);
156
157 /*
158 * Class: org_lwjgl_opengl_LinuxEvent
159 * Method: nGetButtonType
160 * Signature: (Ljava/nio/ByteBuffer;)I
161 */
162 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonType
163 (JNIEnv *, jclass, jobject);
164
165 /*
166 * Class: org_lwjgl_opengl_LinuxEvent
167 * Method: nGetButtonButton
168 * Signature: (Ljava/nio/ByteBuffer;)I
169 */
170 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonButton
171 (JNIEnv *, jclass, jobject);
172
173 /*
174 * Class: org_lwjgl_opengl_LinuxEvent
175 * Method: nGetButtonRoot
176 * Signature: (Ljava/nio/ByteBuffer;)J
177 */
178 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonRoot
179 (JNIEnv *, jclass, jobject);
180
181 /*
182 * Class: org_lwjgl_opengl_LinuxEvent
183 * Method: nGetButtonXRoot
184 * Signature: (Ljava/nio/ByteBuffer;)I
185 */
186 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonXRoot
187 (JNIEnv *, jclass, jobject);
188
189 /*
190 * Class: org_lwjgl_opengl_LinuxEvent
191 * Method: nGetButtonYRoot
192 * Signature: (Ljava/nio/ByteBuffer;)I
193 */
194 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonYRoot
195 (JNIEnv *, jclass, jobject);
196
197 /*
198 * Class: org_lwjgl_opengl_LinuxEvent
199 * Method: nGetButtonX
200 * Signature: (Ljava/nio/ByteBuffer;)I
201 */
202 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonX
203 (JNIEnv *, jclass, jobject);
204
205 /*
206 * Class: org_lwjgl_opengl_LinuxEvent
207 * Method: nGetButtonY
208 * Signature: (Ljava/nio/ByteBuffer;)I
209 */
210 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonY
211 (JNIEnv *, jclass, jobject);
212
213 /*
214 * Class: org_lwjgl_opengl_LinuxEvent
215 * Method: nGetKeyAddress
216 * Signature: (Ljava/nio/ByteBuffer;)J
217 */
218 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress
219 (JNIEnv *, jclass, jobject);
220
221 /*
222 * Class: org_lwjgl_opengl_LinuxEvent
223 * Method: nGetKeyTime
224 * Signature: (Ljava/nio/ByteBuffer;)I
225 */
226 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime
227 (JNIEnv *, jclass, jobject);
228
229 /*
230 * Class: org_lwjgl_opengl_LinuxEvent
231 * Method: nGetKeyType
232 * Signature: (Ljava/nio/ByteBuffer;)I
233 */
234 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyType
235 (JNIEnv *, jclass, jobject);
236
237 /*
238 * Class: org_lwjgl_opengl_LinuxEvent
239 * Method: nGetKeyKeyCode
240 * Signature: (Ljava/nio/ByteBuffer;)I
241 */
242 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyKeyCode
243 (JNIEnv *, jclass, jobject);
244
245 /*
246 * Class: org_lwjgl_opengl_LinuxEvent
247 * Method: nGetKeyState
248 * Signature: (Ljava/nio/ByteBuffer;)I
249 */
250 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyState
251 (JNIEnv *, jclass, jobject);
252
253 #ifdef __cplusplus
254 }
255 #endif
256 #endif
8383
8484 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_openIM(JNIEnv *env, jclass unused, jlong display_ptr) {
8585 Display *disp = (Display *)(intptr_t)display_ptr;
86 XSetLocaleModifiers ("@im=none");
8687 XIM xim = XOpenIM(disp, NULL, NULL, NULL);
8788 return (intptr_t)xim;
8889 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxKeyboard */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxKeyboard
5 #define _Included_org_lwjgl_opengl_LinuxKeyboard
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_LinuxKeyboard_LockMapIndex
10 #define org_lwjgl_opengl_LinuxKeyboard_LockMapIndex 1L
11 #undef org_lwjgl_opengl_LinuxKeyboard_NoSymbol
12 #define org_lwjgl_opengl_LinuxKeyboard_NoSymbol 0i64
13 #undef org_lwjgl_opengl_LinuxKeyboard_ShiftMask
14 #define org_lwjgl_opengl_LinuxKeyboard_ShiftMask 1i64
15 #undef org_lwjgl_opengl_LinuxKeyboard_LockMask
16 #define org_lwjgl_opengl_LinuxKeyboard_LockMask 2i64
17 #undef org_lwjgl_opengl_LinuxKeyboard_XLookupChars
18 #define org_lwjgl_opengl_LinuxKeyboard_XLookupChars 2L
19 #undef org_lwjgl_opengl_LinuxKeyboard_XLookupBoth
20 #define org_lwjgl_opengl_LinuxKeyboard_XLookupBoth 4L
21 #undef org_lwjgl_opengl_LinuxKeyboard_KEYBOARD_BUFFER_SIZE
22 #define org_lwjgl_opengl_LinuxKeyboard_KEYBOARD_BUFFER_SIZE 50L
23 /*
24 * Class: org_lwjgl_opengl_LinuxKeyboard
25 * Method: getModifierMapping
26 * Signature: (J)J
27 */
28 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getModifierMapping
29 (JNIEnv *, jclass, jlong);
30
31 /*
32 * Class: org_lwjgl_opengl_LinuxKeyboard
33 * Method: freeModifierMapping
34 * Signature: (J)V
35 */
36 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_freeModifierMapping
37 (JNIEnv *, jclass, jlong);
38
39 /*
40 * Class: org_lwjgl_opengl_LinuxKeyboard
41 * Method: getMaxKeyPerMod
42 * Signature: (J)I
43 */
44 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getMaxKeyPerMod
45 (JNIEnv *, jclass, jlong);
46
47 /*
48 * Class: org_lwjgl_opengl_LinuxKeyboard
49 * Method: lookupModifierMap
50 * Signature: (JI)I
51 */
52 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupModifierMap
53 (JNIEnv *, jclass, jlong, jint);
54
55 /*
56 * Class: org_lwjgl_opengl_LinuxKeyboard
57 * Method: keycodeToKeySym
58 * Signature: (JI)J
59 */
60 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_keycodeToKeySym
61 (JNIEnv *, jclass, jlong, jint);
62
63 /*
64 * Class: org_lwjgl_opengl_LinuxKeyboard
65 * Method: openIM
66 * Signature: (J)J
67 */
68 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_openIM
69 (JNIEnv *, jclass, jlong);
70
71 /*
72 * Class: org_lwjgl_opengl_LinuxKeyboard
73 * Method: createIC
74 * Signature: (JJ)J
75 */
76 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_createIC
77 (JNIEnv *, jclass, jlong, jlong);
78
79 /*
80 * Class: org_lwjgl_opengl_LinuxKeyboard
81 * Method: setupIMEventMask
82 * Signature: (JJJ)V
83 */
84 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_setupIMEventMask
85 (JNIEnv *, jclass, jlong, jlong, jlong);
86
87 /*
88 * Class: org_lwjgl_opengl_LinuxKeyboard
89 * Method: allocateComposeStatus
90 * Signature: ()Ljava/nio/ByteBuffer;
91 */
92 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_allocateComposeStatus
93 (JNIEnv *, jclass);
94
95 /*
96 * Class: org_lwjgl_opengl_LinuxKeyboard
97 * Method: nSetDetectableKeyRepeat
98 * Signature: (JZ)Z
99 */
100 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_nSetDetectableKeyRepeat
101 (JNIEnv *, jclass, jlong, jboolean);
102
103 /*
104 * Class: org_lwjgl_opengl_LinuxKeyboard
105 * Method: destroyIC
106 * Signature: (J)V
107 */
108 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_destroyIC
109 (JNIEnv *, jclass, jlong);
110
111 /*
112 * Class: org_lwjgl_opengl_LinuxKeyboard
113 * Method: closeIM
114 * Signature: (J)V
115 */
116 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_closeIM
117 (JNIEnv *, jclass, jlong);
118
119 /*
120 * Class: org_lwjgl_opengl_LinuxKeyboard
121 * Method: lookupString
122 * Signature: (JLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I
123 */
124 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupString
125 (JNIEnv *, jclass, jlong, jobject, jobject);
126
127 /*
128 * Class: org_lwjgl_opengl_LinuxKeyboard
129 * Method: utf8LookupString
130 * Signature: (JJLjava/nio/ByteBuffer;II)I
131 */
132 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_utf8LookupString
133 (JNIEnv *, jclass, jlong, jlong, jobject, jint, jint);
134
135 /*
136 * Class: org_lwjgl_opengl_LinuxKeyboard
137 * Method: lookupKeysym
138 * Signature: (JI)J
139 */
140 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupKeysym
141 (JNIEnv *, jclass, jlong, jint);
142
143 /*
144 * Class: org_lwjgl_opengl_LinuxKeyboard
145 * Method: toUpper
146 * Signature: (J)J
147 */
148 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_toUpper
149 (JNIEnv *, jclass, jlong);
150
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif
102102 warp_event.xclient.data.l[1] = y;
103103 XSendEvent(disp, win, False, 0, &warp_event);
104104 }
105
106 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetButtonCount(JNIEnv *env, jclass unused, jlong display_ptr) {
107 Display *disp = (Display *)(intptr_t)display_ptr;
108
109 int count = 256;
110
111 unsigned char * pointer_map = malloc(sizeof(unsigned char) * count);
112 count = XGetPointerMapping(disp, pointer_map, count);
113
114 free(pointer_map);
115
116 return count;
117 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxMouse */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxMouse
5 #define _Included_org_lwjgl_opengl_LinuxMouse
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_LinuxMouse_POINTER_WARP_BORDER
10 #define org_lwjgl_opengl_LinuxMouse_POINTER_WARP_BORDER 10L
11 #undef org_lwjgl_opengl_LinuxMouse_WHEEL_SCALE
12 #define org_lwjgl_opengl_LinuxMouse_WHEEL_SCALE 120L
13 #undef org_lwjgl_opengl_LinuxMouse_Button1
14 #define org_lwjgl_opengl_LinuxMouse_Button1 1L
15 #undef org_lwjgl_opengl_LinuxMouse_Button2
16 #define org_lwjgl_opengl_LinuxMouse_Button2 2L
17 #undef org_lwjgl_opengl_LinuxMouse_Button3
18 #define org_lwjgl_opengl_LinuxMouse_Button3 3L
19 #undef org_lwjgl_opengl_LinuxMouse_Button4
20 #define org_lwjgl_opengl_LinuxMouse_Button4 4L
21 #undef org_lwjgl_opengl_LinuxMouse_Button5
22 #define org_lwjgl_opengl_LinuxMouse_Button5 5L
23 #undef org_lwjgl_opengl_LinuxMouse_Button6
24 #define org_lwjgl_opengl_LinuxMouse_Button6 6L
25 #undef org_lwjgl_opengl_LinuxMouse_Button7
26 #define org_lwjgl_opengl_LinuxMouse_Button7 7L
27 #undef org_lwjgl_opengl_LinuxMouse_Button8
28 #define org_lwjgl_opengl_LinuxMouse_Button8 8L
29 #undef org_lwjgl_opengl_LinuxMouse_Button9
30 #define org_lwjgl_opengl_LinuxMouse_Button9 9L
31 #undef org_lwjgl_opengl_LinuxMouse_ButtonPress
32 #define org_lwjgl_opengl_LinuxMouse_ButtonPress 4L
33 #undef org_lwjgl_opengl_LinuxMouse_ButtonRelease
34 #define org_lwjgl_opengl_LinuxMouse_ButtonRelease 5L
35 /*
36 * Class: org_lwjgl_opengl_LinuxMouse
37 * Method: nSendWarpEvent
38 * Signature: (JJJII)V
39 */
40 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nSendWarpEvent
41 (JNIEnv *, jclass, jlong, jlong, jlong, jint, jint);
42
43 /*
44 * Class: org_lwjgl_opengl_LinuxMouse
45 * Method: nGetWindowHeight
46 * Signature: (JJ)I
47 */
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowHeight
49 (JNIEnv *, jclass, jlong, jlong);
50
51 /*
52 * Class: org_lwjgl_opengl_LinuxMouse
53 * Method: nGetWindowWidth
54 * Signature: (JJ)I
55 */
56 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowWidth
57 (JNIEnv *, jclass, jlong, jlong);
58
59 /*
60 * Class: org_lwjgl_opengl_LinuxMouse
61 * Method: nGetButtonCount
62 * Signature: (J)I
63 */
64 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetButtonCount
65 (JNIEnv *, jclass, jlong);
66
67 /*
68 * Class: org_lwjgl_opengl_LinuxMouse
69 * Method: nQueryPointer
70 * Signature: (JJLjava/nio/IntBuffer;)J
71 */
72 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxMouse_nQueryPointer
73 (JNIEnv *, jclass, jlong, jlong, jobject);
74
75 /*
76 * Class: org_lwjgl_opengl_LinuxMouse
77 * Method: nWarpCursor
78 * Signature: (JJII)V
79 */
80 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nWarpCursor
81 (JNIEnv *, jclass, jlong, jlong, jint, jint);
82
83 #ifdef __cplusplus
84 }
85 #endif
86 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_LinuxPeerInfo.c 3358 2010-06-03 15:49:26Z spasi $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3358 $
36 * @version $Revision$
3737 */
3838
3939 #include <jni.h>
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_LinuxPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_LinuxPeerInfo
5 #define _Included_org_lwjgl_opengl_LinuxPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_LinuxPeerInfo
11 * Method: createHandle
12 * Signature: ()Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_createHandle
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengl_LinuxPeerInfo
19 * Method: nGetDisplay
20 * Signature: (Ljava/nio/ByteBuffer;)J
21 */
22 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDisplay
23 (JNIEnv *, jclass, jobject);
24
25 /*
26 * Class: org_lwjgl_opengl_LinuxPeerInfo
27 * Method: nGetDrawable
28 * Signature: (Ljava/nio/ByteBuffer;)J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDrawable
31 (JNIEnv *, jclass, jobject);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
+0
-90
src/native/linux/org_lwjgl_opengl_Pbuffer.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3358 2010-06-03 15:49:26Z spasi $
34 *
35 * Linux Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3358 $
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 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
33 * $Id: context.h 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * Base Win32 display
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @author mojang
39 * @author kappaOne <one.kappa@gmail.com>
40 * @version $Revision$
3941 */
4042
4143 #ifndef __LWJGL_CONTEXT_H
4547 #include <OpenGL/gl.h>
4648 #include <OpenGL/glext.h>
4749 #include "common_tools.h"
50 #include <jawt_md.h>
51
52 enum {
53 NSControlLeftKeyMask = 0x0001,
54 NSControlRightKeyMask = 0x2000,
55 NSShiftLeftKeyMask = 0x0002,
56 NSShiftRightKeyMask = 0x0004,
57 NSCommandLeftKeyMask = 0x0008,
58 NSCommandRightKeyMask = 0x0010,
59 NSAlternateLeftKeyMask = 0x0020,
60 NSAlternateRightKeyMask = 0x0040
61 };
62
63 @class NSOpenGLContext, NSOpenGLPixelFormat, MacOSXOpenGLView, MacOSXKeyableWindow;
4864
4965 typedef struct {
66 MacOSXKeyableWindow *window;
67
68 NSRect display_rect;
69
70 MacOSXOpenGLView *view;
71 NSOpenGLContext *context;
72
73 // Native objects for Java callbacks
74 jobject jdisplay;
75 jobject jmouse;
76 jobject jkeyboard;
77
78 jboolean fullscreen;
79 jboolean undecorated;
80 jboolean resizable;
81 jboolean parented;
82
83 jboolean enableFullscreenModeAPI;
84 jboolean enableHighDPI;
85
86 jboolean resized;
87
88 } MacOSXWindowInfo;
89
90 @interface MacOSXOpenGLView : NSView
91 {
92 @public
93 MacOSXWindowInfo* _parent;
94
95 @private
96 NSOpenGLContext* _openGLContext;
97 NSOpenGLPixelFormat* _pixelFormat;
98 NSTrackingArea * _trackingArea;
99 }
100
101 + (NSOpenGLPixelFormat*)defaultPixelFormat;
102 - (BOOL)windowShouldClose:(id)sender;
103 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
104 - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format;
105 - (void)setOpenGLContext:(NSOpenGLContext*)context;
106 - (NSOpenGLContext*)openGLContext;
107 - (void)clearGLContext;
108 - (void)prepareOpenGL;
109 - (void)update;
110 - (void)lockFocus;
111 - (void)setPixelFormat:(NSOpenGLPixelFormat*)pixelFormat;
112 - (NSOpenGLPixelFormat*)pixelFormat;
113 - (void)setParent:(MacOSXWindowInfo*)parent;
114 - (BOOL)acceptsFirstResponder;
115 @end
116
117 @interface GLLayer : CAOpenGLLayer {
118 @public
119 JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi;
120 JAWT_Rectangle canvasBounds;
121 MacOSXWindowInfo *window_info;
122 bool setViewport;
123 bool autoResizable;
124
125 @private
126 CGLContextObj contextObject;
127 int fboID;
128 int imageRenderBufferID;
129 int depthRenderBufferID;
130 int fboWidth;
131 int fboHeight;
132 }
133
134 - (void) attachLayer;
135 - (void) removeLayer;
136 - (void) blitFrameBuffer;
137
138 - (int) getWidth;
139 - (int) getHeight;
140 @end
141
142 typedef struct {
143 bool isCALayer;
144 bool isWindowed;
145 MacOSXWindowInfo *window_info;
50146 NSOpenGLPixelFormat *pixel_format;
51 bool window;
52 union {
53 NSView *nsview;
54 NSOpenGLPixelBuffer *pbuffer;
55 };
147 NSOpenGLPixelBuffer *pbuffer;
148 NSView *parent;
149 GLLayer *glLayer;
56150 } MacOSXPeerInfo;
57151
58 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered);
152 @interface MacOSXKeyableWindow : NSWindow
153 + (void)createWindow;
154 + (void)destroyWindow;
155 - (BOOL)canBecomeKeyWindow;
156 @end
157
158 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool gl32, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered);
59159 #endif
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
33 * $Id: context.m 3116 2008-08-19 16:46:03Z spasi $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
36 * @version $Revision$
3737 */
3838
3939 #import <CoreFoundation/CoreFoundation.h>
5050 return address;
5151 }
5252
53 static CFBundleRef loadFramework(JNIEnv *env) {
53 static CFBundleRef loadFramework(JNIEnv *env) {
5454 CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenGL.framework");
5555 if (framework_path == NULL) {
5656 printfDebugJava(env, "Failed to allocate string");
5757 return NULL;
58 }
58 }
5959 CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE);
6060 if (url == NULL) {
6161 printfDebugJava(env, "Failed to allocate URL");
8686 }
8787 }
8888
89 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) {
89 NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool gl32, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) {
9090 int bpp;
9191 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
9292 if (use_display_bpp)
93 bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
93 {
94 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { // if OS X 10.6+ use newer api
95 CGDisplayModeRef mode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
96 CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode);
97 if (CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
98 bpp = 32;
99 else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
100 bpp = 16;
101 else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
102 bpp = 8;
103 else
104 bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
105 } else {
106 bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
107 }
108 }
94109 else
95110 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
96
111
97112 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
98113 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
99114 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
104119 bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
105120 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
106121 // 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"));
122 //bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
108123 // TODO: Add sRGB attribute below
109 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
124 //bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
110125
111126 attrib_list_t attribs;
112127 jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
124139 putAttrib(&attribs, NSOpenGLPFASampleBuffers); putAttrib(&attribs, samples > 0 ? 1 : 0);
125140 putAttrib(&attribs, NSOpenGLPFASamples); putAttrib(&attribs, samples);
126141 putAttrib(&attribs, NSOpenGLPFAAuxBuffers); putAttrib(&attribs, num_aux_buffers);
127 if (support_window)
128 putAttrib(&attribs, NSOpenGLPFAWindow);
129 if (support_pbuffer)
130 putAttrib(&attribs, NSOpenGLPFAPixelBuffer);
142 if (gl32) {
143 putAttrib(&attribs, 99); // NSOpenGLPFAOpenGLProfile
144 putAttrib(&attribs, 0x3200); // NSOpenGLProfileVersion3_2Core
145 } else {
146 if (support_window)
147 putAttrib(&attribs, NSOpenGLPFAWindow);
148 if (support_pbuffer)
149 putAttrib(&attribs, NSOpenGLPFAPixelBuffer);
150 }
131151 if (stereo)
132152 putAttrib(&attribs, NSOpenGLPFAStereo);
133153 if (floating_point)
4040 #include "common_tools.h"
4141
4242 /**
43 * $Id: macosx_al.c 3416 2010-09-27 00:25:59Z spasi $
43 * $Id$
4444 *
4545 * This file contains the AL extension assigning mechanism
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 3416 $
48 * @version $Revision$
4949 */
5050
5151 static const struct mach_header* handleOAL = NULL;
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_MacOSXSysImplementation */
3
4 #ifndef _Included_org_lwjgl_MacOSXSysImplementation
5 #define _Included_org_lwjgl_MacOSXSysImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_MacOSXSysImplementation_JNI_VERSION
10 #define org_lwjgl_MacOSXSysImplementation_JNI_VERSION 25L
11 #ifdef __cplusplus
12 }
13 #endif
14 #endif
+0
-73
src/native/macosx/org_lwjgl_input_Mouse.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 }
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_Display.m 3055 2008-04-30 14:58:47Z elias_naur $
33 * $Id$
3434 *
3535 * Mac OS X specific display functions.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3055 $
38 * @author mojang
39 * @author kappaOne <one.kappa@gmail.com>
40 * @version $Revision$
3941 */
4042
43 #import <AppKit/NSApplication.h>
4144 #import <Cocoa/Cocoa.h>
4245 #import <Carbon/Carbon.h>
43 #import <jawt_md.h>
4446 #import <jni.h>
4547 #import <unistd.h>
46 //#import "display.h"
4748 #import "common_tools.h"
4849 #import "org_lwjgl_opengl_MacOSXDisplay.h"
4950 #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) {
51 #import "context.h"
52
53 static NSOpenGLPixelFormat *default_format = nil;
54
55 static NSAutoreleasePool *pool;
56
57 static MacOSXPeerInfo *peer_info;
58
59 static bool leftMouseDown = false;
60 static bool rightMouseDown = false;
61
62 static NSUInteger lastModifierFlags = 0;
63
64 @implementation MacOSXKeyableWindow
65
66 + (void) createWindow {
67 MacOSXWindowInfo *window_info = peer_info->window_info;
68
69 int width = window_info->display_rect.size.width;
70 int height = window_info->display_rect.size.height;
71
72 NSRect view_rect = NSMakeRect(0.0, 0.0, width, height);
73 window_info->view = [[MacOSXOpenGLView alloc] initWithFrame:view_rect pixelFormat:peer_info->pixel_format];
74 [window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
75
76 // Inform the view of its parent window info;
77 [window_info->view setParent:window_info];
78
79 if (window_info->enableHighDPI) {
80 // call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's
81 [window_info->view performSelector:NSSelectorFromString(@"setWantsBestResolutionOpenGLSurface:") withObject:YES];
82 }
83
84 // set nsapp delegate for catching app quit events
85 [NSApp setDelegate:window_info->view];
86
87 if (window_info->context != nil) {
88 [window_info->view setOpenGLContext:window_info->context];
89 }
90
91 if (!window_info->fullscreen) {
92
93 if (window_info->parented) {
94 window_info->window = [peer_info->parent window];
95 [peer_info->parent addSubview:window_info->view];
96 }
97 else {
98
99 int default_window_mask = NSBorderlessWindowMask; // undecorated
100
101 if (!window_info->undecorated) {
102 default_window_mask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
103 }
104
105 if (window_info->resizable) {
106 default_window_mask |= NSResizableWindowMask;
107 }
108
109 window_info->window = [[MacOSXKeyableWindow alloc] initWithContentRect:window_info->display_rect styleMask:default_window_mask backing:NSBackingStoreBuffered defer:NO];
110
111 [window_info->window setContentView:window_info->view];
112 [window_info->window setContentView:window_info->view]; // call twice to fix issue
113
114 // set NSView as delegate of NSWindow to get windowShouldClose events
115 [window_info->window setDelegate:window_info->view];
116 }
117
118 // disable any fixed backbuffer size to allow resizing
119 CGLContextObj cgcontext = (CGLContextObj)[[window_info->view openGLContext] CGLContextObj];
120 CGLDisable(cgcontext, kCGLCESurfaceBackingSize);
121 }
122 else {
123 // set a fixed backbuffer size for fullscreen
124 CGLContextObj cgcontext = (CGLContextObj)[window_info->context CGLContextObj];
125 GLint dim[2] = {width, height};
126 CGLSetParameter(cgcontext, kCGLCPSurfaceBackingSize, dim);
127 CGLEnable(cgcontext, kCGLCESurfaceBackingSize);
128
129 // enter fullscreen mode
130 [window_info->view enterFullScreenMode: [NSScreen mainScreen] withOptions: nil ];
131 window_info->window = [window_info->view window];
132
133 // adjust the NSView bounds to correct mouse coordinates in fullscreen
134 NSSize windowSize = [window_info->window frame].size;
135 NSSize newBounds = NSMakeSize(windowSize.width/width*windowSize.width, windowSize.height/height*windowSize.height);
136 [window_info->view setBoundsSize:newBounds];
137 }
138
139 if (window_info->enableFullscreenModeAPI && window_info->resizable) {
140 // manually create OS X 10.7+ mask to allow compilation on previous OS X versions
141 NSUInteger NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7;
142 [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
143 }
144
145 [window_info->window makeFirstResponder:window_info->view];
146 [window_info->window setInitialFirstResponder:window_info->view];
147 [window_info->window makeKeyAndOrderFront:[NSApplication sharedApplication]];
148 }
149
150 + (void) destroyWindow {
151 MacOSXWindowInfo *window_info = peer_info->window_info;
152
153 if (window_info->fullscreen) {
154 [window_info->view exitFullScreenModeWithOptions: nil];
155 window_info->window = nil;
156 }
157 else {
158 if (peer_info->isCALayer) {
159 peer_info->isCALayer = false;
160 [peer_info->glLayer removeLayer];
161 [peer_info->glLayer release];
162 peer_info->glLayer = nil;
163 return;
164 }
165
166 if (window_info->window != nil) {
167 // if the nsview has no parent then close window
168 if ([window_info->window contentView] == window_info->view) {
169 // release the nsview and remove it from any parent nsview
170 [window_info->view removeFromSuperviewWithoutNeedingDisplay];
171 [window_info->window close];
172 window_info->window = nil;
173 }
174 else {
175 // release the nsview and remove it from any parent nsview
176 [window_info->view removeFromSuperviewWithoutNeedingDisplay];
177 }
178 }
179 }
180 }
181
182 - (BOOL)canBecomeKeyWindow;
183 {
184 return YES;
185 }
186 @end
187
188 @implementation MacOSXOpenGLView
189
190 + (NSOpenGLPixelFormat*)defaultPixelFormat {
191 NSOpenGLPixelFormatAttribute defaultAttribs[] = {
192 NSOpenGLPFADoubleBuffer,
193 NSOpenGLPFADepthSize, 16,
194 NSOpenGLPFAColorSize, 32,
195 0
196 };
197 if (default_format == nil) {
198 default_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:defaultAttribs];
199 }
200 return default_format;
201 }
202
203 - (BOOL)windowShouldClose:(id)sender {
204 if (_parent != nil) {
205 JNIEnv *env = attachCurrentThread();
206 jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
207 jmethodID close_callback = (*env)->GetMethodID(env, display_class, "doHandleQuit", "()V");
208 (*env)->CallVoidMethod(env, _parent->jdisplay, close_callback);
209 }
210 return NO;
211 }
212
213 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
214 [self windowShouldClose:nil];
215 return NSTerminateCancel;
216 }
217
218 - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format {
219 self = [super initWithFrame:frameRect];
220 if (self != nil) {
221 _pixelFormat = [format retain];
222 [[NSNotificationCenter defaultCenter] addObserver:self
223 selector:@selector(_surfaceNeedsUpdate:)
224 name:NSViewGlobalFrameDidChangeNotification
225 object:self];
226 }
227 return self;
228 }
229
230 - (void) _surfaceNeedsUpdate:(NSNotification*)notification {
231 [self update];
232 }
233
234 - (void)setOpenGLContext:(NSOpenGLContext*)context {
235 _openGLContext = context;
236 }
237
238 - (NSOpenGLContext*)openGLContext {
239 return _openGLContext;
240 }
241
242 - (void)clearGLContext {
243 [_openGLContext release];
244 _openGLContext = nil;
245 }
246
247 - (void)prepareOpenGL {
248
249 }
250
251 - (void)update {
252 [_openGLContext update];
253 }
254
255 - (void)lockFocus {
256 [super lockFocus];
257
258 NSOpenGLContext* context = [self openGLContext];
259
260 if (context == nil) return;
261
262 if ([context view] != self) {
263 [context setView:self];
264 }
265
266 [context makeCurrentContext];
267 }
268
269 - (void)setPixelFormat:(NSOpenGLPixelFormat*)pixelFormat {
270 _pixelFormat = [pixelFormat retain];
271 }
272
273 - (NSOpenGLPixelFormat*)pixelFormat {
274 return _pixelFormat;
275 }
276
277 - (BOOL)acceptsFirstResponder {
278 return YES;
279 }
280
281 - (void)setParent:(MacOSXWindowInfo*)parent {
282 _parent = parent;
283 }
284
285 - (void)keyDown:(NSEvent *)event {
286 JNIEnv *env = attachCurrentThread();
287 if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) {
288 return;
289 }
290 long time = [event timestamp] * 1000000000;
291 jclass keyboard_class = (*env)->GetObjectClass(env, _parent->jkeyboard);
292 jmethodID keydown = (*env)->GetMethodID(env, keyboard_class, "keyPressed", "(ILjava/lang/String;J)V");
293
294 // convert key characters from NSString to jstring
295 const char *unichars = [[event characters] UTF8String];
296 jstring characters = (*env)->NewStringUTF(env, unichars);
297
298 (*env)->CallVoidMethod(env, _parent->jkeyboard, keydown, [event keyCode], characters, time);
299 }
300
301 - (void)keyUp:(NSEvent *)event {
302 JNIEnv *env = attachCurrentThread();
303 if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) {
304 return;
305 }
306 long time = [event timestamp] * 1000000000;
307 jclass keyboard_class = (*env)->GetObjectClass(env, _parent->jkeyboard);
308 jmethodID keyup = (*env)->GetMethodID(env, keyboard_class, "keyReleased", "(ILjava/lang/String;J)V");
309
310 // convert key characters from NSString to jstring
311 const char *unichars = [[event characters] UTF8String];
312 jstring characters = (*env)->NewStringUTF(env, unichars);
313
314 (*env)->CallVoidMethod(env, _parent->jkeyboard, keyup, [event keyCode], characters, time);
315 }
316
317 - (void)flagsChanged:(NSEvent *)event {
318 JNIEnv *env = attachCurrentThread();
319 if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) {
320 return;
321 }
322 long time = [event timestamp] * 1000000000;
323
324 NSUInteger modifierFlags = [event modifierFlags];
325 unsigned short keyCode = [event keyCode];
326
327 NSUInteger mask = ~0;
328
329 switch(keyCode) {
330 case kVK_Control : mask = NSControlLeftKeyMask; break;
331 case kVK_Shift : mask = NSShiftLeftKeyMask; break;
332 case kVK_RightShift : mask = NSShiftRightKeyMask; break;
333 case kVK_Command : mask = NSCommandLeftKeyMask; break;
334 case 0x36 : mask = NSCommandRightKeyMask; break; // Should be: kVK_RightCommand -- missing O.o
335 case kVK_Option : mask = NSAlternateLeftKeyMask; break;
336 case kVK_RightOption : mask = NSAlternateRightKeyMask; break;
337 case kVK_RightControl: mask = NSControlRightKeyMask; break;
338 case kVK_CapsLock : mask = NSAlphaShiftKeyMask; break;
339 case kVK_Function : mask = NSFunctionKeyMask; break;
340 // case 0x?? : mask = NSNumericPadKeyMask; break; // Didn't have the keycode for this one :(
341 default:
342 // key code not specified when left Command key + Tab moves focus to another Window, therefore manually detect and specify correct key code
343 if (((lastModifierFlags & NSCommandLeftKeyMask) == NSCommandLeftKeyMask) && ((modifierFlags & NSCommandLeftKeyMask) != NSCommandLeftKeyMask)) {
344 keyCode = kVK_Command; // left command key code
345 }
346 // key code not specified when right Command key + Tab moves focus to another Window, therefore manually detect and specify correct key code
347 else if (((lastModifierFlags & NSCommandLeftKeyMask) == NSCommandLeftKeyMask) && ((modifierFlags & NSCommandLeftKeyMask) != NSCommandLeftKeyMask)) {
348 keyCode = 0x36; // right command key code
349 }
350 else {
351 NSLog(@"Unknown modifier with keycode: %d\n", [event keyCode]);
352 return;
353 }
354 }
355
356 // save current modifierFlags for next use
357 lastModifierFlags = [event modifierFlags];
358
359 jclass keyboard_class = (*env)->GetObjectClass(env, _parent->jkeyboard);
360
361 jmethodID keyMethod;
362 if ((modifierFlags & mask) == mask) {
363 keyMethod = (*env)->GetMethodID(env, keyboard_class, "keyPressed", "(ILjava/lang/String;J)V");
364 } else {
365 keyMethod = (*env)->GetMethodID(env, keyboard_class, "keyReleased", "(ILjava/lang/String;J)V");
366 }
367
368 (*env)->CallVoidMethod(env, _parent->jkeyboard, keyMethod, keyCode, NULL, time);
369 }
370
371 - (void)mouseButtonState:(NSEvent *)event :(int)button :(int)state {
372 JNIEnv *env = attachCurrentThread();
373 if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) {
374 return;
375 }
376 long time = [event timestamp] * 1000000000;
377 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
378 jmethodID mousebutton = (*env)->GetMethodID(env, mouse_class, "setButton", "(IIJ)V");
379 (*env)->CallVoidMethod(env, _parent->jmouse, mousebutton, button, state, time);
380 }
381
382 - (void)mouseDown:(NSEvent *)event {
383 if ([event modifierFlags] & NSControlKeyMask) {
384 rightMouseDown = true;
385 [self rightMouseDown:event];
386 return;
387 }
388
389 leftMouseDown = true;
390 [self mouseButtonState:event :0 :1];
391 }
392
393 - (void)rightMouseDown:(NSEvent *)event {
394 [self mouseButtonState:event :1 :1];
395 }
396
397 - (void)otherMouseDown:(NSEvent *)event {
398 [self mouseButtonState:event :2 :1];
399 }
400
401 - (void)mouseUp:(NSEvent *)event {
402 if (rightMouseDown) {
403 rightMouseDown = false;
404 [self rightMouseUp:event];
405 }
406
407 if (leftMouseDown) {
408 leftMouseDown = false;
409 [self mouseButtonState:event :0 :0];
410 }
411 }
412
413 - (void)rightMouseUp:(NSEvent *)event {
414 [self mouseButtonState:event :1 :0];
415 }
416
417 - (void)otherMouseUp:(NSEvent *)event {
418 [self mouseButtonState:event :2 :0];
419 }
420
421 - (void)mouseDragged:(NSEvent *)event {
422 JNIEnv *env = attachCurrentThread();
423 if (env == nil || event == nil || _parent == nil || _parent->jmouse == nil) {
424 return;
425 }
426 long time = [event timestamp] * 1000000000;
427 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
428 jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
429 NSPoint loc = [self convertPoint:[event locationInWindow] toView:nil];
430 (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
431 }
432
433 - (void)rightMouseDragged:(NSEvent *)event {
434 JNIEnv *env = attachCurrentThread();
435 if (env == nil || event == nil || _parent == nil || _parent->jmouse == nil) {
436 return;
437 }
438 long time = [event timestamp] * 1000000000;
439 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
440 jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
441 NSPoint loc = [self convertPoint:[event locationInWindow] toView:nil];
442 (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
443 }
444
445 - (void)otherMouseDragged:(NSEvent *)event {
446 JNIEnv *env = attachCurrentThread();
447 if (env == nil || event == nil || _parent == nil || _parent->jmouse == nil) {
448 return;
449 }
450 long time = [event timestamp] * 1000000000;
451 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
452 jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
453 NSPoint loc = [self convertPoint:[event locationInWindow] toView:nil];
454 (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
455 }
456
457 - (void)mouseMoved:(NSEvent *)event {
458 JNIEnv *env = attachCurrentThread();
459 if (env == nil || event == nil || _parent == nil || _parent->jmouse == nil) {
460 return;
461 }
462 long time = [event timestamp] * 1000000000;
463 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
464 jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
465 NSPoint loc = [self convertPoint:[event locationInWindow] toView:nil];
466 (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
467 }
468
469 - (void)scrollWheel:(NSEvent *)event {
470 JNIEnv *env = attachCurrentThread();
471 if (env == nil || event == nil || _parent == nil) {
472 return;
473 }
474 long time = [event timestamp] * 1000000000;
475 jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
476 jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
477 NSPoint loc = [self convertPoint:[event locationInWindow] toView:nil];
478 (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 1.0f, time);
479 }
480
481 - (void)viewDidMoveToWindow {
482 [[NSNotificationCenter defaultCenter] addObserver:self
483 selector:@selector(windowResized:)
484 name:NSWindowDidResizeNotification
485 object:[self window]];
486 }
487
488 - (void)dealloc {
489 [[NSNotificationCenter defaultCenter] removeObserver:self];
490 [super dealloc];
491 }
492
493 - (void)windowResized:(NSNotification *)notification;
494 {
495 if (_parent != nil) {
496 _parent->display_rect = [self frame];
497 _parent->resized = JNI_TRUE;
498 }
499 }
500
501 - (void)viewDidChangeBackingProperties {
502 JNIEnv *env = attachCurrentThread();
503 if (env == nil || _parent == nil || _parent->jdisplay == nil) {
504 return;
505 }
506
507 jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
508 jmethodID setScaleFactor_callback = (*env)->GetMethodID(env, display_class, "setScaleFactor", "(F)V");
509
510 CGFloat scaleFactor;
511
512 // call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's
513 SEL selector = NSSelectorFromString(@"backingScaleFactor");
514
515 // as we are using a runtime selector, we need to use NSInvocations to get a CGFloat value back from it
516 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[[self window] class] instanceMethodSignatureForSelector:selector]];
517 [invocation setSelector:selector];
518 [invocation setTarget:[self window]];
519 [invocation invoke];
520 [invocation getReturnValue:&scaleFactor];
521
522 (*env)->CallVoidMethod(env, _parent->jdisplay, setScaleFactor_callback, scaleFactor);
523 }
524
525 -(void)updateTrackingAreas {
526 if(_trackingArea != nil) {
527 [self removeTrackingArea:_trackingArea];
528 [_trackingArea release];
529 }
530
531 int options = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways);
532 _trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
533 options:options
534 owner:self
535 userInfo:nil];
536 [self addTrackingArea:_trackingArea];
537
538 // since nstrackingarea's don't know if mouse is inside or outside on creation
539 // manually detect this and send a fake mouse entered/exited message
540 NSPoint mouseLocation = [[self window] mouseLocationOutsideOfEventStream];
541 mouseLocation = [self convertPoint:mouseLocation fromView:nil];
542
543 if (NSPointInRect(mouseLocation, [self bounds])) {
544 [self mouseEntered:nil];
545 }
546 else {
547 [self mouseExited:nil];
548 }
549 }
550
551 -(void)mouseEntered:(NSEvent *)event {
552 JNIEnv *env = attachCurrentThread();
553 if (env == nil || _parent == nil || _parent->jdisplay == nil) {
554 return;
555 }
556
557 jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
558 jmethodID mouseInsideWindow_callback = (*env)->GetMethodID(env, display_class, "mouseInsideWindow", "(Z)V");
559 (*env)->CallVoidMethod(env, _parent->jdisplay, mouseInsideWindow_callback, JNI_TRUE);
560 }
561
562 -(void)mouseExited:(NSEvent *)event {
563 JNIEnv *env = attachCurrentThread();
564 if (env == nil || _parent == nil || _parent->jdisplay == nil) {
565 return;
566 }
567
568 jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
569 jmethodID mouseInsideWindow_callback = (*env)->GetMethodID(env, display_class, "mouseInsideWindow", "(Z)V");
570 (*env)->CallVoidMethod(env, _parent->jdisplay, mouseInsideWindow_callback, JNI_FALSE);
571 }
572
573 - (void) drawRect:(NSRect)rect {
574 // set black as the default background color
575 // for the nsview to avoid white flash on fullscreen
576 [[NSColor blackColor] setFill];
577 NSRectFill(rect);
578 }
579 @end
580
581 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsMiniaturized(JNIEnv *env, jobject this, jobject window_handle) {
582 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
583 return (jboolean)[window_info->window isMiniaturized];
584 }
585
586 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsFocused(JNIEnv *env, jobject this, jobject window_handle) {
587 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
588 // Display is focused if nswindow is key window and nsview is first responder in that nswindow
589 return (jboolean)([[window_info->view window] isKeyWindow] && [[window_info->view window] firstResponder] == window_info->view);
590 }
591
592 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nResizeWindow(JNIEnv *env, jobject this, jobject window_handle, jint x, jint y, jint width, jint height) {
593 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
594 window_info->display_rect = NSMakeRect(x, y, width, height);
595 [window_info->window setFrame:window_info->display_rect display:false];
596 [window_info->view update];
597 }
598
599 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWasResized(JNIEnv *env, jobject this, jobject window_handle) {
600 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
601 jboolean was_resized = window_info->resized;
602 window_info->resized = JNI_FALSE;
603 return was_resized;
604 }
605
606 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetWidth(JNIEnv *env, jobject this, jobject window_handle) {
607 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
608 jint width = window_info->display_rect.size.width;
609 return width;
610 }
611
612 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetHeight(JNIEnv *env, jobject this, jobject window_handle) {
613 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
614 jint height = window_info->display_rect.size.height;
615 return height;
616 }
617
618 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetResizable(JNIEnv *env, jobject this, jobject window_handle, jboolean resizable) {
619 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
620 NSUInteger style_mask = [window_info->window styleMask];
621 if (resizable == true) {
622 style_mask |= NSResizableWindowMask;
623 } else {
624 style_mask &= ~NSResizableWindowMask;
625 }
626 [window_info->window setStyleMask:style_mask];
627
628 if (window_info->enableFullscreenModeAPI) {
629 if (resizable) {
630 // manually create OS X 10.7+ mask to allow compilation on previous OS X versions
631 NSUInteger NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7;
632 [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
633 }
634 else {
635 // manually create OS X 10.7+ mask to allow compilation on previous OS X versions
636 NSUInteger NSFullScreenWindowMask = 1 << 14;
637 // on disabling resizing exit fullscreen mode exit otherwise will be stuck in it
638 if ((style_mask & NSFullScreenWindowMask) == NSFullScreenWindowMask) {
639 // call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's
640 [window_info->window performSelector:NSSelectorFromString(@"toggleFullScreen:") withObject:nil];
641 }
642 [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
643 }
644 }
645 }
646
647 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetX(JNIEnv *env, jobject this, jobject window_handle) {
648 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
649 jint x = [[window_info->view window] frame].origin.x;
650 return x;
651 }
652
653 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetY(JNIEnv *env, jobject this, jobject window_handle) {
654 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
655
656 NSRect screenRect = [[window_info->window screen] frame];
657 NSRect winRect = [[window_info->view window] frame];
658
659 // get top corner of window frame, also flip coords so origin is in top left
660 jint y = screenRect.size.height - (winRect.origin.y + winRect.size.height) - 1;
661 return y;
662 }
663
664 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle(JNIEnv *env, jobject this, jobject window_handle, jobject title_buffer) {
665 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
666 const char *title_cstr = (const char *)(*env)->GetDirectBufferAddress(env, title_buffer);
667 NSString *title = [[NSString alloc] initWithUTF8String:title_cstr];
668 [window_info->window performSelectorOnMainThread:@selector(setTitle:) withObject:title waitUntilDone:NO];
669 }
670
671 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jboolean enableFullscreenModeAPI, jboolean enableHighDPI, jobject peer_info_handle, jobject window_handle) {
672
673 pool = [[NSAutoreleasePool alloc] init];
674
675 peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
676
677 if (peer_info->isCALayer && !fullscreen) {
678 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
679 window_info->fullscreen = fullscreen;
680 window_info->undecorated = undecorated;
681 window_info->parented = parented;
682 window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
683
684 return window_handle;
685 }
686
687 if (window_handle == NULL) {
688 window_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXWindowInfo));
689 if (window_handle == NULL) {
690 throwException(env, "Could not create handle buffer");
691 return NULL;
692 }
693 }
694
695 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
696
697 window_info->fullscreen = fullscreen;
698 window_info->undecorated = undecorated;
699 window_info->resizable = resizable;
700 window_info->parented = parented;
701 window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
702 window_info->enableHighDPI = enableHighDPI;
703
704 peer_info->window_info = window_info;
705 peer_info->isWindowed = true;
706
707 window_info->display_rect = NSMakeRect(x, [[NSScreen mainScreen] frame].size.height - y - height, width, height);
708
709 // Cache the necessary info for window-close callbacks into the JVM
710 if (window_info->jdisplay == NULL) {
711 window_info->jdisplay = (*env)->NewGlobalRef(env, this);
712 }
713
714 // create window on main thread
715 [MacOSXKeyableWindow performSelectorOnMainThread:@selector(createWindow) withObject:nil waitUntilDone:YES];
716
717 return window_handle;
718 }
719
720 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyWindow(JNIEnv *env, jobject this, jobject window_handle) {
721
722 // destroy window on main thread
723 [MacOSXKeyableWindow performSelectorOnMainThread:@selector(destroyWindow) withObject:nil waitUntilDone:YES];
724
725 [pool drain];
726 }
727
728 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyCALayer(JNIEnv *env, jobject this, jobject peer_info_handle) {
729 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
730 if (peer_info->isCALayer) {
731 peer_info->isCALayer = false;
732 [peer_info->glLayer performSelectorOnMainThread:@selector(removeLayer) withObject:nil waitUntilDone:YES];
733 [peer_info->glLayer release];
734 peer_info->glLayer = nil;
735 }
736 }
737
738 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsNativeMode(JNIEnv *env, jobject this, jobject peer_info_handle) {
739 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
740 if (peer_info->isCALayer) {
741 return JNI_FALSE;
742 }
743 else {
744 return JNI_TRUE;
745 }
746 }
747
748 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetCurrentDisplayMode(JNIEnv *env, jobject this) {
749
750 jclass displayClass = (*env)->GetObjectClass(env, this);
751 jmethodID createDisplayModeMethod = (*env)->GetMethodID(env, displayClass, "createDisplayMode", "(IIII)Ljava/lang/Object;");
752
753 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { // if OS X 10.6+ use newer api
754
755 CGDisplayModeRef mode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
756
757 int width = (int) CGDisplayModeGetWidth(mode);
758 int height = (int) CGDisplayModeGetHeight(mode);
759 int refreshRate = (int)CGDisplayModeGetRefreshRate(mode);
760 int bitsPerPixel;
761
762 // get bitsPerPixel
763 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
764
765 if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
766 bitsPerPixel = 16;
767 }
768 else {
769 bitsPerPixel = 32;
770 }
771
772 jobject displayMode = (*env)->CallObjectMethod(env, this, createDisplayModeMethod, width, height, bitsPerPixel, refreshRate);
773
774 return displayMode;
775
776 } else {
777
778 CFDictionaryRef mode = CGDisplayCurrentMode(CGMainDisplayID());
779
780 long bitsPerPixel = 0;
781 long width = 0;
782 long height = 0;
783 long refreshRate = 0;
784
785 CFNumberRef value;
786
787 value = CFDictionaryGetValue(mode, kCGDisplayBitsPerPixel);
788 CFNumberGetValue(value, kCFNumberLongType, &bitsPerPixel);
789
790 value = CFDictionaryGetValue(mode, kCGDisplayWidth);
791 CFNumberGetValue(value, kCFNumberLongType, &width);
792
793 value = CFDictionaryGetValue(mode, kCGDisplayHeight);
794 CFNumberGetValue(value, kCFNumberLongType, &height);
795
796 value = CFDictionaryGetValue(mode, kCGDisplayRefreshRate);
797 CFNumberGetValue(value, kCFNumberLongType, &refreshRate);
798
799 jobject displayMode = (*env)->CallObjectMethod(env, this, createDisplayModeMethod, width, height, bitsPerPixel, refreshRate);
800
801 return displayMode;
802 }
803 }
804
805 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetDisplayModes(JNIEnv *env, jobject this, jobject modesList) {
806
807 jclass displayClass = (*env)->GetObjectClass(env, this);
808 jmethodID addDisplayModeMethod = (*env)->GetMethodID(env, displayClass, "addDisplayMode", "(Ljava/lang/Object;IIII)V");
809
810 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { // if OS X 10.6+ use newer api
811
812 CFArrayRef modes = CGDisplayCopyAllDisplayModes(kCGDirectMainDisplay, NULL);
813
814 int i = 0;
815
816 for (i = 0; i < CFArrayGetCount(modes); i++) {
817 CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
818
819 int width = (int) CGDisplayModeGetWidth(mode);
820 int height = (int) CGDisplayModeGetHeight(mode);
821 int refreshRate = (int)CGDisplayModeGetRefreshRate(mode);
822 int bitsPerPixel;
823
824 // get bitsPerPixel
825 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
826 if(CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
827 bitsPerPixel = 32;
828 }
829 else if(CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
830 bitsPerPixel = 16;
831 }
832 else {
833 continue; // ignore DisplayMode of other bitsPerPixel rates
834 }
835
836 (*env)->CallVoidMethod(env, this, addDisplayModeMethod, modesList, width, height, bitsPerPixel, refreshRate);
837 }
838
839 } else {
840
841 CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID());
842 CFIndex index, count;
843 CFDictionaryRef mode;
844
845 count = CFArrayGetCount(modes);
846
847 for (index = 0; index < count; index++) {
848 mode = CFArrayGetValueAtIndex(modes, index);
849
850 long bitsPerPixel = 0;
851 long width = 0;
852 long height = 0;
853 long refreshRate = 0;
854
855 CFNumberRef value;
856
857 value = CFDictionaryGetValue(mode, kCGDisplayBitsPerPixel);
858 CFNumberGetValue(value, kCFNumberLongType, &bitsPerPixel);
859
860 value = CFDictionaryGetValue(mode, kCGDisplayWidth);
861 CFNumberGetValue(value, kCFNumberLongType, &width);
862
863 value = CFDictionaryGetValue(mode, kCGDisplayHeight);
864 CFNumberGetValue(value, kCFNumberLongType, &height);
865
866 value = CFDictionaryGetValue(mode, kCGDisplayRefreshRate);
867 CFNumberGetValue(value, kCFNumberLongType, &refreshRate);
868
869 (*env)->CallVoidMethod(env, this, addDisplayModeMethod, modesList, width, height, bitsPerPixel, refreshRate);
870 }
871 }
872
873 }
874
875 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion(JNIEnv *env, jobject ignored) {
55876 return org_lwjgl_MacOSXSysImplementation_JNI_VERSION;
56877 }
57878
61882
62883 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) {
63884 const CGGammaValue *values = (*env)->GetDirectBufferAddress(env, gamma_buffer);
64 CGTableCount table_size = (*env)->GetDirectBufferCapacity(env, gamma_buffer);
885 uint32_t table_size = (*env)->GetDirectBufferCapacity(env, gamma_buffer);
65886 CGDisplayErr err = CGSetDisplayTransferByTable(kCGDirectMainDisplay, table_size, values, values, values);
66887 if (err != CGDisplayNoErr) {
67888 throwException(env, "Could not set display gamma");
68889 }
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 }
890 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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$
34 *
35 * Mac OS X mouse handling.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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 CGAssociateMouseAndMouseCursorPosition(true);
60 }
61
62 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas(JNIEnv *env, jclass unused, jobject delta_buffer) {
63 int32_t dx, dy;
64 CGGetLastMouseDelta(&dx, &dy);
65 int buffer_length = (*env)->GetDirectBufferCapacity(env, delta_buffer);
66 if (buffer_length != 2) {
67 printfDebugJava(env, "Delta buffer not large enough!");
68 return;
69 }
70 jint *buffer = (*env)->GetDirectBufferAddress(env, delta_buffer);
71 buffer[0] = dx;
72 buffer[1] = dy;
73 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXCanvasPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXCanvasPeerInfo
5 #define _Included_org_lwjgl_opengl_MacOSXCanvasPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_MacOSXCanvasPeerInfo
11 * Method: nInitHandle
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;ZZII)Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
15 (JNIEnv *, jclass, jobject, jobject, jobject, jboolean, jboolean, jint, jint);
16
17 /*
18 * Class: org_lwjgl_opengl_MacOSXCanvasPeerInfo
19 * Method: nSetLayerPosition
20 * Signature: (Ljava/nio/ByteBuffer;II)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerPosition
23 (JNIEnv *, jclass, jobject, jint, jint);
24
25 /*
26 * Class: org_lwjgl_opengl_MacOSXCanvasPeerInfo
27 * Method: nSetLayerBounds
28 * Signature: (Ljava/nio/ByteBuffer;IIII)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerBounds
31 (JNIEnv *, jclass, jobject, jint, jint, jint, jint);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_MacOSXCanvasPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @author Pelle Johnsen
37 * @author kappaOne <one.kappa@gmail.com>
38 * @version $Revision$
3739 */
3840
41 #import <Cocoa/Cocoa.h>
3942 #include <jni.h>
4043 #include <jawt_md.h>
4144 #include "awt_tools.h"
4346 #include "context.h"
4447 #include "common_tools.h"
4548
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
47 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) {
49 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
50 (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle, jobject window_handle, jboolean forceCALayer, jboolean autoResizable, jint x, jint y) {
4851 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
52
4953 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
5054 AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
5155 JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo;
52 peer_info->nsview = macosx_dsi->cocoaViewRef;
53 peer_info->window = true;
56
57 // force CALayer usage or check if CALayer is supported (i.e. on Java 5 and Java 6)
58 if(forceCALayer || (surface->awt.version & 0x80000000)) { //JAWT_MACOSX_USE_CALAYER) {
59
60 if (macosx_dsi != NULL) {
61
62 if (window_handle == NULL) {
63 window_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXWindowInfo));
64 if (window_handle == NULL) {
65 throwException(env, "Could not create handle buffer");
66 }
67 } else if (peer_info->window_info->window != nil) {
68 return window_handle;
69 }
70
71 if (peer_info->isCALayer) {
72 [peer_info->glLayer release];
73 }
74
75 peer_info->glLayer = [GLLayer new];
76
77 peer_info->glLayer->macosx_dsi = macosx_dsi;
78 peer_info->window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
79 peer_info->glLayer->window_info = peer_info->window_info;
80 peer_info->glLayer->autoResizable = autoResizable;
81
82 /* we set bounds as requested w/ frame function */
83 peer_info->glLayer.frame = CGRectMake(x, y, surface->dsi->bounds.width, surface->dsi->bounds.height);
84
85 [peer_info->glLayer performSelectorOnMainThread:@selector(createWindow:) withObject:peer_info->pixel_format waitUntilDone:YES];
86
87 peer_info->isCALayer = true;
88 peer_info->isWindowed = true;
89 peer_info->parent = nil;
90
91 [pool release];
92 return window_handle;
93 }
94 }
95
96 // no CALayer support, fallback to using legacy method of getting the NSView of an AWT Canvas
97 peer_info->parent = macosx_dsi->cocoaViewRef;
98 peer_info->isCALayer = false;
99 peer_info->isWindowed = true;
100
54101 [pool release];
55 }
102 return NULL;
103 }
104
105 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerPosition
106 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint x, jint y) {
107 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
108
109 if (peer_info->glLayer != nil) {
110 NSPoint point = NSMakePoint(x, y);
111 NSValue *value = [NSValue valueWithPoint:point];
112 [peer_info->glLayer performSelectorOnMainThread:@selector(updatePosition:) withObject:value waitUntilDone:NO];
113 }
114 }
115
116 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerBounds
117 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint x, jint y, jint width, jint height) {
118 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
119
120 if (peer_info->glLayer != nil) {
121 NSRect rect = NSMakeRect(x, y, width, height);
122 NSValue *value = [NSValue valueWithRect:rect];
123 [peer_info->glLayer performSelectorOnMainThread:@selector(updateBounds:) withObject:value waitUntilDone:NO];
124 }
125 }
126
127 @implementation GLLayer
128
129 - (void) attachLayer {
130 self.asynchronous = YES;
131 self.needsDisplayOnBoundsChange = YES;
132 self.opaque = NO;
133 if (autoResizable) {
134 self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
135 }
136 else {
137 self.autoresizingMask = kCALayerNotSizable;
138 }
139
140 // get root layer of the AWT Canvas and add self to it
141 id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)macosx_dsi;
142
143 if (surfaceLayers.layer != self) {
144 surfaceLayers.layer = self;
145 }
146 }
147
148 - (void) removeLayer {
149
150 // clean up resources
151 glDeleteFramebuffersEXT(1, &fboID);
152 glDeleteRenderbuffersEXT(1, &imageRenderBufferID);
153 glDeleteRenderbuffersEXT(1, &depthRenderBufferID);
154
155 // finish any pending blits before destroying the offscreen window to prevent crashes
156 glFinish();
157
158 // destroy offscreen Display window
159 [self destroyWindow];
160
161 // remove self from root layer
162 [self removeFromSuperlayer];
163 }
164
165 - (void)updatePosition:(NSValue*)value {
166 NSPoint point = [value pointValue];
167 self.position = CGPointMake(point.x, point.y);
168 }
169
170 - (void)updateBounds:(NSValue*)value {
171 NSRect rect = [value rectValue];
172 self.frame = CGRectMake(rect.origin.x, rect.origin.y,
173 rect.size.width, rect.size.height);
174 }
175
176 - (int) getWidth {
177 return canvasBounds.width;
178 }
179
180 - (int) getHeight {
181 return canvasBounds.height;
182 }
183
184 - (void) createWindow:(NSOpenGLPixelFormat*)pixel_format {
185 if (window_info->window != nil) {
186 [window_info->window close];
187 }
188
189 window_info->display_rect = [[NSScreen mainScreen] frame];
190
191 window_info->view = [[MacOSXOpenGLView alloc] initWithFrame:window_info->display_rect pixelFormat:pixel_format];
192
193 window_info->window = [[MacOSXKeyableWindow alloc] initWithContentRect:window_info->display_rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
194 [window_info->window setContentView:window_info->view];
195
196 [window_info->window orderOut:nil];
197 }
198
199 - (void) destroyWindow {
200 if (window_info->window != nil) {
201 [window_info->view removeFromSuperviewWithoutNeedingDisplay];
202 [window_info->window close];
203 window_info->window = nil;
204 }
205 }
206
207 - (void) blitFrameBuffer {
208
209 // get the size of the CALayer/AWT Canvas
210 int width = self.bounds.size.width;
211 int height = self.bounds.size.height;
212
213 if (width != fboWidth || height != fboHeight) {
214
215 // store current fbo/renderbuffers for later deletion
216 int oldFboID = fboID;
217 int oldImageRenderBufferID = imageRenderBufferID;
218 int oldDepthRenderBufferID = depthRenderBufferID;
219
220 // create new fbo
221 int tempFBO;
222 glGenFramebuffersEXT(1, &tempFBO);
223
224 // create new render buffers
225 glGenRenderbuffersEXT(1, &imageRenderBufferID);
226 glGenRenderbuffersEXT(1, &depthRenderBufferID);
227
228 // switch to new fbo to attach render buffers
229 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tempFBO);
230
231 // initialize and attach image render buffer
232 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, imageRenderBufferID);
233 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, width, height);
234 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, imageRenderBufferID);
235
236 // initialize and attach depth render buffer
237 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBufferID);
238 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
239 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthRenderBufferID);
240
241 // clear garbage background on new fbo
242 glClearColor(0.0, 0.0, 0.0, 1.0);
243 glClear(GL_COLOR_BUFFER_BIT);
244
245 // blit frameBuffer to the new fbo
246 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
247 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, tempFBO);
248 glBlitFramebufferEXT(0, 0, width, height,
249 0, 0, width, height,
250 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
251 GL_NEAREST);
252
253 glFinish(); // finish before using new fbo and resizing the window
254
255 // set new fbo and its sizes
256 fboID = tempFBO;
257 fboWidth = width;
258 fboHeight = height;
259
260 // set the size of the offscreen frame buffer window
261 window_info->display_rect = NSMakeRect(0, 0, width, height);
262
263 // clean up the old fbo and renderBuffers
264 glDeleteFramebuffersEXT(1, &oldFboID);
265 glDeleteRenderbuffersEXT(1, &oldImageRenderBufferID);
266 glDeleteRenderbuffersEXT(1, &oldDepthRenderBufferID);
267 }
268 else {
269 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
270 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fboID);
271
272 glBlitFramebufferEXT(0, 0, width, height,
273 0, 0, width, height,
274 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
275 GL_NEAREST);
276 }
277
278 // restore default framebuffer
279 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
280 }
281
282 -(void)drawInCGLContext:(CGLContextObj)glContext
283 pixelFormat:(CGLPixelFormatObj)pixelFormat
284 forLayerTime:(CFTimeInterval)timeInterval
285 displayTime:(const CVTimeStamp *)timeStamp {
286
287 // set the current context
288 CGLSetCurrentContext(glContext);
289
290 // get the size of the CALayer/AWT Canvas
291 int width = self.bounds.size.width;
292 int height = self.bounds.size.height;
293
294 if (width != fboWidth || height != fboHeight) {
295 // clear garbage background before lwjgl fbo blit
296 glClearColor(0.0, 0.0, 0.0, 1.0);
297 glClear(GL_COLOR_BUFFER_BIT);
298 }
299
300 // read the LWJGL FBO and blit it into this CALayers FBO
301 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fboID);
302 glBlitFramebufferEXT(0, 0, width, height,
303 0, 0, width, height,
304 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
305 GL_NEAREST);
306
307 // call super to finalize the drawing - by default all it does is call glFlush()
308 [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
309 }
310
311 -(BOOL)canDrawInCGLContext:(CGLContextObj)glContext
312 pixelFormat:(CGLPixelFormatObj)pixelFormat
313 forLayerTime:(CFTimeInterval)timeInterval
314 displayTime:(const CVTimeStamp *)timeStamp {
315 return YES;
316 }
317
318 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat {
319 CGLCreateContext(pixelFormat, [window_info->context CGLContextObj], &contextObject);
320 return contextObject;
321 }
322
323 - (void)releaseCGLContext:(CGLContextObj)glContext {
324 CGLClearDrawable(contextObject);
325 // disable releasing context due to nvidia crash bug when releasing shared contexts
326 //CGLDestroyContext(contextObject);
327 }
328
329 - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask {
330 return CGLGetPixelFormat([window_info->context CGLContextObj]);
331 }
332
333 - (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat {
334
335 }
336
337 @end
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXContextImplementation */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXContextImplementation
5 #define _Included_org_lwjgl_opengl_MacOSXContextImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_MacOSXContextImplementation
11 * Method: nCreate
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCreate
15 (JNIEnv *, jclass, jobject, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_MacOSXContextImplementation
19 * Method: getCGLShareGroup
20 * Signature: (Ljava/nio/ByteBuffer;)J
21 */
22 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_getCGLShareGroup
23 (JNIEnv *, jobject, jobject);
24
25 /*
26 * Class: org_lwjgl_opengl_MacOSXContextImplementation
27 * Method: nSwapBuffers
28 * Signature: (Ljava/nio/ByteBuffer;)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSwapBuffers
31 (JNIEnv *, jclass, jobject);
32
33 /*
34 * Class: org_lwjgl_opengl_MacOSXContextImplementation
35 * Method: nUpdate
36 * Signature: (Ljava/nio/ByteBuffer;)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nUpdate
39 (JNIEnv *, jclass, jobject);
40
41 /*
42 * Class: org_lwjgl_opengl_MacOSXContextImplementation
43 * Method: nReleaseCurrentContext
44 * Signature: ()V
45 */
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nReleaseCurrentContext
47 (JNIEnv *, jclass);
48
49 /*
50 * Class: org_lwjgl_opengl_MacOSXContextImplementation
51 * Method: clearDrawable
52 * Signature: (Ljava/nio/ByteBuffer;)V
53 */
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_clearDrawable
55 (JNIEnv *, jclass, jobject);
56
57 /*
58 * Class: org_lwjgl_opengl_MacOSXContextImplementation
59 * Method: setView
60 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
61 */
62 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_setView
63 (JNIEnv *, jclass, jobject, jobject);
64
65 /*
66 * Class: org_lwjgl_opengl_MacOSXContextImplementation
67 * Method: nMakeCurrent
68 * Signature: (Ljava/nio/ByteBuffer;)V
69 */
70 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nMakeCurrent
71 (JNIEnv *, jclass, jobject);
72
73 /*
74 * Class: org_lwjgl_opengl_MacOSXContextImplementation
75 * Method: nIsCurrent
76 * Signature: (Ljava/nio/ByteBuffer;)Z
77 */
78 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nIsCurrent
79 (JNIEnv *, jclass, jobject);
80
81 /*
82 * Class: org_lwjgl_opengl_MacOSXContextImplementation
83 * Method: nSetSwapInterval
84 * Signature: (Ljava/nio/ByteBuffer;I)V
85 */
86 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSetSwapInterval
87 (JNIEnv *, jclass, jobject, jint);
88
89 /*
90 * Class: org_lwjgl_opengl_MacOSXContextImplementation
91 * Method: nDestroy
92 * Signature: (Ljava/nio/ByteBuffer;)V
93 */
94 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nDestroy
95 (JNIEnv *, jclass, jobject);
96
97 #ifdef __cplusplus
98 }
99 #endif
100 #endif
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_MacOSXContextImplementation.m 3116 2008-08-19 16:46:03Z spasi $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
36 * @author kappaOne <one.kappa@gmail.com>
37 * @version $Revision$
3738 */
3839
3940 #import <jni.h>
41 #import <OpenGL/CGLCurrent.h>
42 #import <OpenGL/CGLTypes.h>
43 #import <OpenGL/CGLDevice.h>
4044 #import <Cocoa/Cocoa.h>
4145 #import "org_lwjgl_opengl_MacOSXContextImplementation.h"
4246 #import "context.h"
4347 #import "common_tools.h"
4448
4549 typedef struct {
46 NSOpenGLContext *context;
50 NSOpenGLContext *context;
51 MacOSXPeerInfo *peer_info;
4752 } MacOSXContext;
4853
4954 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCreate
50 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) {
55 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject shared_context_handle) {
5156 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
5257 MacOSXPeerInfo *peer_info;
5358 MacOSXContext *shared_context_info;
5459 MacOSXContext *context_info;
55 NSOpenGLContext *context;
56 NSOpenGLContext *shared_context = NULL;
60 NSOpenGLContext *context;
61 NSOpenGLContext *shared_context = NULL;
62
5763 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXContext));
5864 if (context_handle == NULL) {
5965 throwException(env, "Could not create handle buffer");
6268 peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
6369 if (shared_context_handle != NULL) {
6470 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];
71 shared_context = shared_context_info->context;
72 }
73 context = [[NSOpenGLContext alloc] initWithFormat:peer_info->pixel_format shareContext:shared_context];
6874 if (context == NULL) {
6975 throwException(env, "Could not create context");
7076 return NULL;
7177 }
78
79 if (peer_info->isWindowed) {
80 if (peer_info->window_info->fullscreen) {
81 // set a fixed backbuffer size for fullscreen
82 CGLContextObj cgcontext = (CGLContextObj)[context CGLContextObj];
83 NSSize displaySize = peer_info->window_info->display_rect.size;
84 GLint dim[2] = {displaySize.width, displaySize.height};
85 CGLSetParameter(cgcontext, kCGLCPSurfaceBackingSize, dim);
86 CGLEnable(cgcontext, kCGLCESurfaceBackingSize);
87 }
88 else {
89 // disable any fixed backbuffer size to allow resizing
90 CGLContextObj cgcontext = (CGLContextObj)[context CGLContextObj];
91 CGLDisable(cgcontext, kCGLCESurfaceBackingSize);
92 }
93
94 [peer_info->window_info->view setOpenGLContext:context];
95 peer_info->window_info->context = context;
96 }
97
7298 context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
7399 context_info->context = context;
74 [pool release];
75 return context_handle;
100 context_info->peer_info = peer_info;
101
102 [pool release];
103 return context_handle;
104 }
105
106 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_getCGLShareGroup
107 (JNIEnv *env, jclass clazz, jobject context_handle) {
108 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
109 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
110 CGLContextObj cgl_context = [context_info->context CGLContextObj];
111 CGLShareGroupObj share_group = CGLGetShareGroup(cgl_context);
112 [pool release];
113 return (jlong)share_group;
76114 }
77115
78116 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSwapBuffers
79117 (JNIEnv *env, jclass clazz, jobject context_handle) {
80118 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
119 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
120 [context_info->context flushBuffer];
121
122 if (context_info->peer_info->isCALayer) {
123 // blit the contents of buffer to CALayer
124 [context_info->peer_info->glLayer blitFrameBuffer];
125 }
126
127 [pool release];
128 }
86129
87130 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nUpdate
88131 (JNIEnv *env, jclass clazz, jobject context_handle) {
93136 }
94137
95138 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_clearDrawable
96 (JNIEnv *env, jclass clazz, jobject context_handle) {
139 (JNIEnv *env, jclass clazz, jobject context_handle) {
97140 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
98141 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
99142 [context_info->context clearDrawable];
103146 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nReleaseCurrentContext
104147 (JNIEnv *env, jclass clazz) {
105148 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
106 [NSOpenGLContext clearCurrentContext];
149 [NSOpenGLContext clearCurrentContext];
107150 [pool release];
108151 }
109152
110153 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_setView
111 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
154 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
112155 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
113156 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
114157 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 {
158
159 if (peer_info->isWindowed) {
160 if (peer_info->isCALayer && [context_info->context view] != peer_info->window_info->view) {
161 // mark glViewport to be set manually when setting a new context view
162 peer_info->glLayer->setViewport = YES;
163 }
164
165 [context_info->context setView: peer_info->window_info->view];
166 }
167 else {
118168 [context_info->context setPixelBuffer:peer_info->pbuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:0];
119169 }
170
171 if (peer_info->isCALayer) {
172 // if using a CALayer, attach it to AWT Canvas and create a shared opengl context with current context
173 [peer_info->glLayer performSelectorOnMainThread:@selector(attachLayer) withObject:nil waitUntilDone:NO];
174 }
175
120176 [pool release];
121177 }
122178
123179 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nMakeCurrent
124180 (JNIEnv *env, jclass clazz, jobject context_handle) {
125181 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
126 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
182 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
127183 [context_info->context makeCurrentContext];
184
185 if (context_info->peer_info->isCALayer && context_info->peer_info->glLayer->setViewport) {
186 context_info->peer_info->glLayer->setViewport = NO;
187 glViewport(0, 0, [context_info->peer_info->glLayer getWidth], [context_info->peer_info->glLayer getHeight]);
188 }
189
128190 [pool release];
129191 }
130192
131193 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nIsCurrent
132194 (JNIEnv *env, jclass clazz, jobject context_handle) {
133195 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
134 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
196 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
135197 bool result = context_info->context == [NSOpenGLContext currentContext];
136198 [pool release];
137199 return result ? JNI_TRUE : JNI_FALSE;
149211 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nDestroy
150212 (JNIEnv *env, jclass clazz, jobject context_handle) {
151213 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
152 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
214
215 MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
216
217 if (context_info->peer_info->isCALayer) {
218 context_info->peer_info->isCALayer = false;
219 [context_info->peer_info->glLayer performSelectorOnMainThread:@selector(removeLayer) withObject:nil waitUntilDone:YES];
220 [context_info->peer_info->glLayer release];
221 context_info->peer_info->glLayer = nil;
222 // don't release context due to nvidia driver bug when releasing shared contexts
223 [context_info->context retain];
224 }
225
153226 [context_info->context clearDrawable];
154 [context_info->context release];
155 [pool release];
156 }
227
228 if (context_info->peer_info->isWindowed) {
229 [context_info->peer_info->window_info->view setOpenGLContext:nil];
230 [context_info->context release];
231 context_info->context = nil;
232 context_info->peer_info->window_info->context = nil;
233 }
234 else {
235 // don't release context due to nvidia driver bug when releasing shared contexts
236 //[context_info->context release];
237 //context_info->context = nil;
238 }
239
240 [pool release];
241 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXDisplay */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXDisplay
5 #define _Included_org_lwjgl_opengl_MacOSXDisplay
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_MacOSXDisplay_PBUFFER_HANDLE_SIZE
10 #define org_lwjgl_opengl_MacOSXDisplay_PBUFFER_HANDLE_SIZE 24L
11 #undef org_lwjgl_opengl_MacOSXDisplay_GAMMA_LENGTH
12 #define org_lwjgl_opengl_MacOSXDisplay_GAMMA_LENGTH 256L
13 /*
14 * Class: org_lwjgl_opengl_MacOSXDisplay
15 * Method: nCreateWindow
16 * Signature: (IIIIZZZZZZLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
17 */
18 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow
19 (JNIEnv *, jobject, jint, jint, jint, jint, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jobject, jobject);
20
21 /*
22 * Class: org_lwjgl_opengl_MacOSXDisplay
23 * Method: nGetCurrentDisplayMode
24 * Signature: ()Ljava/lang/Object;
25 */
26 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetCurrentDisplayMode
27 (JNIEnv *, jobject);
28
29 /*
30 * Class: org_lwjgl_opengl_MacOSXDisplay
31 * Method: nGetDisplayModes
32 * Signature: (Ljava/lang/Object;)V
33 */
34 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetDisplayModes
35 (JNIEnv *, jobject, jobject);
36
37 /*
38 * Class: org_lwjgl_opengl_MacOSXDisplay
39 * Method: nIsMiniaturized
40 * Signature: (Ljava/nio/ByteBuffer;)Z
41 */
42 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsMiniaturized
43 (JNIEnv *, jobject, jobject);
44
45 /*
46 * Class: org_lwjgl_opengl_MacOSXDisplay
47 * Method: nIsFocused
48 * Signature: (Ljava/nio/ByteBuffer;)Z
49 */
50 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsFocused
51 (JNIEnv *, jobject, jobject);
52
53 /*
54 * Class: org_lwjgl_opengl_MacOSXDisplay
55 * Method: nSetResizable
56 * Signature: (Ljava/nio/ByteBuffer;Z)V
57 */
58 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetResizable
59 (JNIEnv *, jobject, jobject, jboolean);
60
61 /*
62 * Class: org_lwjgl_opengl_MacOSXDisplay
63 * Method: nResizeWindow
64 * Signature: (Ljava/nio/ByteBuffer;IIII)V
65 */
66 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nResizeWindow
67 (JNIEnv *, jobject, jobject, jint, jint, jint, jint);
68
69 /*
70 * Class: org_lwjgl_opengl_MacOSXDisplay
71 * Method: nWasResized
72 * Signature: (Ljava/nio/ByteBuffer;)Z
73 */
74 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWasResized
75 (JNIEnv *, jobject, jobject);
76
77 /*
78 * Class: org_lwjgl_opengl_MacOSXDisplay
79 * Method: nGetX
80 * Signature: (Ljava/nio/ByteBuffer;)I
81 */
82 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetX
83 (JNIEnv *, jobject, jobject);
84
85 /*
86 * Class: org_lwjgl_opengl_MacOSXDisplay
87 * Method: nGetY
88 * Signature: (Ljava/nio/ByteBuffer;)I
89 */
90 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetY
91 (JNIEnv *, jobject, jobject);
92
93 /*
94 * Class: org_lwjgl_opengl_MacOSXDisplay
95 * Method: nGetWidth
96 * Signature: (Ljava/nio/ByteBuffer;)I
97 */
98 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetWidth
99 (JNIEnv *, jobject, jobject);
100
101 /*
102 * Class: org_lwjgl_opengl_MacOSXDisplay
103 * Method: nGetHeight
104 * Signature: (Ljava/nio/ByteBuffer;)I
105 */
106 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetHeight
107 (JNIEnv *, jobject, jobject);
108
109 /*
110 * Class: org_lwjgl_opengl_MacOSXDisplay
111 * Method: nIsNativeMode
112 * Signature: (Ljava/nio/ByteBuffer;)Z
113 */
114 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nIsNativeMode
115 (JNIEnv *, jobject, jobject);
116
117 /*
118 * Class: org_lwjgl_opengl_MacOSXDisplay
119 * Method: nDestroyCALayer
120 * Signature: (Ljava/nio/ByteBuffer;)V
121 */
122 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyCALayer
123 (JNIEnv *, jobject, jobject);
124
125 /*
126 * Class: org_lwjgl_opengl_MacOSXDisplay
127 * Method: nDestroyWindow
128 * Signature: (Ljava/nio/ByteBuffer;)V
129 */
130 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyWindow
131 (JNIEnv *, jobject, jobject);
132
133 /*
134 * Class: org_lwjgl_opengl_MacOSXDisplay
135 * Method: setGammaRamp
136 * Signature: (Ljava/nio/FloatBuffer;)V
137 */
138 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setGammaRamp
139 (JNIEnv *, jobject, jobject);
140
141 /*
142 * Class: org_lwjgl_opengl_MacOSXDisplay
143 * Method: restoreGamma
144 * Signature: ()V
145 */
146 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma
147 (JNIEnv *, jobject);
148
149 /*
150 * Class: org_lwjgl_opengl_MacOSXDisplay
151 * Method: nSetTitle
152 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
153 */
154 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle
155 (JNIEnv *, jobject, jobject, jobject);
156
157 #ifdef __cplusplus
158 }
159 #endif
160 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXMouseEventQueue */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXMouseEventQueue
5 #define _Included_org_lwjgl_opengl_MacOSXMouseEventQueue
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_MacOSXMouseEventQueue_QUEUE_SIZE
10 #define org_lwjgl_opengl_MacOSXMouseEventQueue_QUEUE_SIZE 200L
11 #undef org_lwjgl_opengl_MacOSXMouseEventQueue_WHEEL_SCALE
12 #define org_lwjgl_opengl_MacOSXMouseEventQueue_WHEEL_SCALE 120L
13 #undef org_lwjgl_opengl_MacOSXMouseEventQueue_NUM_BUTTONS
14 #define org_lwjgl_opengl_MacOSXMouseEventQueue_NUM_BUTTONS 3L
15 /*
16 * Class: org_lwjgl_opengl_MacOSXMouseEventQueue
17 * Method: getMouseDeltas
18 * Signature: (Ljava/nio/IntBuffer;)V
19 */
20 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas
21 (JNIEnv *, jclass, jobject);
22
23 /*
24 * Class: org_lwjgl_opengl_MacOSXMouseEventQueue
25 * Method: nWarpCursor
26 * Signature: (II)V
27 */
28 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nWarpCursor
29 (JNIEnv *, jclass, jint, jint);
30
31 /*
32 * Class: org_lwjgl_opengl_MacOSXMouseEventQueue
33 * Method: nGrabMouse
34 * Signature: (Z)V
35 */
36 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse
37 (JNIEnv *, jclass, jboolean);
38
39 #ifdef __cplusplus
40 }
41 #endif
42 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXNativeKeyboard */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXNativeKeyboard
5 #define _Included_org_lwjgl_opengl_MacOSXNativeKeyboard
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_MacOSXNativeKeyboard_QUEUE_SIZE
10 #define org_lwjgl_opengl_MacOSXNativeKeyboard_QUEUE_SIZE 200L
11 /*
12 * Class: org_lwjgl_opengl_MacOSXNativeKeyboard
13 * Method: nRegisterKeyListener
14 * Signature: (Ljava/nio/ByteBuffer;)V
15 */
16 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeKeyboard_nRegisterKeyListener
17 (JNIEnv *, jobject, jobject);
18
19 /*
20 * Class: org_lwjgl_opengl_MacOSXNativeKeyboard
21 * Method: nUnregisterKeyListener
22 * Signature: (Ljava/nio/ByteBuffer;)V
23 */
24 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeKeyboard_nUnregisterKeyListener
25 (JNIEnv *, jobject, jobject);
26
27 #ifdef __cplusplus
28 }
29 #endif
30 #endif
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_MacOSXNativeKeyboard.m 3055 2012-08-29 0:46:00Z mojang $
34 *
35 * Mac OS X native keyboard functions.
36 *
37 * @author mojang
38 * @version $Revision: 3055 $
39 */
40
41 #import <AppKit/NSApplication.h>
42 #import <Cocoa/Cocoa.h>
43 #import <jni.h>
44 #import <unistd.h>
45 #import "common_tools.h"
46 #import "org_lwjgl_opengl_MacOSXNativeKeyboard.h"
47 #import "context.h"
48
49 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeKeyboard_nRegisterKeyListener(JNIEnv *env, jobject this, jobject window_handle) {
50 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
51 window_info->jkeyboard = (*env)->NewGlobalRef(env, this);
52 }
53
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeKeyboard_nUnregisterKeyListener(JNIEnv *env, jobject this, jobject window_handle) {
55 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
56 window_info->jkeyboard = NULL;
57 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXNativeMouse */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXNativeMouse
5 #define _Included_org_lwjgl_opengl_MacOSXNativeMouse
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_MacOSXNativeMouse_QUEUE_SIZE
10 #define org_lwjgl_opengl_MacOSXNativeMouse_QUEUE_SIZE 200L
11 #undef org_lwjgl_opengl_MacOSXNativeMouse_WHEEL_SCALE
12 #define org_lwjgl_opengl_MacOSXNativeMouse_WHEEL_SCALE 120L
13 #undef org_lwjgl_opengl_MacOSXNativeMouse_NUM_BUTTONS
14 #define org_lwjgl_opengl_MacOSXNativeMouse_NUM_BUTTONS 3L
15 /*
16 * Class: org_lwjgl_opengl_MacOSXNativeMouse
17 * Method: nSetCursorPosition
18 * Signature: (Ljava/nio/ByteBuffer;II)V
19 */
20 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursorPosition
21 (JNIEnv *, jobject, jobject, jint, jint);
22
23 /*
24 * Class: org_lwjgl_opengl_MacOSXNativeMouse
25 * Method: nGrabMouse
26 * Signature: (Z)V
27 */
28 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nGrabMouse
29 (JNIEnv *, jclass, jboolean);
30
31 /*
32 * Class: org_lwjgl_opengl_MacOSXNativeMouse
33 * Method: nRegisterMouseListener
34 * Signature: (Ljava/nio/ByteBuffer;)V
35 */
36 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nRegisterMouseListener
37 (JNIEnv *, jobject, jobject);
38
39 /*
40 * Class: org_lwjgl_opengl_MacOSXNativeMouse
41 * Method: nUnregisterMouseListener
42 * Signature: (Ljava/nio/ByteBuffer;)V
43 */
44 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nUnregisterMouseListener
45 (JNIEnv *, jobject, jobject);
46
47 /*
48 * Class: org_lwjgl_opengl_MacOSXNativeMouse
49 * Method: nCreateCursor
50 * Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)J
51 */
52 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor
53 (JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
54
55 /*
56 * Class: org_lwjgl_opengl_MacOSXNativeMouse
57 * Method: nDestroyCursor
58 * Signature: (J)V
59 */
60 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nDestroyCursor
61 (JNIEnv *, jclass, jlong);
62
63 /*
64 * Class: org_lwjgl_opengl_MacOSXNativeMouse
65 * Method: nSetCursor
66 * Signature: (J)V
67 */
68 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursor
69 (JNIEnv *, jclass, jlong);
70
71 #ifdef __cplusplus
72 }
73 #endif
74 #endif
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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_MacOSXNativeKeyboard.m 3055 2012-08-29 0:46:00Z mojang $
34 *
35 * Mac OS X native keyboard functions.
36 *
37 * @author mojang
38 * @author kappaOne <one.kappa@gmail.com>
39 * @version $Revision: 3055 $
40 */
41
42 #import <AppKit/NSApplication.h>
43 #import <Cocoa/Cocoa.h>
44 #import <jni.h>
45 #import <unistd.h>
46 #import "common_tools.h"
47 #import "org_lwjgl_opengl_MacOSXNativeMouse.h"
48 #import "context.h"
49
50 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nGrabMouse(JNIEnv *env, jclass this, jboolean grab) {
51 CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE);
52 if (grab) {
53 CGDisplayHideCursor(kCGDirectMainDisplay);
54 }
55 else {
56 CGDisplayShowCursor(kCGDirectMainDisplay);
57 }
58 }
59
60 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursorPosition(JNIEnv *env, jclass this, jobject window_handle, jint x, jint y) {
61 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
62
63 CGPoint p;
64
65 if (window_info->fullscreen) {
66 NSPoint point = NSMakePoint(x, y);
67
68 // convert point to window/screen coordinates
69 point = [window_info->view convertPoint:point fromView:nil];
70
71 p.x = point.x;
72 p.y = point.y;
73 }
74 else {
75 NSRect screenRect = [[window_info->window screen] frame];
76 NSRect viewRect = [window_info->view frame];
77 NSRect winRect = [window_info->window frame];
78
79 // get window coords of the view origin
80 NSPoint viewPoint = [window_info->view convertPoint:viewRect.origin fromView:nil];
81
82 // convert y to screen coordinates, origin bottom left
83 p.y = winRect.origin.y + viewPoint.y + (viewRect.size.height - y - 1);
84
85 p.x = winRect.origin.x + viewPoint.x + x;
86 // flip y coordinates (origin top left) to allow use with CGDisplayMoveCursorToPoint
87 p.y = screenRect.size.height - p.y - 1;
88 }
89
90 CGDisplayMoveCursorToPoint(CGMainDisplayID(), p);
91 }
92
93 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nRegisterMouseListener(JNIEnv *env, jobject _this, jobject window_handle) {
94 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
95 [window_info->window setAcceptsMouseMovedEvents:YES];
96 window_info->jmouse = (*env)->NewGlobalRef(env, _this);
97
98 // since initial mouse location is not reported until mouse is moved
99 // manually get the mouse location and report it with a fake event
100 NSPoint mouseLocation = [window_info->window mouseLocationOutsideOfEventStream];
101 mouseLocation = [window_info->view convertPoint:mouseLocation fromView:nil];
102
103 NSEvent *mouseLocationEvent = [NSEvent
104 mouseEventWithType:NSMouseMoved
105 location:mouseLocation
106 modifierFlags:NSMouseMovedMask
107 timestamp:0
108 windowNumber:[window_info->window windowNumber]
109 context:nil
110 eventNumber:0
111 clickCount:0
112 pressure:0];
113
114 [window_info->view mouseMoved:mouseLocationEvent];
115 }
116
117 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nUnregisterMouseListener(JNIEnv *env, jobject this, jobject window_handle) {
118 MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
119 [window_info->window setAcceptsMouseMovedEvents:NO];
120 window_info->jmouse = nil;
121 }
122
123 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor(JNIEnv *env, jobject _this, 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) {
124 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
125
126 jlong *bytes = (jint *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset;
127
128 NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc]
129 initWithBitmapDataPlanes:NULL
130 pixelsWide:width pixelsHigh:height
131 bitsPerSample:8
132 samplesPerPixel:4
133 hasAlpha:YES
134 isPlanar:NO
135 colorSpaceName:NSDeviceRGBColorSpace
136 bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
137 bytesPerRow:width*4
138 bitsPerPixel:32] autorelease];
139 memcpy((void*)bitmap.bitmapData, (void*)bytes, width*height*4);
140
141 NSImage *image = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] autorelease];
142
143 [image addRepresentation:bitmap];
144
145
146 NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(x_hotspot, y_hotspot)];
147
148 [pool release];
149
150 return (jlong)cursor;
151 }
152
153 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nDestroyCursor(JNIEnv *env, jobject _this, jlong cursor_pointer) {
154 if (cursor_pointer != 0) {
155 NSCursor *cursor = (NSCursor *)cursor_pointer;
156 [cursor release];
157 }
158 }
159
160 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursor(JNIEnv *env, jobject _this, jlong cursor_pointer) {
161 if (cursor_pointer == 0) {
162 // restore default cursor
163 [[NSCursor arrowCursor] performSelectorOnMainThread:@selector(set) withObject:nil waitUntilDone:NO];
164 }
165 else {
166 NSCursor *cursor = (NSCursor *)cursor_pointer;
167 [cursor performSelectorOnMainThread:@selector(set) withObject:nil waitUntilDone:NO];
168 }
169 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXPbufferPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXPbufferPeerInfo
5 #define _Included_org_lwjgl_opengl_MacOSXPbufferPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_MacOSXPbufferPeerInfo
11 * Method: nCreate
12 * Signature: (Ljava/nio/ByteBuffer;II)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nCreate
15 (JNIEnv *, jclass, jobject, jint, jint);
16
17 /*
18 * Class: org_lwjgl_opengl_MacOSXPbufferPeerInfo
19 * Method: nDestroy
20 * Signature: (Ljava/nio/ByteBuffer;)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nDestroy
23 (JNIEnv *, jclass, jobject);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_MacOSXPbufferPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision$
3737 */
3838
3939 #import <jni.h>
6464 }
6565 MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
6666 peer_info->pbuffer = pbuffer;
67 peer_info->window = false;
67 peer_info->isWindowed = false;
6868 [pool release];
6969 }
7070
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_MacOSXPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_MacOSXPeerInfo
5 #define _Included_org_lwjgl_opengl_MacOSXPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_MacOSXPeerInfo
11 * Method: createHandle
12 * Signature: ()Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_createHandle
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengl_MacOSXPeerInfo
19 * Method: nChoosePixelFormat
20 * Signature: (Ljava/nio/ByteBuffer;Lorg/lwjgl/opengl/PixelFormat;ZZZZZ)V
21 */
22 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nChoosePixelFormat
23 (JNIEnv *, jclass, jobject, jobject, jboolean, jboolean, jboolean, jboolean, jboolean);
24
25 /*
26 * Class: org_lwjgl_opengl_MacOSXPeerInfo
27 * Method: nDestroy
28 * Signature: (Ljava/nio/ByteBuffer;)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nDestroy
31 (JNIEnv *, jclass, jobject);
32
33 #ifdef __cplusplus
34 }
35 #endif
36 #endif
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_MacOSXPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision$
3737 */
3838
3939 #import <jni.h>
5151 }
5252
5353 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) {
54 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject pixel_format, jboolean gl32, jboolean use_display_bpp, jboolean support_window, jboolean support_pbuffer, jboolean double_buffered) {
5555 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
5656 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);
57 NSOpenGLPixelFormat *macosx_pixel_format = choosePixelFormat(env, pixel_format, gl32, use_display_bpp, support_window, support_pbuffer, double_buffered);
5858 if (pixel_format == nil) {
5959 throwException(env, "Could not find pixel format");
6060 return;
3030 */
3131
3232 /**
33 * $Id: LWJGL.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * Basic DLL stub.
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @version $Revision$
3939 */
4040
4141 #define WIN32_LEAN_AND_MEAN
4545 #include "org_lwjgl_opengl_WindowsDisplay.h"
4646
4747 HINSTANCE dll_handle;
48
49 __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; // Force high performance GPU for Nvidia Optimus systems
4850
4951 /*
5052 * DLL entry point for Windows. Called when Java loads the .dll
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
31
3232 /**
33 * $Id: Window.h 3227 2009-07-07 19:47:55Z matzon $
33 * $Id$
3434 *
3535 * Include file to access public window features
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3227 $
38 * @version $Revision$
3939 */
4040 #ifndef _LWJGL_WINDOW_H_INCLUDED_
4141 #define _LWJGL_WINDOW_H_INCLUDED_
5151 #define _WIN32_WINNT 0x0400
5252 #endif
5353
54 #define _UNICODE
55 #include <tchar.h>
56
57 #define UNICODE
5458 #include <windows.h>
5559 #include <jni.h>
5660 #include "common_tools.h"
+0
-499
src/native/windows/context.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3377 2010-07-12 12:04:56Z matzon $
34 *
35 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3377 $
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 colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
190 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
191 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
192 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
193
194 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
195 jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
196 jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
197 jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
198
199 int pixel_type;
200 int iPixelFormat;
201 unsigned int num_formats_returned;
202 attrib_list_t attrib_list;
203 GLuint *pixelFormatCaps_ptr;
204 jlong pixelFormatCapsSize;
205 BOOL result;
206 jlong i;
207 int bpe = convertToBPE(bpp);
208
209 if ( floating_point )
210 pixel_type = WGL_TYPE_RGBA_FLOAT_ARB;
211 else if ( floating_point_packed )
212 pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT;
213 else
214 pixel_type = WGL_TYPE_RGBA_ARB;
215
216 initAttribList(&attrib_list);
217 if (window) {
218 putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE);
219 }
220 if (pbuffer) {
221 putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE);
222 }
223 if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) {
224 putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB);
225 }
226 putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type);
227 putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE);
228 putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE);
229 putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe);
230 putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe);
231 putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe);
232 putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha);
233 putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth);
234 putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil);
235 // Assume caller checked extension availability
236 if (samples > 0) {
237 putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
238 putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); // WGL_COVERAGE_SAMPLES_NV if colorSamples > 0
239 if ( colorSamples > 0 ) {
240 putAttrib(&attrib_list, WGL_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
241 }
242 }
243 putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp);
244 putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha);
245 putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE);
246 putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers);
247 if (sRGB) {
248 putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, TRUE);
249 }
250
251 // Assume caller checked extension availability
252 if (pixelFormatCaps != NULL) {
253 pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps);
254 pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps);
255
256 for (i = 0; i < pixelFormatCapsSize; i++)
257 putAttrib(&attrib_list, pixelFormatCaps_ptr[i]);
258 }
259 putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0);
260 result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned);
261
262 if (result == FALSE || num_formats_returned < 1) {
263 throwFormattedException(env, "Failed to find ARB pixel format %d %d\n", result, num_formats_returned);
264 return -1;
265 }
266 return iPixelFormat;
267 }
268
269 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) {
270 int bpp;
271 int iPixelFormat;
272 int fallback_bpp = 16;
273 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
274 if (use_hdc_bpp) {
275 bpp = GetDeviceCaps(hdc, BITSPIXEL);
276 iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
277 if ((*env)->ExceptionOccurred(env)) {
278 (*env)->ExceptionClear(env);
279 printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
280 bpp = fallback_bpp;
281 } else
282 return iPixelFormat;
283 } else
284 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
285 return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
286 }
287
288 /*
289 * Find an appropriate pixel format
290 */
291 static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer)
292 {
293 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
294 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
295 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
296 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
297 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
298 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
299 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
300 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
301 unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
302 PFD_SUPPORT_OPENGL |
303 (double_buffer ? PFD_DOUBLEBUFFER : 0) |
304 (stereo ? PFD_STEREO : 0);
305 PIXELFORMATDESCRIPTOR desc;
306 int iPixelFormat;
307 PIXELFORMATDESCRIPTOR pfd = {
308 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
309 1, // version number
310 flags, // RGBA type
311 PFD_TYPE_RGBA,
312 (BYTE)bpp,
313 0, 0, 0, 0, 0, 0, // color bits ignored
314 (BYTE)alpha,
315 0, // shift bit ignored
316 accum_bpp + accum_alpha, // no accumulation buffer
317 0, 0, 0, 0, // accum bits ignored
318 (BYTE)depth,
319 (BYTE)stencil,
320 num_aux_buffers,
321 PFD_MAIN_PLANE, // main layer
322 0, // reserved
323 0, 0, 0 // layer masks ignored
324 };
325 // get the best available match of pixel format for the device context
326 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
327 if (iPixelFormat == 0) {
328 throwException(env, "Failed to choose pixel format");
329 return -1;
330 }
331
332 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
333 throwException(env, "Could not describe pixel format");
334 return -1;
335 }
336
337 if (desc.cColorBits < bpp) {
338 throwException(env, "Insufficient color precision");
339 return -1;
340 }
341
342 if (desc.cAlphaBits < alpha) {
343 throwException(env, "Insufficient alpha precision");
344 return -1;
345 }
346
347 if (desc.cStencilBits < stencil) {
348 throwException(env, "Insufficient stencil precision");
349 return -1;
350 }
351
352 if (desc.cDepthBits < depth) {
353 throwException(env, "Insufficient depth buffer precision");
354 return -1;
355 }
356
357 if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) {
358 jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
359 // secondary check for software override
360 if(!allowSoftwareOpenGL) {
361 throwException(env, "Pixel format not accelerated");
362 return -1;
363 }
364 }
365
366 if ((desc.dwFlags & flags) != flags) {
367 throwException(env, "Capabilities not supported");
368 return -1;
369 }
370 return iPixelFormat;
371 }
372
373 static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bool use_hdc_bpp, bool double_buffer) {
374 int bpp;
375 int iPixelFormat;
376 int fallback_bpp = 16;
377 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
378 if (use_hdc_bpp) {
379 bpp = GetDeviceCaps(hdc, BITSPIXEL);
380 iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
381 if ((*env)->ExceptionOccurred(env)) {
382 (*env)->ExceptionClear(env);
383 printfDebugJava(env, "Failed to find pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
384 bpp = fallback_bpp;
385 } else
386 return iPixelFormat;
387 } else
388 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
389 return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
390 }
391
392 static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, int colorSamples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) {
393 if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) {
394 throwException(env, "Could not bind context to dummy window");
395 return false;
396 }
397 extgl_InitWGL(extensions);
398
399 if (!extensions->WGL_ARB_pixel_format) {
400 throwException(env, "No support for WGL_ARB_pixel_format");
401 return false;
402 }
403 if (samples > 0 && !extensions->WGL_ARB_multisample) {
404 throwException(env, "No support for WGL_ARB_multisample");
405 return false;
406 }
407 if (colorSamples > 0 && !extensions->WGL_NV_multisample_coverage) {
408 throwException(env, "No support for WGL_NV_multisample_coverage");
409 return false;
410 }
411 /*
412 * Apparently, some drivers don't report WGL_ARB_pixel_format_float
413 * even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float
414 * is supported.
415 */
416 if (floating_point && !(extensions->WGL_ARB_pixel_format_float || extensions->WGL_ATI_pixel_format_float)) {
417 throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float");
418 return false;
419 }
420 if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) {
421 throwException(env, "No support for WGL_EXT_pixel_format_packed_float");
422 return false;
423 }
424 if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) {
425 throwException(env, "No support for WGL_ARB_framebuffer_sRGB");
426 return false;
427 }
428 if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) {
429 throwException(env, "No support for WGL_ARB_render_texture");
430 return false;
431 }
432 return true;
433 }
434
435 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) {
436 HGLRC dummy_hglrc;
437 HDC saved_current_hdc;
438 HGLRC saved_current_hglrc;
439 WGLExtensions extensions;
440 HWND dummy_hwnd;
441 HDC dummy_hdc;
442 int pixel_format_id;
443 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
444
445 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
446 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
447 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
448 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
449 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
450 bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL;
451
452 pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer);
453 if (!(*env)->ExceptionOccurred(env) && use_arb_selection) {
454 dummy_hwnd = createDummyWindow(origin_x, origin_y);
455 if (dummy_hwnd == NULL) {
456 throwException(env, "Could not create dummy window");
457 return -1;
458 }
459 dummy_hdc = GetDC(dummy_hwnd);
460 if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) {
461 closeWindow(&dummy_hwnd, &dummy_hdc);
462 return -1;
463 }
464 dummy_hglrc = wglCreateContext(dummy_hdc);
465 if (dummy_hglrc == NULL) {
466 closeWindow(&dummy_hwnd, &dummy_hdc);
467 throwException(env, "Failed to create OpenGL rendering context");
468 return -1;
469 }
470 // Save the current HDC and HGLRC to avoid disruption
471 saved_current_hdc = wglGetCurrentDC();
472 saved_current_hglrc = wglGetCurrentContext();
473 if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, colorSamples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) {
474 pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer);
475 }
476 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
477 wglDeleteContext(dummy_hglrc);
478 closeWindow(&dummy_hwnd, &dummy_hdc);
479 }
480 return pixel_format_id;
481 }
482
483 static bool registerDummyWindow() {
484 static bool window_registered = false;
485 if (!window_registered) {
486 if (!registerWindow(dummyWindowProc, _CONTEXT_PRIVATE_CLASS_NAME)) {
487 return false;
488 }
489 window_registered = true;
490 }
491 return true;
492 }
493
494 HWND createDummyWindow(int origin_x, int origin_y) {
495 if (!registerDummyWindow())
496 return NULL;
497 return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
498 }
+0
-96
src/native/windows/context.h less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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
3030 */
3131
3232 /**
33 * $Id: display.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * Windows specific library for display handling.
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @version $Revision$
3939 */
4040
4141 #include <windows.h>
9494 while(EnumDisplaySettings((const char *) DisplayDevice.DeviceName, j++, &DevMode) != 0) {*/
9595 while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
9696 // Filter out indexed modes
97 if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) {
97 if (DevMode.dmBitsPerPel > 8) {
9898 jobject displayMode;
9999 if (list_size <= n) {
100100 list_size += 1;
202202 float scaledRampEntry;
203203 WORD rampEntry;
204204 const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj);
205 jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj);
205 jint gamma_ramp_length = (jint)(*env)->GetDirectBufferCapacity(env, float_gamma_obj);
206206 jobject native_ramp;
207207 WORD *native_ramp_buffer;
208208
3030 */
3131
3232 /**
33 * $Id: display.h 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * Windows specific library for display handling.
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @version $Revision$
3939 */
4040
4141 #ifndef _DISPLAY_H
+0
-184
src/native/windows/extgl_wgl.c less more
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 extensions->WGL_NV_multisample_coverage = WGLQueryExtension(extensions, "WGL_NV_multisample_coverage");
155 }
156
157 static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) {
158 ExtFunction functions[] = {
159 {"wglGetExtensionsStringEXT", (void *)&extensions->wglGetExtensionsStringEXT}
160 };
161 extensions->WGL_EXT_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
162 }
163
164 static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) {
165 ExtFunction functions[] = {
166 {"wglGetExtensionsStringARB", (void *)&extensions->wglGetExtensionsStringARB}
167 };
168 extensions->WGL_ARB_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
169 }
170
171 void extgl_InitWGL(WGLExtensions *extensions) {
172 extgl_InitWGLARBExtensionsString(extensions);
173 extgl_InitWGLEXTExtensionsString(extensions);
174
175 extgl_InitSupportedWGLExtensions(extensions);
176
177 extgl_InitWGLARBMakeCurrentRead(extensions);
178 extgl_InitWGLEXTSwapControl(extensions);
179 extgl_InitWGLARBRenderTexture(extensions);
180 extgl_InitWGLARBPixelFormat(extensions);
181 extgl_InitWGLARBPbuffer(extensions);
182 extgl_InitWGLARBCreateContext(extensions);
183 }
+0
-261
src/native/windows/extgl_wgl.h less more
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 /*---------------------------------------------------------------------*/
203 /*------------ WGL_NV_multisample_coverage ----------------------------*/
204 /*---------------------------------------------------------------------*/
205
206 #define WGL_COVERAGE_SAMPLES_NV 0x2042
207 #define WGL_COLOR_SAMPLES_NV 0x20B9
208
209 /*---------------------------------------------------------------------*/
210
211 typedef struct {
212 bool WGL_ARB_buffer_region;
213 bool WGL_ARB_extensions_string;
214 bool WGL_ARB_make_current_read;
215 bool WGL_ARB_multisample;
216 bool WGL_ARB_pbuffer;
217 bool WGL_ARB_pixel_format;
218 bool WGL_ARB_render_texture;
219 bool WGL_EXT_extensions_string;
220 bool WGL_EXT_swap_control;
221 bool WGL_NV_render_depth_texture;
222 bool WGL_NV_render_texture_rectangle;
223 bool WGL_ARB_pixel_format_float;
224 bool WGL_ATI_pixel_format_float;
225 bool WGL_ARB_framebuffer_sRGB;
226 bool WGL_EXT_pixel_format_packed_float;
227 bool WGL_ARB_create_context;
228 bool WGL_NV_multisample_coverage;
229
230 wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT;
231
232 wglGetExtensionsStringARBPROC wglGetExtensionsStringARB;
233
234 wglCreatePbufferARBPROC wglCreatePbufferARB;
235 wglGetPbufferDCARBPROC wglGetPbufferDCARB;
236 wglReleasePbufferDCARBPROC wglReleasePbufferDCARB;
237 wglDestroyPbufferARBPROC wglDestroyPbufferARB;
238 wglQueryPbufferARBPROC wglQueryPbufferARB;
239
240 wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB;
241 wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB;
242 wglChoosePixelFormatARBPROC wglChoosePixelFormatARB;
243
244 wglBindTexImageARBPROC wglBindTexImageARB;
245 wglReleaseTexImageARBPROC wglReleaseTexImageARB;
246 wglSetPbufferAttribARBPROC wglSetPbufferAttribARB;
247
248 wglSwapIntervalEXTPROC wglSwapIntervalEXT;
249 wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT;
250
251 wglMakeContextCurrentARBPROC wglMakeContextCurrentARB;
252 wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB;
253
254 wglCreateContextAttribsARBPROC wglCreateContextAttribsARB;
255 } WGLExtensions;
256
257 extern void extgl_InitWGL(WGLExtensions *extensions);
258
259
260 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 * WGL extension implementations.
34 *
35 * @author Spasi
36 */
37 #include "WGL.h"
38
39 /* NV_present_video functions */
40
41 jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) {
42 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
43 HVIDEOOUTPUTDEVICENV *devices_address = ((HVIDEOOUTPUTDEVICENV *)safeGetBufferAddress(env, devices)) + devices_position;
44
45 return peer_info->extensions.wglEnumerateVideoDevicesNV(peer_info->drawable_hdc, devices_address);
46 }
47
48 jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position) {
49 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
50 const int *attrib_list_address = ((const int *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
51
52 return peer_info->extensions.wglBindVideoDeviceNV(peer_info->drawable_hdc, video_slot, video_device == 0 ? INVALID_HANDLE_VALUE : (HVIDEOOUTPUTDEVICENV)(intptr_t)video_device, attrib_list_address);
53 }
54
55 jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position) {
56 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
57 int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
58
59 return peer_info->extensions.wglQueryCurrentContextNV(attrib, value_address);
60 }
61
62 /* NV_video_capture functions */
63
64 jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device) {
65 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
66
67 return peer_info->extensions.wglBindVideoCaptureDeviceNV(video_slot, (HVIDEOINPUTDEVICENV)(intptr_t)device);
68 }
69
70 jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) {
71 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
72 HVIDEOINPUTDEVICENV *devices_address = ((HVIDEOINPUTDEVICENV *)safeGetBufferAddress(env, devices)) + devices_position;
73
74 return peer_info->extensions.wglEnumerateVideoCaptureDevicesNV(peer_info->drawable_hdc, devices_address);
75 }
76
77 jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) {
78 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
79
80 return peer_info->extensions.wglLockVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device);
81 }
82
83 jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position) {
84 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
85 int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
86
87 return peer_info->extensions.wglQueryVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device, attribute, value_address);
88 }
89
90 jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) {
91 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
92
93 return peer_info->extensions.wglReleaseVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device);
94 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 * WGL extension implementations.
34 *
35 * @author Spasi
36 */
37 #ifndef __LWJGL_WGL_H
38 #define __LWJGL_WGL_H
39
40 #include <jni.h>
41 #include "common_tools.h"
42 #include "context.h"
43
44 #include "extgl.h"
45 #include "extgl_wgl.h"
46
47 /* NV_present_video functions */
48 extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
49 extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position);
50 extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position);
51
52 /* NV_video_capture functions */
53 extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device);
54 extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position);
55 extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
56 extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position);
57 extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device);
58
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$
34 *
35 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision$
37 */
38
39 #include <malloc.h>
40 #include "Window.h"
41 #include "extgl.h"
42 #include "extgl_wgl.h"
43 #include "context.h"
44
45 extern HINSTANCE dll_handle; // Handle to the LWJGL dll
46
47 #define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name")
48
49 /*
50 * Register the LWJGL window class.
51 * Returns true for success, or false for failure
52 */
53 bool registerWindow(WNDPROC win_proc, LPCTSTR class_name)
54 {
55 WNDCLASS windowClass;
56 memset(&windowClass, 0, sizeof(windowClass));
57 windowClass.style = CS_OWNDC;
58 windowClass.lpfnWndProc = win_proc;
59 windowClass.cbClsExtra = 0;
60 windowClass.cbWndExtra = 0;
61 windowClass.hInstance = dll_handle;
62 windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
63 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
64 windowClass.hbrBackground = NULL;
65 windowClass.lpszMenuName = NULL;
66 windowClass.lpszClassName = class_name;
67
68 if (RegisterClass(&windowClass) == 0) {
69 printfDebug("Failed to register window class\n");
70 return false;
71 }
72 return true;
73 }
74
75 static LRESULT CALLBACK dummyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
76 return DefWindowProc(hwnd, msg, wParam, lParam);
77 }
78
79 bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat) {
80 PIXELFORMATDESCRIPTOR desc;
81 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
82 throwFormattedException(env, "DescribePixelFormat failed (%d)", GetLastError());
83 return false;
84 }
85
86 // make that the pixel format of the device context
87 if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) {
88 throwFormattedException(env, "SetPixelFormat failed (%d)", GetLastError());
89 return false;
90 }
91 return true;
92 }
93
94 /*
95 * Close the window
96 */
97 void closeWindow(HWND *hwnd, HDC *hdc)
98 {
99 // Release device context
100 if (*hdc != NULL && *hwnd != NULL) {
101 ReleaseDC(*hwnd, *hdc);
102 *hdc = NULL;
103 }
104
105 // Close the window
106 if (*hwnd != NULL) {
107 ShowWindow(*hwnd, SW_HIDE);
108 DestroyWindow(*hwnd);
109 *hwnd = NULL;
110 }
111 }
112
113 void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window) {
114 DWORD exstyle, windowflags;
115 if (undecorated) {
116 exstyle = WS_EX_APPWINDOW;
117 windowflags = WS_POPUP;
118 } else if (child_window) {
119 exstyle = 0;
120 windowflags = WS_CHILD;
121 } else {
122 exstyle = WS_EX_APPWINDOW;
123 windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
124 }
125 windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
126 *windowflags_return = windowflags;
127 *exstyle_return = exstyle;
128 }
129
130 HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent)
131 {
132 RECT clientSize;
133 DWORD exstyle, windowflags;
134 HWND new_hwnd;
135
136 getWindowFlags(&windowflags, &exstyle, undecorated, child_window);
137
138 clientSize.bottom = height;
139 clientSize.left = 0;
140 clientSize.right = width;
141 clientSize.top = 0;
142
143 AdjustWindowRectEx(
144 &clientSize, // client-rectangle structure
145 windowflags, // window styles
146 FALSE, // menu-present option
147 exstyle // extended window style
148 );
149 // Create the window now, using that class:
150 new_hwnd = CreateWindowEx (
151 exstyle,
152 window_class_name,
153 _T(""),
154 windowflags,
155 x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
156 parent,
157 NULL,
158 dll_handle,
159 NULL);
160
161 return new_hwnd;
162 }
163
164 static int convertToBPE(int bpp) {
165 int bpe;
166 switch (bpp) {
167 case 0:
168 bpe = 0;
169 break;
170 case 32:
171 case 24:
172 bpe = 8;
173 break;
174 case 16: /* Fall through */
175 default:
176 bpe = 4;
177 break;
178 }
179 return bpe;
180 }
181
182 static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) {
183 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
184 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
185 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
186 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
187 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
188 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "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 }
225 putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type);
226 if ( double_buffer || samples == 0 ) {
227 // Skip this for FALSE + MSAA: NV drivers won't return any PixelFormat
228 putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE);
229 }
230 putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE);
231 putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe);
232 putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe);
233 putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe);
234 putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha);
235 putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth);
236 putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil);
237 // Assume caller checked extension availability
238 if (samples > 0) {
239 putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
240 putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); // WGL_COVERAGE_SAMPLES_NV if colorSamples > 0
241 if ( colorSamples > 0 ) {
242 putAttrib(&attrib_list, WGL_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
243 }
244 }
245 putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp);
246 putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha);
247 putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE);
248 putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers);
249 if (sRGB) {
250 putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, TRUE);
251 }
252
253 // Assume caller checked extension availability
254 if (pixelFormatCaps != NULL) {
255 pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps);
256 pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps);
257
258 for (i = 0; i < pixelFormatCapsSize; i++)
259 putAttrib(&attrib_list, pixelFormatCaps_ptr[i]);
260 }
261 putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0);
262 result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned);
263
264 if (result == FALSE || num_formats_returned < 1) {
265 throwFormattedException(env, "Failed to find ARB pixel format %d %d\n", result, num_formats_returned);
266 return -1;
267 }
268 return iPixelFormat;
269 }
270
271 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) {
272 int bpp;
273 int iPixelFormat;
274 int fallback_bpp = 16;
275 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
276 if (use_hdc_bpp) {
277 bpp = GetDeviceCaps(hdc, BITSPIXEL);
278 iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
279 if ((*env)->ExceptionOccurred(env)) {
280 (*env)->ExceptionClear(env);
281 printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
282 bpp = fallback_bpp;
283 } else
284 return iPixelFormat;
285 } else
286 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
287 return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
288 }
289
290 /*
291 * Find an appropriate pixel format
292 */
293 static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer)
294 {
295 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
296 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
297 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
298 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
299 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
300 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
301 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
302 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
303 unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
304 PFD_SUPPORT_OPENGL |
305 (double_buffer ? PFD_DOUBLEBUFFER : 0) |
306 (stereo ? PFD_STEREO : 0);
307 PIXELFORMATDESCRIPTOR desc;
308 int iPixelFormat;
309 PIXELFORMATDESCRIPTOR pfd = {
310 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
311 1, // version number
312 flags, // RGBA type
313 PFD_TYPE_RGBA,
314 (BYTE)bpp,
315 0, 0, 0, 0, 0, 0, // color bits ignored
316 (BYTE)alpha,
317 0, // shift bit ignored
318 accum_bpp + accum_alpha, // no accumulation buffer
319 0, 0, 0, 0, // accum bits ignored
320 (BYTE)depth,
321 (BYTE)stencil,
322 num_aux_buffers,
323 PFD_MAIN_PLANE, // main layer
324 0, // reserved
325 0, 0, 0 // layer masks ignored
326 };
327 // get the best available match of pixel format for the device context
328 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
329 if (iPixelFormat == 0) {
330 throwException(env, "Failed to choose pixel format");
331 return -1;
332 }
333
334 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
335 throwException(env, "Could not describe pixel format");
336 return -1;
337 }
338
339 if (desc.cColorBits < bpp) {
340 throwException(env, "Insufficient color precision");
341 return -1;
342 }
343
344 if (desc.cAlphaBits < alpha) {
345 throwException(env, "Insufficient alpha precision");
346 return -1;
347 }
348
349 if (desc.cStencilBits < stencil) {
350 throwException(env, "Insufficient stencil precision");
351 return -1;
352 }
353
354 if (desc.cDepthBits < depth) {
355 throwException(env, "Insufficient depth buffer precision");
356 return -1;
357 }
358
359 if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) {
360 jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
361 // secondary check for software override
362 if(!allowSoftwareOpenGL) {
363 throwException(env, "Pixel format not accelerated");
364 return -1;
365 }
366 }
367
368 if ((desc.dwFlags & flags) != flags) {
369 throwException(env, "Capabilities not supported");
370 return -1;
371 }
372 return iPixelFormat;
373 }
374
375 static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bool use_hdc_bpp, bool double_buffer) {
376 int bpp;
377 int iPixelFormat;
378 int fallback_bpp = 16;
379 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
380 if (use_hdc_bpp) {
381 bpp = GetDeviceCaps(hdc, BITSPIXEL);
382 iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
383 if ((*env)->ExceptionOccurred(env)) {
384 (*env)->ExceptionClear(env);
385 printfDebugJava(env, "Failed to find pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
386 bpp = fallback_bpp;
387 } else
388 return iPixelFormat;
389 } else
390 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
391 return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
392 }
393
394 static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, int colorSamples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) {
395 if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) {
396 throwException(env, "Could not bind context to dummy window");
397 return false;
398 }
399 extgl_InitWGL(extensions);
400
401 if (!extensions->WGL_ARB_pixel_format) {
402 throwException(env, "No support for WGL_ARB_pixel_format");
403 return false;
404 }
405 if (samples > 0 && !extensions->WGL_ARB_multisample) {
406 throwException(env, "No support for WGL_ARB_multisample");
407 return false;
408 }
409 if (colorSamples > 0 && !extensions->WGL_NV_multisample_coverage) {
410 throwException(env, "No support for WGL_NV_multisample_coverage");
411 return false;
412 }
413 /*
414 * Apparently, some drivers don't report WGL_ARB_pixel_format_float
415 * even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float
416 * is supported.
417 */
418 if (floating_point && !(extensions->WGL_ARB_pixel_format_float || extensions->WGL_ATI_pixel_format_float)) {
419 throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float");
420 return false;
421 }
422 if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) {
423 throwException(env, "No support for WGL_EXT_pixel_format_packed_float");
424 return false;
425 }
426 if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) {
427 throwException(env, "No support for WGL_ARB_framebuffer_sRGB");
428 return false;
429 }
430 if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) {
431 throwException(env, "No support for WGL_ARB_render_texture");
432 return false;
433 }
434 return true;
435 }
436
437 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) {
438 HGLRC dummy_hglrc;
439 HDC saved_current_hdc;
440 HGLRC saved_current_hglrc;
441 WGLExtensions extensions;
442 HWND dummy_hwnd;
443 HDC dummy_hdc;
444 int pixel_format_id;
445 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
446
447 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
448 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
449 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
450 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
451 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
452 bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL;
453
454 pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer);
455 if (!(*env)->ExceptionOccurred(env) && use_arb_selection) {
456 dummy_hwnd = createDummyWindow(origin_x, origin_y);
457 if (dummy_hwnd == NULL) {
458 throwException(env, "Could not create dummy window");
459 return -1;
460 }
461 dummy_hdc = GetDC(dummy_hwnd);
462 if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) {
463 closeWindow(&dummy_hwnd, &dummy_hdc);
464 return -1;
465 }
466 dummy_hglrc = wglCreateContext(dummy_hdc);
467 if (dummy_hglrc == NULL) {
468 closeWindow(&dummy_hwnd, &dummy_hdc);
469 throwException(env, "Failed to create OpenGL rendering context");
470 return -1;
471 }
472 // Save the current HDC and HGLRC to avoid disruption
473 saved_current_hdc = wglGetCurrentDC();
474 saved_current_hglrc = wglGetCurrentContext();
475 if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, colorSamples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) {
476 pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer);
477 }
478 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
479 wglDeleteContext(dummy_hglrc);
480 closeWindow(&dummy_hwnd, &dummy_hdc);
481 }
482 return pixel_format_id;
483 }
484
485 static bool registerDummyWindow() {
486 static bool window_registered = false;
487 if (!window_registered) {
488 if (!registerWindow(dummyWindowProc, _CONTEXT_PRIVATE_CLASS_NAME)) {
489 return false;
490 }
491 window_registered = true;
492 }
493 return true;
494 }
495
496 HWND createDummyWindow(int origin_x, int origin_y) {
497 if (!registerDummyWindow())
498 return NULL;
499 return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
500 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
37 */
38
39 #ifndef __LWJGL_CONTEXT_H
40 #define __LWJGL_CONTEXT_H
41
42 #include "Window.h"
43 #include "extgl.h"
44 #include "extgl_wgl.h"
45
46 typedef struct {
47 union {
48 HWND hwnd;
49 HPBUFFERARB pbuffer;
50 } u;
51 HDC drawable_hdc;
52 WGLExtensions extensions;
53 } WindowsPeerInfo;
54
55 /*
56 * Register the LWJGL window class.
57 * Returns true for success, or false for failure
58 */
59 extern bool registerWindow(WNDPROC win_proc, LPCTSTR class_name);
60
61 extern bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat);
62
63 /*
64 * Close the window
65 */
66 extern void closeWindow(HWND *hwnd, HDC *hdc);
67
68 /**
69 * Create a dummy window suitable to create contexts from
70 */
71 extern HWND createDummyWindow(int x, int y);
72
73 /**
74 * Return appropriate window and extended style flags from the given fullscreen and undecorated property
75 */
76 extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window);
77
78 /*
79 * Create a window with the specified position, size, and
80 * fullscreen attribute. The window will have DirectInput associated
81 * with it.
82 *
83 * Returns true for success, or false for failure
84 */
85 extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent);
86
87 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);
88
89 #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 /*---------------------------------------------------------------------*/
87
88 static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) {
89 ExtFunction functions[] = {
90 {"wglCreatePbufferARB", (void *)&extensions->wglCreatePbufferARB},
91 {"wglGetPbufferDCARB", (void *)&extensions->wglGetPbufferDCARB},
92 {"wglReleasePbufferDCARB", (void *)&extensions->wglReleasePbufferDCARB},
93 {"wglDestroyPbufferARB", (void *)&extensions->wglDestroyPbufferARB},
94 {"wglQueryPbufferARB", (void *)&extensions->wglQueryPbufferARB}};
95 if (extensions->WGL_ARB_pbuffer)
96 extensions->WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
97 }
98
99 static void extgl_InitWGLARBPixelFormat(WGLExtensions *extensions) {
100 ExtFunction functions[] = {
101 {"wglGetPixelFormatAttribivARB", (void *)&extensions->wglGetPixelFormatAttribivARB},
102 {"wglGetPixelFormatAttribfvARB", (void *)&extensions->wglGetPixelFormatAttribfvARB},
103 {"wglChoosePixelFormatARB", (void *)&extensions->wglChoosePixelFormatARB}};
104 if (extensions->WGL_ARB_pixel_format)
105 extensions->WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
106 }
107
108 static void extgl_InitWGLARBRenderTexture(WGLExtensions *extensions) {
109 ExtFunction functions[] = {
110 {"wglBindTexImageARB", (void *)&extensions->wglBindTexImageARB},
111 {"wglReleaseTexImageARB", (void *)&extensions->wglReleaseTexImageARB},
112 {"wglSetPbufferAttribARB", (void *)&extensions->wglSetPbufferAttribARB}};
113 if (extensions->WGL_ARB_render_texture)
114 extensions->WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
115 }
116
117 static void extgl_InitWGLEXTSwapControl(WGLExtensions *extensions) {
118 ExtFunction functions[] = {
119 {"wglSwapIntervalEXT", (void *)&extensions->wglSwapIntervalEXT},
120 {"wglGetSwapIntervalEXT", (void *)&extensions->wglGetSwapIntervalEXT}};
121 if (extensions->WGL_EXT_swap_control)
122 extensions->WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
123 }
124
125 static void extgl_InitWGLARBMakeCurrentRead(WGLExtensions *extensions) {
126 ExtFunction functions[] = {
127 {"wglMakeContextCurrentARB", (void *)&extensions->wglMakeContextCurrentARB},
128 {"wglGetCurrentReadDCARB", (void *)&extensions->wglGetCurrentReadDCARB}};
129 if (extensions->WGL_ARB_make_current_read)
130 extensions->WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
131 }
132
133 static void extgl_InitWGLARBCreateContext(WGLExtensions *extensions) {
134 ExtFunction functions[] = {
135 {"wglCreateContextAttribsARB", (void *)&extensions->wglCreateContextAttribsARB}
136 };
137 if (extensions->WGL_ARB_create_context)
138 extensions->WGL_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
139 }
140
141 static void extgl_InitWGLNVPresentVideo(WGLExtensions *extensions) {
142 ExtFunction functions[] = {
143 {"wglEnumerateVideoDevicesNV", (void *)&extensions->wglEnumerateVideoDevicesNV},
144 {"wglBindVideoDeviceNV", (void *)&extensions->wglBindVideoDeviceNV},
145 {"wglQueryCurrentContextNV", (void *)&extensions->wglQueryCurrentContextNV}
146 };
147
148 if (extensions->WGL_NV_present_video)
149 extensions->WGL_NV_present_video = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
150 }
151
152 static void extgl_InitWGLNVVideoCapture(WGLExtensions *extensions) {
153 ExtFunction functions[] = {
154 {"wglBindVideoCaptureDeviceNV", (void *)&extensions->wglBindVideoCaptureDeviceNV},
155 {"wglEnumerateVideoCaptureDevicesNV", (void *)&extensions->wglEnumerateVideoCaptureDevicesNV},
156 {"wglLockVideoCaptureDeviceNV", (void *)&extensions->wglLockVideoCaptureDeviceNV},
157 {"wglQueryVideoCaptureDeviceNV", (void *)&extensions->wglQueryVideoCaptureDeviceNV},
158 {"wglReleaseVideoCaptureDeviceNV", (void *)&extensions->wglReleaseVideoCaptureDeviceNV}
159 };
160
161 if (extensions->WGL_NV_video_capture)
162 extensions->WGL_NV_video_capture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
163 }
164
165 /*---------------------------------------------------------------------*/
166
167 static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) {
168 extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region");
169 extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read");
170 extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample");
171 extensions->WGL_ARB_pixel_format_float = WGLQueryExtension(extensions, "WGL_ARB_pixel_format_float");
172 extensions->WGL_ATI_pixel_format_float = WGLQueryExtension(extensions, "WGL_ATI_pixel_format_float");
173 extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer");
174 extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format");
175 extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture");
176 extensions->WGL_EXT_swap_control = WGLQueryExtension(extensions, "WGL_EXT_swap_control");
177 extensions->WGL_NV_render_depth_texture = WGLQueryExtension(extensions, "WGL_NV_render_depth_texture");
178 extensions->WGL_NV_render_texture_rectangle = WGLQueryExtension(extensions, "WGL_NV_render_texture_rectangle");
179 extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB");
180 extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float");
181 extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context");
182 extensions->WGL_NV_multisample_coverage = WGLQueryExtension(extensions, "WGL_NV_multisample_coverage");
183 extensions->WGL_NV_present_video = WGLQueryExtension(extensions, "WGL_NV_present_video");
184 extensions->WGL_NV_video_capture = WGLQueryExtension(extensions, "WGL_NV_video_capture");
185 }
186
187 static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) {
188 ExtFunction functions[] = {
189 {"wglGetExtensionsStringEXT", (void *)&extensions->wglGetExtensionsStringEXT}
190 };
191 extensions->WGL_EXT_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
192 }
193
194 static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) {
195 ExtFunction functions[] = {
196 {"wglGetExtensionsStringARB", (void *)&extensions->wglGetExtensionsStringARB}
197 };
198 extensions->WGL_ARB_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions);
199 }
200
201 void extgl_InitWGL(WGLExtensions *extensions) {
202 extgl_InitWGLARBExtensionsString(extensions);
203 extgl_InitWGLEXTExtensionsString(extensions);
204
205 extgl_InitSupportedWGLExtensions(extensions);
206
207 extgl_InitWGLARBMakeCurrentRead(extensions);
208 extgl_InitWGLEXTSwapControl(extensions);
209 extgl_InitWGLARBRenderTexture(extensions);
210 extgl_InitWGLARBPixelFormat(extensions);
211 extgl_InitWGLARBPbuffer(extensions);
212 extgl_InitWGLARBCreateContext(extensions);
213 extgl_InitWGLNVPresentVideo(extensions);
214 extgl_InitWGLNVVideoCapture(extensions);
215 }
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 /*---------------------------------------------------------------------*/
203 /*------------ WGL_NV_multisample_coverage ----------------------------*/
204 /*---------------------------------------------------------------------*/
205
206 #define WGL_COVERAGE_SAMPLES_NV 0x2042
207 #define WGL_COLOR_SAMPLES_NV 0x20B9
208
209 /*--------------------------------------------------------------*/
210 /*------------ WGL_NV_present_video ----------------------------*/
211 /*--------------------------------------------------------------*/
212
213 DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
214
215 #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
216
217 typedef int (APIENTRY * wglEnumerateVideoDevicesNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList);
218 typedef BOOL (APIENTRY * wglBindVideoDeviceNVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
219 typedef BOOL (APIENTRY * wglQueryCurrentContextNVPROC) (int iAttribute, int *piValue);
220
221 /*--------------------------------------------------------------*/
222 /*------------ WGL_NV_video_capture ----------------------------*/
223 /*--------------------------------------------------------------*/
224
225 DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
226
227 #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
228
229 typedef BOOL (APIENTRY * wglBindVideoCaptureDeviceNVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
230 typedef UINT (APIENTRY * wglEnumerateVideoCaptureDevicesNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
231 typedef BOOL (APIENTRY * wglLockVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
232 typedef BOOL (APIENTRY * wglQueryVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
233 typedef BOOL (APIENTRY * wglReleaseVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
234
235 /*---------------------------------------------------------------------*/
236
237 typedef struct {
238 bool WGL_ARB_buffer_region;
239 bool WGL_ARB_extensions_string;
240 bool WGL_ARB_make_current_read;
241 bool WGL_ARB_multisample;
242 bool WGL_ARB_pbuffer;
243 bool WGL_ARB_pixel_format;
244 bool WGL_ARB_render_texture;
245 bool WGL_EXT_extensions_string;
246 bool WGL_EXT_swap_control;
247 bool WGL_NV_render_depth_texture;
248 bool WGL_NV_render_texture_rectangle;
249 bool WGL_ARB_pixel_format_float;
250 bool WGL_ATI_pixel_format_float;
251 bool WGL_ARB_framebuffer_sRGB;
252 bool WGL_EXT_pixel_format_packed_float;
253 bool WGL_ARB_create_context;
254 bool WGL_NV_multisample_coverage;
255 bool WGL_NV_present_video;
256 bool WGL_NV_video_capture;
257
258 wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT;
259
260 wglGetExtensionsStringARBPROC wglGetExtensionsStringARB;
261
262 wglCreatePbufferARBPROC wglCreatePbufferARB;
263 wglGetPbufferDCARBPROC wglGetPbufferDCARB;
264 wglReleasePbufferDCARBPROC wglReleasePbufferDCARB;
265 wglDestroyPbufferARBPROC wglDestroyPbufferARB;
266 wglQueryPbufferARBPROC wglQueryPbufferARB;
267
268 wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB;
269 wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB;
270 wglChoosePixelFormatARBPROC wglChoosePixelFormatARB;
271
272 wglBindTexImageARBPROC wglBindTexImageARB;
273 wglReleaseTexImageARBPROC wglReleaseTexImageARB;
274 wglSetPbufferAttribARBPROC wglSetPbufferAttribARB;
275
276 wglSwapIntervalEXTPROC wglSwapIntervalEXT;
277 wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT;
278
279 wglMakeContextCurrentARBPROC wglMakeContextCurrentARB;
280 wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB;
281
282 wglCreateContextAttribsARBPROC wglCreateContextAttribsARB;
283
284 wglEnumerateVideoDevicesNVPROC wglEnumerateVideoDevicesNV;
285 wglBindVideoDeviceNVPROC wglBindVideoDeviceNV;
286 wglQueryCurrentContextNVPROC wglQueryCurrentContextNV;
287
288 wglBindVideoCaptureDeviceNVPROC wglBindVideoCaptureDeviceNV;
289 wglEnumerateVideoCaptureDevicesNVPROC wglEnumerateVideoCaptureDevicesNV;
290 wglLockVideoCaptureDeviceNVPROC wglLockVideoCaptureDeviceNV;
291 wglQueryVideoCaptureDeviceNVPROC wglQueryVideoCaptureDeviceNV;
292 wglReleaseVideoCaptureDeviceNVPROC wglReleaseVideoCaptureDeviceNV;
293 } WGLExtensions;
294
295 extern void extgl_InitWGL(WGLExtensions *extensions);
296
297
298 #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$
34 *
35 * Windows Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision$
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->extensions = extensions;
170 peer_info->u.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->extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer, peer_info->drawable_hdc);
178 peer_info->extensions.wglDestroyPbufferARB(peer_info->u.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->extensions.wglQueryPbufferARB(peer_info->u.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->extensions.wglSetPbufferAttribARB(peer_info->u.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->extensions.wglBindTexImageARB(peer_info->u.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->extensions.wglReleaseTexImageARB(peer_info->u.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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
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 peer_info->extensions = extensions;
93
94 // Restore previous context
95 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
96
97 //
98 if ( extensions.WGL_ARB_create_context ) { // We support WGL_ARB_create_context, use the new context creation routine
99 // 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).
100 if ( shared_context != NULL || attribList != NULL ) {
101 // Delete the oldschool context
102 wglDeleteContext(context);
103 // Create a new context using WGL_ARB_create_context
104 context = (HGLRC)extensions.wglCreateContextAttribsARB(peer_info->drawable_hdc, shared_context, attribList);
105 if (context == NULL) {
106 throwException(env, "Could not create context (WGL_ARB_create_context)");
107 return NULL;
108 }
109 }
110 } else { // We don't support WGL_ARB_create_context, use the old context creation routine
111 if (shared_context != NULL && !wglShareLists(shared_context, context)) { // Use wglShareLists to share context data
112 wglDeleteContext(context);
113 throwException(env, "Could not share contexts");
114 return NULL;
115 }
116 }
117
118 context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
119 context_info->context = context;
120 return context_handle;
121 }
122
123 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHGLRC(JNIEnv *env, jclass clazz, jobject context_handle) {
124 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
125 return (intptr_t)context_info->context;
126 }
127
128 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
129 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
130 return (intptr_t)peer_info->drawable_hdc;
131 }
132
133 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers
134 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
135 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
136 SwapBuffers(peer_info->drawable_hdc);
137 }
138
139 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext
140 (JNIEnv *env, jclass clazz) {
141 wglMakeCurrent(NULL, NULL);
142 }
143
144 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nMakeCurrent
145 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
146 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
147 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
148 if (!wglMakeCurrent(peer_info->drawable_hdc, context_info->context))
149 throwException(env, "Could not make context current");
150 }
151
152 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nIsCurrent
153 (JNIEnv *env, jclass clazz, jobject context_handle) {
154 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
155 return wglGetCurrentContext() == context_info->context;
156 }
157
158 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
159 (JNIEnv *env, jclass clazz, jint value) {
160 WGLExtensions extensions;
161 extgl_InitWGL(&extensions);
162 if (extensions.WGL_EXT_swap_control) {
163 return extensions.wglSwapIntervalEXT(value) ? JNI_TRUE : JNI_FALSE;
164 } else
165 return JNI_FALSE;
166 }
167
168 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy
169 (JNIEnv *env, jclass clazz, jobject context_handle) {
170 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
171 wglDeleteContext(context_info->context);
172 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsContextImplementation */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsContextImplementation
5 #define _Included_org_lwjgl_opengl_WindowsContextImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsContextImplementation
11 * Method: nCreate
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCreate
15 (JNIEnv *, jclass, jobject, jobject, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_WindowsContextImplementation
19 * Method: getHGLRC
20 * Signature: (Ljava/nio/ByteBuffer;)J
21 */
22 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHGLRC
23 (JNIEnv *, jobject, jobject);
24
25 /*
26 * Class: org_lwjgl_opengl_WindowsContextImplementation
27 * Method: getHDC
28 * Signature: (Ljava/nio/ByteBuffer;)J
29 */
30 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC
31 (JNIEnv *, jobject, jobject);
32
33 /*
34 * Class: org_lwjgl_opengl_WindowsContextImplementation
35 * Method: nSwapBuffers
36 * Signature: (Ljava/nio/ByteBuffer;)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers
39 (JNIEnv *, jclass, jobject);
40
41 /*
42 * Class: org_lwjgl_opengl_WindowsContextImplementation
43 * Method: nReleaseCurrentContext
44 * Signature: ()V
45 */
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext
47 (JNIEnv *, jclass);
48
49 /*
50 * Class: org_lwjgl_opengl_WindowsContextImplementation
51 * Method: nMakeCurrent
52 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
53 */
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nMakeCurrent
55 (JNIEnv *, jclass, jobject, jobject);
56
57 /*
58 * Class: org_lwjgl_opengl_WindowsContextImplementation
59 * Method: nIsCurrent
60 * Signature: (Ljava/nio/ByteBuffer;)Z
61 */
62 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nIsCurrent
63 (JNIEnv *, jclass, jobject);
64
65 /*
66 * Class: org_lwjgl_opengl_WindowsContextImplementation
67 * Method: nSetSwapInterval
68 * Signature: (I)Z
69 */
70 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
71 (JNIEnv *, jclass, jint);
72
73 /*
74 * Class: org_lwjgl_opengl_WindowsContextImplementation
75 * Method: nDestroy
76 * Signature: (Ljava/nio/ByteBuffer;)V
77 */
78 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy
79 (JNIEnv *, jclass, jobject);
80
81 #ifdef __cplusplus
82 }
83 #endif
84 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsPbufferPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsPbufferPeerInfo
5 #define _Included_org_lwjgl_opengl_WindowsPbufferPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
11 * Method: nCreate
12 * Signature: (Ljava/nio/ByteBuffer;IILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nCreate
15 (JNIEnv *, jclass, jobject, jint, jint, jobject, jobject, jobject);
16
17 /*
18 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
19 * Method: nIsBufferLost
20 * Signature: (Ljava/nio/ByteBuffer;)Z
21 */
22 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost
23 (JNIEnv *, jclass, jobject);
24
25 /*
26 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
27 * Method: nSetPbufferAttrib
28 * Signature: (Ljava/nio/ByteBuffer;II)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nSetPbufferAttrib
31 (JNIEnv *, jclass, jobject, jint, jint);
32
33 /*
34 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
35 * Method: nBindTexImageToPbuffer
36 * Signature: (Ljava/nio/ByteBuffer;I)V
37 */
38 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer
39 (JNIEnv *, jclass, jobject, jint);
40
41 /*
42 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
43 * Method: nReleaseTexImageFromPbuffer
44 * Signature: (Ljava/nio/ByteBuffer;I)V
45 */
46 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer
47 (JNIEnv *, jclass, jobject, jint);
48
49 /*
50 * Class: org_lwjgl_opengl_WindowsPbufferPeerInfo
51 * Method: nDestroy
52 * Signature: (Ljava/nio/ByteBuffer;)V
53 */
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy
55 (JNIEnv *, jclass, jobject);
56
57 #ifdef __cplusplus
58 }
59 #endif
60 #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$
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision$
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(JNIEnv *env, jclass clazz) {
45 return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo));
46 }
47
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat
49 (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) {
50 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
51 return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer);
52 }
53
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat
55 (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint pixel_format) {
56 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
57 applyPixelFormat(env, hdc, pixel_format);
58 }
59
60 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) {
61 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
62 return (intptr_t)peer_info->drawable_hdc;
63 }
64
65 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
66 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
67 return (intptr_t)peer_info->u.hwnd;
68 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsPeerInfo
5 #define _Included_org_lwjgl_opengl_WindowsPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsPeerInfo
11 * Method: createHandle
12 * Signature: ()Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengl_WindowsPeerInfo
19 * Method: nChoosePixelFormat
20 * Signature: (JIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;ZZZZ)I
21 */
22 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat
23 (JNIEnv *, jclass, jlong, jint, jint, jobject, jobject, jboolean, jboolean, jboolean, jboolean);
24
25 /*
26 * Class: org_lwjgl_opengl_WindowsPeerInfo
27 * Method: setPixelFormat
28 * Signature: (JI)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat
31 (JNIEnv *, jclass, jlong, jint);
32
33 /*
34 * Class: org_lwjgl_opengl_WindowsPeerInfo
35 * Method: nGetHdc
36 * Signature: (Ljava/nio/ByteBuffer;)J
37 */
38 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc
39 (JNIEnv *, jclass, jobject);
40
41 /*
42 * Class: org_lwjgl_opengl_WindowsPeerInfo
43 * Method: nGetHwnd
44 * Signature: (Ljava/nio/ByteBuffer;)J
45 */
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd
47 (JNIEnv *, jclass, jobject);
48
49 #ifdef __cplusplus
50 }
51 #endif
52 #endif
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 -1 $
34 *
35 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision: -1 $
37 */
38
39 #include <malloc.h>
40 #include "Window.h"
41 #include "extgl.h"
42 /*#include "extgl_wgl.h"*/
43 #include "context.h"
44
45 extern HINSTANCE dll_handle; // Handle to the LWJGL dll
46
47 #define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name")
48
49 /*
50 * Register the LWJGL window class.
51 * Returns true for success, or false for failure
52 */
53 bool registerWindow(WNDPROC win_proc, LPCTSTR class_name)
54 {
55 WNDCLASS windowClass;
56 memset(&windowClass, 0, sizeof(windowClass));
57 windowClass.style = CS_OWNDC;
58 windowClass.lpfnWndProc = win_proc;
59 windowClass.cbClsExtra = 0;
60 windowClass.cbWndExtra = 0;
61 windowClass.hInstance = dll_handle;
62 windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
63 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
64 windowClass.hbrBackground = NULL;
65 windowClass.lpszMenuName = NULL;
66 windowClass.lpszClassName = class_name;
67
68 if (RegisterClass(&windowClass) == 0) {
69 printfDebug("Failed to register window class\n");
70 return false;
71 }
72 return true;
73 }
74
75 static LRESULT CALLBACK dummyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
76 return DefWindowProc(hwnd, msg, wParam, lParam);
77 }
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 /*
97 * Close the window
98 */
99 void closeWindow(HWND *hwnd, HDC *hdc)
100 {
101 // Release device context
102 if (*hdc != NULL && *hwnd != NULL) {
103 ReleaseDC(*hwnd, *hdc);
104 *hdc = NULL;
105 }
106
107 // Close the window
108 if (*hwnd != NULL) {
109 ShowWindow(*hwnd, SW_HIDE);
110 DestroyWindow(*hwnd);
111 *hwnd = NULL;
112 }
113 }
114
115 void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window) {
116 DWORD exstyle, windowflags;
117 if (undecorated) {
118 exstyle = WS_EX_APPWINDOW;
119 windowflags = WS_POPUP;
120 } else if (child_window) {
121 exstyle = 0;
122 windowflags = WS_CHILDWINDOW;
123 } else {
124 exstyle = WS_EX_APPWINDOW;
125 windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
126 }
127 windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
128 *windowflags_return = windowflags;
129 *exstyle_return = exstyle;
130 }
131
132 HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent)
133 {
134 RECT clientSize;
135 DWORD exstyle, windowflags;
136 HWND new_hwnd;
137
138 getWindowFlags(&windowflags, &exstyle, undecorated, child_window);
139
140 clientSize.bottom = height;
141 clientSize.left = 0;
142 clientSize.right = width;
143 clientSize.top = 0;
144
145 AdjustWindowRectEx(
146 &clientSize, // client-rectangle structure
147 windowflags, // window styles
148 FALSE, // menu-present option
149 exstyle // extended window style
150 );
151 // Create the window now, using that class:
152 new_hwnd = CreateWindowEx (
153 exstyle,
154 window_class_name,
155 _T(""),
156 windowflags,
157 x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
158 parent,
159 NULL,
160 dll_handle,
161 NULL);
162
163 return new_hwnd;
164 }
165
166 /*
167 static int convertToBPE(int bpp) {
168 int bpe;
169 switch (bpp) {
170 case 0:
171 bpe = 0;
172 break;
173 case 32:
174 case 24:
175 bpe = 8;
176 break;
177 case 16: // Fall through
178 default:
179 bpe = 4;
180 break;
181 }
182 return bpe;
183 }
184 */
185
186 /*
187 static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) {
188 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
189 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
190 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
191 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
192 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
193 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
194 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
195 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
196 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
197
198 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
199 jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
200 jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
201 jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
202
203 int pixel_type;
204 int iPixelFormat;
205 unsigned int num_formats_returned;
206 attrib_list_t attrib_list;
207 GLuint *pixelFormatCaps_ptr;
208 jlong pixelFormatCapsSize;
209 BOOL result;
210 jlong i;
211 int bpe = convertToBPE(bpp);
212
213 if ( floating_point )
214 pixel_type = WGL_TYPE_RGBA_FLOAT_ARB;
215 else if ( floating_point_packed )
216 pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT;
217 else
218 pixel_type = WGL_TYPE_RGBA_ARB;
219
220 initAttribList(&attrib_list);
221 if (window) {
222 putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE);
223 }
224 if (pbuffer) {
225 putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE);
226 }
227 if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) {
228 putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB);
229 }
230 putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type);
231 putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE);
232 putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE);
233 putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe);
234 putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe);
235 putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe);
236 putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha);
237 putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth);
238 putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil);
239 // Assume caller checked extension availability
240 if (samples > 0) {
241 putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1);
242 putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); // WGL_COVERAGE_SAMPLES_NV if colorSamples > 0
243 if ( colorSamples > 0 ) {
244 putAttrib(&attrib_list, WGL_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples);
245 }
246 }
247 putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp);
248 putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha);
249 putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE);
250 putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers);
251 if (sRGB) {
252 putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, TRUE);
253 }
254
255 // Assume caller checked extension availability
256 if (pixelFormatCaps != NULL) {
257 pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps);
258 pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps);
259
260 for (i = 0; i < pixelFormatCapsSize; i++)
261 putAttrib(&attrib_list, pixelFormatCaps_ptr[i]);
262 }
263 putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0);
264 result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned);
265
266 if (result == FALSE || num_formats_returned < 1) {
267 throwFormattedException(env, "Failed to find ARB pixel format %d %d\n", result, num_formats_returned);
268 return -1;
269 }
270 return iPixelFormat;
271 }
272
273 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) {
274 int bpp;
275 int iPixelFormat;
276 int fallback_bpp = 16;
277 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
278 if (use_hdc_bpp) {
279 bpp = GetDeviceCaps(hdc, BITSPIXEL);
280 iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
281 if ((*env)->ExceptionOccurred(env)) {
282 (*env)->ExceptionClear(env);
283 printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
284 bpp = fallback_bpp;
285 } else
286 return iPixelFormat;
287 } else
288 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
289 return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer);
290 }
291 */
292
293 /*
294 * Find an appropriate pixel format
295 */
296 /*
297 static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer)
298 {
299 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
300 int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));
301 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
302 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
303 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
304 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
305 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
306 jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
307 unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
308 PFD_SUPPORT_OPENGL |
309 (double_buffer ? PFD_DOUBLEBUFFER : 0) |
310 (stereo ? PFD_STEREO : 0);
311 PIXELFORMATDESCRIPTOR desc;
312 int iPixelFormat;
313 PIXELFORMATDESCRIPTOR pfd = {
314 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
315 1, // version number
316 flags, // RGBA type
317 PFD_TYPE_RGBA,
318 (BYTE)bpp,
319 0, 0, 0, 0, 0, 0, // color bits ignored
320 (BYTE)alpha,
321 0, // shift bit ignored
322 accum_bpp + accum_alpha, // no accumulation buffer
323 0, 0, 0, 0, // accum bits ignored
324 (BYTE)depth,
325 (BYTE)stencil,
326 num_aux_buffers,
327 PFD_MAIN_PLANE, // main layer
328 0, // reserved
329 0, 0, 0 // layer masks ignored
330 };
331 // get the best available match of pixel format for the device context
332 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
333 if (iPixelFormat == 0) {
334 throwException(env, "Failed to choose pixel format");
335 return -1;
336 }
337
338 if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {
339 throwException(env, "Could not describe pixel format");
340 return -1;
341 }
342
343 if (desc.cColorBits < bpp) {
344 throwException(env, "Insufficient color precision");
345 return -1;
346 }
347
348 if (desc.cAlphaBits < alpha) {
349 throwException(env, "Insufficient alpha precision");
350 return -1;
351 }
352
353 if (desc.cStencilBits < stencil) {
354 throwException(env, "Insufficient stencil precision");
355 return -1;
356 }
357
358 if (desc.cDepthBits < depth) {
359 throwException(env, "Insufficient depth buffer precision");
360 return -1;
361 }
362
363 if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) {
364 jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
365 // secondary check for software override
366 if(!allowSoftwareOpenGL) {
367 throwException(env, "Pixel format not accelerated");
368 return -1;
369 }
370 }
371
372 if ((desc.dwFlags & flags) != flags) {
373 throwException(env, "Capabilities not supported");
374 return -1;
375 }
376 return iPixelFormat;
377 }
378
379 static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bool use_hdc_bpp, bool double_buffer) {
380 int bpp;
381 int iPixelFormat;
382 int fallback_bpp = 16;
383 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
384 if (use_hdc_bpp) {
385 bpp = GetDeviceCaps(hdc, BITSPIXEL);
386 iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
387 if ((*env)->ExceptionOccurred(env)) {
388 (*env)->ExceptionClear(env);
389 printfDebugJava(env, "Failed to find pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp);
390 bpp = fallback_bpp;
391 } else
392 return iPixelFormat;
393 } else
394 bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I"));
395 return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
396 }
397 */
398
399 /*
400 static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, int colorSamples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) {
401 if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) {
402 throwException(env, "Could not bind context to dummy window");
403 return false;
404 }
405 extgl_InitWGL(extensions);
406
407 if (!extensions->WGL_ARB_pixel_format) {
408 throwException(env, "No support for WGL_ARB_pixel_format");
409 return false;
410 }
411 if (samples > 0 && !extensions->WGL_ARB_multisample) {
412 throwException(env, "No support for WGL_ARB_multisample");
413 return false;
414 }
415 if (colorSamples > 0 && !extensions->WGL_NV_multisample_coverage) {
416 throwException(env, "No support for WGL_NV_multisample_coverage");
417 return false;
418 }
419
420 // Apparently, some drivers don't report WGL_ARB_pixel_format_float
421 // even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float
422 // is supported.
423 if (floating_point && !(extensions->WGL_ARB_pixel_format_float || extensions->WGL_ATI_pixel_format_float)) {
424 throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float");
425 return false;
426 }
427 if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) {
428 throwException(env, "No support for WGL_EXT_pixel_format_packed_float");
429 return false;
430 }
431 if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) {
432 throwException(env, "No support for WGL_ARB_framebuffer_sRGB");
433 return false;
434 }
435 if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) {
436 throwException(env, "No support for WGL_ARB_render_texture");
437 return false;
438 }
439 return true;
440 }
441
442 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) {
443 HGLRC dummy_hglrc;
444 HDC saved_current_hdc;
445 HGLRC saved_current_hglrc;
446 WGLExtensions extensions;
447 HWND dummy_hwnd;
448 HDC dummy_hdc;
449 int pixel_format_id;
450 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
451
452 int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
453 int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
454 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
455 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
456 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
457 bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL;
458
459 pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer);
460 if (!(*env)->ExceptionOccurred(env) && use_arb_selection) {
461 dummy_hwnd = createDummyWindow(origin_x, origin_y);
462 if (dummy_hwnd == NULL) {
463 throwException(env, "Could not create dummy window");
464 return -1;
465 }
466 dummy_hdc = GetDC(dummy_hwnd);
467 if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) {
468 closeWindow(&dummy_hwnd, &dummy_hdc);
469 return -1;
470 }
471 dummy_hglrc = wglCreateContext(dummy_hdc);
472 if (dummy_hglrc == NULL) {
473 closeWindow(&dummy_hwnd, &dummy_hdc);
474 throwException(env, "Failed to create OpenGL rendering context");
475 return -1;
476 }
477 // Save the current HDC and HGLRC to avoid disruption
478 saved_current_hdc = wglGetCurrentDC();
479 saved_current_hglrc = wglGetCurrentContext();
480 if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, colorSamples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) {
481 pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer);
482 }
483 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
484 wglDeleteContext(dummy_hglrc);
485 closeWindow(&dummy_hwnd, &dummy_hdc);
486 }
487 return pixel_format_id;
488 }
489 */
490
491 static bool registerDummyWindow() {
492 static bool window_registered = false;
493 if (!window_registered) {
494 if (!registerWindow(dummyWindowProc, _CONTEXT_PRIVATE_CLASS_NAME)) {
495 return false;
496 }
497 window_registered = true;
498 }
499 return true;
500 }
501
502 HWND createDummyWindow(int origin_x, int origin_y) {
503 if (!registerDummyWindow())
504 return NULL;
505 return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
506 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 -1 $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: -1 $
37 */
38
39 #ifndef __LWJGL_CONTEXT_H
40 #define __LWJGL_CONTEXT_H
41
42 #include "Window.h"
43 #include "extgl.h"
44
45 typedef struct {
46 union {
47 HWND hwnd;
48 } u;
49 HDC drawable_hdc;
50 } WindowsPeerInfo;
51
52 /*
53 * Register the LWJGL window class.
54 * Returns true for success, or false for failure
55 */
56 extern bool registerWindow(WNDPROC win_proc, LPCTSTR class_name);
57
58 //extern bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat);
59
60 /*
61 * Close the window
62 */
63 extern void closeWindow(HWND *hwnd, HDC *hdc);
64
65 /**
66 * Create a dummy window suitable to create contexts from
67 */
68 extern HWND createDummyWindow(int x, int y);
69
70 /**
71 * Return appropriate window and extended style flags from the given fullscreen and undecorated property
72 */
73 extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window);
74
75 /*
76 * Create a window with the specified position, size, and
77 * fullscreen attribute. The window will have DirectInput associated
78 * with it.
79 *
80 * Returns true for success, or false for failure
81 */
82 extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent);
83
84 //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);
85
86 #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
39 static HMODULE lib_gl_handle = NULL;
40
41 void *extgl_GetProcAddress(const char *name) {
42 void *t = eglGetProcAddress(name);
43 if (t == NULL)
44 {
45 t = GetProcAddress(lib_gl_handle, name);
46 if (t == NULL)
47 {
48 printfDebug("Could not locate symbol %s\n", name);
49 }
50 }
51 return t;
52 }
53
54 bool extgl_Open(JNIEnv *env) {
55 if (lib_gl_handle != NULL)
56 return true;
57 // load the dynamic libraries for OpenGL
58 lib_gl_handle = LoadLibrary("libGLESv2.dll");
59 if (lib_gl_handle == NULL) {
60 throwException(env, "Could not load OpenGL ES library");
61 return false;
62 }
63 return true;
64 }
65
66 void extgl_Close(void) {
67 FreeLibrary(lib_gl_handle);
68 lib_gl_handle = NULL;
69 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 -1 $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: -1 $
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(JNIEnv *env, jclass clazz) {
45 return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo));
46 }
47
48 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) {
49 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
50 return (intptr_t)peer_info->drawable_hdc;
51 }
52
53 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
54 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
55 return (intptr_t)peer_info->u.hwnd;
56 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsPeerInfo
5 #define _Included_org_lwjgl_opengl_WindowsPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsPeerInfo
11 * Method: createHandle
12 * Signature: ()Ljava/nio/ByteBuffer;
13 */
14 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengl_WindowsPeerInfo
19 * Method: nChoosePixelFormat
20 * Signature: (JIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;ZZZZ)I
21 */
22 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat
23 (JNIEnv *, jclass, jlong, jint, jint, jobject, jobject, jboolean, jboolean, jboolean, jboolean);
24
25 /*
26 * Class: org_lwjgl_opengl_WindowsPeerInfo
27 * Method: setPixelFormat
28 * Signature: (JI)V
29 */
30 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat
31 (JNIEnv *, jclass, jlong, jint);
32
33 /*
34 * Class: org_lwjgl_opengl_WindowsPeerInfo
35 * Method: nGetHdc
36 * Signature: (Ljava/nio/ByteBuffer;)J
37 */
38 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc
39 (JNIEnv *, jclass, jobject);
40
41 /*
42 * Class: org_lwjgl_opengl_WindowsPeerInfo
43 * Method: nGetHwnd
44 * Signature: (Ljava/nio/ByteBuffer;)J
45 */
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd
47 (JNIEnv *, jclass, jobject);
48
49 #ifdef __cplusplus
50 }
51 #endif
52 #endif
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
31
3232 /**
33 * $Id: org_lwjgl_Sys.c 3259 2009-12-02 23:11:14Z matzon $
33 * $Id$
3434 *
3535 * Windows system library.
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3259 $
38 * @version $Revision$
3939 */
4040
4141 #include "Window.h"
5555 return time;
5656 }
5757
58 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) {
58 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title, jlong message) {
5959 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);
60 MessageBox(hwnd, (LPCTSTR)(intptr_t)message, (LPCTSTR)(intptr_t)title, MB_OK | MB_TOPMOST);
6861 }
6962
7063 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls(JNIEnv * env, jclass unused) {
9689 return NULL;
9790 }
9891 str = (const wchar_t *)clipboard_data;
99 ret = (*env)->NewString(env, str, wcslen(str));
92 ret = (*env)->NewString(env, str, (jsize)wcslen(str));
10093 } else if (textAvailable) {
10194 if (!OpenClipboard(NULL))
10295 return NULL;
110103 CloseClipboard();
111104 return NULL;
112105 }
113 ret = NewStringNativeWithLength(env, (const char *) clipboard_data, strlen(clipboard_data));
106 ret = NewStringNativeWithLength(env, (const char *) clipboard_data, (jsize)strlen(clipboard_data));
114107 } else {
115108 return NULL;
116109 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_WindowsSysImplementation */
3
4 #ifndef _Included_org_lwjgl_WindowsSysImplementation
5 #define _Included_org_lwjgl_WindowsSysImplementation
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_WindowsSysImplementation_JNI_VERSION
10 #define org_lwjgl_WindowsSysImplementation_JNI_VERSION 24L
11 /*
12 * Class: org_lwjgl_WindowsSysImplementation
13 * Method: nGetTime
14 * Signature: ()J
15 */
16 JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetTime
17 (JNIEnv *, jclass);
18
19 /*
20 * Class: org_lwjgl_WindowsSysImplementation
21 * Method: nAlert
22 * Signature: (JJJ)V
23 */
24 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert
25 (JNIEnv *, jclass, jlong, jlong, jlong);
26
27 /*
28 * Class: org_lwjgl_WindowsSysImplementation
29 * Method: initCommonControls
30 * Signature: ()V
31 */
32 JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls
33 (JNIEnv *, jclass);
34
35 /*
36 * Class: org_lwjgl_WindowsSysImplementation
37 * Method: nGetClipboard
38 * Signature: ()Ljava/lang/String;
39 */
40 JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard
41 (JNIEnv *, jclass);
42
43 #ifdef __cplusplus
44 }
45 #endif
46 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_input_Cursor.c 3263 2010-01-10 22:46:41Z matzon $
33 * $Id$
3434 *
3535 * win32 mouse handling.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3263 $
38 * @version $Revision$
3939 */
4040
4141 #include "Window.h"
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
5 * modification, are permitted provided that the following conditions are
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2626 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31
31
3232 /**
33 * $Id: org_lwjgl_opengl_Display.c 3302 2010-03-31 23:56:24Z spasi $
33 * $Id$
3434 *
3535 * Base Windows display
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3302 $
38 * @version $Revision$
3939 */
4040
4141 #define _PRIVATE_WINDOW_H_
42 #include <windowsx.h>
4342 #include <malloc.h>
4443 #include "Window.h"
45 #include "extgl_wgl.h"
44 #include <windowsx.h>
45 /*#include "extgl_wgl.h"*/
4646 #include "common_tools.h"
4747 #include "display.h"
4848 #include "org_lwjgl_opengl_WindowsDisplay.h"
5050 #include "context.h"
5151 #include <commctrl.h>
5252
53 #define WINDOWCLASSNAME "LWJGL"
53 #define WINDOWCLASSNAME _T("LWJGL")
54
55 static jclass windowsDisplayClass;
56 static jmethodID javaWindowProc;
5457
5558 /*
5659 * WindowProc for the GL window.
6063 WPARAM wParam,
6164 LPARAM lParam)
6265 {
66 /*
6367 jclass display_class;
6468 jclass display_class_global;
6569 jmethodID handleMessage_method;
6670 LONG message_time;
71 */
6772 JNIEnv *env = getThreadEnv();
6873 if (env != NULL && !(*env)->ExceptionOccurred(env)) {
6974 /*
7984 * a window is created, where we are sure that the calling class' classloader has
8085 * LWJGL classes in it.
8186 */
87
88 /*
8289 display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA);
8390 if (display_class_global == NULL) {
8491 display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay");
9097 }
9198 if (display_class_global != NULL) {
9299 message_time = GetMessageTime();
93 handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I");
100 handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)J");
94101 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);
102 return (*env)->CallStaticLongMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
103
96104 }
105 */
106
107 return (*env)->CallStaticLongMethod(
108 env, windowsDisplayClass, javaWindowProc,
109 (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)GetMessageTime()
110 );
97111 }
98112 return DefWindowProc(hWnd, msg, wParam, lParam);
99113 }
100114
101 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
115 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowProc(JNIEnv *env, jclass clazz, jobject method) {
116 windowsDisplayClass = (*env)->NewGlobalRef(env, clazz);
117 javaWindowProc = (*env)->FromReflectedMethod(env, method);
118 }
119
120 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
102121 return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
103122 }
104123
120139 PM_REMOVE // removal options
121140 ))
122141 {
123 if (msg.message == WM_QUIT)
124 break;
142 if (msg.message == WM_QUIT)
143 break;
125144 TranslateMessage(&msg);
126145 DispatchMessage(&msg);
127146 }
133152 }
134153
135154 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle
136 (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) {
155 (JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title) {
137156 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
138 char * title = GetStringNativeChars(env, title_obj);
139 SetWindowText(hwnd, title);
140 free(title);
157 SetWindowText(hwnd, (LPCTSTR)(intptr_t)title);
141158 }
142159
143160 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate(JNIEnv * env, jclass class) {
200217 buffer[1] = point.y;
201218 }
202219
220
221 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowRect(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) {
222 HWND hwnd = (HWND)(INT_PTR)hwnd_int;
223 RECT *buffer = (RECT *)(*env)->GetDirectBufferAddress(env, buffer_handle);
224 jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle);
225 if (size < 4) {
226 throwFormattedRuntimeException(env, "Buffer size < 4", size);
227 return false;
228 }
229 return GetWindowRect(hwnd, buffer);
230 }
231
203232 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow(JNIEnv *env, jclass unused) {
204233 return (INT_PTR)GetForegroundWindow();
205234 }
215244 throwFormattedRuntimeException(env, "Buffer size < 4", size);
216245 return;
217246 }
218 rect->top = buffer[0];
219 rect->bottom = buffer[1];
220 rect->left = buffer[2];
221 rect->right = buffer[3];
247 rect->left = buffer[0];
248 rect->top = buffer[1];
249 rect->right = buffer[2];
250 rect->bottom = buffer[3];
222251 }
223252
224253 static void copyRectToBuffer(JNIEnv *env, RECT *rect, jobject buffer_handle) {
228257 throwFormattedRuntimeException(env, "Buffer size < 4", size);
229258 return;
230259 }
231 buffer[0] = rect->top;
232 buffer[1] = rect->bottom;
233 buffer[2] = rect->left;
234 buffer[3] = rect->right;
260 buffer[0] = rect->left;
261 buffer[1] = rect->top;
262 buffer[2] = rect->right;
263 buffer[3] = rect->bottom;
235264 }
236265
237266 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jobject handle_buffer) {
302331 RECT clientSize;
303332
304333 getWindowFlags(&windowflags, &exstyle, undecorated, child);
305
334
306335 // If we're not a fullscreen window, adjust the height to account for the
307336 // height of the title bar:
308337 clientSize.bottom = height;
309338 clientSize.left = 0;
310339 clientSize.right = width;
311340 clientSize.top = 0;
312
341
313342 AdjustWindowRectEx(
314343 &clientSize, // client-rectangle structure
315344 windowflags, // window styles
316345 FALSE, // menu-present option
317346 exstyle // extended window style
318347 );
319
320348 SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER);
321349 }
322350
323351 static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) {
324 unsigned char col;
325 unsigned char mask;
326352 BITMAPV5HEADER bitmapInfo;
327353 HBITMAP cursorMask;
328354 HBITMAP colorBitmap;
334360 int imageSize;
335361 unsigned char *maskPixels;
336362 int widthInBytes;
337 int leftShift;
338 int maskPixelsOff;
339363 int scanlineWidth;
340364 HBITMAP colorDIB;
341
365
342366 memset(&bitmapInfo, 0, sizeof(BITMAPV5HEADER));
343367 bitmapInfo.bV5Size = sizeof(BITMAPV5HEADER);
344368 bitmapInfo.bV5Width = width;
379403 DeleteObject(colorDIB);
380404
381405 // Convert alpha map to pixel packed mask
382
406
383407 // number of bytes it takes to fit a bit packed scan line.
384408 widthInBytes = (width & 0x7) != 0 ? (width >> 3) + 1 : (width >> 3);
385409
391415 imageSize = scanlineWidth*height;
392416 maskPixels = (unsigned char*)malloc(sizeof(unsigned char)*imageSize);
393417 memset(maskPixels, 0xFF, sizeof(unsigned char)*imageSize);
394
418
395419 cursorMask = CreateBitmap(width, height, 1, 1, maskPixels);
396
420
397421 memset(&iconInfo, 0, sizeof(ICONINFO));
398422 iconInfo.hbmMask = cursorMask;
399423 iconInfo.hbmColor = colorBitmap;
426450 return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam);
427451 }
428452
453 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr
454 (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex, jlong longPtr) {
455 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
456 return SetWindowLongPtr(hwnd, nindex, (LONG_PTR) longPtr);
457 }
458
459 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr
460 (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex) {
461 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
462 jlong result = GetWindowLongPtr(hwnd, nindex);
463 return result;
464 }
465
466 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos
467 (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) {
468 jboolean result;
469 HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
470 HWND hwnd_after = (HWND)(INT_PTR)hwnd_after_ptr;
471
472 result = SetWindowPos(hwnd, hwnd_after, x, y, width, height, (UINT) uflags);
473 return result;
474 }
475
429476 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition
430477 (JNIEnv * env, jclass unused, jint x, jint y) {
431478 if (!SetCursorPos(x, y))
438485 RECT clientRect;
439486 GetClientRect(hwnd, &clientRect);
440487 copyRectToBuffer(env, &clientRect, rect_buffer);
488 }
489
490 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx
491 (JNIEnv *env, jclass unused, jobject rect_buffer, jint style, jboolean menu, jint styleex) {
492 jboolean result;
493 RECT clientRect;
494 copyBufferToRect(env, rect_buffer, &clientRect);
495 result = AdjustWindowRectEx(&clientRect, style, menu, styleex);
496 copyRectToBuffer(env, &clientRect, rect_buffer);
497 return result;
441498 }
442499
443500 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor
+0
-212
src/native/windows/org_lwjgl_opengl_Pbuffer.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3358 2010-06-03 15:49:26Z spasi $
34 *
35 * Windows Pbuffer.
36 *
37 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3358 $
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 }
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision$
3737 */
3838
3939 #include <jni.h>
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo
5 #define _Included_org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo
11 * Method: nInitHandle
12 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo_nInitHandle
15 (JNIEnv *, jclass, jobject, jobject);
16
17 #ifdef __cplusplus
18 }
19 #endif
20 #endif
+0
-172
src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3412 2010-09-26 23:43:24Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3412 $
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 jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHGLRC(JNIEnv *env, jclass clazz, jobject context_handle) {
123 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
124 return (intptr_t)context_info->context;
125 }
126
127 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
128 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
129 return (intptr_t)peer_info->drawable_hdc;
130 }
131
132 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers
133 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
134 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
135 SwapBuffers(peer_info->drawable_hdc);
136 }
137
138 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext
139 (JNIEnv *env, jclass clazz) {
140 wglMakeCurrent(NULL, NULL);
141 }
142
143 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nMakeCurrent
144 (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) {
145 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
146 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
147 if (!wglMakeCurrent(peer_info->drawable_hdc, context_info->context))
148 throwException(env, "Could not make context current");
149 }
150
151 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nIsCurrent
152 (JNIEnv *env, jclass clazz, jobject context_handle) {
153 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
154 return wglGetCurrentContext() == context_info->context;
155 }
156
157 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
158 (JNIEnv *env, jclass clazz, jint value) {
159 WGLExtensions extensions;
160 extgl_InitWGL(&extensions);
161 if (extensions.WGL_EXT_swap_control) {
162 return extensions.wglSwapIntervalEXT(value) ? JNI_TRUE : JNI_FALSE;
163 } else
164 return JNI_FALSE;
165 }
166
167 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy
168 (JNIEnv *env, jclass clazz, jobject context_handle) {
169 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
170 wglDeleteContext(context_info->context);
171 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsDisplay */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsDisplay
5 #define _Included_org_lwjgl_opengl_WindowsDisplay
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH
10 #define org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH 256L
11 #undef org_lwjgl_opengl_WindowsDisplay_WM_WINDOWPOSCHANGED
12 #define org_lwjgl_opengl_WindowsDisplay_WM_WINDOWPOSCHANGED 71L
13 #undef org_lwjgl_opengl_WindowsDisplay_WM_MOVE
14 #define org_lwjgl_opengl_WindowsDisplay_WM_MOVE 3L
15 #undef org_lwjgl_opengl_WindowsDisplay_WM_CANCELMODE
16 #define org_lwjgl_opengl_WindowsDisplay_WM_CANCELMODE 31L
17 #undef org_lwjgl_opengl_WindowsDisplay_WM_MOUSEMOVE
18 #define org_lwjgl_opengl_WindowsDisplay_WM_MOUSEMOVE 512L
19 #undef org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONDOWN
20 #define org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONDOWN 513L
21 #undef org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONUP
22 #define org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONUP 514L
23 #undef org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONDBLCLK
24 #define org_lwjgl_opengl_WindowsDisplay_WM_LBUTTONDBLCLK 515L
25 #undef org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONDOWN
26 #define org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONDOWN 516L
27 #undef org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONUP
28 #define org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONUP 517L
29 #undef org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONDBLCLK
30 #define org_lwjgl_opengl_WindowsDisplay_WM_RBUTTONDBLCLK 518L
31 #undef org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONDOWN
32 #define org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONDOWN 519L
33 #undef org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONUP
34 #define org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONUP 520L
35 #undef org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONDBLCLK
36 #define org_lwjgl_opengl_WindowsDisplay_WM_MBUTTONDBLCLK 521L
37 #undef org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONDOWN
38 #define org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONDOWN 523L
39 #undef org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONUP
40 #define org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONUP 524L
41 #undef org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONDBLCLK
42 #define org_lwjgl_opengl_WindowsDisplay_WM_XBUTTONDBLCLK 525L
43 #undef org_lwjgl_opengl_WindowsDisplay_WM_MOUSEWHEEL
44 #define org_lwjgl_opengl_WindowsDisplay_WM_MOUSEWHEEL 522L
45 #undef org_lwjgl_opengl_WindowsDisplay_WM_CAPTURECHANGED
46 #define org_lwjgl_opengl_WindowsDisplay_WM_CAPTURECHANGED 533L
47 #undef org_lwjgl_opengl_WindowsDisplay_WM_MOUSELEAVE
48 #define org_lwjgl_opengl_WindowsDisplay_WM_MOUSELEAVE 675L
49 #undef org_lwjgl_opengl_WindowsDisplay_WM_ENTERSIZEMOVE
50 #define org_lwjgl_opengl_WindowsDisplay_WM_ENTERSIZEMOVE 561L
51 #undef org_lwjgl_opengl_WindowsDisplay_WM_EXITSIZEMOVE
52 #define org_lwjgl_opengl_WindowsDisplay_WM_EXITSIZEMOVE 562L
53 #undef org_lwjgl_opengl_WindowsDisplay_WM_SIZING
54 #define org_lwjgl_opengl_WindowsDisplay_WM_SIZING 532L
55 #undef org_lwjgl_opengl_WindowsDisplay_WM_KEYDOWN
56 #define org_lwjgl_opengl_WindowsDisplay_WM_KEYDOWN 256L
57 #undef org_lwjgl_opengl_WindowsDisplay_WM_KEYUP
58 #define org_lwjgl_opengl_WindowsDisplay_WM_KEYUP 257L
59 #undef org_lwjgl_opengl_WindowsDisplay_WM_SYSKEYUP
60 #define org_lwjgl_opengl_WindowsDisplay_WM_SYSKEYUP 261L
61 #undef org_lwjgl_opengl_WindowsDisplay_WM_SYSKEYDOWN
62 #define org_lwjgl_opengl_WindowsDisplay_WM_SYSKEYDOWN 260L
63 #undef org_lwjgl_opengl_WindowsDisplay_WM_SYSCHAR
64 #define org_lwjgl_opengl_WindowsDisplay_WM_SYSCHAR 262L
65 #undef org_lwjgl_opengl_WindowsDisplay_WM_CHAR
66 #define org_lwjgl_opengl_WindowsDisplay_WM_CHAR 258L
67 #undef org_lwjgl_opengl_WindowsDisplay_WM_GETICON
68 #define org_lwjgl_opengl_WindowsDisplay_WM_GETICON 127L
69 #undef org_lwjgl_opengl_WindowsDisplay_WM_SETICON
70 #define org_lwjgl_opengl_WindowsDisplay_WM_SETICON 128L
71 #undef org_lwjgl_opengl_WindowsDisplay_WM_SETCURSOR
72 #define org_lwjgl_opengl_WindowsDisplay_WM_SETCURSOR 32L
73 #undef org_lwjgl_opengl_WindowsDisplay_WM_MOUSEACTIVATE
74 #define org_lwjgl_opengl_WindowsDisplay_WM_MOUSEACTIVATE 33L
75 #undef org_lwjgl_opengl_WindowsDisplay_WM_QUIT
76 #define org_lwjgl_opengl_WindowsDisplay_WM_QUIT 18L
77 #undef org_lwjgl_opengl_WindowsDisplay_WM_SYSCOMMAND
78 #define org_lwjgl_opengl_WindowsDisplay_WM_SYSCOMMAND 274L
79 #undef org_lwjgl_opengl_WindowsDisplay_WM_PAINT
80 #define org_lwjgl_opengl_WindowsDisplay_WM_PAINT 15L
81 #undef org_lwjgl_opengl_WindowsDisplay_WM_KILLFOCUS
82 #define org_lwjgl_opengl_WindowsDisplay_WM_KILLFOCUS 8L
83 #undef org_lwjgl_opengl_WindowsDisplay_WM_SETFOCUS
84 #define org_lwjgl_opengl_WindowsDisplay_WM_SETFOCUS 7L
85 #undef org_lwjgl_opengl_WindowsDisplay_SC_SIZE
86 #define org_lwjgl_opengl_WindowsDisplay_SC_SIZE 61440L
87 #undef org_lwjgl_opengl_WindowsDisplay_SC_MOVE
88 #define org_lwjgl_opengl_WindowsDisplay_SC_MOVE 61456L
89 #undef org_lwjgl_opengl_WindowsDisplay_SC_MINIMIZE
90 #define org_lwjgl_opengl_WindowsDisplay_SC_MINIMIZE 61472L
91 #undef org_lwjgl_opengl_WindowsDisplay_SC_MAXIMIZE
92 #define org_lwjgl_opengl_WindowsDisplay_SC_MAXIMIZE 61488L
93 #undef org_lwjgl_opengl_WindowsDisplay_SC_NEXTWINDOW
94 #define org_lwjgl_opengl_WindowsDisplay_SC_NEXTWINDOW 61504L
95 #undef org_lwjgl_opengl_WindowsDisplay_SC_PREVWINDOW
96 #define org_lwjgl_opengl_WindowsDisplay_SC_PREVWINDOW 61520L
97 #undef org_lwjgl_opengl_WindowsDisplay_SC_CLOSE
98 #define org_lwjgl_opengl_WindowsDisplay_SC_CLOSE 61536L
99 #undef org_lwjgl_opengl_WindowsDisplay_SC_VSCROLL
100 #define org_lwjgl_opengl_WindowsDisplay_SC_VSCROLL 61552L
101 #undef org_lwjgl_opengl_WindowsDisplay_SC_HSCROLL
102 #define org_lwjgl_opengl_WindowsDisplay_SC_HSCROLL 61568L
103 #undef org_lwjgl_opengl_WindowsDisplay_SC_MOUSEMENU
104 #define org_lwjgl_opengl_WindowsDisplay_SC_MOUSEMENU 61584L
105 #undef org_lwjgl_opengl_WindowsDisplay_SC_KEYMENU
106 #define org_lwjgl_opengl_WindowsDisplay_SC_KEYMENU 61696L
107 #undef org_lwjgl_opengl_WindowsDisplay_SC_ARRANGE
108 #define org_lwjgl_opengl_WindowsDisplay_SC_ARRANGE 61712L
109 #undef org_lwjgl_opengl_WindowsDisplay_SC_RESTORE
110 #define org_lwjgl_opengl_WindowsDisplay_SC_RESTORE 61728L
111 #undef org_lwjgl_opengl_WindowsDisplay_SC_TASKLIST
112 #define org_lwjgl_opengl_WindowsDisplay_SC_TASKLIST 61744L
113 #undef org_lwjgl_opengl_WindowsDisplay_SC_SCREENSAVE
114 #define org_lwjgl_opengl_WindowsDisplay_SC_SCREENSAVE 61760L
115 #undef org_lwjgl_opengl_WindowsDisplay_SC_HOTKEY
116 #define org_lwjgl_opengl_WindowsDisplay_SC_HOTKEY 61776L
117 #undef org_lwjgl_opengl_WindowsDisplay_SC_DEFAULT
118 #define org_lwjgl_opengl_WindowsDisplay_SC_DEFAULT 61792L
119 #undef org_lwjgl_opengl_WindowsDisplay_SC_MONITORPOWER
120 #define org_lwjgl_opengl_WindowsDisplay_SC_MONITORPOWER 61808L
121 #undef org_lwjgl_opengl_WindowsDisplay_SC_CONTEXTHELP
122 #define org_lwjgl_opengl_WindowsDisplay_SC_CONTEXTHELP 61824L
123 #undef org_lwjgl_opengl_WindowsDisplay_SC_SEPARATOR
124 #define org_lwjgl_opengl_WindowsDisplay_SC_SEPARATOR 61455L
125 #undef org_lwjgl_opengl_WindowsDisplay_SM_CXCURSOR
126 #define org_lwjgl_opengl_WindowsDisplay_SM_CXCURSOR 13L
127 #undef org_lwjgl_opengl_WindowsDisplay_SM_CYCURSOR
128 #define org_lwjgl_opengl_WindowsDisplay_SM_CYCURSOR 14L
129 #undef org_lwjgl_opengl_WindowsDisplay_SM_CMOUSEBUTTONS
130 #define org_lwjgl_opengl_WindowsDisplay_SM_CMOUSEBUTTONS 43L
131 #undef org_lwjgl_opengl_WindowsDisplay_SM_MOUSEWHEELPRESENT
132 #define org_lwjgl_opengl_WindowsDisplay_SM_MOUSEWHEELPRESENT 75L
133 #undef org_lwjgl_opengl_WindowsDisplay_SIZE_RESTORED
134 #define org_lwjgl_opengl_WindowsDisplay_SIZE_RESTORED 0L
135 #undef org_lwjgl_opengl_WindowsDisplay_SIZE_MINIMIZED
136 #define org_lwjgl_opengl_WindowsDisplay_SIZE_MINIMIZED 1L
137 #undef org_lwjgl_opengl_WindowsDisplay_SIZE_MAXIMIZED
138 #define org_lwjgl_opengl_WindowsDisplay_SIZE_MAXIMIZED 2L
139 #undef org_lwjgl_opengl_WindowsDisplay_WM_SIZE
140 #define org_lwjgl_opengl_WindowsDisplay_WM_SIZE 5L
141 #undef org_lwjgl_opengl_WindowsDisplay_WM_ACTIVATE
142 #define org_lwjgl_opengl_WindowsDisplay_WM_ACTIVATE 6L
143 #undef org_lwjgl_opengl_WindowsDisplay_WA_INACTIVE
144 #define org_lwjgl_opengl_WindowsDisplay_WA_INACTIVE 0L
145 #undef org_lwjgl_opengl_WindowsDisplay_WA_ACTIVE
146 #define org_lwjgl_opengl_WindowsDisplay_WA_ACTIVE 1L
147 #undef org_lwjgl_opengl_WindowsDisplay_WA_CLICKACTIVE
148 #define org_lwjgl_opengl_WindowsDisplay_WA_CLICKACTIVE 2L
149 #undef org_lwjgl_opengl_WindowsDisplay_SW_NORMAL
150 #define org_lwjgl_opengl_WindowsDisplay_SW_NORMAL 1L
151 #undef org_lwjgl_opengl_WindowsDisplay_SW_SHOWMINNOACTIVE
152 #define org_lwjgl_opengl_WindowsDisplay_SW_SHOWMINNOACTIVE 7L
153 #undef org_lwjgl_opengl_WindowsDisplay_SW_SHOWDEFAULT
154 #define org_lwjgl_opengl_WindowsDisplay_SW_SHOWDEFAULT 10L
155 #undef org_lwjgl_opengl_WindowsDisplay_SW_RESTORE
156 #define org_lwjgl_opengl_WindowsDisplay_SW_RESTORE 9L
157 #undef org_lwjgl_opengl_WindowsDisplay_SW_MAXIMIZE
158 #define org_lwjgl_opengl_WindowsDisplay_SW_MAXIMIZE 3L
159 #undef org_lwjgl_opengl_WindowsDisplay_ICON_SMALL
160 #define org_lwjgl_opengl_WindowsDisplay_ICON_SMALL 0L
161 #undef org_lwjgl_opengl_WindowsDisplay_ICON_BIG
162 #define org_lwjgl_opengl_WindowsDisplay_ICON_BIG 1L
163 #undef org_lwjgl_opengl_WindowsDisplay_HWND_TOP
164 #define org_lwjgl_opengl_WindowsDisplay_HWND_TOP 0i64
165 #undef org_lwjgl_opengl_WindowsDisplay_HWND_BOTTOM
166 #define org_lwjgl_opengl_WindowsDisplay_HWND_BOTTOM 1i64
167 #undef org_lwjgl_opengl_WindowsDisplay_HWND_TOPMOST
168 #define org_lwjgl_opengl_WindowsDisplay_HWND_TOPMOST -1i64
169 #undef org_lwjgl_opengl_WindowsDisplay_HWND_NOTOPMOST
170 #define org_lwjgl_opengl_WindowsDisplay_HWND_NOTOPMOST -2i64
171 #undef org_lwjgl_opengl_WindowsDisplay_SWP_NOSIZE
172 #define org_lwjgl_opengl_WindowsDisplay_SWP_NOSIZE 1L
173 #undef org_lwjgl_opengl_WindowsDisplay_SWP_NOMOVE
174 #define org_lwjgl_opengl_WindowsDisplay_SWP_NOMOVE 2L
175 #undef org_lwjgl_opengl_WindowsDisplay_SWP_NOZORDER
176 #define org_lwjgl_opengl_WindowsDisplay_SWP_NOZORDER 4L
177 #undef org_lwjgl_opengl_WindowsDisplay_SWP_FRAMECHANGED
178 #define org_lwjgl_opengl_WindowsDisplay_SWP_FRAMECHANGED 32L
179 #undef org_lwjgl_opengl_WindowsDisplay_GWL_STYLE
180 #define org_lwjgl_opengl_WindowsDisplay_GWL_STYLE -16L
181 #undef org_lwjgl_opengl_WindowsDisplay_GWL_EXSTYLE
182 #define org_lwjgl_opengl_WindowsDisplay_GWL_EXSTYLE -20L
183 #undef org_lwjgl_opengl_WindowsDisplay_WS_THICKFRAME
184 #define org_lwjgl_opengl_WindowsDisplay_WS_THICKFRAME 262144L
185 #undef org_lwjgl_opengl_WindowsDisplay_WS_MAXIMIZEBOX
186 #define org_lwjgl_opengl_WindowsDisplay_WS_MAXIMIZEBOX 65536L
187 #undef org_lwjgl_opengl_WindowsDisplay_HTCLIENT
188 #define org_lwjgl_opengl_WindowsDisplay_HTCLIENT 1L
189 #undef org_lwjgl_opengl_WindowsDisplay_MK_XBUTTON1
190 #define org_lwjgl_opengl_WindowsDisplay_MK_XBUTTON1 32L
191 #undef org_lwjgl_opengl_WindowsDisplay_MK_XBUTTON2
192 #define org_lwjgl_opengl_WindowsDisplay_MK_XBUTTON2 64L
193 #undef org_lwjgl_opengl_WindowsDisplay_XBUTTON1
194 #define org_lwjgl_opengl_WindowsDisplay_XBUTTON1 1L
195 #undef org_lwjgl_opengl_WindowsDisplay_XBUTTON2
196 #define org_lwjgl_opengl_WindowsDisplay_XBUTTON2 2L
197 /*
198 * Class: org_lwjgl_opengl_WindowsDisplay
199 * Method: nCreateWindow
200 * Signature: (IIIIZZJ)J
201 */
202 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow
203 (JNIEnv *, jclass, jint, jint, jint, jint, jboolean, jboolean, jlong);
204
205 /*
206 * Class: org_lwjgl_opengl_WindowsDisplay
207 * Method: nReleaseDC
208 * Signature: (JJ)V
209 */
210 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC
211 (JNIEnv *, jclass, jlong, jlong);
212
213 /*
214 * Class: org_lwjgl_opengl_WindowsDisplay
215 * Method: nDestroyWindow
216 * Signature: (J)V
217 */
218 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow
219 (JNIEnv *, jclass, jlong);
220
221 /*
222 * Class: org_lwjgl_opengl_WindowsDisplay
223 * Method: clipCursor
224 * Signature: (Ljava/nio/IntBuffer;)V
225 */
226 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor
227 (JNIEnv *, jclass, jobject);
228
229 /*
230 * Class: org_lwjgl_opengl_WindowsDisplay
231 * Method: nSwitchDisplayMode
232 * Signature: (Lorg/lwjgl/opengl/DisplayMode;)V
233 */
234 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSwitchDisplayMode
235 (JNIEnv *, jclass, jobject);
236
237 /*
238 * Class: org_lwjgl_opengl_WindowsDisplay
239 * Method: showWindow
240 * Signature: (JI)V
241 */
242 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_showWindow
243 (JNIEnv *, jclass, jlong, jint);
244
245 /*
246 * Class: org_lwjgl_opengl_WindowsDisplay
247 * Method: setForegroundWindow
248 * Signature: (J)V
249 */
250 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setForegroundWindow
251 (JNIEnv *, jclass, jlong);
252
253 /*
254 * Class: org_lwjgl_opengl_WindowsDisplay
255 * Method: setFocus
256 * Signature: (J)V
257 */
258 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setFocus
259 (JNIEnv *, jclass, jlong);
260
261 /*
262 * Class: org_lwjgl_opengl_WindowsDisplay
263 * Method: nResetDisplayMode
264 * Signature: ()V
265 */
266 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nResetDisplayMode
267 (JNIEnv *, jclass);
268
269 /*
270 * Class: org_lwjgl_opengl_WindowsDisplay
271 * Method: convertToNativeRamp
272 * Signature: (Ljava/nio/FloatBuffer;)Ljava/nio/ByteBuffer;
273 */
274 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_convertToNativeRamp
275 (JNIEnv *, jclass, jobject);
276
277 /*
278 * Class: org_lwjgl_opengl_WindowsDisplay
279 * Method: getCurrentGammaRamp
280 * Signature: ()Ljava/nio/ByteBuffer;
281 */
282 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentGammaRamp
283 (JNIEnv *, jclass);
284
285 /*
286 * Class: org_lwjgl_opengl_WindowsDisplay
287 * Method: nSetGammaRamp
288 * Signature: (Ljava/nio/ByteBuffer;)V
289 */
290 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetGammaRamp
291 (JNIEnv *, jclass, jobject);
292
293 /*
294 * Class: org_lwjgl_opengl_WindowsDisplay
295 * Method: nGetVersion
296 * Signature: (Ljava/lang/String;)Lorg/lwjgl/opengl/WindowsFileVersion;
297 */
298 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetVersion
299 (JNIEnv *, jobject, jstring);
300
301 /*
302 * Class: org_lwjgl_opengl_WindowsDisplay
303 * Method: getCurrentDisplayMode
304 * Signature: ()Lorg/lwjgl/opengl/DisplayMode;
305 */
306 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentDisplayMode
307 (JNIEnv *, jclass);
308
309 /*
310 * Class: org_lwjgl_opengl_WindowsDisplay
311 * Method: nSetTitle
312 * Signature: (JJ)V
313 */
314 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle
315 (JNIEnv *, jclass, jlong, jlong);
316
317 /*
318 * Class: org_lwjgl_opengl_WindowsDisplay
319 * Method: nUpdate
320 * Signature: ()V
321 */
322 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate
323 (JNIEnv *, jclass);
324
325 /*
326 * Class: org_lwjgl_opengl_WindowsDisplay
327 * Method: nReshape
328 * Signature: (JIIIIZZ)V
329 */
330 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape
331 (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jboolean, jboolean);
332
333 /*
334 * Class: org_lwjgl_opengl_WindowsDisplay
335 * Method: getAvailableDisplayModes
336 * Signature: ()[Lorg/lwjgl/opengl/DisplayMode;
337 */
338 JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getAvailableDisplayModes
339 (JNIEnv *, jobject);
340
341 /*
342 * Class: org_lwjgl_opengl_WindowsDisplay
343 * Method: nSetCursorPosition
344 * Signature: (II)V
345 */
346 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition
347 (JNIEnv *, jclass, jint, jint);
348
349 /*
350 * Class: org_lwjgl_opengl_WindowsDisplay
351 * Method: nSetNativeCursor
352 * Signature: (JLjava/lang/Object;)V
353 */
354 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor
355 (JNIEnv *, jclass, jlong, jobject);
356
357 /*
358 * Class: org_lwjgl_opengl_WindowsDisplay
359 * Method: getSystemMetrics
360 * Signature: (I)I
361 */
362 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics
363 (JNIEnv *, jclass, jint);
364
365 /*
366 * Class: org_lwjgl_opengl_WindowsDisplay
367 * Method: getDllInstance
368 * Signature: ()J
369 */
370 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDllInstance
371 (JNIEnv *, jclass);
372
373 /*
374 * Class: org_lwjgl_opengl_WindowsDisplay
375 * Method: getDC
376 * Signature: (J)J
377 */
378 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDC
379 (JNIEnv *, jclass, jlong);
380
381 /*
382 * Class: org_lwjgl_opengl_WindowsDisplay
383 * Method: getDesktopWindow
384 * Signature: ()J
385 */
386 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow
387 (JNIEnv *, jclass);
388
389 /*
390 * Class: org_lwjgl_opengl_WindowsDisplay
391 * Method: getForegroundWindow
392 * Signature: ()J
393 */
394 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow
395 (JNIEnv *, jclass);
396
397 /*
398 * Class: org_lwjgl_opengl_WindowsDisplay
399 * Method: nCreateCursor
400 * Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)Ljava/nio/ByteBuffer;
401 */
402 JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateCursor
403 (JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
404
405 /*
406 * Class: org_lwjgl_opengl_WindowsDisplay
407 * Method: doDestroyCursor
408 * Signature: (Ljava/lang/Object;)V
409 */
410 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_doDestroyCursor
411 (JNIEnv *, jclass, jobject);
412
413 /*
414 * Class: org_lwjgl_opengl_WindowsDisplay
415 * Method: nGetPbufferCapabilities
416 * Signature: (Lorg/lwjgl/opengl/PixelFormat;)I
417 */
418 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetPbufferCapabilities
419 (JNIEnv *, jobject, jobject);
420
421 /*
422 * Class: org_lwjgl_opengl_WindowsDisplay
423 * Method: createIcon
424 * Signature: (IILjava/nio/IntBuffer;)J
425 */
426 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_createIcon
427 (JNIEnv *, jclass, jint, jint, jobject);
428
429 /*
430 * Class: org_lwjgl_opengl_WindowsDisplay
431 * Method: destroyIcon
432 * Signature: (J)V
433 */
434 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyIcon
435 (JNIEnv *, jclass, jlong);
436
437 /*
438 * Class: org_lwjgl_opengl_WindowsDisplay
439 * Method: sendMessage
440 * Signature: (JJJJ)J
441 */
442 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_sendMessage
443 (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
444
445 /*
446 * Class: org_lwjgl_opengl_WindowsDisplay
447 * Method: setWindowLongPtr
448 * Signature: (JIJ)J
449 */
450 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr
451 (JNIEnv *, jclass, jlong, jint, jlong);
452
453 /*
454 * Class: org_lwjgl_opengl_WindowsDisplay
455 * Method: getWindowLongPtr
456 * Signature: (JI)J
457 */
458 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr
459 (JNIEnv *, jclass, jlong, jint);
460
461 /*
462 * Class: org_lwjgl_opengl_WindowsDisplay
463 * Method: setWindowPos
464 * Signature: (JJIIIIJ)Z
465 */
466 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos
467 (JNIEnv *, jclass, jlong, jlong, jint, jint, jint, jint, jlong);
468
469 /*
470 * Class: org_lwjgl_opengl_WindowsDisplay
471 * Method: nSetCapture
472 * Signature: (J)J
473 */
474 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCapture
475 (JNIEnv *, jclass, jlong);
476
477 /*
478 * Class: org_lwjgl_opengl_WindowsDisplay
479 * Method: nReleaseCapture
480 * Signature: ()Z
481 */
482 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseCapture
483 (JNIEnv *, jclass);
484
485 /*
486 * Class: org_lwjgl_opengl_WindowsDisplay
487 * Method: getClientRect
488 * Signature: (JLjava/nio/IntBuffer;)V
489 */
490 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect
491 (JNIEnv *, jclass, jlong, jobject);
492
493 /*
494 * Class: org_lwjgl_opengl_WindowsDisplay
495 * Method: clientToScreen
496 * Signature: (JLjava/nio/IntBuffer;)V
497 */
498 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen
499 (JNIEnv *, jclass, jlong, jobject);
500
501 /*
502 * Class: org_lwjgl_opengl_WindowsDisplay
503 * Method: setWindowProc
504 * Signature: (Ljava/lang/reflect/Method;)V
505 */
506 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowProc
507 (JNIEnv *, jclass, jobject);
508
509 /*
510 * Class: org_lwjgl_opengl_WindowsDisplay
511 * Method: defWindowProc
512 * Signature: (JIJJ)J
513 */
514 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc
515 (JNIEnv *, jclass, jlong, jint, jlong, jlong);
516
517 /*
518 * Class: org_lwjgl_opengl_WindowsDisplay
519 * Method: getWindowRect
520 * Signature: (JLjava/nio/IntBuffer;)Z
521 */
522 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowRect
523 (JNIEnv *, jobject, jlong, jobject);
524
525 /*
526 * Class: org_lwjgl_opengl_WindowsDisplay
527 * Method: nTrackMouseEvent
528 * Signature: (J)Z
529 */
530 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nTrackMouseEvent
531 (JNIEnv *, jobject, jlong);
532
533 /*
534 * Class: org_lwjgl_opengl_WindowsDisplay
535 * Method: adjustWindowRectEx
536 * Signature: (Ljava/nio/IntBuffer;IZI)Z
537 */
538 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx
539 (JNIEnv *, jobject, jobject, jint, jboolean, jint);
540
541 #ifdef __cplusplus
542 }
543 #endif
544 #endif
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_WindowsDisplayPeerInfo.c 3057 2008-04-30 16:01:25Z elias_naur $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3057 $
36 * @version $Revision$
3737 */
3838
3939 #include <jni.h>
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsDisplayPeerInfo */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsDisplayPeerInfo
5 #define _Included_org_lwjgl_opengl_WindowsDisplayPeerInfo
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsDisplayPeerInfo
11 * Method: nInitDC
12 * Signature: (Ljava/nio/ByteBuffer;JJ)V
13 */
14 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nInitDC
15 (JNIEnv *, jclass, jobject, jlong, jlong);
16
17 #ifdef __cplusplus
18 }
19 #endif
20 #endif
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsDisplay_Rect */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsDisplay_Rect
5 #define _Included_org_lwjgl_opengl_WindowsDisplay_Rect
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #ifdef __cplusplus
10 }
11 #endif
12 #endif
4040 #include <jni.h>
4141 #include "org_lwjgl_opengl_WindowsKeyboard.h"
4242
43 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) {
43 JNIEXPORT jshort JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) {
4444 return GetKeyState(virt_key);
45 }
46
47 JNIEXPORT jshort JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetAsyncKeyState(JNIEnv *env, jclass unused, jint virt_key) {
48 return GetAsyncKeyState(virt_key);
4549 }
4650
4751 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) {
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsKeyboard */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsKeyboard
5 #define _Included_org_lwjgl_opengl_WindowsKeyboard
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 /*
10 * Class: org_lwjgl_opengl_WindowsKeyboard
11 * Method: isWindowsNT
12 * Signature: ()Z
13 */
14 JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_isWindowsNT
15 (JNIEnv *, jclass);
16
17 /*
18 * Class: org_lwjgl_opengl_WindowsKeyboard
19 * Method: MapVirtualKey
20 * Signature: (II)I
21 */
22 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey
23 (JNIEnv *, jclass, jint, jint);
24
25 /*
26 * Class: org_lwjgl_opengl_WindowsKeyboard
27 * Method: ToUnicode
28 * Signature: (IILjava/nio/ByteBuffer;Ljava/nio/CharBuffer;II)I
29 */
30 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToUnicode
31 (JNIEnv *, jclass, jint, jint, jobject, jobject, jint, jint);
32
33 /*
34 * Class: org_lwjgl_opengl_WindowsKeyboard
35 * Method: ToAscii
36 * Signature: (IILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;I)I
37 */
38 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToAscii
39 (JNIEnv *, jclass, jint, jint, jobject, jobject, jint);
40
41 /*
42 * Class: org_lwjgl_opengl_WindowsKeyboard
43 * Method: GetKeyboardState
44 * Signature: (Ljava/nio/ByteBuffer;)I
45 */
46 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyboardState
47 (JNIEnv *, jclass, jobject);
48
49 /*
50 * Class: org_lwjgl_opengl_WindowsKeyboard
51 * Method: GetKeyState
52 * Signature: (I)S
53 */
54 JNIEXPORT jshort JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState
55 (JNIEnv *, jclass, jint);
56
57 /*
58 * Class: org_lwjgl_opengl_WindowsKeyboard
59 * Method: GetAsyncKeyState
60 * Signature: (I)S
61 */
62 JNIEXPORT jshort JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetAsyncKeyState
63 (JNIEnv *, jclass, jint);
64
65 #ifdef __cplusplus
66 }
67 #endif
68 #endif
+0
-69
src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR 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 3358 2010-06-03 15:49:26Z spasi $
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3358 $
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(JNIEnv *env, jclass clazz) {
45 return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo));
46 }
47
48 JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat
49 (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) {
50 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
51 return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer);
52 }
53
54 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat
55 (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint pixel_format) {
56 HDC hdc = (HDC)(INT_PTR)hdc_ptr;
57 applyPixelFormat(env, hdc, pixel_format);
58 }
59
60 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) {
61 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
62 return (intptr_t)peer_info->drawable_hdc;
63 }
64
65 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
66 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
67 return (intptr_t)peer_info->u.hwnd;
68 }
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_WindowsRegistry.c 2985 2008-04-07 18:42:36Z matzon $
33 * $Id$
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision$
3737 */
3838
3939 #include <jni.h>
9292 return NULL;
9393 }
9494 result[buf_size - 1] = '\0';
95 java_result = NewStringNativeWithLength(env, result, strlen(result));
95 java_result = NewStringNativeWithLength(env, result, (jsize)strlen(result));
9696 free(result);
9797 return java_result;
9898 }
0 /* DO NOT EDIT THIS FILE - it is machine generated */
1 #include <jni.h>
2 /* Header for class org_lwjgl_opengl_WindowsRegistry */
3
4 #ifndef _Included_org_lwjgl_opengl_WindowsRegistry
5 #define _Included_org_lwjgl_opengl_WindowsRegistry
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #undef org_lwjgl_opengl_WindowsRegistry_HKEY_CLASSES_ROOT
10 #define org_lwjgl_opengl_WindowsRegistry_HKEY_CLASSES_ROOT 1L
11 #undef org_lwjgl_opengl_WindowsRegistry_HKEY_CURRENT_USER
12 #define org_lwjgl_opengl_WindowsRegistry_HKEY_CURRENT_USER 2L
13 #undef org_lwjgl_opengl_WindowsRegistry_HKEY_LOCAL_MACHINE
14 #define org_lwjgl_opengl_WindowsRegistry_HKEY_LOCAL_MACHINE 3L
15 #undef org_lwjgl_opengl_WindowsRegistry_HKEY_USERS
16 #define org_lwjgl_opengl_WindowsRegistry_HKEY_USERS 4L
17 /*
18 * Class: org_lwjgl_opengl_WindowsRegistry
19 * Method: nQueryRegistrationKey
20 * Signature: (ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;
21 */
22 JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_WindowsRegistry_nQueryRegistrationKey
23 (JNIEnv *, jclass, jint, jstring, jstring);
24
25 #ifdef __cplusplus
26 }
27 #endif
28 #endif
3636 #include "common_tools.h"
3737
3838 /**
39 * $Id: windows_al.c 3412 2010-09-26 23:43:24Z spasi $
39 * $Id$
4040 *
4141 * This file contains the AL extension assigning mechanism
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 3412 $
44 * @version $Revision$
4545 */
4646 /* Handle to OpenAL Library */
4747 static HMODULE handleOAL;
4444 * AL.h version 1.0
4545 *
4646 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 3412 $
48 * $Id: AL10.java 3412 2010-09-26 23:43:24Z spasi $
47 * @version $Revision$
48 * $Id$
4949 */
5050 public interface AL10 {
5151 /** Bad value */
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_uint;
38 import org.lwjgl.util.generator.opencl.cl_ulong;
39
40 @CLDeviceExtension
41 public interface AMD_bus_addressable_memory {
42
43 /** cl_mem flag - bitfield */
44 int CL_MEM_BUS_ADDRESSABLE_AMD = (1 << 30),
45 CL_MEM_EXTERNAL_PHYSICAL_AMD = (1 << 31);
46
47 int CL_COMMAND_WAIT_SIGNAL_AMD = 0x4080,
48 CL_COMMAND_WRITE_SIGNAL_AMD = 0x4081,
49 CL_COMMAND_MAKE_BUFFERS_RESIDENT_AMD = 0x4082;
50
51 /*
52 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
53 @cl_int
54 int clEnqueueWaitSignalAMD(
55 @PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
56 @PointerWrapper("cl_mem") CLMem mem_object,
57 @cl_uint int value,
58 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events,
59 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
60 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event
61 );
62
63 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
64 @cl_int
65 int clEnqueueWriteSignalAMD(
66 @PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
67 @PointerWrapper("cl_mem") CLMem mem_object,
68 @cl_uint int value,
69 @cl_ulong long offset,
70 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events,
71 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
72 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event
73 );
74
75 // TODO: Implement
76 int clEnqueueMakeBuffersResidentAMD();
77 */
78
79 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_device_memory_flags {
37
38 /** Alloc from GPU's CPU visible heap. */
39 int CL_MEM_USE_PERSISTENT_MEM_AMD = (1 << 6);
40
41 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_media_ops2 {
37
38 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_offline_devices {
37
38 int CL_CONTEXT_OFFLINE_DEVICES_AMD = 0x403F;
39
40 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_popcnt {
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_vec3 {
37
38 }
3131 package org.lwjgl.opencl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35 import org.lwjgl.util.generator.opencl.cl_char;
36 import org.lwjgl.util.generator.opencl.cl_void;
37 import org.lwjgl.util.generator.opencl.size_t;
34 import org.lwjgl.util.generator.opencl.*;
3835
3936 import java.nio.ByteBuffer;
4037
4138 @Private
39 @CLPlatformExtension
4240 @CLDeviceExtension
41 @Extension(postfix = "APPLE", nativeName = "cl_APPLE_ContextLoggingFunctions")
4342 public interface APPLE_ContextLoggingFunctions {
4443
4544 @Extern
3232
3333 import org.lwjgl.util.generator.Code;
3434 import org.lwjgl.util.generator.Constant;
35 import org.lwjgl.util.generator.Extension;
3536 import org.lwjgl.util.generator.PointerWrapper;
3637 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
38 import org.lwjgl.util.generator.opencl.CLPlatformExtension;
3739 import org.lwjgl.util.generator.opencl.cl_int;
3840
41 @CLPlatformExtension
3942 @CLDeviceExtension
43 @Extension(postfix = "APPLE", nativeName = "cl_APPLE_SetMemObjectDestructor")
4044 public interface APPLE_SetMemObjectDestructor {
4145
4246 @Code(
3232
3333 import org.lwjgl.PointerBuffer;
3434 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_void;
38 import org.lwjgl.util.generator.opencl.size_t;
35 import org.lwjgl.util.generator.opencl.*;
3936
4037 import java.nio.ByteBuffer;
4138
39 @CLPlatformExtension
4240 @CLDeviceExtension
43 @Extension(postfix = "APPLE", className = "APPLEGLSharing")
41 @Extension(postfix = "APPLE", className = "APPLEGLSharing", nativeName = "cl_APPLE_gl_sharing")
4442 public interface APPLE_gl_sharing {
4543
4644 /**
398398 // Create a GlobalRef to the callback object.
399399 javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);",
400400 // Associate context with the GlobalRef, so we can delete it later.
401 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
401 javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);"
402402 )
403403 @Check(value = "errcode_ret", canBeNull = true)
404404 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
416416 // Create a GlobalRef to the callback object.
417417 javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);",
418418 // Associate context with the GlobalRef, so we can delete it later.
419 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
419 javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);"
420420 )
421421 @Check(value = "errcode_ret", canBeNull = true)
422422 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
423423 CLContext clCreateContext(@NullTerminated @Check("3") @Const @NativeType("cl_context_properties") PointerBuffer properties,
424424 @Constant("1") @cl_uint int num_devices,
425 @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device,
425 @Constant(value = "APIUtil.getPointer(device)", keepParam = true) CLDevice device,
426426 @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify,
427427 @Constant("user_data") @PointerWrapper("void *") long user_data,
428428 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
431431 @Code(
432432 tryBlock = true,
433433 // Create a GlobalRef to the callback object.
434 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
434 javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);",
435435 // Associate context with the GlobalRef, so we can delete it later.
436 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
436 javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);"
437437 )
438438 @Check(value = "errcode_ret", canBeNull = true)
439439 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
449449
450450 @Code(
451451 javaBeforeNative = "\t\tAPIUtil.releaseObjects(context);",
452 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) CallbackUtil.unregisterCallback(context);"
452 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) context.releaseImpl();"
453453 )
454454 @cl_int
455455 int clReleaseContext(@PointerWrapper("cl_context") CLContext context);
510510 @PointerWrapper("cl_mem") CLMem buffer,
511511 @cl_bool int blocking_read,
512512 @size_t long offset,
513 @AutoSize("ptr") @size_t long cb,
513 @AutoSize("ptr") @size_t long size,
514514 @OutParameter
515515 @cl_byte
516516 @cl_short
528528 @PointerWrapper("cl_mem") CLMem buffer,
529529 @cl_bool int blocking_write,
530530 @size_t long offset,
531 @AutoSize("ptr") @size_t long cb,
531 @AutoSize("ptr") @size_t long size,
532532 @Const
533533 @cl_byte
534534 @cl_short
547547 @PointerWrapper("cl_mem") CLMem dst_buffer,
548548 @size_t long src_offset,
549549 @size_t long dst_offset,
550 @size_t long cb,
550 @size_t long size,
551551 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
552552 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
553553 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
555555 @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);")
556556 @Check(value = "errcode_ret", canBeNull = true)
557557 @cl_void
558 @AutoSize("cb")
558 @AutoSize("size")
559559 ByteBuffer clEnqueueMapBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
560560 @PointerWrapper("cl_mem") CLMem buffer,
561561 @cl_bool int blocking_map,
562562 @NativeType("cl_map_flags") long map_flags,
563563 @size_t long offset,
564 @size_t long cb,
564 @size_t long size,
565565 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
566566 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
567567 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event,
682682 @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);")
683683 @Check(value = "errcode_ret", canBeNull = true)
684684 @cl_void
685 @AutoSize(value = "extcl_CalculateImageSize(region_address, *image_row_pitch_address, image_slice_pitch == NULL ? 0 : *image_slice_pitch_address)", isNative = true)
685 @AutoSize(value = "extcl_CalculateImageSize(region_address, *image_row_pitch_address, image_slice_pitch_address == NULL ? 0 : *image_slice_pitch_address)", isNative = true)
686686 ByteBuffer clEnqueueMapImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
687687 @PointerWrapper("cl_mem") CLMem image,
688688 @cl_bool int blocking_map,
775775 CLProgram clCreateProgramWithSource3(@PointerWrapper("cl_context") CLContext context,
776776 @Constant("strings.length") @cl_uint int count,
777777 @Check("1") @PointerArray(value = "count") @Const @NativeType("cl_char") ByteBuffer[] strings,
778 @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
778 @Constant("APIUtil.getLengths(strings)") @Const @NativeType("size_t") PointerBuffer lengths,
779779 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
780780
781781 @Alternate("clCreateProgramWithSource")
793793 CLProgram clCreateProgramWithSource4(@PointerWrapper("cl_context") CLContext context,
794794 @Constant("strings.length") @cl_uint int count,
795795 @Const @PointerArray(value = "count", lengths = "lengths") CharSequence[] strings,
796 @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
796 @Constant("APIUtil.getLengths(strings)") @Const @NativeType("size_t") PointerBuffer lengths,
797797 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
798798
799799 // ------[ clCreateProgramWithBinary ]------
825825 CLProgram clCreateProgramWithBinary3(@PointerWrapper("cl_context") CLContext context,
826826 @Constant("binaries.length") @cl_uint int num_devices,
827827 @Check("binaries.length") @Const @NativeType("cl_device_id") PointerBuffer device_list,
828 @Constant("APIUtil.getLengths(binaries).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
828 @Constant("APIUtil.getLengths(binaries)") @Const @NativeType("size_t") PointerBuffer lengths,
829829 @Check("1") @PointerArray("num_devices") @Const @NativeType("cl_uchar") ByteBuffer[] binaries,
830830 @OutParameter @Check("binaries.length") @cl_int IntBuffer binary_status,
831831 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
844844 @Code(
845845 tryBlock = true,
846846 // Create a GlobalRef to the callback object.
847 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
847 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
848 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
848849 // Check if we need to delete the GlobalRef.
849850 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
850851 )
853854 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
854855 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
855856 @Check @NullTerminated @Const @cl_char ByteBuffer options,
856 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
857 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
857858 @Constant("user_data") @PointerWrapper("void *") long user_data);
858859
859860 @Alternate("clBuildProgram")
860861 @Code(
861862 tryBlock = true,
862863 // Create a GlobalRef to the callback object.
863 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
864 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
865 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
864866 // Check if we need to delete the GlobalRef.
865867 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
866868 )
869871 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
870872 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
871873 @NullTerminated @Const CharSequence options,
872 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
874 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
873875 @Constant("user_data") @PointerWrapper("void *") long user_data);
874876
875877 @Alternate("clBuildProgram")
876878 @Code(
877879 tryBlock = true,
878880 // Create a GlobalRef to the callback object.
879 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
881 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
882 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
880883 // Check if we need to delete the GlobalRef.
881884 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
882885 )
883886 @cl_int
884887 int clBuildProgram(@PointerWrapper("cl_program") CLProgram program,
885888 @Constant("1") @cl_uint int num_devices,
886 @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device,
889 @Constant(value = "APIUtil.getPointer(device)", keepParam = true) CLDevice device,
887890 @NullTerminated @Const CharSequence options,
888 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
891 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
889892 @Constant("user_data") @PointerWrapper("void *") long user_data);
890893
891894 @cl_int
914917 @cl_int
915918 int clGetProgramInfo2(@PointerWrapper("cl_program") CLProgram program,
916919 @Constant("CL_PROGRAM_BINARIES") @NativeType("cl_program_info") int param_name,
917 @Constant("sizes.remainingByte()") @size_t long param_value_size,
920 @Constant(value = "sizes_len * sizeof(cl_uchar *)", isNative = true) @size_t long param_value_size,
921 @Constant("sizes.remaining()") @Helper(passToNative = true) @size_t long sizes_len,
918922 @Helper(passToNative = true) @Check("1") @Const @NativeType("size_t") PointerBuffer sizes,
919 @OutParameter @Check("APIUtil.getSize(sizes)") @PointerArray(value = "param_value_size", lengths = "sizes") @NativeType("cl_uchar") ByteBuffer param_value,
923 @OutParameter @Check("APIUtil.getSize(sizes)") @PointerArray(value = "sizes_len", lengths = "sizes") @NativeType("cl_uchar") ByteBuffer param_value,
920924 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
921925
922926 /**
935939 @cl_int
936940 int clGetProgramInfo3(@PointerWrapper("cl_program") CLProgram program,
937941 @Constant("CL_PROGRAM_BINARIES") @NativeType("cl_program_info") int param_name,
938 @Constant("param_value.length * PointerBuffer.getPointerSize()") @size_t long param_value_size,
939 @PointerArray("param_value_size") @NativeType("cl_uchar") ByteBuffer[] param_value,
942 @Constant(value = "param_value_len * sizeof(cl_uchar *)", isNative = true) @size_t long param_value_size,
943 @Constant("param_value.length") @Helper(passToNative = true) @size_t long param_value_len,
944 @PointerArray("param_value_len") @NativeType("cl_uchar") ByteBuffer[] param_value,
940945 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
941946
942947 @cl_int
975980 @cl_int
976981 int clReleaseKernel(@PointerWrapper("cl_kernel") CLKernel kernel);
977982
983 @GenerateAutos
978984 @cl_int
979985 int clSetKernelArg(@PointerWrapper("cl_kernel") CLKernel kernel,
980986 @cl_uint int arg_index,
993999 @cl_uint int arg_index,
9941000 @Constant("PointerBuffer.getPointerSize()") @size_t long arg_size,
9951001 @Check(canBeNull = true) @Const
996 @Constant(value = "APIUtil.getBufferPointer().put(0, arg_value == null ? 0 : arg_value.getPointer()).getBuffer(), 0", keepParam = true) CLObject arg_value);
997
998 /** Sets the size of a __local kernel argument at the specified index. */
999 @Alternate("clSetKernelArg")
1000 @cl_int
1001 int clSetKernelArg2(@PointerWrapper("cl_kernel") CLKernel kernel,
1002 @cl_uint int arg_index,
1003 @size_t long arg_size,
1004 @Constant("null, 0") Buffer arg_value);
1002 @Constant(value = "APIUtil.getPointerSafe(arg_value)", keepParam = true) CLObject arg_value);
10051003
10061004 // This is used by CLKernelUtil. Assumes arg_value.position() == 0.
10071005
10111009 int clSetKernelArg3(@PointerWrapper("cl_kernel") CLKernel kernel,
10121010 @cl_uint int arg_index,
10131011 @size_t long arg_size,
1014 @Constant(value = "arg_value, 0", keepParam = true) Buffer arg_value);
1012 @Constant(value = "MemoryUtil.getAddress0(arg_value)", keepParam = true) Buffer arg_value);
10151013
10161014 @cl_int
10171015 int clGetKernelInfo(@PointerWrapper("cl_kernel") CLKernel kernel,
10761074 nativeAfterVars = "\tvoid **args_mem_loc = num_mem_objects == 0 ? NULL : (void **)malloc(num_mem_objects * sizeof(void *));",
10771075 nativeBeforeCall = "\t_ptr_i = 0;\n" +
10781076 "\twhile ( _ptr_i < num_mem_objects ) {\n" +
1079 "\t\targs_mem_loc[_ptr_i] = (cl_void *)((char *)args_address + (4 + _ptr_i * (4 + sizeof(void *))));\n" +
1077 "\t\targs_mem_loc[_ptr_i] = (cl_void *)((char *)args_address + (12 + 4 + _ptr_i * (4 + sizeof(void *))));\n" +
10801078 "\t\t_ptr_i++;\n" +
10811079 "\t}",
10821080 nativeAfterCall = "\tfree(args_mem_loc);"
10841082 @cl_int
10851083 int clEnqueueNativeKernel(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
10861084 @PointerWrapper("cl_native_kernel_func") CLNativeKernel user_func,
1087 @Constant("args, 0") @cl_void ByteBuffer args,
1085 @Constant("MemoryUtil.getAddress0(args)") @cl_void ByteBuffer args,
10881086 @AutoSize("args") @size_t long cb_args,
10891087 @Constant("mem_list == null ? 0 : mem_list.length") @cl_uint int num_mem_objects,
10901088 @Check(value = "1", canBeNull = true) @PointerArray("num_mem_objects") @Const @NativeType("cl_mem") CLMem[] mem_list,
11011099 @Alternate("clWaitForEvents")
11021100 @cl_int
11031101 int clWaitForEvents(@Constant("1") @cl_uint int num_events,
1104 @Constant(value = "APIUtil.getBufferPointer().put(0, event).getBuffer(), 0", keepParam = true) CLEvent event);
1102 @Constant(value = "APIUtil.getPointer(event)", keepParam = true) CLEvent event);
11051103
11061104 @cl_int
11071105 int clGetEventInfo(@PointerWrapper("cl_event") CLEvent event,
11351133 @cl_int
11361134 int clEnqueueWaitForEvents(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
11371135 @Constant("1") @cl_uint int num_events,
1138 @Constant(value = "APIUtil.getBufferPointer().put(0, event).getBuffer(), 0", keepParam = true) CLEvent event);
1136 @Constant(value = "APIUtil.getPointer(event)", keepParam = true) CLEvent event);
11391137
11401138 @cl_int
11411139 int clGetEventProfilingInfo(@PointerWrapper("cl_event") CLEvent event,
11521150
11531151 @Private
11541152 @PointerWrapper("void *")
1155 CLFunctionAddress clGetExtensionFunctionAddress(@Check("1") @Const @cl_char ByteBuffer func_name);
1153 CLFunctionAddress clGetExtensionFunctionAddress(@NullTerminated @Const @cl_char ByteBuffer func_name);
11561154
11571155 @Alternate("clGetExtensionFunctionAddress")
11581156 @Private
11591157 @PointerWrapper("void *")
1160 CLFunctionAddress clGetExtensionFunctionAddress(CharSequence func_name);
1158 CLFunctionAddress clGetExtensionFunctionAddress(@NullTerminated CharSequence func_name);
11611159
11621160 }
111111 @cl_int
112112 int clEnqueueAcquireGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
113113 @Constant("1") @cl_uint int num_objects,
114 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
114 @Constant(value = "APIUtil.getPointer(mem_object)", keepParam = true) CLMem mem_object,
115115 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
116116 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
117117 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
130130 @cl_int
131131 int clEnqueueReleaseGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
132132 @Constant("1") @cl_uint int num_objects,
133 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
133 @Constant(value = "APIUtil.getPointer(mem_object)", keepParam = true) CLMem mem_object,
134134 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
135135 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
136136 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
120120 int clEnqueueReadBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
121121 @PointerWrapper("cl_mem") CLMem buffer,
122122 @cl_bool int blocking_read,
123 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin,
124 @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin,
123 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_offset,
124 @Const @Check("3") @NativeType("size_t") PointerBuffer host_offset,
125125 @Const @Check("3") @NativeType("size_t") PointerBuffer region,
126126 @size_t long buffer_row_pitch,
127127 @size_t long buffer_slice_pitch,
128128 @size_t long host_row_pitch,
129129 @size_t long host_slice_pitch,
130 @OutParameter @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)")
130 @OutParameter @Check("CLChecks.calculateBufferRectSize(host_offset, region, host_row_pitch, host_slice_pitch)")
131131 @cl_byte
132132 @cl_short
133133 @cl_int
143143 int clEnqueueWriteBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
144144 @PointerWrapper("cl_mem") CLMem buffer,
145145 @cl_bool int blocking_write,
146 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin,
147 @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin,
146 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_offset,
147 @Const @Check("3") @NativeType("size_t") PointerBuffer host_offset,
148148 @Const @Check("3") @NativeType("size_t") PointerBuffer region,
149149 @size_t long buffer_row_pitch,
150150 @size_t long buffer_slice_pitch,
151151 @size_t long host_row_pitch,
152152 @size_t long host_slice_pitch,
153 @Const @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)")
153 @Const @Check("CLChecks.calculateBufferRectSize(host_offset, region, host_row_pitch, host_slice_pitch)")
154154 @cl_byte
155155 @cl_short
156156 @cl_int
189189 @Code(
190190 tryBlock = true,
191191 // Create a GlobalRef to the callback object.
192 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
192 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
193 "\t\tpfn_notify.setRegistry(event.getParentRegistry());",
193194 // Check if we need to delete the GlobalRef.
194195 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
195196 )
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.*;
36
37 import java.nio.Buffer;
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40 import java.nio.LongBuffer;
41
42 /** The core OpenCL 1.1 API */
43 public interface CL12 {
44
45 /** Error Codes */
46 int CL_COMPILE_PROGRAM_FAILURE = -15,
47 CL_LINKER_NOT_AVAILABLE = -16,
48 CL_LINK_PROGRAM_FAILURE = -17,
49 CL_DEVICE_PARTITION_FAILED = -18,
50 CL_KERNEL_ARG_INFO_NOT_AVAILABLE = -19,
51 CL_INVALID_IMAGE_DESCRIPTOR = -65,
52 CL_INVALID_COMPILER_OPTIONS = -66,
53 CL_INVALID_LINKER_OPTIONS = -67,
54 CL_INVALID_DEVICE_PARTITION_COUNT = -68;
55
56 /** OpenCL Version */
57 int CL_VERSION_1_2 = 1;
58
59 /** cl_bool */
60 int CL_BLOCKING = CL10.CL_TRUE,
61 CL_NON_BLOCKING = CL10.CL_FALSE;
62
63 /** cl_device_type - bitfield */
64 int CL_DEVICE_TYPE_CUSTOM = (1 << 4);
65
66 /* cl_device_info */
67 int CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032,
68 CL_DEVICE_LINKER_AVAILABLE = 0x103E,
69 CL_DEVICE_BUILT_IN_KERNELS = 0x103F,
70 CL_DEVICE_IMAGE_MAX_BUFFER_SIZE = 0x1040,
71 CL_DEVICE_IMAGE_MAX_ARRAY_SIZE = 0x1041,
72 CL_DEVICE_PARENT_DEVICE = 0x1042,
73 CL_DEVICE_PARTITION_MAX_SUB_DEVICES = 0x1043,
74 CL_DEVICE_PARTITION_PROPERTIES = 0x1044,
75 CL_DEVICE_PARTITION_AFFINITY_DOMAIN = 0x1045,
76 CL_DEVICE_PARTITION_TYPE = 0x1046,
77 CL_DEVICE_REFERENCE_COUNT = 0x1047,
78 CL_DEVICE_PREFERRED_INTEROP_USER_SYNC = 0x1048,
79 CL_DEVICE_PRINTF_BUFFER_SIZE = 0x1049;
80
81 /* cl_device_fp_config - bitfield */
82 int CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7);
83
84 /* cl_context_properties */
85 int CL_CONTEXT_INTEROP_USER_SYNC = 0x1085;
86
87 /* cl_device_partition_property */
88 int CL_DEVICE_PARTITION_EQUALLY = 0x1086,
89 CL_DEVICE_PARTITION_BY_COUNTS = 0x1087,
90 CL_DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0,
91 CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088;
92
93 /* cl_device_affinity_domain */
94 int CL_DEVICE_AFFINITY_DOMAIN_NUMA = (1 << 0),
95 CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE = (1 << 1),
96 CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE = (1 << 2),
97 CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE = (1 << 3),
98 CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE = (1 << 4),
99 CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5);
100
101 /* cl_mem_flags - bitfield */
102 int CL_MEM_HOST_WRITE_ONLY = (1 << 7),
103 CL_MEM_HOST_READ_ONLY = (1 << 8),
104 CL_MEM_HOST_NO_ACCESS = (1 << 9);
105
106 /* cl_mem_migration_flags - bitfield */
107 int CL_MIGRATE_MEM_OBJECT_HOST = (1 << 0),
108 CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = (1 << 1);
109
110 /* cl_mem_object_type */
111 int CL_MEM_OBJECT_IMAGE2D_ARRAY = 0x10F3,
112 CL_MEM_OBJECT_IMAGE1D = 0x10F4,
113 CL_MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5,
114 CL_MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6;
115
116 /* cl_image_info */
117 int CL_IMAGE_ARRAY_SIZE = 0x1117,
118 CL_IMAGE_BUFFER = 0x1118,
119 CL_IMAGE_NUM_MIP_LEVELS = 0x1119,
120 CL_IMAGE_NUM_SAMPLES = 0x111A;
121
122 /* cl_map_flags - bitfield */
123 int CL_MAP_WRITE_INVALIDATE_REGION = (1 << 2);
124
125 /* cl_program_info */
126 int CL_PROGRAM_NUM_KERNELS = 0x1167,
127 CL_PROGRAM_KERNEL_NAMES = 0x1168;
128
129 /* cl_program_build_info */
130 int CL_PROGRAM_BINARY_TYPE = 0x1184;
131
132 /* cl_program_binary_type */
133 int CL_PROGRAM_BINARY_TYPE_NONE = 0x0,
134 CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1,
135 CL_PROGRAM_BINARY_TYPE_LIBRARY = 0x2,
136 CL_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4;
137
138 /* cl_kernel_info */
139 int CL_KERNEL_ATTRIBUTES = 0x1195;
140
141 /* cl_kernel_arg_info */
142 int CL_KERNEL_ARG_ADDRESS_QUALIFIER = 0x1196,
143 CL_KERNEL_ARG_ACCESS_QUALIFIER = 0x1197,
144 CL_KERNEL_ARG_TYPE_NAME = 0x1198,
145 CL_KERNEL_ARG_TYPE_QUALIFIER = 0x1199,
146 CL_KERNEL_ARG_NAME = 0x119A;
147
148 /* cl_kernel_arg_address_qualifier */
149 int CL_KERNEL_ARG_ADDRESS_GLOBAL = 0x119A,
150 CL_KERNEL_ARG_ADDRESS_LOCAL = 0x119B,
151 CL_KERNEL_ARG_ADDRESS_CONSTANT = 0x119C,
152 CL_KERNEL_ARG_ADDRESS_PRIVATE = 0x119D;
153
154 /* cl_kernel_arg_access_qualifier */
155 int CL_KERNEL_ARG_ACCESS_READ_ONLY = 0x11A0,
156 CL_KERNEL_ARG_ACCESS_WRITE_ONLY = 0x11A1,
157 CL_KERNEL_ARG_ACCESS_READ_WRITE = 0x11A2,
158 CL_KERNEL_ARG_ACCESS_NONE = 0x11A3;
159
160 /* cl_kernel_arg_type_qualifer */
161 int CL_KERNEL_ARG_TYPE_NONE = 0,
162 CL_KERNEL_ARG_TYPE_CONST = (1 << 0),
163 CL_KERNEL_ARG_TYPE_RESTRICT = (1 << 1),
164 CL_KERNEL_ARG_TYPE_VOLATILE = (1 << 2);
165
166 /* cl_kernel_work_group_info */
167 int CL_KERNEL_GLOBAL_WORK_SIZE = 0x11B5;
168
169 /* cl_command_type */
170 int CL_COMMAND_BARRIER = 0x1205,
171 CL_COMMAND_MIGRATE_MEM_OBJECTS = 0x1206,
172 CL_COMMAND_FILL_BUFFER = 0x1207,
173 CL_COMMAND_FILL_IMAGE = 0x1208;
174
175 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.retain();")
176 @cl_int
177 int clRetainDevice(@PointerWrapper("cl_device_id") CLDevice device);
178
179 /**
180 * Warning: LWJGL will not automatically release any objects associated with sub-devices.
181 * The user is responsible for tracking and releasing everything prior to calling this method.
182 *
183 * @param device the parent CLDevice
184 *
185 * @return the error code
186 */
187 @Code(
188 javaBeforeNative = "\t\tAPIUtil.releaseObjects(device);",
189 javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.release();"
190 )
191 @cl_int
192 int clReleaseDevice(@PointerWrapper("cl_device_id") CLDevice device);
193
194 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && out_devices != null ) in_device.registerSubCLDevices(out_devices);")
195 @cl_int
196 int clCreateSubDevices(
197 @PointerWrapper("cl_device_id") CLDevice in_device,
198 @NullTerminated @Const @NativeType("cl_device_partition_property") LongBuffer properties,
199 @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_devices,
200 @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices,
201 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices_ret);
202
203 @Check(value = "errcode_ret", canBeNull = true)
204 @PointerWrapper(value = "cl_mem", params = "context")
205 CLMem clCreateImage(@PointerWrapper("cl_context") CLContext context,
206 @NativeType("cl_mem_flags") long flags,
207 @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format,
208 // On x64 there's 4 byte padding after image_type (to align image_width)
209 @Check("7 * PointerBuffer.getPointerSize() + 2 * 4 + PointerBuffer.getPointerSize()") @Const @NativeType("cl_image_desc") ByteBuffer image_desc,
210 @Check(canBeNull = true)
211 @cl_byte
212 @cl_short
213 @cl_int
214 @cl_float Buffer host_ptr,
215 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
216
217 @Check(value = "errcode_ret", canBeNull = true)
218 @PointerWrapper(value = "cl_program", params = "context")
219 CLProgram clCreateProgramWithBuiltInKernels(@PointerWrapper("cl_context") CLContext context,
220 @AutoSize("device_list") @cl_uint int num_devices,
221 @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list,
222 @Check @Const @cl_char ByteBuffer kernel_names,
223 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
224
225 @Alternate("clCreateProgramWithBuiltInKernels")
226 @Check(value = "errcode_ret", canBeNull = true)
227 @PointerWrapper(value = "cl_program", params = "context")
228 CLProgram clCreateProgramWithBuiltInKernels(@PointerWrapper("cl_context") CLContext context,
229 @AutoSize("device_list") @cl_uint int num_devices,
230 @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list,
231 CharSequence kernel_names,
232 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
233
234 /** Single null-terminated header include name. */
235 @Code(
236 tryBlock = true,
237 // Create a GlobalRef to the callback object.
238 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
239 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
240 // Check if we need to delete the GlobalRef.
241 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
242 )
243 @cl_int
244 int clCompileProgram(@PointerWrapper("cl_program") CLProgram program,
245 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
246 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
247 @Check @NullTerminated @Const @cl_char ByteBuffer options,
248 @Constant("1") @cl_uint int num_input_headers,
249 @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header,
250 @NullTerminated @Check @Const @cl_char @Indirect ByteBuffer header_include_name,
251 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify,
252 @Constant("user_data") @PointerWrapper("void *") long user_data);
253
254 /** Multiple null-terminated header include names, one after the other. */
255 @Alternate(value = "clCompileProgram", nativeAlt = true, javaAlt = true)
256 @Code(
257 tryBlock = true,
258 // Create a GlobalRef to the callback object.
259 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
260 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
261 // Check if we need to delete the GlobalRef.
262 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
263 )
264 @cl_int
265 int clCompileProgramMulti(@PointerWrapper("cl_program") CLProgram program,
266 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
267 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
268 @Check @NullTerminated @Const @cl_char ByteBuffer options,
269 @AutoSize("input_headers") @cl_uint int num_input_headers,
270 @Check("1") @Const @NativeType("cl_program") PointerBuffer input_headers,
271 @NullTerminated("input_headers.remaining()") @Check @Const @Indirect @cl_char @PointerArray("num_input_headers") ByteBuffer header_include_names,
272 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify,
273 @Constant("user_data") @PointerWrapper("void *") long user_data);
274
275 @Alternate(value = "clCompileProgram", nativeAlt = true)
276 @Code(
277 tryBlock = true,
278 // Create a GlobalRef to the callback object.
279 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
280 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
281 // Check if we need to delete the GlobalRef.
282 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
283 )
284 @cl_int
285 int clCompileProgram3(@PointerWrapper("cl_program") CLProgram program,
286 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
287 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
288 @Check @NullTerminated @Const @cl_char ByteBuffer options,
289 @Constant("header_include_names.length") @cl_uint int num_input_headers,
290 @Check("header_include_names.length") @Const @NativeType("cl_program") PointerBuffer input_headers,
291 @NullTerminated @Check("1") @PointerArray(value = "num_input_headers") @Const @NativeType("cl_char") ByteBuffer[] header_include_names,
292 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify,
293 @Constant("user_data") @PointerWrapper("void *") long user_data);
294
295 @Alternate("clCompileProgram")
296 @Code(
297 tryBlock = true,
298 // Create a GlobalRef to the callback object.
299 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
300 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
301 // Check if we need to delete the GlobalRef.
302 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
303 )
304 @cl_int
305 int clCompileProgram(@PointerWrapper("cl_program") CLProgram program,
306 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
307 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
308 @NullTerminated CharSequence options,
309 @Constant("1") @cl_uint int num_input_headers,
310 @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header,
311 @NullTerminated @Const CharSequence header_include_name,
312 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify,
313 @Constant("user_data") @PointerWrapper("void *") long user_data);
314
315 @Alternate(value = "clCompileProgram", nativeAlt = true, skipNative = true)
316 @Code(
317 tryBlock = true,
318 // Create a GlobalRef to the callback object.
319 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
320 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());",
321 // Check if we need to delete the GlobalRef.
322 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
323 )
324 @cl_int
325 int clCompileProgramMulti(@PointerWrapper("cl_program") CLProgram program,
326 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
327 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
328 @NullTerminated CharSequence options,
329 @AutoSize("input_header") @cl_uint int num_input_headers,
330 @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header,
331 @NullTerminated @PointerArray(value = "num_input_headers") @Const CharSequence[] header_include_name,
332 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify,
333 @Constant("user_data") @PointerWrapper("void *") long user_data);
334
335 @Code(
336 tryBlock = true,
337 // Create a GlobalRef to the callback object.
338 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
339 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(context);",
340 // Check if we need to delete the GlobalRef.
341 javaFinally = "\t\t\tCallbackUtil.checkCallback(errcode_ret.get(errcode_ret.position()), user_data);"
342 )
343 @Check(value = "errcode_ret", canBeNull = true)
344 @PointerWrapper(value = "cl_program", params = "context")
345 CLProgram clLinkProgram(@PointerWrapper("cl_context") CLContext context,
346 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
347 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
348 @NullTerminated @Check @Const @cl_char ByteBuffer options,
349 @AutoSize("input_programs") @cl_uint int num_input_programs,
350 @Check @Const @NativeType("cl_program") PointerBuffer input_programs,
351 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLLinkProgramCallback pfn_notify,
352 @Constant("user_data") @PointerWrapper("void *") long user_data,
353 @OutParameter @Check("1") @cl_int IntBuffer errcode_ret);
354
355 @Alternate("clLinkProgram")
356 @Code(
357 tryBlock = true,
358 // Create a GlobalRef to the callback object.
359 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" +
360 "\t\tif ( pfn_notify != null ) pfn_notify.setContext(context);",
361 // Check if we need to delete the GlobalRef.
362 javaFinally = "\t\t\tCallbackUtil.checkCallback(errcode_ret.get(errcode_ret.position()), user_data);"
363 )
364 @Check(value = "errcode_ret", canBeNull = true)
365 @PointerWrapper(value = "cl_program", params = "context")
366 CLProgram clLinkProgram(@PointerWrapper("cl_context") CLContext context,
367 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
368 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
369 @NullTerminated CharSequence options,
370 @AutoSize("input_programs") @cl_uint int num_input_programs,
371 @Check @Const @NativeType("cl_program") PointerBuffer input_programs,
372 @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLLinkProgramCallback pfn_notify,
373 @Constant("user_data") @PointerWrapper("void *") long user_data,
374 @OutParameter @Check("1") @cl_int IntBuffer errcode_ret);
375
376 @cl_int
377 int clUnloadPlatformCompiler(@PointerWrapper("cl_platform_id") CLPlatform platform);
378
379 @cl_int
380 int clGetKernelArgInfo(@PointerWrapper("cl_kernel") CLKernel kernel,
381 @cl_uint int arg_indx,
382 @NativeType("cl_kernel_arg_info") int param_name,
383 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
384 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
385 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
386
387 @cl_int
388 int clEnqueueFillBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
389 @PointerWrapper("cl_mem") CLMem buffer,
390 @Check @Const @cl_void ByteBuffer pattern,
391 @AutoSize("pattern") @size_t long pattern_size,
392 @size_t long offset,
393 @size_t long size,
394 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
395 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
396 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
397
398 @cl_int
399 int clEnqueueFillImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
400 @PointerWrapper("cl_mem") CLMem image,
401 @Check("4 * 4") @Const @cl_void ByteBuffer fill_color,
402 @Check("3") @Const @NativeType("size_t") PointerBuffer origin,
403 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
404 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
405 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
406 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
407
408 @cl_int
409 int clEnqueueMigrateMemObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
410 @AutoSize("mem_objects") @cl_uint int num_mem_objects,
411 @Check @Const @NativeType("cl_mem") PointerBuffer mem_objects,
412 @NativeType("cl_mem_migration_flags") long flags,
413 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
414 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
415 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
416
417 @cl_int
418 int clEnqueueMarkerWithWaitList(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
419 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
420 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
421 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
422
423 @cl_int
424 int clEnqueueBarrierWithWaitList(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
425 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
426 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
427 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
428
429 @Optional(reason = "Missing from AMD CL 1.2 preview drivers.")
430 @Code(
431 tryBlock = true,
432 // Create a GlobalRef to the callback object.
433 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
434 // Check if we need to delete the GlobalRef.
435 javaFinally = "\t\t\tcontext.setPrintfCallback(user_data, __result);"
436 )
437 @cl_int
438 int clSetPrintfCallback(@PointerWrapper("cl_context") CLContext context,
439 @PointerWrapper("cl_printf_callback") CLPrintfCallback pfn_notify,
440 @Constant("user_data") @PointerWrapper("void *") long user_data);
441
442 @Private
443 @PointerWrapper("void *")
444 CLFunctionAddress clGetExtensionFunctionAddressForPlatform(@PointerWrapper("cl_platform_id") CLPlatform platform,
445 @NullTerminated @Const @cl_char ByteBuffer func_name);
446
447 @Alternate("clGetExtensionFunctionAddressForPlatform")
448 @Private
449 @PointerWrapper("void *")
450 CLFunctionAddress clGetExtensionFunctionAddressForPlatform(@PointerWrapper("cl_platform_id") CLPlatform platform,
451 @NullTerminated CharSequence func_name);
452
453 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.Check;
34 import org.lwjgl.util.generator.NativeType;
35 import org.lwjgl.util.generator.OutParameter;
36 import org.lwjgl.util.generator.PointerWrapper;
37 import org.lwjgl.util.generator.opencl.cl_int;
38
39 import java.nio.IntBuffer;
40
41 /** The core OpenCL 1.2 OpenGL interrop functionality. */
42 public interface CL12GL {
43
44 /* cl_gl_object_type */
45 int CL_GL_OBJECT_TEXTURE2D_ARRAY = 0x200E,
46 CL_GL_OBJECT_TEXTURE1D = 0x200F,
47 CL_GL_OBJECT_TEXTURE1D_ARRAY = 0x2010,
48 CL_GL_OBJECT_TEXTURE_BUFFER = 0x2011;
49
50 @Check(value = "errcode_ret", canBeNull = true)
51 @PointerWrapper(value = "cl_mem", params = "context")
52 CLMem clCreateFromGLTexture(@PointerWrapper("cl_context") CLContext context,
53 @NativeType("cl_mem_flags") long flags,
54 @NativeType("GLenum") int target,
55 @NativeType("GLint") int miplevel,
56 @NativeType("GLuint") int texture,
57 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
58
59 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface EXT_atomic_counters_32 {
37
38 /** CLDevice query: Max number of atomic counters that can be used by a kernel. */
39 int CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = 0x4032;
40
41 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface EXT_atomic_counters_64 {
37
38 /** CLDevice query: Max number of atomic counters that can be used by a kernel. */
39 int CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = 0x4032;
40
41 }
134134 @cl_int
135135 int clCreateSubDevicesEXT(
136136 @PointerWrapper("cl_device_id") CLDevice in_device,
137 // TODO: cl_device_partition_property_ext is a cl_bitfield (ulong), but the spec says properties is a {property-value, cl_int[]} list...
138137 @NullTerminated @Const @NativeType("cl_device_partition_property_ext") LongBuffer properties,
139138 @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_entries,
140139 @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices,
6767 @cl_int
6868 int clEnqueueMigrateMemObjectEXT(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
6969 @Constant("1") @cl_uint int num_mem_objects,
70 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
70 @Constant(value = "APIUtil.getPointer(mem_object)", keepParam = true) CLMem mem_object,
7171 @cl_bitfield @NativeType("cl_mem_migration_flags_ext") long flags,
7272 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
7373 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface INTEL_immediate_execution {
37
38 // TODO: Update when spec is released publicly.
39
40 /** cl_command_queue_properties - bitfield */
41 int CL_QUEUE_IMMEDIATE_EXECUTION_ENABLE_INTEL = (1 << 2);
42
43 /** cl_device_exec_capabilities - bitfield */
44 int CL_EXEC_IMMEDIATE_EXECUTION_INTEL = (1 << 2);
45
46 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface INTEL_printf {
37
38 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface INTEL_thread_local_exec {
37
38 /**
39 * Allows the user to execute OpenCL tasks and kernels with
40 * the user application's threads. This token that can
41 * be passed to clCreateCommandQueue, creating a queue with the "thread
42 * local exec" capability.
43 * <p/>
44 * All enqueue APIs (e.g., clEnqueueRead) submitted to such a queue
45 * never enqueue commands. An Enqueue API call is executed by the
46 * caller host-thread itself without involving any of the OpenCL
47 * runtime threads, much like function calls.
48 */
49 int CL_QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL = (1 << 31);
50
51 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_depth_images {
37
38 /** cl_channel_order */
39 int CL_DEPTH = 0x10BD;
40
41 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.Extension;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35
36 @CLDeviceExtension
37 @Extension(postfix = "KHR", className = "KHRGLDepthImages")
38 public interface KHR_gl_depth_images {
39
40 /** cl_channel_order */
41 int CL_DEPTH_STENCIL = 0x10BE;
42
43 /** cl_channel_type */
44 int CL_UNORM_INT24 = 0x10DF;
45
46 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.Extension;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35
36 @CLDeviceExtension
37 @Extension(postfix = "KHR", className = "KHRGLMsaaSharing")
38 public interface KHR_gl_msaa_sharing {
39
40 /** cl_gl_texture_info */
41 int CL_GL_NUM_SAMPLES = 0x2012;
42
43 }
4848 /** Returned by clGetPlatformIDs when no platforms are found */
4949 int CL_PLATFORM_NOT_FOUND_KHR = -1001;
5050
51 @Optional(reason = "AMD Stream does not expose this (version tested: 2.2)")
51 @Optional(reason = "AMD Stream does not expose this (version tested: 2.5)")
5252 @cl_int
5353 int clIcdGetPlatformIDsKHR(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries,
5454 @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms,
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.Extension;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35
36 @CLDeviceExtension
37 @Extension(postfix = "KHR", className = "KHRImage2DFromBuffer")
38 public interface KHR_image2d_from_buffer {
39
40 /** cl_device_info */
41 int CL_DEVICE_IMAGE_PITCH_ALIGNMENT = 0x104A,
42 CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT = 0x104B;
43
44 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_initialize_memory {
37
38 /** cl_context_properties */
39 int CL_CONTEXT_MEMORY_INITIALIZE_KHR = 0x200E;
40
41 /** */
42 int CL_CONTEXT_MEMORY_INITIALIZE_LOCAL_KHR = 0x1, // TODO: Find value
43 CL_CONTEXT_MEMORY_INITIALIZE_PRIVATE_KHR = 0x2; // TODO: Find value
44
45 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_mipmap_image {
37
38 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_mipmap_image_writes {
37
38 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.Extension;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35
36 @CLDeviceExtension
37 @Extension(postfix = "KHR", className = "KHRSPIR")
38 public interface KHR_spir {
39 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_srgb_image_writes {
37
38 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_void;
38 import org.lwjgl.util.generator.opencl.size_t;
39
40 import java.nio.ByteBuffer;
41
42 @CLDeviceExtension
43 public interface KHR_subgroups {
44
45 @cl_int
46 int clGetKernelSubGroupInfoKHR(@PointerWrapper("cl_kernel") CLKernel kernel,
47 @PointerWrapper(value = "cl_device_id", canBeNull = true) CLDevice device,
48 @NativeType("cl_kernel_sub_group_info") int param_name,
49 @AutoSize(value = "input_value", canBeNull = true) @size_t long input_value_size,
50 @Check(canBeNull = true) @Const @cl_void ByteBuffer input_value,
51 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
52 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
53 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
54
55 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opencl;
32
33 import org.lwjgl.util.generator.PointerWrapper;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35 import org.lwjgl.util.generator.opencl.cl_int;
36
37 @CLDeviceExtension
38 public interface KHR_terminate_context {
39
40 int CL_DEVICE_TERMINATE_CAPABILITY_KHR = 0x200F,
41 CL_CONTEXT_TERMINATE_KHR = 0x2010;
42
43 @cl_int
44 int clTerminateContextKHR(@PointerWrapper("cl_context") CLContext context);
45
46 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface AMD_blend_minmax_factor {
34
35 /**
36 * Accepted by the &lt;mode&gt; parameter of BlendEquation and BlendEquationi, and by
37 * the &lt;modeRGB> and &lt;modeAlpha&gt; parameters of BlendEquationSeparate and
38 * BlendEquationSeparatei:
39 */
40 int GL_FACTOR_MIN_AMD = 0x901C,
41 GL_FACTOR_MAX_AMD = 0x901D;
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 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface AMD_interleaved_elements {
37
38 /**
39 * Accepted by the &lt;pname&gt; parameter of VertexAttribParameteriAMD and
40 * GetVertexAttrib{iv|dv|fv|Iiv|Iuiv|Ldv}:
41 */
42 int GL_VERTEX_ELEMENT_SWIZZLE_AMD = 0x91A4;
43
44 /** Selected by the &lt;pname&gt; parameter of ProgramParameteri and GetProgramiv: */
45 int GL_VERTEX_ID_SWIZZLE_AMD = 0x91A5;
46
47 void glVertexAttribParameteriAMD(@GLuint int index, @GLenum int pname, int param);
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 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLvoid;
37
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40
41 import javax.lang.model.type.TypeKind;
42
43 public interface AMD_multi_draw_indirect {
44
45 void glMultiDrawArraysIndirectAMD(@GLenum int mode,
46 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
47 @GLsizei int primcount,
48 @GLsizei int stride);
49
50 @Alternate("glMultiDrawArraysIndirectAMD")
51 void glMultiDrawArraysIndirectAMD(@GLenum int mode,
52 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
53 @GLsizei int primcount,
54 @GLsizei int stride);
55
56 void glMultiDrawElementsIndirectAMD(@GLenum int mode,
57 @GLenum int type,
58 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
59 @GLsizei int primcount,
60 @GLsizei int stride);
61
62 @Alternate("glMultiDrawElementsIndirectAMD")
63 void glMultiDrawElementsIndirectAMD(@GLenum int mode,
64 @GLenum int type,
65 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
66 @GLsizei int primcount,
67 @GLsizei int stride);
68
69 }
5757 void glDeleteNamesAMD(@GLenum int identifier, @AutoSize("names") @GLsizei int num, @Const @GLuint IntBuffer names);
5858
5959 @Alternate("glDeleteNamesAMD")
60 void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getBufferInt().put(0, name), 0", keepParam = true) int name);
60 void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getInt(caps, name)", keepParam = true) int name);
6161
6262 boolean glIsNameAMD(@GLenum int identifier, @GLuint int name);
6363
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
3534 import org.lwjgl.util.generator.opengl.*;
3635
3736 import java.nio.ByteBuffer;
4039 public interface AMD_performance_monitor {
4140
4241 /** Accepted by the &lt;pame&gt; parameter of GetPerfMonitorCounterInfoAMD */
43 int GL_COUNTER_TYPE_AMD = 0x8BC0;
44 int GL_COUNTER_RANGE_AMD = 0x8BC1;
42 int GL_COUNTER_TYPE_AMD = 0x8BC0,
43 GL_COUNTER_RANGE_AMD = 0x8BC1;
4544
4645 /**
4746 * Returned as a valid value in &lt;data&gt; parameter of
4847 * GetPerfMonitorCounterInfoAMD if &lt;pname&gt; = COUNTER_TYPE_AMD
4948 */
50 int GL_UNSIGNED_INT = 0x1405;
51 int GL_FLOAT = 0x1406;
52 int GL_UNSIGNED_INT64_AMD = 0x8BC2;
53 int GL_PERCENTAGE_AMD = 0x8BC3;
49 int GL_UNSIGNED_INT64_AMD = 0x8BC2,
50 GL_PERCENTAGE_AMD = 0x8BC3;
5451
5552 /** Accepted by the &lt;pname&gt; parameter of GetPerfMonitorCounterDataAMD */
56
57 int GL_PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4;
58 int GL_PERFMON_RESULT_SIZE_AMD = 0x8BC5;
59 int GL_PERFMON_RESULT_AMD = 0x8BC6;
53 int GL_PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4,
54 GL_PERFMON_RESULT_SIZE_AMD = 0x8BC5,
55 GL_PERFMON_RESULT_AMD = 0x8BC6;
6056
6157 void glGetPerfMonitorGroupsAMD(@OutParameter @Check(value = "1", canBeNull = true) @GLint IntBuffer numGroups,
6258 @AutoSize("groups") @GLsizei int groupsSize, @GLuint IntBuffer groups);
6460 void glGetPerfMonitorCountersAMD(@GLuint int group,
6561 @OutParameter @Check(value = "1") @GLint IntBuffer numCounters,
6662 @OutParameter @Check(value = "1") @GLint IntBuffer maxActiveCounters,
67 @AutoSize("counters") @GLsizei int countersSize,
68 @GLuint IntBuffer counters);
63 @AutoSize(value = "counters", canBeNull = true) @GLsizei int countersSize,
64 @Check(canBeNull = true) @GLuint IntBuffer counters);
6965
7066 void glGetPerfMonitorGroupStringAMD(@GLuint int group,
71 @AutoSize("groupString") @GLsizei int bufSize,
67 @AutoSize(value = "groupString", canBeNull = true) @GLsizei int bufSize,
7268 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
73 @OutParameter @GLchar ByteBuffer groupString);
69 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer groupString);
7470
7571 @Alternate("glGetPerfMonitorGroupStringAMD")
7672 @GLreturn(value = "groupString", maxLength = "bufSize")
7773 void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize,
78 @OutParameter @GLsizei @Constant("groupString_length, 0") IntBuffer length,
79 @OutParameter @GLchar ByteBuffer groupString);
74 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(groupString_length)") IntBuffer length,
75 @OutParameter @GLchar ByteBuffer groupString);
8076
81 void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize,
77 void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize(value = "counterString", canBeNull = true) @GLsizei int bufSize,
8278 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
83 @OutParameter @GLchar ByteBuffer counterString);
79 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer counterString);
8480
8581 @Alternate("glGetPerfMonitorCounterStringAMD")
8682 @GLreturn(value = "counterString", maxLength = "bufSize")
8783 void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize,
88 @OutParameter @GLsizei @Constant("counterString_length, 0") IntBuffer length,
89 @OutParameter @GLchar ByteBuffer counterString);
84 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(counterString_length)") IntBuffer length,
85 @OutParameter @GLchar ByteBuffer counterString);
9086
9187 void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data);
9288
9995 void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors);
10096
10197 @Alternate("glDeletePerfMonitorsAMD")
102 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor);
98 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, monitor)", keepParam = true) int monitor);
10399
104100 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList);
105101
106102 @Alternate("glSelectPerfMonitorCountersAMD")
107 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getBufferInt().put(0, counter), 0", keepParam = true) int counter);
103 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(caps, counter)", keepParam = true) int counter);
108104
109105 void glBeginPerfMonitorAMD(@GLuint int monitor);
110106
118114 @GLreturn("data")
119115 void glGetPerfMonitorCounterDataAMD2(@GLuint int monitor, @GLenum int pname, @Constant("4") @GLsizei int dataSize,
120116 @OutParameter @GLuint IntBuffer data,
121 @OutParameter @GLint @Constant("null, 0") IntBuffer bytesWritten);
117 @OutParameter @GLint @Constant("0L") IntBuffer bytesWritten);
122118
123119 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_pinned_memory {
34
35 /**
36 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
37 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
38 * GetBufferParameteriv, GetBufferPointerv, MapBufferRange:
39 */
40 int GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD = 0x9160;
41
42 }
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 public interface AMD_query_buffer_object {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv, GetQueryObjectuiv,
37 * GetQueryObjecti64v and GetQueryObjectui64v:
38 */
39 int GL_QUERY_RESULT_NO_WAIT_AMD = 0x9194;
40
41 /**
42 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
43 * BufferSubData, MapBuffer, UnmapBuffer, MapBufferRange, GetBufferSubData,
44 * GetBufferParameteriv
45 * and GetBufferPointerv:
46 */
47 int GL_QUERY_BUFFER_AMD = 0x9192;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
51 * and GetDoublev:
52 */
53 int GL_QUERY_BUFFER_BINDING_AMD = 0x9193;
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.StripPostfix;
36 import org.lwjgl.util.generator.opengl.GLenum;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.FloatBuffer;
40
41 public interface AMD_sample_positions {
42
43 /** Accepted by the &lt;pname&gt; parameter of GetFloatv: */
44 int GL_SUBSAMPLE_DISTANCE_AMD = 0x883F;
45
46 @StripPostfix("val")
47 void glSetMultisamplefvAMD(@GLenum int pname, @GLuint int index, @Check("2") @Const FloatBuffer val);
48
49 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_atomic_counter_ops {
34
35 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_trinary_minmax {
34 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLbitfield;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 public interface AMD_sparse_texture {
39
40 /** Accepted by the &lt;flags&gt; parameter to TexStorageSparseAMD and TextureStorageSparseAMD: */
41 int GL_TEXTURE_STORAGE_SPARSE_BIT_AMD = 0x00000001;
42
43 /** Accepted by the &lt;pname&gt; parameter to GetInternalformativ: */
44 int GL_VIRTUAL_PAGE_SIZE_X_AMD = 0x9195,
45 GL_VIRTUAL_PAGE_SIZE_Y_AMD = 0x9196,
46 GL_VIRTUAL_PAGE_SIZE_Z_AMD = 0x9197;
47
48 /**
49 * Accepted by the &lt;pname&gt; parameter to GetIntegerv, GetFloatv, GetDoublev,
50 * GetInteger64v, and GetBooleanv:
51 */
52 int GL_MAX_SPARSE_TEXTURE_SIZE_AMD = 0x9198,
53 GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD = 0x9199,
54 GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS = 0x919A;
55
56 /** Accepted by the &lt;pname&gt; parameter of GetTexParameter{if}v: */
57 int GL_MIN_SPARSE_LEVEL_AMD = 0x919B;
58
59 /**
60 * Accepted by the &lt;pname&gt; parameter of TexParameter{if}{v} and
61 * GetTexParameter{if}v:
62 */
63 int GL_MIN_LOD_WARNING_AMD = 0x919C;
64
65 void glTexStorageSparseAMD(@GLenum int target,
66 @GLenum int internalFormat,
67 @GLsizei int width,
68 @GLsizei int height,
69 @GLsizei int depth,
70 @GLsizei int layers,
71 @GLbitfield int flags);
72
73 void glTextureStorageSparseAMD(@GLuint int texture,
74 @GLenum int target,
75 @GLenum int internalFormat,
76 @GLsizei int width,
77 @GLsizei int height,
78 @GLsizei int depth,
79 @GLsizei int layers,
80 @GLbitfield int flags);
81
82 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface AMD_stencil_operation_extended {
37
38 /**
39 * Accepted by the &lt;sfail&gt;, &lt;dpfail&gt; and &lt;dppass&gt; parameters of StencilOp
40 * and StencilOpSeparate:
41 */
42 int GL_SET_AMD = 0x874A,
43 GL_REPLACE_VALUE_AMD = 0x874B;
44
45 /**
46 * Accepted by the &lt;param&gt; parameter of GetIntegerv, GetFloatv, GetBooleanv
47 * GetDoublev and GetInteger64v:
48 */
49 int GL_STENCIL_OP_VALUE_AMD = 0x874C,
50 GL_STENCIL_BACK_OP_VALUE_AMD = 0x874D;
51
52 void glStencilOpValueAMD(@GLenum int face, @GLuint int value);
53
54 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_vertex_shader_layer {
34 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_vertex_shader_viewport_index {
34 }
5454 void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences);
5555
5656 @Alternate("glDeleteFencesAPPLE")
57 void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
57 void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, fence)", keepParam = true) int fence);
5858
5959 void glSetFenceAPPLE(@GLuint int fence);
6060
7474
7575 @Alternate("glGetObjectParameterivAPPLE")
7676 @GLreturn("params")
77 @StripPostfix("params")
77 @StripPostfix(value = "params", hasPostfix = false)
7878 void glGetObjectParameterivAPPLE2(@GLenum int objectType, @GLuint int name, @GLenum int pname, @OutParameter IntBuffer params);
7979
8080 }
5151 void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
5252
5353 @Alternate("glDeleteVertexArraysAPPLE")
54 void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
54 void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array);
5555
5656 void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
5757
6464 GL_MEDIUM_INT = 0x8DF4,
6565 GL_HIGH_INT = 0x8DF5;
6666
67 /** Accepted by the &lt;format&gt; parameter of most commands taking sized internal formats: */
68 int GL_RGB565 = 0x8D62;
69
6770 @Reuse("GL41")
6871 void glReleaseShaderCompiler();
6972
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLbitfield;
35
36 public interface ARB_ES3_1_compatibility {
37
38 @Reuse("GL45")
39 void glMemoryBarrierByRegion(@GLbitfield int barriers);
40
41 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_ES3_compatibility {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D */
36 int GL_COMPRESSED_RGB8_ETC2 = 0x9274,
37 GL_COMPRESSED_SRGB8_ETC2 = 0x9275,
38 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
39 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
40 GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
41 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
42 GL_COMPRESSED_R11_EAC = 0x9270,
43 GL_COMPRESSED_SIGNED_R11_EAC = 0x9271,
44 GL_COMPRESSED_RG11_EAC = 0x9272,
45 GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
46
47 /** Accepted by the &lt;target&gt; parameter of Enable and Disable: */
48 int GL_PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69;
49
50 /**
51 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
52 * GetQueryIndexediv and GetQueryiv:
53 */
54 int GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A;
55
56 /** Accepted by the &lt;value&gt; parameter of the GetInteger* functions: */
57 int GL_MAX_ELEMENT_INDEX = 0x8D6B;
58
59 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_arrays_of_arrays {
34 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37
38 public interface ARB_base_instance {
39
40 @Reuse("GL42")
41 void glDrawArraysInstancedBaseInstance(@GLenum int mode,
42 int first,
43 @GLsizei int count,
44 @GLsizei int primcount,
45 @GLuint int baseinstance);
46
47 @Reuse("GL42")
48 void glDrawElementsInstancedBaseInstance(@GLenum int mode,
49 @AutoSize("indices") @GLsizei int count,
50 @AutoType("indices") @GLenum int type,
51 @Const
52 @BufferObject(BufferKind.ElementVBO)
53 @GLubyte
54 @GLushort
55 @GLuint Buffer indices,
56 @GLsizei int primcount,
57 @GLuint int baseinstance);
58
59 @Reuse("GL42")
60 void glDrawElementsInstancedBaseVertexBaseInstance(@GLenum int mode,
61 @AutoSize("indices") @GLsizei int count,
62 @AutoType("indices") @GLenum int type,
63 @Const
64 @BufferObject(BufferKind.ElementVBO)
65 @GLubyte
66 @GLushort
67 @GLuint Buffer indices,
68 @GLsizei int primcount,
69 int basevertex,
70 @GLuint int baseinstance);
71
72 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Check;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.StripPostfix;
37 import org.lwjgl.util.generator.opengl.*;
38
39 import java.nio.LongBuffer;
40
41 public interface ARB_bindless_texture {
42
43 /** Accepted by the &lt;type&gt; parameter of VertexAttribLPointer: */
44 int GL_UNSIGNED_INT64_ARB = 0x140F;
45
46 @GLuint64
47 long glGetTextureHandleARB(@GLuint int texture);
48
49 @GLuint64
50 long glGetTextureSamplerHandleARB(@GLuint int texture, @GLuint int sampler);
51
52 void glMakeTextureHandleResidentARB(@GLuint64 long handle);
53
54 void glMakeTextureHandleNonResidentARB(@GLuint64 long handle);
55
56 @GLuint64
57 long glGetImageHandleARB(@GLuint int texture, int level, boolean layered, int layer, @GLenum int format);
58
59 void glMakeImageHandleResidentARB(@GLuint64 long handle, @GLenum int access);
60
61 void glMakeImageHandleNonResidentARB(@GLuint64 long handle);
62
63 void glUniformHandleui64ARB(int location, @GLuint64 long value);
64
65 @StripPostfix("value")
66 void glUniformHandleui64vARB(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64 LongBuffer value);
67
68 void glProgramUniformHandleui64ARB(@GLuint int program, int location, @GLuint64 long value);
69
70 @StripPostfix("values")
71 void glProgramUniformHandleui64vARB(@GLuint int program, int location, @AutoSize("values") @GLsizei int count, @Const @GLuint64 LongBuffer values);
72
73 boolean glIsTextureHandleResidentARB(@GLuint64 long handle);
74
75 boolean glIsImageHandleResidentARB(@GLuint64 long handle);
76
77 void glVertexAttribL1ui64ARB(@GLuint int index, @GLuint64EXT long x);
78
79 @StripPostfix("v")
80 void glVertexAttribL1ui64vARB(@GLuint int index, @Check("1") @Const @GLuint64EXT LongBuffer v);
81
82 @StripPostfix("params")
83 void glGetVertexAttribLui64vARB(@GLuint int index, @GLenum int pname, @Check("4") @GLuint64EXT LongBuffer params);
84
85 }
7070 void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
7171
7272 @Alternate("glDeleteBuffersARB")
73 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
73 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
7474
7575 void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
7676
8282
8383 @GenerateAutos
8484 void glBufferDataARB(@GLenum int target, @AutoSize("data") @GLsizeiptrARB long size,
85 @Check
8586 @Const
8687 @GLbyte
8788 @GLshort
132133 */
133134 @CachedResult
134135 @GLvoid
135 @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)")
136 @AutoSize("glGetBufferParameteriARB(target, GL_BUFFER_SIZE_ARB)")
136137 ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access);
137138
138139 boolean glUnmapBufferARB(@GLenum int target);
140141 @StripPostfix("params")
141142 void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
142143
144 /** @deprecated Will be removed in 3.0. Use {@link #glGetBufferParameteriARB} instead. */
143145 @Alternate("glGetBufferParameterivARB")
144146 @GLreturn("params")
145147 @StripPostfix("params")
148 @Reuse(value = "ARBBufferObject", method = "glGetBufferParameteriARB")
149 @Deprecated
146150 void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
147151
152 @Alternate("glGetBufferParameterivARB")
153 @GLreturn("params")
154 @StripPostfix(value = "params", hasPostfix = false)
155 void glGetBufferParameterivARB3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
156
148157 @StripPostfix("pointer")
149 @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)")
158 @AutoSize("glGetBufferParameteriARB(target, GL_BUFFER_SIZE_ARB)")
150159 void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
151160 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37
38 @Dependent
39 public interface ARB_buffer_storage {
40
41 /**
42 * Accepted in the &lt;flags&gt; parameter of BufferStorage and
43 * NamedBufferStorageEXT:
44 */
45 int GL_MAP_PERSISTENT_BIT = 0x0040,
46 GL_MAP_COHERENT_BIT = 0x0080,
47 GL_DYNAMIC_STORAGE_BIT = 0x0100,
48 GL_CLIENT_STORAGE_BIT = 0x0200;
49
50 /** Accepted by the &lt;pname&gt; parameter of GetBufferParameter{i|i64}v:\ */
51
52 int GL_BUFFER_IMMUTABLE_STORAGE = 0x821F,
53 GL_BUFFER_STORAGE_FLAGS = 0x8220;
54
55 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrier: */
56 int GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT = 0x00004000;
57
58 @Reuse("GL44")
59 void glBufferStorage(@GLenum int target,
60 @AutoSize("data") @GLsizeiptr long size,
61 @Const
62 @GLbyte
63 @GLshort
64 @GLint
65 @GLuint64
66 @GLfloat
67 @GLdouble Buffer data,
68 @GLbitfield int flags);
69
70 @Reuse("GL44")
71 @Alternate("glBufferStorage")
72 void glBufferStorage2(@GLenum int target,
73 @GLsizeiptr long size,
74 @Constant("0L") @Const Buffer data,
75 @GLbitfield int flags);
76
77 @Dependent("GL_EXT_direct_state_access")
78 void glNamedBufferStorageEXT(@GLuint int buffer,
79 @AutoSize("data") @GLsizeiptr long size,
80 @Const
81 @GLbyte
82 @GLshort
83 @GLint
84 @GLuint64
85 @GLfloat
86 @GLdouble Buffer data,
87 @GLbitfield int flags);
88
89 @Dependent("GL_EXT_direct_state_access")
90 @Alternate("glNamedBufferStorageEXT")
91 void glNamedBufferStorageEXT2(@GLuint int buffer,
92 @GLsizeiptr long size,
93 @Constant("0L") @Const Buffer data,
94 @GLbitfield int flags);
95
96 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37
38 @Dependent
39 public interface ARB_clear_buffer_object {
40
41 @Reuse("GL43")
42 void glClearBufferData(@GLenum int target,
43 @GLenum int internalformat,
44 @GLenum int format,
45 @GLenum int type,
46 @Check("1") @Const @GLvoid ByteBuffer data);
47
48 @Reuse("GL43")
49 void glClearBufferSubData(@GLenum int target,
50 @GLenum int internalformat,
51 @GLintptr long offset,
52 @GLsizeiptr long size,
53 @GLenum int format,
54 @GLenum int type,
55 @Check("1") @Const @GLvoid ByteBuffer data);
56
57 @Dependent("GL_EXT_direct_state_access")
58 void glClearNamedBufferDataEXT(@GLuint int buffer,
59 @GLenum int internalformat,
60 @GLenum int format,
61 @GLenum int type,
62 @Check("1") @Const @GLvoid ByteBuffer data);
63
64 @Dependent("GL_EXT_direct_state_access")
65 void glClearNamedBufferSubDataEXT(@GLuint int buffer,
66 @GLenum int internalformat,
67 @GLintptr long offset,
68 @GLsizeiptr long size,
69 @GLenum int format,
70 @GLenum int type,
71 @Check("1") @GLvoid ByteBuffer data);
72
73 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
36 import org.lwjgl.util.generator.opengl.*;
37
38 import java.nio.Buffer;
39
40 public interface ARB_clear_texture {
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter for GetInternalformativ and
44 * GetInternalformati64v:
45 */
46 int GL_CLEAR_TEXTURE = 0x9365;
47
48 @Reuse("GL44")
49 void glClearTexImage(@GLuint int texture, int level,
50 @GLenum int format, @GLenum int type,
51 @Check(value = "1", canBeNull = true)
52 @Const
53 @GLbyte
54 @GLshort
55 @GLint
56 @GLuint64
57 @GLfloat
58 @GLdouble Buffer data);
59
60 @Reuse("GL44")
61 void glClearTexSubImage(@GLuint int texture, int level,
62 int xoffset, int yoffset, int zoffset,
63 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
64 @GLenum int format, @GLenum int type,
65 @Check(value = "1", canBeNull = true)
66 @Const
67 @GLbyte
68 @GLshort
69 @GLint
70 @GLuint64
71 @GLfloat
72 @GLdouble Buffer data);
73
74 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35
36 public interface ARB_clip_control {
37
38 /** Accepted by the &lt;origin&gt; parameter of ClipControl: */
39 int GL_LOWER_LEFT = 0x8CA1,
40 GL_UPPER_LEFT = 0x8CA2;
41
42 /** Accepted by the &lt;depth&gt; parameter of ClipControl: */
43 int GL_NEGATIVE_ONE_TO_ONE = 0x935E,
44 GL_ZERO_TO_ONE = 0x935F;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
48 * GetFloatv, and GetDoublev:
49 */
50 int GL_CLIP_ORIGIN = 0x935C,
51 GL_CLIP_DEPTH_MODE = 0x935D;
52
53 @Reuse("GL45")
54 void glClipControl(@GLenum int origin, @GLenum int depth);
55
56 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_compressed_texture_pixel_storage {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of PixelStore[fi], GetBooleanv,
37 * GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev:
38 */
39 int GL_UNPACK_COMPRESSED_BLOCK_WIDTH = 0x9127,
40 GL_UNPACK_COMPRESSED_BLOCK_HEIGHT = 0x9128,
41 GL_UNPACK_COMPRESSED_BLOCK_DEPTH = 0x9129,
42 GL_UNPACK_COMPRESSED_BLOCK_SIZE = 0x912A,
43 GL_PACK_COMPRESSED_BLOCK_WIDTH = 0x912B,
44 GL_PACK_COMPRESSED_BLOCK_HEIGHT = 0x912C,
45 GL_PACK_COMPRESSED_BLOCK_DEPTH = 0x912D,
46 GL_PACK_COMPRESSED_BLOCK_SIZE = 0x912E;
47
48 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLintptr;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface ARB_compute_shader {
38
39 /**
40 * Accepted by the &lt;type&gt; parameter of CreateShader and returned in the
41 * &lt;params&gt; parameter by GetShaderiv:
42 */
43 int GL_COMPUTE_SHADER = 0x91B9;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
47 * GetDoublev and GetInteger64v:
48 */
49 int GL_MAX_COMPUTE_UNIFORM_BLOCKS = 0x91BB,
50 GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS = 0x91BC,
51 GL_MAX_COMPUTE_IMAGE_UNIFORMS = 0x91BD,
52 GL_MAX_COMPUTE_SHARED_MEMORY_SIZE = 0x8262,
53 GL_MAX_COMPUTE_UNIFORM_COMPONENTS = 0x8263,
54 GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS = 0x8264,
55 GL_MAX_COMPUTE_ATOMIC_COUNTERS = 0x8265,
56 GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS = 0x8266,
57 GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS = 0x90EB;
58
59 /**
60 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleani_v,
61 * GetFloati_v, GetDoublei_v and GetInteger64i_v:
62 */
63
64 int GL_MAX_COMPUTE_WORK_GROUP_COUNT = 0x91BE,
65 GL_MAX_COMPUTE_WORK_GROUP_SIZE = 0x91BF;
66
67 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
68 int GL_COMPUTE_WORK_GROUP_SIZE = 0x8267;
69
70 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockiv: */
71 int GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER = 0x90EC;
72
73 /** Accepted by the &lt;pname&gt; parameter of GetActiveAtomicCounterBufferiv: */
74 int GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER = 0x90ED;
75
76 /**
77 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
78 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
79 * GetBufferPointerv:
80 */
81 int GL_DISPATCH_INDIRECT_BUFFER = 0x90EE;
82
83 /**
84 * Accepted by the &lt;value&gt; parameter of GetIntegerv, GetBooleanv,
85 * GetInteger64v, GetFloatv, and GetDoublev:
86 */
87 int GL_DISPATCH_INDIRECT_BUFFER_BINDING = 0x90EF;
88
89 /** Accepted by the &lt;stages&gt; parameter of UseProgramStages: */
90 int GL_COMPUTE_SHADER_BIT = 0x00000020;
91
92 @Reuse("GL43")
93 void glDispatchCompute(@GLuint int num_groups_x,
94 @GLuint int num_groups_y,
95 @GLuint int num_groups_z);
96
97 @Reuse("GL43")
98 void glDispatchComputeIndirect(@GLintptr long indirect);
99
100 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLuint;
34
35 public interface ARB_compute_variable_group_size {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
39 * GetDoublev and GetInteger64v:
40 */
41 int GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB = 0x9344,
42 GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB = 0x90EB;
43 /**
44 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleani_v,
45 * GetFloati_v, GetDoublei_v and GetInteger64i_v:
46 */
47 int GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB = 0x9345,
48 GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB = 0x91BF;
49
50 void glDispatchComputeGroupSizeARB(@GLuint int num_groups_x, @GLuint int num_groups_y,
51 @GLuint int num_groups_z, @GLuint int group_size_x,
52 @GLuint int group_size_y, @GLuint int group_size_z);
53
54 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_conditional_render_inverted {
34
35 /** Accepted by the &lt;mode&gt; parameter of BeginConditionalRender: */
36 int GL_QUERY_WAIT_INVERTED = 0x8E17,
37 GL_QUERY_NO_WAIT_INVERTED = 0x8E18,
38 GL_QUERY_BY_REGION_WAIT_INVERTED = 0x8E19,
39 GL_QUERY_BY_REGION_NO_WAIT_INVERTED = 0x8E1A;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_conservative_depth {
34 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 public interface ARB_copy_image {
39
40 @Reuse("GL43")
41 void glCopyImageSubData(
42 @GLuint int srcName, @GLenum int srcTarget, int srcLevel,
43 int srcX, int srcY, int srcZ,
44 @GLuint int dstName, @GLenum int dstTarget, int dstLevel,
45 int dstX, int dstY, int dstZ,
46 @GLsizei int srcWidth, @GLsizei int srcHeight, @GLsizei int srcDepth);
47
48 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_cull_distance {
34
35 /** Accepted by the &lt;pname&gt; parameter of GetBooeleanv, GetDoublev, GetFloatv GetIntegerv, and GetInteger64v: */
36 int GL_MAX_CULL_DISTANCES = 0x82F9,
37 GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 0x82FA;
38
39 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_derivative_control {
34 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.*;
38
39 @Extension(postfix = "")
40 public interface ARB_direct_state_access {
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetTextureParameter{if}v and
44 * GetTextureParameterI{i ui}v:
45 */
46 int GL_TEXTURE_TARGET = 0x1006;
47
48 /** Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv: */
49 int GL_QUERY_TARGET = 0x82EA;
50
51 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
52 int GL_TEXTURE_BINDING = 0x82EB;
53
54 // Transform Feedback object functions
55
56 @Reuse("GL45")
57 void glCreateTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
58
59 @Alternate("glCreateTransformFeedbacks")
60 @GLreturn("ids")
61 @Reuse("GL45")
62 void glCreateTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
63
64 @Reuse("GL45")
65 void glTransformFeedbackBufferBase(@GLuint int xfb, @GLuint int index, @GLuint int buffer);
66
67 @Reuse("GL45")
68 void glTransformFeedbackBufferRange(@GLuint int xfb, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
69
70 @StripPostfix("param")
71 @Reuse("GL45")
72 void glGetTransformFeedbackiv(@GLuint int xfb, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
73
74 @Alternate("glGetTransformFeedbackiv")
75 @GLreturn("param")
76 @StripPostfix(value = "param", hasPostfix = false)
77 @Reuse("GL45")
78 void glGetTransformFeedbackiv2(@GLuint int xfb, @GLenum int pname, @OutParameter IntBuffer param);
79
80 @StripPostfix("param")
81 @Reuse("GL45")
82 void glGetTransformFeedbacki_v(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @Check("1") IntBuffer param);
83
84 @Alternate("glGetTransformFeedbacki_v")
85 @GLreturn("param")
86 @StripPostfix(value = "param", postfix = "_v")
87 @Reuse("GL45")
88 void glGetTransformFeedbacki_v2(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter IntBuffer param);
89
90 @StripPostfix("param")
91 @Reuse("GL45")
92 void glGetTransformFeedbacki64_v(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @Check("1") @GLint64 LongBuffer param);
93
94 @Alternate("glGetTransformFeedbacki64_v")
95 @GLreturn("param")
96 @StripPostfix(value = "param", postfix = "_v")
97 @Reuse("GL45")
98 void glGetTransformFeedbacki64_v2(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @GLint64 LongBuffer param);
99
100 // Buffer object functions
101
102 @Reuse("GL45")
103 void glCreateBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
104
105 @Alternate("glCreateBuffers")
106 @GLreturn("buffers")
107 @Reuse("GL45")
108 void glCreateBuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
109
110 @Reuse("GL45")
111 void glNamedBufferStorage(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
112 @Const
113 @GLbyte
114 @GLshort
115 @GLint
116 @GLuint64
117 @GLfloat
118 @GLdouble Buffer data,
119 @GLbitfield int flags);
120
121 @Alternate("glNamedBufferStorage")
122 @Reuse("GL45")
123 void glNamedBufferStorage2(@GLuint int buffer, @GLsizeiptr long size, @Constant("0L") @Const Buffer data, @GLbitfield int flags);
124
125 @GenerateAutos
126 @Reuse("GL45")
127 void glNamedBufferData(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
128 @Check
129 @Const
130 @GLbyte
131 @GLshort
132 @GLint
133 @GLfloat
134 @GLdouble Buffer data,
135 @GLenum int usage);
136
137 @Reuse("GL45")
138 void glNamedBufferSubData(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
139 @Check
140 @Const
141 @GLbyte
142 @GLshort
143 @GLint
144 @GLfloat
145 @GLdouble Buffer data);
146
147 @Reuse("GL45")
148 void glCopyNamedBufferSubData(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readOffset, @GLintptr long writeOffset, @GLsizeiptr long size);
149
150 @Reuse("GL45")
151 void glClearNamedBufferData(@GLuint int buffer, @GLenum int internalformat, @GLenum int format, @GLenum int type, @Check("1") @Const @GLvoid ByteBuffer data);
152
153 @Reuse("GL45")
154 void glClearNamedBufferSubData(@GLuint int buffer, @GLenum int internalformat, @GLintptr long offset, @GLsizeiptr long size, @GLenum int format, @GLenum int type, @Check("1") @Const @GLvoid ByteBuffer data);
155
156 /**
157 * Maps a buffer object's data store.
158 * <p/>
159 * <b>LWJGL note</b>: This method comes in 2 flavors:
160 * <ol>
161 * <li>{@link #glMapNamedBuffer(int, int, ByteBuffer)} - Calls {@link #glGetNamedBufferParameteri} to retrieve the buffer size and the {@code old_buffer} parameter is reused if the returned size and pointer match the buffer capacity and address, respectively.</li>
162 * <li>{@link #glMapNamedBuffer(int, int, int, ByteBuffer)} - The buffer size is explicitly specified and the {@code old_buffer} parameter is reused if {@code size} and the returned pointer match the buffer capacity and address, respectively. This is the most efficient method.</li>
163 * </ol>
164 *
165 * @param buffer the buffer object being mapped
166 * @param access the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store
167 */
168 @CachedResult
169 @GLvoid
170 @AutoSize("glGetNamedBufferParameteri(buffer, GL15.GL_BUFFER_SIZE)")
171 @Reuse("GL45")
172 ByteBuffer glMapNamedBuffer(@GLuint int buffer, @GLenum int access);
173
174 @CachedResult(isRange = true)
175 @GLvoid
176 @AutoSize("length")
177 @Reuse("GL45")
178 ByteBuffer glMapNamedBufferRange(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
179
180 @Reuse("GL45")
181 boolean glUnmapNamedBuffer(@GLuint int buffer);
182
183 @Reuse("GL45")
184 void glFlushMappedNamedBufferRange(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
185
186 @StripPostfix("params")
187 @Reuse("GL45")
188 void glGetNamedBufferParameteriv(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params);
189
190 @Alternate("glGetNamedBufferParameteriv")
191 @GLreturn("params")
192 @StripPostfix(value = "params", hasPostfix = false)
193 @Reuse("GL45")
194 void glGetNamedBufferParameteriv2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params);
195
196 @StripPostfix("params")
197 @Reuse("GL45")
198 void glGetNamedBufferParameteri64v(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
199
200 @Alternate("glGetNamedBufferParameteri64v")
201 @GLreturn("params")
202 @StripPostfix(value = "params", hasPostfix = false)
203 @Reuse("GL45")
204 void glGetNamedBufferParameteri64v2(@GLuint int buffer, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
205
206 @StripPostfix("params")
207 @AutoSize("glGetNamedBufferParameteri(buffer, GL15.GL_BUFFER_SIZE)")
208 @Reuse("GL45")
209 void glGetNamedBufferPointerv(@GLuint int buffer, @GLenum int pname, @Result @GLvoid ByteBuffer params);
210
211 @Reuse("GL45")
212 void glGetNamedBufferSubData(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
213 @OutParameter
214 @Check
215 @GLbyte
216 @GLshort
217 @GLint
218 @GLfloat
219 @GLdouble Buffer data);
220
221 // Framebuffer object functions
222
223 @Reuse("GL45")
224 void glCreateFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
225
226 @Alternate("glCreateFramebuffers")
227 @GLreturn("framebuffers")
228 @Reuse("GL45")
229 void glCreateFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
230
231 @Reuse("GL45")
232 void glNamedFramebufferRenderbuffer(@GLuint int framebuffer, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
233
234 @Reuse("GL45")
235 void glNamedFramebufferParameteri(@GLuint int framebuffer, @GLenum int pname, int param);
236
237 @Reuse("GL45")
238 void glNamedFramebufferTexture(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level);
239
240 @Reuse("GL45")
241 void glNamedFramebufferTextureLayer(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer);
242
243 @Reuse("GL45")
244 void glNamedFramebufferDrawBuffer(@GLuint int framebuffer, @GLenum int mode);
245
246 @Reuse("GL45")
247 void glNamedFramebufferDrawBuffers(@GLuint int framebuffer, @AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs);
248
249 @Reuse("GL45")
250 void glNamedFramebufferReadBuffer(@GLuint int framebuffer, @GLenum int mode);
251
252 @Reuse("GL45")
253 void glInvalidateNamedFramebufferData(@GLuint int framebuffer, @AutoSize("attachments") @GLsizei int numAttachments, @Const @GLenum IntBuffer attachments);
254
255 @Reuse("GL45")
256 void glInvalidateNamedFramebufferSubData(@GLuint int framebuffer, @AutoSize("attachments") @GLsizei int numAttachments, @Const @GLenum IntBuffer attachments, int x, int y, @GLsizei int width, @GLsizei int height);
257
258 @StripPostfix("value")
259 @Reuse("GL45")
260 void glClearNamedFramebufferiv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("1") IntBuffer value);
261
262 @StripPostfix("value")
263 @Reuse("GL45")
264 void glClearNamedFramebufferuiv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("4") @GLuint IntBuffer value);
265
266 @StripPostfix("value")
267 @Reuse("GL45")
268 void glClearNamedFramebufferfv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("1") FloatBuffer value);
269
270 @Reuse("GL45")
271 void glClearNamedFramebufferfi(@GLuint int framebuffer, @GLenum int buffer, float depth, int stencil);
272
273 @Reuse("GL45")
274 void glBlitNamedFramebuffer(
275 @GLuint int readFramebuffer, @GLuint int drawFramebuffer,
276 int srcX0, int srcY0, int srcX1, int srcY1,
277 int dstX0, int dstY0, int dstX1, int dstY1,
278 @GLbitfield int mask, @GLenum int filter);
279
280 @GLenum
281 @Reuse("GL45")
282 int glCheckNamedFramebufferStatus(@GLuint int framebuffer, @GLenum int target);
283
284 @StripPostfix("params")
285 @Reuse("GL45")
286 void glGetNamedFramebufferParameteriv(@GLuint int framebuffer, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
287
288 @Alternate("glGetNamedFramebufferParameteriv")
289 @GLreturn("params")
290 @StripPostfix("params")
291 @Reuse("GL45")
292 void glGetNamedFramebufferParameteriv2(@GLuint int framebuffer, @GLenum int pname, @OutParameter IntBuffer params);
293
294 @StripPostfix("params")
295 @Reuse("GL45")
296 void glGetNamedFramebufferAttachmentParameteriv(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
297
298 @Alternate("glGetNamedFramebufferAttachmentParameteriv")
299 @GLreturn("params")
300 @StripPostfix("params")
301 @Reuse("GL45")
302 void glGetNamedFramebufferAttachmentParameteriv2(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
303
304 // Renderbuffer object functions
305
306 @Reuse("GL45")
307 void glCreateRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
308
309 @Alternate("glCreateRenderbuffers")
310 @GLreturn("renderbuffers")
311 @Reuse("GL45")
312 void glCreateRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
313
314 @Reuse("GL45")
315 void glNamedRenderbufferStorage(@GLuint int renderbuffer, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
316
317 @Reuse("GL45")
318 void glNamedRenderbufferStorageMultisample(@GLuint int renderbuffer, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
319
320 @StripPostfix("params")
321 @Reuse("GL45")
322 void glGetNamedRenderbufferParameteriv(@GLuint int renderbuffer, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
323
324 @Alternate("glGetNamedRenderbufferParameteriv")
325 @GLreturn("params")
326 @StripPostfix("params")
327 @Reuse("GL45")
328 void glGetNamedRenderbufferParameteriv2(@GLuint int renderbuffer, @GLenum int pname, @OutParameter IntBuffer params);
329
330 // Texture object functions
331
332 @Reuse("GL45")
333 void glCreateTextures(@GLenum int target, @AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
334
335 @Alternate("glCreateTextures")
336 @GLreturn("textures")
337 @Reuse("GL45")
338 void glCreateTextures2(@GLenum int target, @Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
339
340 @Reuse("GL45")
341 void glTextureBuffer(@GLuint int texture, @GLenum int internalformat, @GLuint int buffer);
342
343 @Reuse("GL45")
344 void glTextureBufferRange(@GLuint int texture, @GLenum int internalformat, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
345
346 @Reuse("GL45")
347 void glTextureStorage1D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width);
348
349 @Reuse("GL45")
350 void glTextureStorage2D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
351
352 @Reuse("GL45")
353 void glTextureStorage3D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth);
354
355 @Reuse("GL45")
356 void glTextureStorage2DMultisample(@GLuint int texture, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, boolean fixedsamplelocations);
357
358 @Reuse("GL45")
359 void glTextureStorage3DMultisample(@GLuint int texture, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, boolean fixedsamplelocations);
360
361 @Reuse("GL45")
362 void glTextureSubImage1D(@GLuint int texture, int level, int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type,
363 @BufferObject(BufferKind.UnpackPBO)
364 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)")
365 @Const
366 @GLbyte
367 @GLshort
368 @GLint
369 @GLfloat
370 @GLdouble Buffer pixels);
371
372 @Reuse("GL45")
373 void glTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
374 @BufferObject(BufferKind.UnpackPBO)
375 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
376 @Const
377 @GLbyte
378 @GLshort
379 @GLint
380 @GLfloat
381 @GLdouble Buffer pixels);
382
383 @Reuse("GL45")
384 void glTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type,
385 @BufferObject(BufferKind.UnpackPBO)
386 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
387 @Const
388 @GLbyte
389 @GLshort
390 @GLint
391 @GLfloat
392 @GLdouble Buffer pixels);
393
394 @Reuse("GL45")
395 void glCompressedTextureSubImage1D(@GLuint int texture, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
396 @BufferObject(BufferKind.UnpackPBO)
397 @Check
398 @Const
399 @GLvoid
400 ByteBuffer data);
401
402 @Reuse("GL45")
403 void glCompressedTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
404 @BufferObject(BufferKind.UnpackPBO)
405 @Check
406 @Const
407 @GLvoid
408 ByteBuffer data);
409
410 @Reuse("GL45")
411 void glCompressedTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLsizei int imageSize,
412 @BufferObject(BufferKind.UnpackPBO)
413 @Check
414 @Const
415 @GLvoid
416 ByteBuffer data);
417
418 @Reuse("GL45")
419 void glCopyTextureSubImage1D(@GLuint int texture, int level, int xoffset, int x, int y, @GLsizei int width);
420
421 @Reuse("GL45")
422 void glCopyTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height);
423
424 @Reuse("GL45")
425 void glCopyTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
426
427 @Reuse("GL45")
428 void glTextureParameterf(@GLuint int texture, @GLenum int pname, float param);
429
430 @StripPostfix("params")
431 @Reuse("GL45")
432 void glTextureParameterfv(@GLuint int texture, @GLenum int pname, @Const @Check("4") FloatBuffer params);
433
434 @Reuse("GL45")
435 void glTextureParameteri(@GLuint int texture, @GLenum int pname, int param);
436
437 @StripPostfix("params")
438 @Reuse("GL45")
439 void glTextureParameterIiv(@GLuint int texture, @GLenum int pname, @Const @Check("1") IntBuffer params);
440
441 @StripPostfix("params")
442 @Reuse("GL45")
443 void glTextureParameterIuiv(@GLuint int texture, @GLenum int pname, @Const @Check("1") @GLuint IntBuffer params);
444
445 @StripPostfix("params")
446 @Reuse("GL45")
447 void glTextureParameteriv(@GLuint int texture, @GLenum int pname, @Const @Check("4") IntBuffer params);
448
449 @Reuse("GL45")
450 void glGenerateTextureMipmap(@GLuint int texture);
451
452 @Reuse("GL45")
453 void glBindTextureUnit(@GLuint int unit, @GLuint int texture);
454
455 @Reuse("GL45")
456 void glGetTextureImage(@GLuint int texture, int level, @GLenum int format, @GLenum int type, @AutoSize("pixels") @GLsizei int bufSize,
457 @OutParameter
458 @BufferObject(BufferKind.PackPBO)
459 @GLbyte
460 @GLshort
461 @GLint
462 @GLfloat
463 @GLdouble Buffer pixels);
464
465 @Reuse("GL45")
466 void glGetCompressedTextureImage(@GLuint int texture, int level, @AutoSize("pixels") @GLsizei int bufSize,
467 @OutParameter
468 @BufferObject(BufferKind.PackPBO)
469 @Check
470 @GLbyte
471 @GLshort
472 @GLint Buffer pixels);
473
474 @StripPostfix("params")
475 @Reuse("GL45")
476 void glGetTextureLevelParameterfv(@GLuint int texture, int level, @GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
477
478 @Alternate("glGetTextureLevelParameterfv")
479 @GLreturn("params")
480 @StripPostfix(value = "params", hasPostfix = false)
481 @Reuse("GL45")
482 void glGetTextureLevelParameterfv2(@GLuint int texture, int level, @GLenum int pname, @OutParameter FloatBuffer params);
483
484 @StripPostfix("params")
485 @Reuse("GL45")
486 void glGetTextureLevelParameteriv(@GLuint int texture, int level, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
487
488 @Alternate("glGetTextureLevelParameteriv")
489 @GLreturn("params")
490 @StripPostfix(value = "params", hasPostfix = false)
491 @Reuse("GL45")
492 void glGetTextureLevelParameteriv2(@GLuint int texture, int level, @GLenum int pname, @OutParameter IntBuffer params);
493
494 @StripPostfix("params")
495 @Reuse("GL45")
496 void glGetTextureParameterfv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
497
498 @Alternate("glGetTextureParameterfv")
499 @GLreturn("params")
500 @StripPostfix(value = "params", hasPostfix = false)
501 @Reuse("GL45")
502 void glGetTextureParameterfv2(@GLuint int texture, @GLenum int pname, @OutParameter FloatBuffer params);
503
504 @StripPostfix("params")
505 @Reuse("GL45")
506 void glGetTextureParameterIiv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
507
508 @Alternate("glGetTextureParameterIiv")
509 @GLreturn("params")
510 @StripPostfix(value = "params", hasPostfix = false)
511 @Reuse("GL45")
512 void glGetTextureParameterIiv2(@GLuint int texture, @GLenum int pname, @OutParameter IntBuffer params);
513
514 @StripPostfix("params")
515 @Reuse("GL45")
516 void glGetTextureParameterIuiv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
517
518 @Alternate("glGetTextureParameterIuiv")
519 @GLreturn("params")
520 @StripPostfix(value = "params", hasPostfix = false)
521 @Reuse("GL45")
522 void glGetTextureParameterIuiv2(@GLuint int texture, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
523
524 @StripPostfix("params")
525 @Reuse("GL45")
526 void glGetTextureParameteriv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
527
528 @Alternate("glGetTextureParameteriv")
529 @GLreturn("params")
530 @StripPostfix(value = "params", hasPostfix = false)
531 @Reuse("GL45")
532 void glGetTextureParameteriv2(@GLuint int texture, @GLenum int pname, @OutParameter IntBuffer params);
533
534 // Vertex Array object functions
535
536 @Reuse("GL45")
537 void glCreateVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
538
539 @Alternate("glCreateVertexArrays")
540 @GLreturn("arrays")
541 @Reuse("GL45")
542 void glCreateVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
543
544 @Reuse("GL45")
545 void glDisableVertexArrayAttrib(@GLuint int vaobj, @GLuint int index);
546
547 @Reuse("GL45")
548 void glEnableVertexArrayAttrib(@GLuint int vaobj, @GLuint int index);
549
550 @Reuse("GL45")
551 void glVertexArrayElementBuffer(@GLuint int vaobj, @GLuint int buffer);
552
553 @Reuse("GL45")
554 void glVertexArrayVertexBuffer(@GLuint int vaobj, @GLuint int bindingindex, @GLuint int buffer, @GLintptr long offset, @GLsizei int stride);
555
556 @Reuse("GL45")
557 void glVertexArrayVertexBuffers(@GLuint int vaobj, @GLuint int first, @GLsizei int count,
558 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
559 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
560 @Check(value = "count", canBeNull = true) @Const @GLsizei IntBuffer strides);
561
562 @Reuse("GL45")
563 void glVertexArrayAttribFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, boolean normalized, @GLuint int relativeoffset);
564
565 @Reuse("GL45")
566 void glVertexArrayAttribIFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, @GLuint int relativeoffset);
567
568 @Reuse("GL45")
569 void glVertexArrayAttribLFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, @GLuint int relativeoffset);
570
571 @Reuse("GL45")
572 void glVertexArrayAttribBinding(@GLuint int vaobj, @GLuint int attribindex, @GLuint int bindingindex);
573
574 @Reuse("GL45")
575 void glVertexArrayBindingDivisor(@GLuint int vaobj, @GLuint int bindingindex, @GLuint int divisor);
576
577 @StripPostfix("param")
578 @Reuse("GL45")
579 void glGetVertexArrayiv(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
580
581 @Alternate("glGetVertexArrayiv")
582 @GLreturn("param")
583 @StripPostfix("param")
584 @Reuse("GL45")
585 void glGetVertexArrayiv2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
586
587 @StripPostfix("param")
588 @Reuse("GL45")
589 void glGetVertexArrayIndexediv(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
590
591 @Alternate("glGetVertexArrayIndexediv")
592 @GLreturn("param")
593 @StripPostfix("param")
594 @Reuse("GL45")
595 void glGetVertexArrayIndexediv2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
596
597 @StripPostfix("param")
598 @Reuse("GL45")
599 void glGetVertexArrayIndexed64iv(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer param);
600
601 @Alternate("glGetVertexArrayIndexed64iv")
602 @GLreturn("param")
603 @StripPostfix("param")
604 @Reuse("GL45")
605 void glGetVertexArrayIndexed64iv2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @GLint64 LongBuffer param);
606
607 // Sampler object functions
608
609 @Reuse("GL45")
610 void glCreateSamplers(@AutoSize("samplers") @GLsizei int n, @OutParameter @GLuint IntBuffer samplers);
611
612 @Alternate("glCreateSamplers")
613 @GLreturn("samplers")
614 @Reuse("GL45")
615 void glCreateSamplers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer samplers);
616
617 // Program Pipeline object functions
618
619 @Reuse("GL45")
620 void glCreateProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
621
622 @Alternate("glCreateProgramPipelines")
623 @GLreturn("pipelines")
624 @Reuse("GL45")
625 void glCreateProgramPipelines2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
626
627 // Query object functions
628
629 @Reuse("GL45")
630 void glCreateQueries(@GLenum int target, @AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
631
632 @Alternate("glCreateQueries")
633 @GLreturn("ids")
634 @Reuse("GL45")
635 void glCreateQueries2(@GLenum int target, @Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
636
637 }
6464 void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
6565
6666 @Alternate("glDrawBuffersARB")
67 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
67 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
6868 }
3434 import org.lwjgl.util.generator.opengl.GLenum;
3535 import org.lwjgl.util.generator.opengl.GLvoid;
3636
37 import java.nio.ByteBuffer;
3738 import java.nio.IntBuffer;
3839
39 import com.sun.mirror.type.PrimitiveType;
40 import javax.lang.model.type.TypeKind;
4041
4142 public interface ARB_draw_indirect {
4243
5657 int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43;
5758
5859 @Reuse("GL40")
59 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
60 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4 * 4") @Const @GLvoid ByteBuffer indirect);
6061
6162 @Reuse("GL40")
62 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
63 @Alternate("glDrawArraysIndirect")
64 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @Const @GLvoid(TypeKind.INT) IntBuffer indirect);
65
66 @Reuse("GL40")
67 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5 * 4") @Const @GLvoid ByteBuffer indirect);
68
69 @Reuse("GL40")
70 @Alternate("glDrawElementsIndirect")
71 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @Const @GLvoid(TypeKind.INT) IntBuffer indirect);
6372
6473 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_enhanced_layouts {
34
35 /** Accepted in the &lt;props&gt; array of GetProgramResourceiv: */
36 int GL_LOCATION_COMPONENT = 0x934A,
37 GL_TRANSFORM_FEEDBACK_BUFFER_INDEX = 0x934B,
38 GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE = 0x934C;
39
40 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_uniform_location {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
37 * GetFloatv, GetDoublev, and GetInteger64v:
38 */
39 int GL_MAX_UNIFORM_LOCATIONS = 0x826E;
40
41 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_layer_viewport {
34 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 import java.nio.IntBuffer;
39
40 @Dependent
41 @Extension(postfix = "")
42 public interface ARB_framebuffer_no_attachments {
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of FramebufferParameteri,
46 * GetFramebufferParameteriv, NamedFramebufferParameteriEXT, and
47 * GetNamedFramebufferParameterivEXT:
48 */
49 int GL_FRAMEBUFFER_DEFAULT_WIDTH = 0x9310,
50 GL_FRAMEBUFFER_DEFAULT_HEIGHT = 0x9311,
51 GL_FRAMEBUFFER_DEFAULT_LAYERS = 0x9312,
52 GL_FRAMEBUFFER_DEFAULT_SAMPLES = 0x9313,
53 GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314;
54
55 /**
56 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv,
57 * GetInteger64v, GetFloatv, and GetDoublev:
58 */
59 int GL_MAX_FRAMEBUFFER_WIDTH = 0x9315,
60 GL_MAX_FRAMEBUFFER_HEIGHT = 0x9316,
61 GL_MAX_FRAMEBUFFER_LAYERS = 0x9317,
62 GL_MAX_FRAMEBUFFER_SAMPLES = 0x9318;
63
64 @Reuse("GL43")
65 void glFramebufferParameteri(@GLenum int target, @GLenum int pname, int param);
66
67 @Reuse("GL43")
68 @StripPostfix("params")
69 void glGetFramebufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
70
71 @Reuse("GL43")
72 @Alternate("glGetFramebufferParameteriv")
73 @GLreturn("params")
74 @StripPostfix(value = "params", hasPostfix = false)
75 void glGetFramebufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
76
77 @Dependent("GL_EXT_direct_state_access")
78 void glNamedFramebufferParameteriEXT(@GLuint int framebuffer, @GLenum int pname,
79 int param);
80
81 @Dependent("GL_EXT_direct_state_access")
82 @StripPostfix(value = "params", extension = "EXT")
83 void glGetNamedFramebufferParameterivEXT(@GLuint int framebuffer, @GLenum int pname,
84 @OutParameter @Check("1") IntBuffer params);
85
86 @Alternate("glGetNamedFramebufferParameterivEXT")
87 @GLreturn("params")
88 @Dependent("GL_EXT_direct_state_access")
89 @StripPostfix(value = "params", extension = "EXT")
90 void glGetNamedFramebufferParameterivEXT2(@GLuint int framebuffer, @GLenum int pname,
91 @OutParameter IntBuffer params);
92
93 }
196196
197197 @Reuse("GL30")
198198 @Alternate("glDeleteRenderbuffers")
199 void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
199 void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer);
200200
201201 @Reuse("GL30")
202202 void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
219219 @StripPostfix("params")
220220 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
221221
222 @Reuse("GL30")
222 /** @deprecated Will be removed in 3.0. Use {@link #glGetRenderbufferParameteri} instead. */
223223 @Alternate("glGetRenderbufferParameteriv")
224224 @GLreturn("params")
225225 @StripPostfix("params")
226 @Reuse(value = "ARBFramebufferObject", method = "glGetRenderbufferParameteri")
227 @Deprecated
226228 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
227229
228230 @Reuse("GL30")
231 @Alternate("glGetRenderbufferParameteriv")
232 @GLreturn("params")
233 @StripPostfix(value = "params", hasPostfix = false)
234 void glGetRenderbufferParameteriv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
235
236 @Reuse("GL30")
229237 boolean glIsFramebuffer(@GLuint int framebuffer);
230238
231239 @Reuse("GL30")
236244
237245 @Reuse("GL30")
238246 @Alternate("glDeleteFramebuffers")
239 void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
247 void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer);
240248
241249 @Reuse("GL30")
242250 void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
276284 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment,
277285 @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
278286
279 @Reuse("GL30")
287 /** @deprecated Will be removed in 3.0. Use {@link #glGetFramebufferAttachmentParameteri} instead. */
280288 @Alternate("glGetFramebufferAttachmentParameteriv")
281289 @GLreturn("params")
282290 @StripPostfix("params")
291 @Reuse(value = "GL30", method = "glGetFramebufferAttachmentParameteri")
292 @Deprecated
283293 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment,
294 @GLenum int pname, @OutParameter IntBuffer params);
295
296 @Reuse("GL30")
297 @Alternate("glGetFramebufferAttachmentParameteriv")
298 @GLreturn("params")
299 @StripPostfix(value = "params", hasPostfix = false)
300 void glGetFramebufferAttachmentParameteriv3(@GLenum int target, @GLenum int attachment,
284301 @GLenum int pname, @OutParameter IntBuffer params);
285302
286303 @Reuse("GL30")
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37
38 public interface ARB_get_texture_sub_image {
39
40 @Reuse("GL45")
41 void glGetTextureSubImage(
42 @GLuint int texture, int level, int xoffset, int yoffset, int zoffset,
43 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
44 @GLenum int format, @GLenum int type,
45 @AutoSize("pixels") @GLsizei int bufSize,
46 @OutParameter
47 @BufferObject(BufferKind.PackPBO)
48 @GLbyte
49 @GLshort
50 @GLint
51 @GLfloat
52 @GLdouble Buffer pixels
53 );
54
55 @Reuse("GL45")
56 void glGetCompressedTextureSubImage(
57 @GLuint int texture, int level, int xoffset, int yoffset, int zoffset,
58 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
59 @AutoSize("pixels") @GLsizei int bufSize,
60 @OutParameter
61 @BufferObject(BufferKind.PackPBO)
62 @GLbyte
63 @GLshort
64 @GLint
65 @GLfloat
66 @GLdouble Buffer pixels
67 );
68
69 }
4444 * Returned in the &lt;type&gt; parameter of GetActiveUniform, and
4545 * GetTransformFeedbackVarying:
4646 */
47 int GL_DOUBLE = GL11.GL_DOUBLE;
4847 int GL_DOUBLE_VEC2 = 0x8FFC;
4948 int GL_DOUBLE_VEC3 = 0x8FFD;
5049 int GL_DOUBLE_VEC4 = 0x8FFE;
4040 * The GL12 imaging subset extension.
4141 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3412 $
44 * $Id: ARB_imaging.java 3412 2010-09-26 23:43:24Z spasi $
43 * @version $Revision$
44 * $Id$
4545 */
4646
4747 @Extension(postfix = "")
4848 @DeprecatedGL
4949 public interface ARB_imaging {
5050
51 int GL_CONSTANT_COLOR = 0x8001;
52 int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
53 int GL_CONSTANT_ALPHA = 0x8003;
54 int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;
5551 int GL_BLEND_COLOR = 0x8005;
5652 int GL_FUNC_ADD = 0x8006;
5753 int GL_MIN = 0x8007;
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLintptr;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLvoid;
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 import javax.lang.model.type.TypeKind;
43
44 public interface ARB_indirect_parameters {
45
46 /**
47 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
48 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
49 * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange,
50 * GetBufferParameteriv, and CopyBufferSubData:
51 */
52 int GL_PARAMETER_BUFFER_ARB = 0x80EE;
53
54 /**
55 * Accepted by the &lt;value&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
56 * and GetDoublev:
57 */
58 int GL_PARAMETER_BUFFER_BINDING_ARB = 0x80EF;
59
60 void glMultiDrawArraysIndirectCountARB(@GLenum int mode,
61 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 * 4 : stride) * maxdrawcount") @Const @GLvoid ByteBuffer indirect,
62 @GLintptr long drawcount,
63 @GLsizei int maxdrawcount,
64 @GLsizei int stride);
65
66 @Alternate("glMultiDrawArraysIndirectCountARB")
67 void glMultiDrawArraysIndirectCountARB(@GLenum int mode,
68 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 : stride >> 2) * maxdrawcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
69 @GLintptr long drawcount,
70 @GLsizei int maxdrawcount,
71 @GLsizei int stride);
72
73 void glMultiDrawElementsIndirectCountARB(@GLenum int mode,
74 @GLenum int type,
75 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 * 4 : stride) * maxdrawcount") @Const @GLvoid ByteBuffer indirect,
76 @GLintptr long drawcount,
77 @GLsizei int maxdrawcount,
78 @GLsizei int stride);
79
80 @Alternate("glMultiDrawElementsIndirectCountARB")
81 void glMultiDrawElementsIndirectCountARB(@GLenum int mode,
82 @GLenum int type,
83 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * maxdrawcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
84 @GLintptr long drawcount,
85 @GLsizei int maxdrawcount,
86 @GLsizei int stride);
87
88 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37
38 import java.nio.IntBuffer;
39
40 @Extension(postfix = "")
41 public interface ARB_internalformat_query {
42
43 /** Accepted by the &lt;pname&gt; parameter of GetInternalformativ: */
44 int GL_NUM_SAMPLE_COUNTS = 0x9380;
45
46 @StripPostfix("params")
47 @Reuse("GL42")
48 void glGetInternalformativ(@GLenum int target, @GLenum int internalformat,
49 @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
50
51 @Alternate("glGetInternalformativ")
52 @StripPostfix("params")
53 @GLreturn("params")
54 @Reuse("GL42")
55 void glGetInternalformativ2(@GLenum int target, @GLenum int internalformat,
56 @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter IntBuffer params);
57
58 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLint64;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38
39 import java.nio.LongBuffer;
40
41 @Extension(postfix = "")
42 public interface ARB_internalformat_query2 {
43
44 /**
45 * Accepted by the &lt;target&gt; parameter of GetInternalformativ
46 * and GetInternalformati64v:
47 */
48 int GL_TEXTURE_1D_ARRAY = 0x8C18,
49 GL_TEXTURE_2D_ARRAY = 0x8C1A,
50 GL_TEXTURE_CUBE_MAP_ARRAY = 0x9009,
51 GL_TEXTURE_RECTANGLE = 0x84F5,
52 GL_TEXTURE_BUFFER = 0x8C2A,
53 GL_RENDERBUFFER = 0x8D41,
54 GL_TEXTURE_2D_MULTISAMPLE = 0x9100,
55 GL_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102;
56
57 /**
58 * Accepted by the &lt;pname&gt; parameter of GetInternalformativ
59 * and GetInternalformati64v:
60 */
61 int GL_NUM_SAMPLE_COUNTS = 0x9380,
62 GL_INTERNALFORMAT_SUPPORTED = 0x826F,
63 GL_INTERNALFORMAT_PREFERRED = 0x8270,
64 GL_INTERNALFORMAT_RED_SIZE = 0x8271,
65 GL_INTERNALFORMAT_GREEN_SIZE = 0x8272,
66 GL_INTERNALFORMAT_BLUE_SIZE = 0x8273,
67 GL_INTERNALFORMAT_ALPHA_SIZE = 0x8274,
68 GL_INTERNALFORMAT_DEPTH_SIZE = 0x8275,
69 GL_INTERNALFORMAT_STENCIL_SIZE = 0x8276,
70 GL_INTERNALFORMAT_SHARED_SIZE = 0x8277,
71 GL_INTERNALFORMAT_RED_TYPE = 0x8278,
72 GL_INTERNALFORMAT_GREEN_TYPE = 0x8279,
73 GL_INTERNALFORMAT_BLUE_TYPE = 0x827A,
74 GL_INTERNALFORMAT_ALPHA_TYPE = 0x827B,
75 GL_INTERNALFORMAT_DEPTH_TYPE = 0x827C,
76 GL_INTERNALFORMAT_STENCIL_TYPE = 0x827D,
77 GL_MAX_WIDTH = 0x827E,
78 GL_MAX_HEIGHT = 0x827F,
79 GL_MAX_DEPTH = 0x8280,
80 GL_MAX_LAYERS = 0x8281,
81 GL_MAX_COMBINED_DIMENSIONS = 0x8282,
82 GL_COLOR_COMPONENTS = 0x8283,
83 GL_DEPTH_COMPONENTS = 0x8284,
84 GL_STENCIL_COMPONENTS = 0x8285,
85 GL_COLOR_RENDERABLE = 0x8286,
86 GL_DEPTH_RENDERABLE = 0x8287,
87 GL_STENCIL_RENDERABLE = 0x8288,
88 GL_FRAMEBUFFER_RENDERABLE = 0x8289,
89 GL_FRAMEBUFFER_RENDERABLE_LAYERED = 0x828A,
90 GL_FRAMEBUFFER_BLEND = 0x828B,
91 GL_READ_PIXELS = 0x828C,
92 GL_READ_PIXELS_FORMAT = 0x828D,
93 GL_READ_PIXELS_TYPE = 0x828E,
94 GL_TEXTURE_IMAGE_FORMAT = 0x828F,
95 GL_TEXTURE_IMAGE_TYPE = 0x8290,
96 GL_GET_TEXTURE_IMAGE_FORMAT = 0x8291,
97 GL_GET_TEXTURE_IMAGE_TYPE = 0x8292,
98 GL_MIPMAP = 0x8293,
99 GL_MANUAL_GENERATE_MIPMAP = 0x8294,
100 GL_AUTO_GENERATE_MIPMAP = 0x8295,
101 GL_COLOR_ENCODING = 0x8296,
102 GL_SRGB_READ = 0x8297,
103 GL_SRGB_WRITE = 0x8298,
104 GL_SRGB_DECODE_ARB = 0x8299,
105 GL_FILTER = 0x829A,
106 GL_VERTEX_TEXTURE = 0x829B,
107 GL_TESS_CONTROL_TEXTURE = 0x829C,
108 GL_TESS_EVALUATION_TEXTURE = 0x829D,
109 GL_GEOMETRY_TEXTURE = 0x829E,
110 GL_FRAGMENT_TEXTURE = 0x829F,
111 GL_COMPUTE_TEXTURE = 0x82A0,
112 GL_TEXTURE_SHADOW = 0x82A1,
113 GL_TEXTURE_GATHER = 0x82A2,
114 GL_TEXTURE_GATHER_SHADOW = 0x82A3,
115 GL_SHADER_IMAGE_LOAD = 0x82A4,
116 GL_SHADER_IMAGE_STORE = 0x82A5,
117 GL_SHADER_IMAGE_ATOMIC = 0x82A6,
118 GL_IMAGE_TEXEL_SIZE = 0x82A7,
119 GL_IMAGE_COMPATIBILITY_CLASS = 0x82A8,
120 GL_IMAGE_PIXEL_FORMAT = 0x82A9,
121 GL_IMAGE_PIXEL_TYPE = 0x82AA,
122 GL_IMAGE_FORMAT_COMPATIBILITY_TYPE = 0x90C7,
123 GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST = 0x82AC,
124 GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST = 0x82AD,
125 GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE = 0x82AE,
126 GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE = 0x82AF,
127 GL_TEXTURE_COMPRESSED_BLOCK_WIDTH = 0x82B1,
128 GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT = 0x82B2,
129 GL_TEXTURE_COMPRESSED_BLOCK_SIZE = 0x82B3,
130 GL_CLEAR_BUFFER = 0x82B4,
131 GL_TEXTURE_VIEW = 0x82B5,
132 GL_VIEW_COMPATIBILITY_CLASS = 0x82B6;
133
134 /**
135 * Returned as possible responses for various &lt;pname&gt; queries
136 * to GetInternalformativ and GetInternalformati64v
137 */
138 int GL_FULL_SUPPORT = 0x82B7,
139 GL_CAVEAT_SUPPORT = 0x82B8,
140 GL_IMAGE_CLASS_4_X_32 = 0x82B9,
141 GL_IMAGE_CLASS_2_X_32 = 0x82BA,
142 GL_IMAGE_CLASS_1_X_32 = 0x82BB,
143 GL_IMAGE_CLASS_4_X_16 = 0x82BC,
144 GL_IMAGE_CLASS_2_X_16 = 0x82BD,
145 GL_IMAGE_CLASS_1_X_16 = 0x82BE,
146 GL_IMAGE_CLASS_4_X_8 = 0x82BF,
147 GL_IMAGE_CLASS_2_X_8 = 0x82C0,
148 GL_IMAGE_CLASS_1_X_8 = 0x82C1,
149 GL_IMAGE_CLASS_11_11_10 = 0x82C2,
150 GL_IMAGE_CLASS_10_10_10_2 = 0x82C3,
151 GL_VIEW_CLASS_128_BITS = 0x82C4,
152 GL_VIEW_CLASS_96_BITS = 0x82C5,
153 GL_VIEW_CLASS_64_BITS = 0x82C6,
154 GL_VIEW_CLASS_48_BITS = 0x82C7,
155 GL_VIEW_CLASS_32_BITS = 0x82C8,
156 GL_VIEW_CLASS_24_BITS = 0x82C9,
157 GL_VIEW_CLASS_16_BITS = 0x82CA,
158 GL_VIEW_CLASS_8_BITS = 0x82CB,
159 GL_VIEW_CLASS_S3TC_DXT1_RGB = 0x82CC,
160 GL_VIEW_CLASS_S3TC_DXT1_RGBA = 0x82CD,
161 GL_VIEW_CLASS_S3TC_DXT3_RGBA = 0x82CE,
162 GL_VIEW_CLASS_S3TC_DXT5_RGBA = 0x82CF,
163 GL_VIEW_CLASS_RGTC1_RED = 0x82D0,
164 GL_VIEW_CLASS_RGTC2_RG = 0x82D1,
165 GL_VIEW_CLASS_BPTC_UNORM = 0x82D2,
166 GL_VIEW_CLASS_BPTC_FLOAT = 0x82D3;
167
168 @Reuse("GL43")
169 @StripPostfix("params")
170 void glGetInternalformati64v(@GLenum int target, @GLenum int internalformat,
171 @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter @GLint64 LongBuffer params);
172
173 @Reuse("GL43")
174 @Alternate("glGetInternalformati64v")
175 @GLreturn("params")
176 @StripPostfix(value = "params", hasPostfix = false)
177 void glGetInternalformati64v2(@GLenum int target, @GLenum int internalformat,
178 @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter @GLint64 LongBuffer params);
179
180 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Const;
35 import org.lwjgl.util.generator.Reuse;
36 import org.lwjgl.util.generator.opengl.*;
37
38 import java.nio.IntBuffer;
39
40 public interface ARB_invalidate_subdata {
41
42 @Reuse("GL43")
43 void glInvalidateTexSubImage(@GLuint int texture, int level,
44 int xoffset, int yoffset, int zoffset,
45 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
46
47 @Reuse("GL43")
48 void glInvalidateTexImage(@GLuint int texture, int level);
49
50 @Reuse("GL43")
51 void glInvalidateBufferSubData(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
52
53 @Reuse("GL43")
54 void glInvalidateBufferData(@GLuint int buffer);
55
56 @Reuse("GL43")
57 void glInvalidateFramebuffer(@GLenum int target,
58 @AutoSize("attachments") @GLsizei int numAttachments,
59 @Const @GLenum IntBuffer attachments);
60
61 @Reuse("GL43")
62 void glInvalidateSubFramebuffer(@GLenum int target,
63 @AutoSize("attachments") @GLsizei int numAttachments,
64 @Const @GLenum IntBuffer attachments,
65 int x, int y, @GLsizei int width, @GLsizei int height);
66
67 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_map_buffer_alignment {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
37 * GetInteger64v, GetFloatv, and GetDoublev:
38 */
39 int GL_MIN_MAP_BUFFER_ALIGNMENT = 0x90BC;
40
41 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.Reuse;
37 import org.lwjgl.util.generator.opengl.*;
38
39 import java.nio.IntBuffer;
40
41 public interface ARB_multi_bind {
42
43 @Reuse("GL44")
44 void glBindBuffersBase(@GLenum int target, @GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers);
45
46 @Reuse("GL44")
47 void glBindBuffersRange(@GLenum int target, @GLuint int first, @GLsizei int count,
48 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
49 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
50 @Check(value = "count", canBeNull = true) @Const @GLsizeiptr PointerBuffer sizes);
51
52 @Reuse("GL44")
53 void glBindTextures(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer textures);
54
55 @Reuse("GL44")
56 void glBindSamplers(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer samplers);
57
58 @Reuse("GL44")
59 void glBindImageTextures(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer textures);
60
61 @Reuse("GL44")
62 void glBindVertexBuffers(@GLuint int first, @GLsizei int count,
63 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
64 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
65 @Check(value = "count", canBeNull = true) @Const @GLsizei IntBuffer strides);
66
67 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLvoid;
37
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40
41 import javax.lang.model.type.TypeKind;
42
43 public interface ARB_multi_draw_indirect {
44
45 @Reuse("GL43")
46 void glMultiDrawArraysIndirect(@GLenum int mode,
47 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
48 @GLsizei int primcount,
49 @GLsizei int stride);
50
51 @Reuse("GL43")
52 @Alternate("glMultiDrawArraysIndirect")
53 void glMultiDrawArraysIndirect(@GLenum int mode,
54 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
55 @GLsizei int primcount,
56 @GLsizei int stride);
57
58 @Reuse("GL43")
59 void glMultiDrawElementsIndirect(@GLenum int mode,
60 @GLenum int type,
61 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
62 @GLsizei int primcount,
63 @GLsizei int stride);
64
65 @Reuse("GL43")
66 @Alternate("glMultiDrawElementsIndirect")
67 void glMultiDrawElementsIndirect(@GLenum int mode,
68 @GLenum int type,
69 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
70 @GLsizei int primcount,
71 @GLsizei int stride);
72
73 }
6767 void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
6868
6969 @Alternate("glDeleteQueriesARB")
70 void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
70 void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
7171
7272 boolean glIsQueryARB(@GLuint int id);
7373
7878 @StripPostfix("params")
7979 void glGetQueryivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
8080
81 /** @deprecated Will be removed in 3.0. Use {@link #glGetQueryiARB} instead. */
8182 @Alternate("glGetQueryivARB")
8283 @GLreturn("params")
8384 @StripPostfix("params")
85 @Reuse(value = "ARBOcclusionQuery", method = "glGetQueryiARB")
86 @Deprecated
8487 void glGetQueryivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
88
89 @Alternate("glGetQueryivARB")
90 @GLreturn("params")
91 @StripPostfix(value = "params", hasPostfix = false)
92 void glGetQueryivARB3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
8593
8694 @StripPostfix("params")
8795 void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
8896
8997 @Alternate("glGetQueryObjectivARB")
9098 @GLreturn("params")
91 @StripPostfix(value = "params", postfix = "v")
99 @StripPostfix(value = "params", hasPostfix = false)
92100 void glGetQueryObjectivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
93101
94102 @StripPostfix("params")
96104
97105 @Alternate("glGetQueryObjectuivARB")
98106 @GLreturn("params")
99 @StripPostfix(value = "params", postfix = "v")
107 @StripPostfix(value = "params", hasPostfix = false)
100108 void glGetQueryObjectuivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
101109 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_pipeline_statistics_query {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery, GetQueryiv,
37 * BeginQueryIndexed, EndQueryIndexed and GetQueryIndexediv:
38 */
39 int GL_VERTICES_SUBMITTED_ARB = 0x82EE,
40 GL_PRIMITIVES_SUBMITTED_ARB = 0x82EF,
41 GL_VERTEX_SHADER_INVOCATIONS_ARB = 0x82F0,
42 GL_TESS_CONTROL_SHADER_PATCHES_ARB = 0x82F1,
43 GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB = 0x82F2,
44 GL_GEOMETRY_SHADER_INVOCATIONS = 0x887F,
45 GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB = 0x82F3,
46 GL_FRAGMENT_SHADER_INVOCATIONS_ARB = 0x82F4,
47 GL_COMPUTE_SHADER_INVOCATIONS_ARB = 0x82F5,
48 GL_CLIPPING_INPUT_PRIMITIVES_ARB = 0x82F6,
49 GL_CLIPPING_OUTPUT_PRIMITIVES_ARB = 0x82F7;
50
51 }
127127 void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
128128
129129 @Alternate("glDeleteProgramsARB")
130 void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program);
130 void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, program)", keepParam = true) int program);
131131
132132 void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
133133
170170 @StripPostfix("params")
171171 void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params);
172172
173 /** @deprecated Will be removed in 3.0. Use {@link #glGetProgramiARB} instead. */
173174 @Alternate("glGetProgramivARB")
174175 @GLreturn("params")
175176 @StripPostfix("params")
177 @Reuse(value = "ARBProgram", method = "glGetProgramiARB")
178 @Deprecated
176179 void glGetProgramivARB2(@GLenum int target, @GLenum int parameterName, @OutParameter IntBuffer params);
180
181 @Alternate("glGetProgramivARB")
182 @GLreturn("params")
183 @StripPostfix(value = "params", hasPostfix = false)
184 void glGetProgramivARB3(@GLenum int target, @GLenum int parameterName, @OutParameter IntBuffer params);
177185
178186 void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check @GLbyte Buffer paramString);
179187
180188 @Alternate("glGetProgramStringARB")
181 @Code("\t\tint programLength = glGetProgramARB(target, GL_PROGRAM_LENGTH_ARB);")
189 @Code("\t\tint programLength = glGetProgramiARB(target, GL_PROGRAM_LENGTH_ARB);")
182190 @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true)
183191 void glGetProgramStringARB2(@GLenum int target, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString);
184192
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 @Extension(postfix = "")
40 public interface ARB_program_interface_query {
41
42 /**
43 * Accepted by the &lt;programInterface&gt; parameter of GetProgramInterfaceiv,
44 * GetProgramResourceIndex, GetProgramResourceName, GetProgramResourceiv,
45 * GetProgramResourceLocation, and GetProgramResourceLocationIndex:
46 */
47 int GL_UNIFORM = 0x92E1,
48 GL_UNIFORM_BLOCK = 0x92E2,
49 GL_PROGRAM_INPUT = 0x92E3,
50 GL_PROGRAM_OUTPUT = 0x92E4,
51 GL_BUFFER_VARIABLE = 0x92E5,
52 GL_SHADER_STORAGE_BLOCK = 0x92E6,
53 GL_VERTEX_SUBROUTINE = 0x92E8,
54 GL_TESS_CONTROL_SUBROUTINE = 0x92E9,
55 GL_TESS_EVALUATION_SUBROUTINE = 0x92EA,
56 GL_GEOMETRY_SUBROUTINE = 0x92EB,
57 GL_FRAGMENT_SUBROUTINE = 0x92EC,
58 GL_COMPUTE_SUBROUTINE = 0x92ED,
59 GL_VERTEX_SUBROUTINE_UNIFORM = 0x92EE,
60 GL_TESS_CONTROL_SUBROUTINE_UNIFORM = 0x92EF,
61 GL_TESS_EVALUATION_SUBROUTINE_UNIFORM = 0x92F0,
62 GL_GEOMETRY_SUBROUTINE_UNIFORM = 0x92F1,
63 GL_FRAGMENT_SUBROUTINE_UNIFORM = 0x92F2,
64 GL_COMPUTE_SUBROUTINE_UNIFORM = 0x92F3,
65 GL_TRANSFORM_FEEDBACK_VARYING = 0x92F4;
66
67 /** Accepted by the &lt;pname&gt; parameter of GetProgramInterfaceiv: */
68 int GL_ACTIVE_RESOURCES = 0x92F5,
69 GL_MAX_NAME_LENGTH = 0x92F6,
70 GL_MAX_NUM_ACTIVE_VARIABLES = 0x92F7,
71 GL_MAX_NUM_COMPATIBLE_SUBROUTINES = 0x92F8;
72
73 /** Accepted in the &lt;props&gt; array of GetProgramResourceiv: */
74 int GL_NAME_LENGTH = 0x92F9,
75 GL_TYPE = 0x92FA,
76 GL_ARRAY_SIZE = 0x92FB,
77 GL_OFFSET = 0x92FC,
78 GL_BLOCK_INDEX = 0x92FD,
79 GL_ARRAY_STRIDE = 0x92FE,
80 GL_MATRIX_STRIDE = 0x92FF,
81 GL_IS_ROW_MAJOR = 0x9300,
82 GL_ATOMIC_COUNTER_BUFFER_INDEX = 0x9301,
83 GL_BUFFER_BINDING = 0x9302,
84 GL_BUFFER_DATA_SIZE = 0x9303,
85 GL_NUM_ACTIVE_VARIABLES = 0x9304,
86 GL_ACTIVE_VARIABLES = 0x9305,
87 GL_REFERENCED_BY_VERTEX_SHADER = 0x9306,
88 GL_REFERENCED_BY_TESS_CONTROL_SHADER = 0x9307,
89 GL_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x9308,
90 GL_REFERENCED_BY_GEOMETRY_SHADER = 0x9309,
91 GL_REFERENCED_BY_FRAGMENT_SHADER = 0x930A,
92 GL_REFERENCED_BY_COMPUTE_SHADER = 0x930B,
93 GL_TOP_LEVEL_ARRAY_SIZE = 0x930C,
94 GL_TOP_LEVEL_ARRAY_STRIDE = 0x930D,
95 GL_LOCATION = 0x930E,
96 GL_LOCATION_INDEX = 0x930F,
97 GL_IS_PER_PATCH = 0x92E7;
98
99 @Reuse("GL43")
100 @StripPostfix("params")
101 void glGetProgramInterfaceiv(@GLuint int program, @GLenum int programInterface,
102 @GLenum int pname, @Check("1") @OutParameter IntBuffer params);
103
104 @Reuse("GL43")
105 @Alternate("glGetProgramInterfaceiv")
106 @GLreturn("params")
107 @StripPostfix(value = "params", hasPostfix = false)
108 void glGetProgramInterfaceiv2(@GLuint int program, @GLenum int programInterface,
109 @GLenum int pname, @OutParameter IntBuffer params);
110
111 @Reuse("GL43")
112 @GLuint
113 int glGetProgramResourceIndex(@GLuint int program, @GLenum int programInterface,
114 @NullTerminated @Const @GLchar ByteBuffer name);
115
116 @Reuse("GL43")
117 @Alternate("glGetProgramResourceIndex")
118 @GLuint
119 int glGetProgramResourceIndex(@GLuint int program, @GLenum int programInterface,
120 @NullTerminated CharSequence name);
121
122 @Reuse("GL43")
123 void glGetProgramResourceName(@GLuint int program, @GLenum int programInterface,
124 @GLuint int index, @AutoSize(value = "name", canBeNull = true) @GLsizei int bufSize, @Check(value = "1", canBeNull = true) @OutParameter @GLsizei IntBuffer length,
125 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer name);
126
127 @Reuse("GL43")
128 @Alternate("glGetProgramResourceName")
129 @GLreturn(value = "name", maxLength = "bufSize")
130 void glGetProgramResourceName2(@GLuint int program, @GLenum int programInterface,
131 @GLuint int index, @GLsizei int bufSize,
132 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
133 @OutParameter @GLchar ByteBuffer name);
134
135 @Reuse("GL43")
136 @StripPostfix("params")
137 void glGetProgramResourceiv(@GLuint int program, @GLenum int programInterface,
138 @GLuint int index, @AutoSize("props") @GLsizei int propCount,
139 @Const @GLenum IntBuffer props, @AutoSize("params") @GLsizei int bufSize,
140 @Check(value = "1", canBeNull = true) @OutParameter @GLsizei IntBuffer length, @OutParameter IntBuffer params);
141
142 @Reuse("GL43")
143 int glGetProgramResourceLocation(@GLuint int program, @GLenum int programInterface,
144 @NullTerminated @Const @GLchar ByteBuffer name);
145
146 @Reuse("GL43")
147 @Alternate("glGetProgramResourceLocation")
148 int glGetProgramResourceLocation(@GLuint int program, @GLenum int programInterface,
149 @NullTerminated CharSequence name);
150
151 @Reuse("GL43")
152 int glGetProgramResourceLocationIndex(@GLuint int program, @GLenum int programInterface,
153 @NullTerminated @Const @GLchar ByteBuffer name);
154
155 @Reuse("GL43")
156 @Alternate("glGetProgramResourceLocationIndex")
157 int glGetProgramResourceLocationIndex(@GLuint int program, @GLenum int programInterface,
158 @NullTerminated CharSequence name);
159
160 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_query_buffer_object {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv, GetQueryObjectuiv,
37 * GetQueryObjecti64v and GetQueryObjectui64v:
38 */
39 int GL_QUERY_RESULT_NO_WAIT = 0x9194;
40
41 /**
42 * Accepted by the &lt;target&gt; parameter of BindBuffer, BufferData,
43 * BufferSubData, MapBuffer, UnmapBuffer, MapBufferRange, GetBufferSubData,
44 * GetBufferParameteriv, GetBufferParameteri64v, GetBufferPointerv,
45 * ClearBufferSubData, and the &lt;readtarget&gt; and &lt;writetarget&gt; parameters of
46 * CopyBufferSubData:
47 */
48 int GL_QUERY_BUFFER = 0x9192;
49
50 /**
51 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
52 * and GetDoublev:
53 */
54 int GL_QUERY_BUFFER_BINDING = 0x9193;
55
56 /** Accepted in the &lt;barriers&gt; bitfield in MemoryBarrier: */
57 int GL_QUERY_BUFFER_BARRIER_BIT = 0x00008000;
58
59 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_robust_buffer_access_behavior {
34 }
4040 public interface ARB_robustness {
4141
4242 /** Returned by GetGraphicsResetStatusARB: */
43 int GL_NO_ERROR = 0x0000,
44 GL_GUILTY_CONTEXT_RESET_ARB = 0x8253,
43 int GL_GUILTY_CONTEXT_RESET_ARB = 0x8253,
4544 GL_INNOCENT_CONTEXT_RESET_ARB = 0x8254,
4645 GL_UNKNOWN_CONTEXT_RESET_ARB = 0x8255;
4746
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_robustness_isolation {
34 }
6262
6363 @Reuse("GL33")
6464 @Alternate("glDeleteSamplers")
65 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
65 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(caps, sampler)", keepParam = true) int sampler);
6666
6767 @Reuse("GL33")
6868 boolean glIsSampler(@GLuint int sampler);
9999 @Reuse("GL33")
100100 @Alternate("glGetSamplerParameteriv")
101101 @GLreturn("params")
102 @StripPostfix(value = "params", postfix = "v")
102 @StripPostfix(value = "params", hasPostfix = false)
103103 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
104104
105105 @Reuse("GL33")
109109 @Reuse("GL33")
110110 @Alternate("glGetSamplerParameterfv")
111111 @GLreturn("params")
112 @StripPostfix(value = "params", postfix = "v")
112 @StripPostfix(value = "params", hasPostfix = false)
113113 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
114114
115115 @Reuse("GL33")
119119 @Reuse("GL33")
120120 @Alternate("glGetSamplerParameterIiv")
121121 @GLreturn("params")
122 @StripPostfix(value = "params", postfix = "v")
122 @StripPostfix(value = "params", hasPostfix = false)
123123 void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
124124
125125 @Reuse("GL33")
129129 @Reuse("GL33")
130130 @Alternate("glGetSamplerParameterIuiv")
131131 @GLreturn("params")
132 @StripPostfix(value = "params", postfix = "v")
132 @StripPostfix(value = "params", hasPostfix = false)
133133 void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
134134
135135 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_cubemap_per_texture {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of TexParameter{if},
37 * TexParameter{if}v, GetTexParameter{if}v, SamplerParameter{if},
38 * SamplerParameter{if}v, and GetSamplerParameter{if}v:
39 */
40 int GL_TEXTURE_CUBE_MAP_SEAMLESS = 0x884F;
41
42 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
3534 import org.lwjgl.util.generator.opengl.*;
3635
3736 import java.nio.ByteBuffer;
4342 public interface ARB_separate_shader_objects {
4443
4544 /** Accepted by &lt;stages&gt; parameter to UseProgramStages: */
46 int GL_VERTEX_SHADER_BIT = 0x00000001,
47 GL_FRAGMENT_SHADER_BIT = 0x00000002,
48 GL_GEOMETRY_SHADER_BIT = 0x00000004,
49 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
45 int GL_VERTEX_SHADER_BIT = 0x00000001,
46 GL_FRAGMENT_SHADER_BIT = 0x00000002,
47 GL_GEOMETRY_SHADER_BIT = 0x00000004,
48 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
5049 GL_TESS_EVALUATION_SHADER_BIT = 0x00000010,
51 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
50 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
5251
5352 /**
5453 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
7170 @Reuse("GL41")
7271 void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program);
7372
74 @Reuse("GL41")
75 @StripPostfix(value = "strings", postfix = "v")
76 @GLuint
77 int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings);
73 /** Single null-terminated source code string. */
74 @Reuse("GL41")
75 @StripPostfix(value = "string", hasPostfix = false)
76 @GLuint
77 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated @Check @Const @Indirect @GLchar ByteBuffer string);
78
79 /** Multiple null-terminated source code strings, one after the other. */
80 @Reuse("GL41")
81 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true)
82 @StripPostfix(value = "strings", hasPostfix = false)
83 @GLuint
84 int glCreateShaderProgramv2(@GLenum int type, @GLsizei int count, @NullTerminated("count") @Check @Const @Indirect @GLchar @PointerArray("count") ByteBuffer strings);
85
86 @Reuse("GL41")
87 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true)
88 @StripPostfix(value = "strings", hasPostfix = false)
89 @GLuint
90 int glCreateShaderProgramv3(@GLenum int type, @Constant("strings.length") @GLsizei int count, @NullTerminated @Check("1") @PointerArray(value = "count") @Const @NativeType("GLchar") ByteBuffer[] strings);
7891
7992 @Reuse("GL41")
8093 @Alternate("glCreateShaderProgramv")
81 @StripPostfix(value = "string", postfix = "v")
94 @StripPostfix(value = "string", hasPostfix = false)
8295 @GLuint
8396 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string);
8497
8598 @Reuse("GL41")
86 @Alternate("glCreateShaderProgramv")
87 @StripPostfix(value = "strings", postfix = "v")
88 @GLuint
89 int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count,
90 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
99 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true, skipNative = true)
100 @StripPostfix(value = "strings", hasPostfix = false)
101 @GLuint
102 int glCreateShaderProgramv2(@GLenum int type, @Constant("strings.length") @GLsizei int count,
103 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
91104
92105 @Reuse("GL41")
93106 void glBindProgramPipeline(@GLuint int pipeline);
97110
98111 @Reuse("GL41")
99112 @Alternate("glDeleteProgramPipelines")
100 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline);
113 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, pipeline)", keepParam = true) int pipeline);
101114
102115 @Reuse("GL41")
103116 void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
120133 @Reuse("GL41")
121134 @Alternate("glGetProgramPipelineiv")
122135 @GLreturn("params")
123 @StripPostfix("params")
136 @StripPostfix(value = "params", hasPostfix = false)
124137 void glGetProgramPipelineiv2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params);
125138
126139 @Reuse("GL41")
331344 @Alternate("glGetProgramPipelineInfoLog")
332345 @GLreturn(value = "infoLog", maxLength = "bufSize")
333346 void glGetProgramPipelineInfoLog2(@GLuint int pipeline, @GLsizei int bufSize,
334 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
347 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
335348 @OutParameter @GLchar ByteBuffer infoLog);
336349
337350 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 import java.nio.IntBuffer;
39
40 @Extension(postfix = "")
41 public interface ARB_shader_atomic_counters {
42
43 /** Accepted by the &lt;target&gt; parameter of BindBufferBase and BindBufferRange: */
44 int GL_ATOMIC_COUNTER_BUFFER = 0x92C0;
45
46 /**
47 * Accepted by the &lt;pname&gt; parameter of GetBooleani_v, GetIntegeri_v,
48 * GetFloati_v, GetDoublei_v, GetInteger64i_v, GetBooleanv, GetIntegerv,
49 * GetInteger64v, GetFloatv, GetDoublev, and GetActiveAtomicCounterBufferiv:
50 */
51 int GL_ATOMIC_COUNTER_BUFFER_BINDING = 0x92C1;
52
53 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_64v: */
54 int GL_ATOMIC_COUNTER_BUFFER_START = 0x92C2,
55 GL_ATOMIC_COUNTER_BUFFER_SIZE = 0x92C3;
56
57 /** Accepted by the &lt;pname&gt; parameter of GetActiveAtomicCounterBufferiv: */
58 int GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE = 0x92C4,
59 GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS = 0x92C5,
60 GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES = 0x92C6,
61 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER = 0x92C7,
62 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 0x92C8,
63 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x92C9,
64 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 0x92CA,
65 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 0x92CB;
66
67 /**
68 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
69 * GetInteger64v, GetFloatv, and GetDoublev:
70 */
71 int GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS = 0x92CC,
72 GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS = 0x92CD,
73 GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS = 0x92CE,
74 GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS = 0x92CF,
75 GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS = 0x92D0,
76 GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS = 0x92D1,
77 GL_MAX_VERTEX_ATOMIC_COUNTERS = 0x92D2,
78 GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS = 0x92D3,
79 GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS = 0x92D4,
80 GL_MAX_GEOMETRY_ATOMIC_COUNTERS = 0x92D5,
81 GL_MAX_FRAGMENT_ATOMIC_COUNTERS = 0x92D6,
82 GL_MAX_COMBINED_ATOMIC_COUNTERS = 0x92D7,
83 GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE = 0x92D8,
84 GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = 0x92DC;
85
86 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
87 int GL_ACTIVE_ATOMIC_COUNTER_BUFFERS = 0x92D9;
88
89 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformsiv: */
90 int GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA;
91
92 /** Returned in &lt;params&gt; by GetActiveUniform and GetActiveUniformsiv: */
93 int GL_UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB;
94
95 @StripPostfix("params")
96 @Reuse("GL42")
97 void glGetActiveAtomicCounterBufferiv(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @Check("1") @OutParameter IntBuffer params);
98
99 @Alternate("glGetActiveAtomicCounterBufferiv")
100 @StripPostfix("params")
101 @GLreturn("params")
102 @Reuse("GL42")
103 void glGetActiveAtomicCounterBufferiv2(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @OutParameter IntBuffer params);
104
105 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_draw_parameters {
34
35 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_group_vote {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLbitfield;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 public interface ARB_shader_image_load_store {
39
40 /**
41 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
42 * GetFloatv, GetDoublev, and GetInteger64v:
43 */
44 int GL_MAX_IMAGE_UNITS = 0x8F38,
45 GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39,
46 GL_MAX_IMAGE_SAMPLES = 0x906D,
47 GL_MAX_VERTEX_IMAGE_UNIFORMS = 0x90CA,
48 GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS = 0x90CB,
49 GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS = 0x90CC,
50 GL_MAX_GEOMETRY_IMAGE_UNIFORMS = 0x90CD,
51 GL_MAX_FRAGMENT_IMAGE_UNIFORMS = 0x90CE,
52 GL_MAX_COMBINED_IMAGE_UNIFORMS = 0x90CF;
53
54 /** Accepted by the &lt;target&gt; parameter of GetIntegeri_v and GetBooleani_v: */
55 int GL_IMAGE_BINDING_NAME = 0x8F3A,
56 GL_IMAGE_BINDING_LEVEL = 0x8F3B,
57 GL_IMAGE_BINDING_LAYERED = 0x8F3C,
58 GL_IMAGE_BINDING_LAYER = 0x8F3D,
59 GL_IMAGE_BINDING_ACCESS = 0x8F3E,
60 GL_IMAGE_BINDING_FORMAT = 0x906E;
61
62 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrier: */
63 int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT = 0x00000001,
64 GL_ELEMENT_ARRAY_BARRIER_BIT = 0x00000002,
65 GL_UNIFORM_BARRIER_BIT = 0x00000004,
66 GL_TEXTURE_FETCH_BARRIER_BIT = 0x00000008,
67 GL_SHADER_IMAGE_ACCESS_BARRIER_BIT = 0x00000020,
68 GL_COMMAND_BARRIER_BIT = 0x00000040,
69 GL_PIXEL_BUFFER_BARRIER_BIT = 0x00000080,
70 GL_TEXTURE_UPDATE_BARRIER_BIT = 0x00000100,
71 GL_BUFFER_UPDATE_BARRIER_BIT = 0x00000200,
72 GL_FRAMEBUFFER_BARRIER_BIT = 0x00000400,
73 GL_TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800,
74 GL_ATOMIC_COUNTER_BARRIER_BIT = 0x00001000,
75 GL_ALL_BARRIER_BITS = 0xFFFFFFFF;
76
77 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
78 int GL_IMAGE_1D = 0x904C,
79 GL_IMAGE_2D = 0x904D,
80 GL_IMAGE_3D = 0x904E,
81 GL_IMAGE_2D_RECT = 0x904F,
82 GL_IMAGE_CUBE = 0x9050,
83 GL_IMAGE_BUFFER = 0x9051,
84 GL_IMAGE_1D_ARRAY = 0x9052,
85 GL_IMAGE_2D_ARRAY = 0x9053,
86 GL_IMAGE_CUBE_MAP_ARRAY = 0x9054,
87 GL_IMAGE_2D_MULTISAMPLE = 0x9055,
88 GL_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9056,
89 GL_INT_IMAGE_1D = 0x9057,
90 GL_INT_IMAGE_2D = 0x9058,
91 GL_INT_IMAGE_3D = 0x9059,
92 GL_INT_IMAGE_2D_RECT = 0x905A,
93 GL_INT_IMAGE_CUBE = 0x905B,
94 GL_INT_IMAGE_BUFFER = 0x905C,
95 GL_INT_IMAGE_1D_ARRAY = 0x905D,
96 GL_INT_IMAGE_2D_ARRAY = 0x905E,
97 GL_INT_IMAGE_CUBE_MAP_ARRAY = 0x905F,
98 GL_INT_IMAGE_2D_MULTISAMPLE = 0x9060,
99 GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9061,
100 GL_UNSIGNED_INT_IMAGE_1D = 0x9062,
101 GL_UNSIGNED_INT_IMAGE_2D = 0x9063,
102 GL_UNSIGNED_INT_IMAGE_3D = 0x9064,
103 GL_UNSIGNED_INT_IMAGE_2D_RECT = 0x9065,
104 GL_UNSIGNED_INT_IMAGE_CUBE = 0x9066,
105 GL_UNSIGNED_INT_IMAGE_BUFFER = 0x9067,
106 GL_UNSIGNED_INT_IMAGE_1D_ARRAY = 0x9068,
107 GL_UNSIGNED_INT_IMAGE_2D_ARRAY = 0x9069,
108 GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY = 0x906A,
109 GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE = 0x906B,
110 GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x906C;
111
112 /**
113 * Accepted by the &lt;value&gt; parameter of GetTexParameteriv, GetTexParameterfv,
114 * GetTexParameterIiv, and GetTexParameterIuiv:
115 */
116 int GL_IMAGE_FORMAT_COMPATIBILITY_TYPE = 0x90C7;
117
118 /**
119 * Returned in the &lt;data&gt; parameter of GetTexParameteriv, GetTexParameterfv,
120 * GetTexParameterIiv, and GetTexParameterIuiv when &lt;value&gt; is
121 * IMAGE_FORMAT_COMPATIBILITY_TYPE:
122 */
123 int GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE = 0x90C8,
124 IMAGE_FORMAT_COMPATIBILITY_BY_CLASS = 0x90C9;
125
126 @Reuse("GL42")
127 void glBindImageTexture(@GLuint int unit, @GLuint int texture, int level,
128 boolean layered, int layer, @GLenum int access,
129 @GLenum int format);
130
131 @Reuse("GL42")
132 void glMemoryBarrier(@GLbitfield int barriers);
133
134 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_image_size {
34 }
6060 int GL_SHADER_OBJECT_ARB = 0x8B48;
6161
6262 /** Returned by the &lt;type&gt; parameter of GetActiveUniformARB: */
63 int GL_FLOAT = 0x1406;
6463 int GL_FLOAT_VEC2_ARB = 0x8B50;
6564 int GL_FLOAT_VEC3_ARB = 0x8B51;
6665 int GL_FLOAT_VEC4_ARB = 0x8B52;
67 int GL_INT = 0x1404;
6866 int GL_INT_VEC2_ARB = 0x8B53;
6967 int GL_INT_VEC3_ARB = 0x8B54;
7068 int GL_INT_VEC4_ARB = 0x8B55;
109107 @Alternate(value = "glShaderSourceARB", nativeAlt = true)
110108 void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count,
111109 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
112 @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length);
110 @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length);
113111
114112 void glCompileShaderARB(@GLhandleARB int shaderObj);
115113
178176
179177 @Alternate("glGetObjectParameterfvARB")
180178 @GLreturn("params")
181 @StripPostfix(value = "params", postfix = "v")
179 @StripPostfix(value = "params", hasPostfix = false)
182180 void glGetObjectParameterfvARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter FloatBuffer params);
183181
184182 @StripPostfix("params")
186184
187185 @Alternate("glGetObjectParameterivARB")
188186 @GLreturn("params")
189 @StripPostfix(value = "params", postfix = "v")
187 @StripPostfix(value = "params", hasPostfix = false)
190188 void glGetObjectParameterivARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter IntBuffer params);
191189
192190 void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength,
196194 @Alternate("glGetInfoLogARB")
197195 @GLreturn(value = "infoLog", maxLength = "maxLength")
198196 void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength,
199 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
197 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
200198 @OutParameter @GLcharARB ByteBuffer infoLog);
201199
202200 void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount,
224222 @Alternate("glGetActiveUniformARB")
225223 @GLreturn(value = "name", maxLength = "maxLength")
226224 void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
227 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
225 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
228226 @OutParameter @Check("2") IntBuffer sizeType,
229 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
227 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
230228 @OutParameter @GLcharARB ByteBuffer name);
231229
232230 /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
233231 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
234232 @GLreturn(value = "name", maxLength = "maxLength")
235233 void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
236 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
234 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
237235 @OutParameter @GLcharARB ByteBuffer name);
238236
239237 /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */
240238 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
241239 @GLreturn(value = "size")
242240 void glGetActiveUniformSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
243 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
241 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
244242 @OutParameter IntBuffer size,
245 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
246 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
243 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
244 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
247245
248246 /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */
249247 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
250248 @GLreturn(value = "type")
251249 void glGetActiveUniformTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
252 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
253 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
250 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
251 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
254252 @OutParameter @GLenum IntBuffer type,
255 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
253 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
256254
257255 @StripPostfix("params")
258256 void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params);
267265 @Alternate("glGetShaderSourceARB")
268266 @GLreturn(value = "source", maxLength = "maxLength")
269267 void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength,
270 @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length,
268 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(source_length)") IntBuffer length,
271269 @OutParameter @GLcharARB ByteBuffer source);
272270
273271 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface ARB_shader_storage_buffer_object {
37
38 /**
39 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
40 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
41 * GetBufferPointerv:
42 */
43 int GL_SHADER_STORAGE_BUFFER = 0x90D2;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetIntegeri_v,
47 * GetBooleanv, GetInteger64v, GetFloatv, GetDoublev, GetBooleani_v,
48 * GetIntegeri_v, GetFloati_v, GetDoublei_v, and GetInteger64i_v:
49 */
50 int GL_SHADER_STORAGE_BUFFER_BINDING = 0x90D3;
51
52 /**
53 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleani_v,
54 * GetIntegeri_v, GetFloati_v, GetDoublei_v, and GetInteger64i_v:
55 */
56 int GL_SHADER_STORAGE_BUFFER_START = 0x90D4,
57 GL_SHADER_STORAGE_BUFFER_SIZE = 0x90D5;
58
59 /**
60 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv,
61 * GetInteger64v, GetFloatv, and GetDoublev:
62 */
63 int GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS = 0x90D6,
64 GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS = 0x90D7,
65 GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS = 0x90D8,
66 GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS = 0x90D9,
67 GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS = 0x90DA,
68 GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS = 0x90DB,
69 GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS = 0x90DC,
70 GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 0x90DD,
71 GL_MAX_SHADER_STORAGE_BLOCK_SIZE = 0x90DE,
72 GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT = 0x90DF;
73
74 /** Accepted in the &lt;barriers&gt; bitfield in glMemoryBarrier: */
75 int GL_SHADER_STORAGE_BARRIER_BIT = 0x2000;
76
77 /**
78 * Alias for the existing token
79 * MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS:
80 */
81 int GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES = 0x8F39;
82
83 @Reuse("GL43")
84 void glShaderStorageBlockBinding(@GLuint int program, @GLuint int storageBlockIndex,
85 @GLuint int storageBlockBinding);
86 }
5757 /** Accepted by the &lt;pname&gt; parameter of GetActiveSubroutineUniformiv: */
5858 int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A;
5959 int GL_COMPATIBLE_SUBROUTINES = 0x8E4B;
60 int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE;
61 int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH;
6260
6361 @Reuse("GL40")
6462 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
6563
64 @Alternate("glGetSubroutineUniformLocation")
65 @Reuse("GL40")
66 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @NullTerminated CharSequence name);
67
6668 @Reuse("GL40")
6769 @GLuint
6870 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
71
72 @Alternate("glGetSubroutineIndex")
73 @Reuse("GL40")
74 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @NullTerminated CharSequence name);
6975
7076 @Reuse("GL40")
7177 @StripPostfix("values")
7581 @Reuse("GL40")
7682 @Alternate("glGetActiveSubroutineUniformiv")
7783 @GLreturn("values")
78 @StripPostfix("values")
84 @StripPostfix(value = "values", hasPostfix = false)
7985 void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
8086 @OutParameter IntBuffer values);
8187
8894 @Alternate("glGetActiveSubroutineUniformName")
8995 @GLreturn(value = "name", maxLength = "bufsize")
9096 void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
91 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
97 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
9298 @OutParameter @GLchar ByteBuffer name);
9399
94100 @Reuse("GL40")
100106 @Alternate("glGetActiveSubroutineName")
101107 @GLreturn(value = "name", maxLength = "bufsize")
102108 void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
103 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
109 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
104110 @OutParameter @GLchar ByteBuffer name);
105111
106112 @Reuse("GL40")
114120 @Reuse("GL40")
115121 @Alternate("glGetUniformSubroutineuiv")
116122 @GLreturn("params")
117 @StripPostfix("params")
123 @StripPostfix(value = "params", hasPostfix = false)
118124 void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
119125
120126 @Reuse("GL40")
124130 @Reuse("GL40")
125131 @Alternate("glGetProgramStageiv")
126132 @GLreturn("values")
127 @StripPostfix("values")
133 @StripPostfix(value = "values", hasPostfix = false)
128134 void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values);
129135
130136 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_image_samples {
34 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_420pack {
34
35 }
6262
6363 void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count,
6464 @Const @NullTerminated("count") @PointerArray("count") @GLchar ByteBuffer path,
65 @Constant("null, 0") @Const IntBuffer length);
65 @Constant("0L") @Const IntBuffer length);
6666
6767 @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true)
6868 void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count,
6969 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] path,
70 @Constant("APIUtil.getLengths(path), 0") @Const IntBuffer length);
70 @Constant("APIUtil.getLengths(caps, path)") @Const IntBuffer length);
7171
7272 boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name);
7373
8989 @GLreturn(value = "string", maxLength = "bufSize")
9090 void glGetNamedStringARB2(@Constant("name.length()") int namelen, CharSequence name,
9191 @GLsizei int bufSize,
92 @OutParameter @Constant("string_length, 0") IntBuffer stringlen,
92 @OutParameter @Constant("MemoryUtil.getAddress0(string_length)") IntBuffer stringlen,
9393 @OutParameter @GLchar ByteBuffer string);
9494
9595 @StripPostfix("params")
9696 void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
9797
9898 @Alternate("glGetNamedStringivARB")
99 @StripPostfix(value = "params", postfix = "v")
99 @StripPostfix(value = "params", hasPostfix = false)
100100 void glGetNamedStringivARB(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
101101
102102 @Alternate("glGetNamedStringivARB")
103103 @GLreturn("params")
104 @StripPostfix(value = "params", postfix = "v")
104 @StripPostfix(value = "params", hasPostfix = false)
105105 void glGetNamedStringivARB2(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter IntBuffer params);
106106
107107 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_packing {
34
35 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLintptr;
35 import org.lwjgl.util.generator.opengl.GLsizeiptr;
36
37 public interface ARB_sparse_buffer {
38
39 /** Accepted as part of the the &lt;flags&gt; parameter to BufferStorage */
40 int GL_SPARSE_STORAGE_BIT_ARB = 0x0400;
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetFloatv,
44 * GetIntegerv, and GetInteger64v:
45 */
46 int GL_SPARSE_BUFFER_PAGE_SIZE_ARB = 0x82F8;
47
48 void glBufferPageCommitmentARB(@GLenum int target, @GLintptr long offset, @GLsizeiptr long size, boolean commit);
49
50 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Dependent;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 @Dependent
39 public interface ARB_sparse_texture {
40
41 /**
42 * Accepted by the &lt;pname&gt; parameter to TexParameter{i f}{v},
43 * TexParameterI{u}v, GetTexParameter{if}v and GetTexParameterIi{u}v:
44 */
45 int GL_TEXTURE_SPARSE_ARB = 0x91A6,
46 GL_VIRTUAL_PAGE_SIZE_INDEX_ARB = 0x91A7;
47
48 /**
49 * Accepted by the &lt;pname&gt; parameter of GetTexParameter{if}v and
50 * GetTexParameterIi{u}v:
51 */
52 int GL_NUM_SPARSE_LEVELS_ARB = 0x91AA;
53
54 /** Accepted by the &lt;pname&gt; parameter to GetInternalformativ: */
55 int GL_NUM_VIRTUAL_PAGE_SIZES_ARB = 0x91A8,
56 GL_VIRTUAL_PAGE_SIZE_X_ARB = 0x9195,
57 GL_VIRTUAL_PAGE_SIZE_Y_ARB = 0x9196,
58 GL_VIRTUAL_PAGE_SIZE_Z_ARB = 0x9197;
59
60 /**
61 * Accepted by the &lt;pname&gt; parameter to GetIntegerv, GetFloatv, GetDoublev,
62 * GetInteger64v, and GetBooleanv:
63 */
64 int GL_MAX_SPARSE_TEXTURE_SIZE_ARB = 0x9198,
65 GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB = 0x9199,
66 GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB = 0x919A,
67 GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB = 0x91A9;
68
69 void glTexPageCommitmentARB(@GLenum int target,
70 int level,
71 int xoffset,
72 int yoffset,
73 int zoffset,
74 @GLsizei int width,
75 @GLsizei int height,
76 @GLsizei int depth,
77 boolean commit);
78
79 @Dependent("GL_EXT_direct_state_access")
80 void glTexturePageCommitmentEXT(@GLuint int texture,
81 @GLenum int target,
82 int level,
83 int xoffset,
84 int yoffset,
85 int zoffset,
86 @GLsizei int width,
87 @GLsizei int height,
88 @GLsizei int depth,
89 boolean commit);
90
91 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_stencil_texturing {
34
35 /** Accepted by the &lt;pname&gt; parameter of TexParameter* and GetTexParameter*: */
36 int GL_DEPTH_STENCIL_TEXTURE_MODE = 0x90EA;
37
38 }
9696 @Reuse("GL32")
9797 @Alternate("glGetInteger64v")
9898 @GLreturn("params")
99 @StripPostfix("params")
99 @StripPostfix(value = "params", hasPostfix = false)
100100 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params);
101101
102102 @Reuse("GL32")
105105 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
106106 @OutParameter IntBuffer values);
107107
108 /** @deprecated Will be removed in 3.0. Use {@link #glGetSynci} instead. */
109 @Alternate("glGetSynciv")
110 @GLreturn("values")
111 @StripPostfix("values")
112 @Reuse(value = "GL32", method = "glGetSynci")
113 @Deprecated
114 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
115 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
116 @OutParameter IntBuffer values);
117
108118 @Reuse("GL32")
109119 @Alternate("glGetSynciv")
110120 @GLreturn("values")
111 @StripPostfix("values")
112 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
113 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
121 @StripPostfix(value = "values", hasPostfix = false)
122 void glGetSynciv3(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
123 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
114124 @OutParameter IntBuffer values);
115125 }
6565 int GL_TESS_GEN_POINT_MODE = 0x8E79;
6666
6767 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_MODE: */
68 int GL_TRIANGLES = GL11.GL_TRIANGLES;
69 int GL_QUADS = GL11.GL_QUADS;
7068 int GL_ISOLINES = 0x8E7A;
7169
7270 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_SPACING: */
73 int GL_EQUAL = GL11.GL_EQUAL;
7471 int GL_FRACTIONAL_ODD = 0x8E7B;
7572 int GL_FRACTIONAL_EVEN = 0x8E7C;
76
77 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_VERTEX_ORDER: */
78 int GL_CCW = GL11.GL_CCW;
79 int GL_CW = GL11.GL_CW;
80
81 /** Returned by GetProgramiv when &lt;pname&gt; is TESS_GEN_POINT_MODE: */
82 int GL_FALSE = GL11.GL_FALSE;
83 int GL_TRUE = GL11.GL_TRUE;
8473
8574 /**
8675 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetFloatv,
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34
35 public interface ARB_texture_barrier {
36
37 @Reuse("GL45")
38 void glTextureBarrier();
39
40 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Dependent;
34 import org.lwjgl.util.generator.Reuse;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLintptr;
37 import org.lwjgl.util.generator.opengl.GLsizeiptr;
38 import org.lwjgl.util.generator.opengl.GLuint;
39
40 @Dependent
41 public interface ARB_texture_buffer_range {
42
43 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter: */
44 int GL_TEXTURE_BUFFER_OFFSET = 0x919D,
45 GL_TEXTURE_BUFFER_SIZE = 0x919E;
46
47 /**
48 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
49 * and GetDoublev:
50 */
51 int GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT = 0x919F;
52
53 @Reuse("GL43")
54 void glTexBufferRange(@GLenum int target,
55 @GLenum int internalformat,
56 @GLuint int buffer,
57 @GLintptr long offset,
58 @GLsizeiptr long size);
59
60 @Dependent("GL_EXT_direct_state_access")
61 void glTextureBufferRangeEXT(@GLuint int texture,
62 @GLenum int target,
63 @GLenum int internalformat,
64 @GLuint int buffer,
65 @GLintptr long offset,
66 @GLsizeiptr long size);
67
68 }
4040 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
4141 * of CompressedTexSubImage2D:
4242 */
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;
43 int GL_COMPRESSED_RED_RGTC1 = 0x8DBB,
44 GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC,
45 GL_COMPRESSED_RG_RGTC2 = 0x8DBD,
46 GL_COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE;
4747
4848 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_mirror_clamp_to_edge {
34
35 /**
36 * Accepted by the &lt;param&gt; parameter of TexParameter{if}, SamplerParameter{if}
37 * and SamplerParameter{if}v, and by the &lt;params&gt; parameter of
38 * TexParameter{if}v, TexParameterI{i ui}v and SamplerParameterI{i ui}v when
39 * their &lt;pname&gt; parameter is TEXTURE_WRAP_S, TEXTURE_WRAP_T, or
40 * TEXTURE_WRAP_R:
41 */
42 int GL_MIRROR_CLAMP_TO_EDGE = 0x8743;
43
44 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_levels {
34 }
7070 int GL_RG = 0x8227;
7171 int GL_RG_INTEGER = 0x8228;
7272
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
7973 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_stencil8 {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Alias;
34 import org.lwjgl.util.generator.Dependent;
35 import org.lwjgl.util.generator.Reuse;
36 import org.lwjgl.util.generator.opengl.GLenum;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
39
40 @Dependent
41 @Alias(value = "EXT_texture_storage", postfix = "EXT")
42 public interface ARB_texture_storage {
43
44 /** Accepted by the &lt;value&gt; parameter of GetTexParameter{if}v: */
45 int GL_TEXTURE_IMMUTABLE_FORMAT = 0x912F;
46
47 @Reuse("GL42")
48 void glTexStorage1D(@GLenum int target, @GLsizei int levels,
49 @GLenum int internalformat,
50 @GLsizei int width);
51
52 @Reuse("GL42")
53 void glTexStorage2D(@GLenum int target, @GLsizei int levels,
54 @GLenum int internalformat,
55 @GLsizei int width, @GLsizei int height);
56
57 @Reuse("GL42")
58 void glTexStorage3D(@GLenum int target, @GLsizei int levels,
59 @GLenum int internalformat,
60 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
61
62 @Dependent("GL_EXT_direct_state_access")
63 void glTextureStorage1DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
64 @GLenum int internalformat,
65 @GLsizei int width);
66
67 @Dependent("GL_EXT_direct_state_access")
68 void glTextureStorage2DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
69 @GLenum int internalformat,
70 @GLsizei int width, @GLsizei int height);
71
72 @Dependent("GL_EXT_direct_state_access")
73 void glTextureStorage3DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
74 @GLenum int internalformat,
75 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
76
77 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Dependent;
34 import org.lwjgl.util.generator.Reuse;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 @Dependent
40 public interface ARB_texture_storage_multisample {
41
42 @Reuse("GL43")
43 void glTexStorage2DMultisample(@GLenum int target,
44 @GLsizei int samples,
45 @GLenum int internalformat,
46 @GLsizei int width,
47 @GLsizei int height,
48 boolean fixedsamplelocations);
49
50 @Reuse("GL43")
51 void glTexStorage3DMultisample(@GLenum int target,
52 @GLsizei int samples,
53 @GLenum int internalformat,
54 @GLsizei int width,
55 @GLsizei int height,
56 @GLsizei int depth,
57 boolean fixedsamplelocations);
58
59 @Dependent("GL_EXT_direct_state_access")
60 void glTextureStorage2DMultisampleEXT(@GLuint int texture,
61 @GLenum int target,
62 @GLsizei int samples,
63 @GLenum int internalformat,
64 @GLsizei int width,
65 @GLsizei int height,
66 boolean fixedsamplelocations);
67
68 @Dependent("GL_EXT_direct_state_access")
69 void glTextureStorage3DMultisampleEXT(@GLuint int texture,
70 @GLenum int target,
71 @GLsizei int samples,
72 @GLenum int internalformat,
73 @GLsizei int width,
74 @GLsizei int height,
75 @GLsizei int depth,
76 boolean fixedsamplelocations);
77
78 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface ARB_texture_view {
38
39 /**
40 * Accepted by the &lt;pname&gt; parameters of GetTexParameterfv and
41 * GetTexParameteriv:
42 */
43 int GL_TEXTURE_VIEW_MIN_LEVEL = 0x82DB,
44 GL_TEXTURE_VIEW_NUM_LEVELS = 0x82DC,
45 GL_TEXTURE_VIEW_MIN_LAYER = 0x82DD,
46 GL_TEXTURE_VIEW_NUM_LAYERS = 0x82DE,
47 GL_TEXTURE_IMMUTABLE_LEVELS = 0x82DF;
48
49 @Reuse("GL43")
50 void glTextureView(@GLuint int texture, @GLenum int target, @GLuint int origtexture,
51 @GLenum int internalformat,
52 @GLuint int minlevel, @GLuint int numlevels,
53 @GLuint int minlayer, @GLuint int numlayers);
54
55 }
6262 @Reuse("GL33")
6363 @Alternate("glGetQueryObjecti64v")
6464 @GLreturn("params")
65 @StripPostfix("params")
65 @StripPostfix(value = "params", hasPostfix = false)
6666 void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
6767
6868 @Reuse("GL33")
7272 @Reuse("GL33")
7373 @Alternate("glGetQueryObjectui64v")
7474 @GLreturn("params")
75 @StripPostfix("params")
75 @StripPostfix(value = "params", hasPostfix = false)
7676 void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params);
7777
7878 }
6060
6161 @Reuse("GL40")
6262 @Alternate("glDeleteTransformFeedbacks")
63 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
63 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
6464
6565 @Reuse("GL40")
6666 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
6464 @Reuse("GL40")
6565 @Alternate("glGetQueryIndexediv")
6666 @GLreturn("params")
67 @StripPostfix("params")
67 @StripPostfix(value = "params", hasPostfix = false)
6868 void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params);
6969
7070 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 public interface ARB_transform_feedback_instanced {
39
40 @Reuse("GL42")
41 void glDrawTransformFeedbackInstanced(@GLenum int mode, @GLuint int id, @GLsizei int primcount);
42
43 @Reuse("GL42")
44 void glDrawTransformFeedbackStreamInstanced(@GLenum int mode, @GLuint int id, @GLuint int stream, @GLsizei int primcount);
45
46 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_transform_feedback_overflow_query {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
37 * BeginQueryIndexed, EndQueryIndexed, GetQueryiv, and GetQueryIndexediv:
38 */
39 int GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB = 0x82EC,
40 GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB = 0x82ED;
41
42 }
117117 @GLenum int pname,
118118 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
119119
120 @Reuse("GL31")
120 /** @deprecated Will be removed in 3.0. Use {@link #glGetActiveUniformsi} instead. */
121121 @Alternate("glGetActiveUniformsiv")
122122 @GLreturn("params")
123123 @StripPostfix("params")
124 @Reuse(value = "GL31", method = "glGetActiveUniformsi")
125 @Deprecated
124126 void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
125127 @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer
126128 @GLenum int pname,
127129 @OutParameter @GLint IntBuffer params);
128130
129131 @Reuse("GL31")
132 @Alternate("glGetActiveUniformsiv")
133 @GLreturn("params")
134 @StripPostfix(value = "params", hasPostfix = false)
135 void glGetActiveUniformsiv2(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
136 @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer
137 @GLenum int pname,
138 @OutParameter @GLint IntBuffer params);
139
140 @Reuse("GL31")
130141 void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize,
131142 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
132143 @OutParameter @GLchar ByteBuffer uniformName);
135146 @Alternate("glGetActiveUniformName")
136147 @GLreturn(value = "uniformName", maxLength = "bufSize")
137148 void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize,
138 @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length,
149 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(uniformName_length)") IntBuffer length,
139150 @OutParameter @GLchar ByteBuffer uniformName);
140151
141152 @Reuse("GL31")
152163 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
153164 @OutParameter @Check(value = "16") @GLint IntBuffer params);
154165
155 @Reuse("GL31")
166 /** @deprecated Will be removed in 3.0. Use {@link #glGetActiveUniformBlocki} instead. */
156167 @Alternate("glGetActiveUniformBlockiv")
157168 @GLreturn("params")
158169 @StripPostfix("params")
170 @Reuse(value = "GL31", method = "glGetActiveUniformBlocki")
171 @Deprecated
159172 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
173 @OutParameter @GLint IntBuffer params);
174
175 @Reuse("GL31")
176 @Alternate("glGetActiveUniformBlockiv")
177 @GLreturn("params")
178 @StripPostfix(value = "params", hasPostfix = false)
179 void glGetActiveUniformBlockiv3(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
160180 @OutParameter @GLint IntBuffer params);
161181
162182 @Reuse("GL31")
168188 @Alternate("glGetActiveUniformBlockName")
169189 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
170190 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
171 @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length,
191 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(uniformBlockName_length)") IntBuffer length,
172192 @OutParameter @GLchar ByteBuffer uniformBlockName);
173193
174194 @Reuse("GL30")
5454
5555 @Reuse("GL30")
5656 @Alternate("glDeleteVertexArrays")
57 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
57 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array);
5858
5959 @Reuse("GL30")
6060 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
9292 @StripPostfix("params")
9393 void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
9494
95 @Dependent("EXT_direct_state_access")
95 @Dependent("GL_EXT_direct_state_access")
9696 void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
9797
9898 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLintptr;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 public interface ARB_vertex_attrib_binding {
40
41 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib*v: */
42 int GL_VERTEX_ATTRIB_BINDING = 0x82D4,
43 GL_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D5;
44
45 /**
46 * Accepted by the &lt;target&gt; parameter of GetBooleani_v, GetIntegeri_v,
47 * GetFloati_v, GetDoublei_v, and GetInteger64i_v:
48 */
49 int GL_VERTEX_BINDING_DIVISOR = 0x82D6,
50 GL_VERTEX_BINDING_OFFSET = 0x82D7,
51 GL_VERTEX_BINDING_STRIDE = 0x82D8;
52
53 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv, ... */
54 int GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D9,
55 GL_MAX_VERTEX_ATTRIB_BINDINGS = 0x82DA;
56
57 @Reuse("GL43")
58 void glBindVertexBuffer(@GLuint int bindingindex, @GLuint int buffer, @GLintptr long offset,
59 @GLsizei int stride);
60
61 @Reuse("GL43")
62 void glVertexAttribFormat(@GLuint int attribindex, int size, @GLenum int type,
63 boolean normalized, @GLuint int relativeoffset);
64
65 @Reuse("GL43")
66 void glVertexAttribIFormat(@GLuint int attribindex, int size, @GLenum int type,
67 @GLuint int relativeoffset);
68
69 @Reuse("GL43")
70 void glVertexAttribLFormat(@GLuint int attribindex, int size, @GLenum int type,
71 @GLuint int relativeoffset);
72
73 @Reuse("GL43")
74 void glVertexAttribBinding(@GLuint int attribindex, @GLuint int bindingindex);
75
76 @Reuse("GL43")
77 void glVertexBindingDivisor(@GLuint int bindingindex, @GLuint int divisor);
78
79 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
3534 import org.lwjgl.util.generator.opengl.*;
3635
3736 import java.nio.*;
4847 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
4948 * GetFloatv, and GetDoublev:
5049 */
51 int GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = 0x8B4A;
52 int GL_MAX_VARYING_FLOATS_ARB = 0x8B4B;
53 int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869;
54 int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872;
55 int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C;
50 int GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = 0x8B4A;
51 int GL_MAX_VARYING_FLOATS_ARB = 0x8B4B;
52 int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869;
53 int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872;
54 int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C;
5655 int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB = 0x8B4D;
57 int GL_MAX_TEXTURE_COORDS_ARB = 0x8871;
56 int GL_MAX_TEXTURE_COORDS_ARB = 0x8871;
5857
5958 /**
6059 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and
6261 * GetDoublev:
6362 */
6463 int GL_VERTEX_PROGRAM_POINT_SIZE_ARB = 0x8642;
65 int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643;
64 int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643;
6665
6766 /** Accepted by the &lt;pname&gt; parameter GetObjectParameter{if}vARB: */
68 int GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = 0x8B89;
67 int GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = 0x8B89;
6968 int GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB = 0x8B8A;
7069
7170 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib{dfi}vARB: */
72 int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622;
73 int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623;
74 int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624;
75 int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625;
71 int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622;
72 int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623;
73 int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624;
74 int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625;
7675 int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = 0x886A;
77 int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626;
76 int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626;
7877
7978 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttribPointervARB: */
8079 int GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = 0x8645;
8180
8281 /** Returned by the &lt;type&gt; parameter of GetActiveAttribARB: */
83 int GL_FLOAT = 0x1406;
8482 int GL_FLOAT_VEC2_ARB = 0x8B50;
8583 int GL_FLOAT_VEC3_ARB = 0x8B51;
8684 int GL_FLOAT_VEC4_ARB = 0x8B52;
141139 @GLfloat
142140 @GLdouble Buffer buffer);
143141
142 @Alternate("glVertexAttribPointerARB")
143 void glVertexAttribPointerARB(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride,
144 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
145 @BufferObject(BufferKind.ArrayVBO)
146 @Check
147 @Const ByteBuffer buffer);
148
144149 void glEnableVertexAttribArrayARB(@GLuint int index);
145150
146151 void glDisableVertexAttribArrayARB(@GLuint int index);
160165 @Alternate("glGetActiveAttribARB")
161166 @GLreturn(value = "name", maxLength = "maxLength")
162167 void glGetActiveAttribARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
163 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
168 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
164169 @OutParameter @Check("2") IntBuffer sizeType,
165 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
170 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
166171 @OutParameter @GLcharARB ByteBuffer name);
167172
168173 /** Overloads glGetActiveAttribARB. This version returns only the attrib name. */
169174 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
170175 @GLreturn(value = "name", maxLength = "maxLength")
171176 void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
172 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
177 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
173178 @OutParameter @GLcharARB ByteBuffer name);
174179
175180 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
176181 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
177182 @GLreturn(value = "size")
178183 void glGetActiveAttribSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
179 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
184 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
180185 @OutParameter IntBuffer size,
181 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
182 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
186 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
187 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
183188
184189 /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */
185190 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
186191 @GLreturn(value = "type")
187192 void glGetActiveAttribTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength,
188 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
189 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
193 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
194 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
190195 @OutParameter @GLenum IntBuffer type,
191 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
196 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
192197
193198 int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
194199
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_type_10f_11f_11f_rev {
34
35 }
5050 GL_VIEWPORT_BOUNDS_RANGE = 0x825D,
5151 GL_LAYER_PROVOKING_VERTEX = 0x825E,
5252 GL_VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F;
53
54 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
55 int GL_SCISSOR_BOX = 0x0C10;
56
57 /** Accepted by the &lt;pname&gt; parameter of GetFloati_v: */
58 int GL_VIEWPORT = 0x0BA2;
59
60 /** Accepted by the &lt;pname&gt; parameter of GetDoublei_v: */
61 int GL_DEPTH_RANGE = 0x0B70;
62
63 /** Accepted by the &lt;pname&gt; parameter of Enablei, Disablei, and IsEnabledi: */
64 int GL_SCISSOR_TEST = 0x0C11;
6553
6654 /**
6755 * Returned in the &lt;data&gt; parameter from a Get query with a &lt;pname&gt; of
6464 void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
6565
6666 @Alternate("glDrawBuffersATI")
67 void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
67 void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
6868 }
6363 */
6464 @CachedResult
6565 @GLvoid
66 @AutoSize("GLChecks.getBufferObjectSizeATI(caps, buffer)")
66 @AutoSize("ATIVertexArrayObject.glGetObjectBufferiATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI)")
6767 ByteBuffer glMapObjectBufferATI(@GLuint int buffer);
6868
6969 void glUnmapObjectBufferATI(@GLuint int buffer);
7474
7575 @Alternate("glGetObjectBufferivATI")
7676 @GLreturn("params")
77 @StripPostfix("params")
77 @StripPostfix(value = "params", hasPostfix = false)
7878 void glGetObjectBufferivATI2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params);
7979
8080 void glFreeObjectBufferATI(@GLuint int buffer);
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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
-44
src/templates/org/lwjgl/opengl/EXT_cg_shader.java less more
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 }
197197
198198 @Alternate("glGetTextureParameterfvEXT")
199199 @GLreturn("params")
200 @StripPostfix(value = "params", postfix = "v")
200 @StripPostfix(value = "params", hasPostfix = false)
201201 void glGetTextureParameterfvEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
202202
203203 @StripPostfix("params")
205205
206206 @Alternate("glGetTextureParameterivEXT")
207207 @GLreturn("params")
208 @StripPostfix(value = "params", postfix = "v")
208 @StripPostfix(value = "params", hasPostfix = false)
209209 void glGetTextureParameterivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
210210
211211 @StripPostfix("params")
213213
214214 @Alternate("glGetTextureLevelParameterfvEXT")
215215 @GLreturn("params")
216 @StripPostfix(value = "params", postfix = "v")
216 @StripPostfix(value = "params", hasPostfix = false)
217217 void glGetTextureLevelParameterfvEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
218218
219219 @StripPostfix("params")
221221
222222 @Alternate("glGetTextureLevelParameterivEXT")
223223 @GLreturn("params")
224 @StripPostfix(value = "params", postfix = "v")
224 @StripPostfix(value = "params", hasPostfix = false)
225225 void glGetTextureLevelParameterivEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
226226
227227 /*
437437
438438 @Alternate("glGetMultiTexParameterfvEXT")
439439 @GLreturn("params")
440 @StripPostfix(value = "params", postfix = "v")
440 @StripPostfix(value = "params", hasPostfix = false)
441441 void glGetMultiTexParameterfvEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
442442
443443 @Dependent("OpenGL13")
447447 @Alternate("glGetMultiTexParameterivEXT")
448448 @GLreturn("params")
449449 @Dependent("OpenGL13")
450 @StripPostfix(value = "params", postfix = "v")
450 @StripPostfix(value = "params", hasPostfix = false)
451451 void glGetMultiTexParameterivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
452452
453453 @Dependent("OpenGL13")
457457 @Alternate("glGetMultiTexLevelParameterfvEXT")
458458 @GLreturn("params")
459459 @Dependent("OpenGL13")
460 @StripPostfix(value = "params", postfix = "v")
460 @StripPostfix(value = "params", hasPostfix = false)
461461 void glGetMultiTexLevelParameterfvEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
462462
463463 @Dependent("OpenGL13")
467467 @Alternate("glGetMultiTexLevelParameterivEXT")
468468 @GLreturn("params")
469469 @Dependent("OpenGL13")
470 @StripPostfix(value = "params", postfix = "v")
470 @StripPostfix(value = "params", hasPostfix = false)
471471 void glGetMultiTexLevelParameterivEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
472472
473473 @Dependent("OpenGL13")
519519 value parameters
520520 */
521521
522 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
522 @Optional(reason = "AMD does not expose this (last driver checked: 14.7)")
523523 @Dependent("OpenGL30")
524524 void glEnableClientStateiEXT(@GLenum int array, @GLuint int index);
525525
526 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
526 @Optional(reason = "AMD does not expose this (last driver checked: 14.7)")
527527 @Dependent("OpenGL30")
528528 void glDisableClientStateiEXT(@GLenum int array, @GLuint int index);
529529
565565 and before state value parameters
566566 */
567567
568 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
568 @Optional(reason = "AMD does not expose this (last driver checked: 14.7)")
569569 @Dependent("OpenGL30")
570570 @StripPostfix("params")
571571 void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
576576 @StripPostfix("params")
577577 void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
578578
579 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
579 @Optional(reason = "AMD does not expose this (last driver checked: 14.7)")
580580 @Dependent("OpenGL30")
581581 @StripPostfix("params")
582582 void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
587587 @StripPostfix("params")
588588 void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
589589
590 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
591 @Dependent("OpenGL30")
592 @StripPostfix(value = "params", hasPostfix = false)
590 @Optional(reason = "AMD does not expose this (last driver checked: 14.7)")
591 @Dependent("OpenGL30")
592 @StripPostfix(value = "params", postfix = "i_v")
593593 void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
594594
595595 /*
861861 @Dependent("OpenGL15")
862862 @GenerateAutos
863863 void glNamedBufferDataEXT(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
864 @Check
864865 @Const
865866 @GLbyte
866867 @GLshort
904905 @Dependent("OpenGL15")
905906 @CachedResult
906907 @GLvoid
907 @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
908 @AutoSize("glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE)")
908909 ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access);
909910
910911 @Dependent("OpenGL15")
922923
923924 @Dependent("OpenGL15")
924925 @StripPostfix("params")
925 @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
926 @AutoSize("glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE)")
926927 void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params);
927928
928929 @Dependent("OpenGL15")
10741075 @Alternate("glTextureParameterIivEXT")
10751076 @Dependent("GL_EXT_texture_integer")
10761077 @StripPostfix("param")
1077 void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
1078 void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
10781079
10791080 @Dependent("GL_EXT_texture_integer")
10801081 @StripPostfix("params")
10831084 @Alternate("glTextureParameterIuivEXT")
10841085 @Dependent("GL_EXT_texture_integer")
10851086 @StripPostfix("param")
1086 void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param);
1087 void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) @GLuint int param);
10871088
10881089 @Dependent("GL_EXT_texture_integer")
10891090 @StripPostfix("params")
10921093 @Alternate("glGetTextureParameterIivEXT")
10931094 @GLreturn("params")
10941095 @Dependent("GL_EXT_texture_integer")
1095 @StripPostfix(value = "params", postfix = "v")
1096 @StripPostfix(value = "params", hasPostfix = false)
10961097 void glGetTextureParameterIivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
10971098
10981099 @Dependent("GL_EXT_texture_integer")
11021103 @Alternate("glGetTextureParameterIuivEXT")
11031104 @GLreturn("params")
11041105 @Dependent("GL_EXT_texture_integer")
1105 @StripPostfix(value = "params", postfix = "v")
1106 @StripPostfix(value = "params", hasPostfix = false)
11061107 void glGetTextureParameterIuivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
11071108
11081109 /*
11181119 @Alternate("glMultiTexParameterIivEXT")
11191120 @Dependent("GL_EXT_texture_integer")
11201121 @StripPostfix("param")
1121 void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
1122 void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
11221123
11231124 @Dependent("GL_EXT_texture_integer")
11241125 @StripPostfix("params")
11271128 @Alternate("glMultiTexParameterIuivEXT")
11281129 @Dependent("GL_EXT_texture_integer")
11291130 @StripPostfix("param")
1130 void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
1131 void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
11311132
11321133 @Dependent("GL_EXT_texture_integer")
11331134 @StripPostfix("params")
11361137 @Alternate("glGetMultiTexParameterIivEXT")
11371138 @GLreturn("params")
11381139 @Dependent("GL_EXT_texture_integer")
1139 @StripPostfix(value = "params", postfix = "v")
1140 @StripPostfix(value = "params", hasPostfix = false)
11401141 void glGetMultiTexParameterIivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
11411142
11421143 @Dependent("GL_EXT_texture_integer")
11461147 @Alternate("glGetMultiTexParameterIuivEXT")
11471148 @GLreturn("params")
11481149 @Dependent("GL_EXT_texture_integer")
1149 @StripPostfix(value = "params", postfix = "v")
1150 @StripPostfix(value = "params", hasPostfix = false)
11501151 void glGetMultiTexParameterIuivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
11511152
11521153 /*
13511352 framebuffer"
13521353 */
13531354
1354 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1355 @Dependent("GL_EXT_geometry_shader4,GL_NV_geometry_program4")
13551356 void glNamedFramebufferTextureEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level);
13561357
1357 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1358 @Dependent("GL_EXT_geometry_shader4,GL_NV_geometry_program4")
13581359 void glNamedFramebufferTextureLayerEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer);
13591360
1360 @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4")
1361 @Dependent("GL_EXT_geometry_shader4,GL_NV_geometry_program4")
13611362 void glNamedFramebufferTextureFaceEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
13621363
13631364 /*
14791480 void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
14801481
14811482 @Dependent("OpenGL30")
1482 @StripPostfix(value = "param")
1483 @StripPostfix(value = "param", postfix = "i_v")
14831484 void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param);
14841485
14851486 /*
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_multisample_blit_scaled {
34
35 /** Accepted by the &lt;filter&gt; parameter of BlitFramebuffer: */
36 int GL_SCALED_RESOLVE_FASTEST_EXT = 0x90BA,
37 GL_SCALED_RESOLVE_NICEST_EXT = 0x90BB;
38
39 }
135135 void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
136136
137137 @Alternate("glDeleteRenderbuffersEXT")
138 void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
138 void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer);
139139
140140 void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
141141
148148 @StripPostfix("params")
149149 void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
150150
151 /** @deprecated Will be removed in 3.0. Use {@link #glGetRenderbufferParameteriEXT} instead. */
151152 @Alternate("glGetRenderbufferParameterivEXT")
152153 @GLreturn("params")
153154 @StripPostfix("params")
155 @Reuse(value = "EXTFramebufferObject", method = "glGetRenderbufferParameteriEXT")
156 @Deprecated
154157 void glGetRenderbufferParameterivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
155158
159 @Alternate("glGetRenderbufferParameterivEXT")
160 @GLreturn("params")
161 @StripPostfix(value = "params", hasPostfix = false)
162 void glGetRenderbufferParameterivEXT3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
163
156164 boolean glIsFramebufferEXT(@GLuint int framebuffer);
157165
158166 void glBindFramebufferEXT(@GLenum int target, @GLuint int framebuffer);
160168 void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
161169
162170 @Alternate("glDeleteFramebuffersEXT")
163 void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
171 void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer);
164172
165173 void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
166174
182190 @StripPostfix("params")
183191 void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
184192
193 /** @deprecated Will be removed in 3.0. Use {@link #glGetFramebufferAttachmentParameteriEXT} instead. */
185194 @Alternate("glGetFramebufferAttachmentParameterivEXT")
186195 @GLreturn("params")
187196 @StripPostfix("params")
197 @Reuse(value = "EXTFramebufferObject", method = "glGetFramebufferAttachmentParameteriEXT")
198 @Deprecated
188199 void glGetFramebufferAttachmentParameterivEXT2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
200
201 @Alternate("glGetFramebufferAttachmentParameterivEXT")
202 @GLreturn("params")
203 @StripPostfix(value = "params", hasPostfix = false)
204 void glGetFramebufferAttachmentParameterivEXT3(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
189205
190206 void glGenerateMipmapEXT(@GLenum int target);
191207 }
5656 int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3;
5757 int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4;
5858 int GL_SAMPLER_CUBE_SHADOW_EXT = 0x8DC5;
59 int GL_UNSIGNED_INT = 0x1405;
6059 int GL_UNSIGNED_INT_VEC2_EXT = 0x8DC6;
6160 int GL_UNSIGNED_INT_VEC3_EXT = 0x8DC7;
6261 int GL_UNSIGNED_INT_VEC4_EXT = 0x8DC8;
157156 void glVertexAttribI4usvEXT(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
158157
159158 void glVertexAttribIPointerEXT(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
160 @CachedReference
159 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
161160 @BufferObject(BufferKind.ArrayVBO)
162161 @Check
163162 @Const
116116 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params);
117117
118118 @Alternate("glTexParameterIivEXT")
119 @StripPostfix(value = "param", postfix = "v")
120 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
119 @StripPostfix(value = "param", hasPostfix = false)
120 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
121121
122122 @StripPostfix("params")
123123 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
124124
125125 @Alternate("glTexParameterIuivEXT")
126 @StripPostfix(value = "param", postfix = "v")
127 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
126 @StripPostfix(value = "param", hasPostfix = false)
127 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
128128
129129 @StripPostfix("params")
130130 void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
131131
132132 @Alternate("glGetTexParameterIivEXT")
133133 @GLreturn("params")
134 @StripPostfix(value = "params", postfix = "v")
134 @StripPostfix(value = "params", hasPostfix = false)
135135 void glGetTexParameterIivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
136136
137137 @StripPostfix("params")
139139
140140 @Alternate("glGetTexParameterIuivEXT")
141141 @GLreturn("params")
142 @StripPostfix(value = "params", postfix = "v")
142 @StripPostfix(value = "params", hasPostfix = false)
143143 void glGetTexParameterIuivEXT2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
144144
145145 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.Extension;
3434
3535 @Extension(postfix = "EXT", className = "EXTTextureLODBias")
3636 public interface EXT_texture_lod_bias {
37
38 /**
39 * Accepted by the &lt;target&gt; parameters of GetTexEnvfv, GetTexEnviv,
40 * TexEnvi, TexEnvf, Texenviv, and TexEnvfv:
41 */
3742 int GL_TEXTURE_FILTER_CONTROL_EXT = 0x8500;
43
44 /**
45 * When the &lt;target&gt; parameter of GetTexEnvfv, GetTexEnviv, TexEnvi,
46 * TexEnvf, TexEnviv, and TexEnvfv is TEXTURE_FILTER_CONTROL_EXT, then
47 * the value of &lt;pname&gt; may be:
48 */
3849 int GL_TEXTURE_LOD_BIAS_EXT = 0x8501;
50
51 /**
52 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
53 * GetFloatv, and GetDoublev:
54 */
3955 int GL_MAX_TEXTURE_LOD_BIAS_EXT = 0x84FD;
40 }
56
57 }
120120 @Alternate("glGetTransformFeedbackVaryingEXT")
121121 @GLreturn(value = "name", maxLength = "bufSize")
122122 void glGetTransformFeedbackVaryingEXT2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
123 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
123 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
124124 @OutParameter @GLsizei @Check("1") IntBuffer size,
125125 @OutParameter @GLenum @Check("1") IntBuffer type,
126126 @OutParameter @GLchar ByteBuffer name);
8282 void glGetVertexAttribLdvEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
8383
8484 @Reuse("ARBVertexAttrib64bit")
85 @Dependent("EXT_direct_state_access")
85 @Dependent("GL_EXT_direct_state_access")
8686 void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
8787
8888 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
3534 import org.lwjgl.util.generator.opengl.*;
3635
3736 import java.nio.*;
4039 * The core OpenGL1.1 API.
4140 *
4241 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3460 $
44 * $Id: GL11.java 3460 2010-11-29 18:25:28Z spasi $
42 * @version $Revision$
43 * $Id$
4544 */
4645 @DeprecatedGL
4746 public interface GL11 {
718717 void glAccum(@GLenum int op, float value);
719718
720719 @DeprecatedGL
721 void glAlphaFunc(@GLenum int func, @GLclampf float ref);
722
723 void glClearColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
720 void glAlphaFunc(@GLenum int func, float ref);
721
722 void glClearColor(float red, float green, float blue, float alpha);
724723
725724 @DeprecatedGL
726725 void glClearAccum(float red, float green, float blue, float alpha);
742741 @DeprecatedGL
743742 void glBitmap(@GLsizei int width, @GLsizei int height, float xorig, float yorig, float xmove, float ymove,
744743 @BufferObject(BufferKind.UnpackPBO)
745 @Check("(((width + 7)/8)*height)")
744 @Check(value = "(((width + 7)/8)*height)", canBeNull = true)
746745 @Const
747746 @GLubyte ByteBuffer bitmap);
748747
754753 @GLuint IntBuffer textures,
755754 @Const
756755 @Check("textures.remaining()")
757 @GLclampf FloatBuffer priorities);
756 FloatBuffer priorities);
758757
759758 @DeprecatedGL
760759 boolean glAreTexturesResident(@AutoSize("textures") @GLsizei int n,
775774 @NoErrorCheck
776775 void glArrayElement(int i);
777776
778 void glClearDepth(@GLclampd double depth);
777 void glClearDepth(double depth);
779778
780779 @DeprecatedGL
781780 void glDeleteLists(@GLuint int list, @GLsizei int range);
783782 void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures);
784783
785784 @Alternate("glDeleteTextures")
786 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, texture), 0", keepParam = true) int texture);
785 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, texture)", keepParam = true) int texture);
787786
788787 void glCullFace(@GLenum int mode);
789788
809808 @GLbyte Buffer pointer);
810809
811810 @DeprecatedGL
811 @Alternate("glColorPointer")
812 void glColorPointer(int size, @GLenum int type, @GLsizei int stride,
813 @CachedReference
814 @Check
815 @BufferObject(BufferKind.ArrayVBO)
816 @Const ByteBuffer pointer);
817
818 @DeprecatedGL
812819 void glColorMaterial(@GLenum int face, @GLenum int mode);
813820
814821 void glColorMask(boolean red, boolean green, boolean blue, boolean alpha);
913920 @GLushort
914921 @GLuint Buffer indices);
915922
923 @Alternate("glDrawElements")
924 void glDrawElements(@GLenum int mode, @GLsizei int count, @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const @Check("count") ByteBuffer indices);
925
916926 void glDrawBuffer(@GLenum int mode);
917927
918928 void glDrawArrays(@GLenum int mode, int first, @GLsizei int count);
919929
920 void glDepthRange(@GLclampd double zNear, @GLclampd double zFar);
930 void glDepthRange(double zNear, double zFar);
921931
922932 void glDepthMask(boolean flag);
923933
10611071
10621072 @Alternate("glGetTexParameterfv")
10631073 @GLreturn("params")
1064 @StripPostfix(value = "params", postfix = "v")
1074 @StripPostfix(value = "params", hasPostfix = false)
10651075 void glGetTexParameterfv2(@GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
10661076
10671077 @StripPostfix("params")
10691079
10701080 @Alternate("glGetTexParameteriv")
10711081 @GLreturn("params")
1072 @StripPostfix(value = "params", postfix = "v")
1082 @StripPostfix(value = "params", hasPostfix = false)
10731083 void glGetTexParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
10741084
10751085 @StripPostfix("params")
10771087
10781088 @Alternate("glGetTexLevelParameterfv")
10791089 @GLreturn("params")
1080 @StripPostfix(value = "params", postfix = "v")
1090 @StripPostfix(value = "params", hasPostfix = false)
10811091 void glGetTexLevelParameterfv2(@GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params);
10821092
10831093 @StripPostfix("params")
10851095
10861096 @Alternate("glGetTexLevelParameteriv")
10871097 @GLreturn("params")
1088 @StripPostfix(value = "params", postfix = "v")
1098 @StripPostfix(value = "params", hasPostfix = false)
10891099 void glGetTexLevelParameteriv2(@GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params);
10901100
10911101 void glGetTexImage(@GLenum int target, int level, @GLenum int format, @GLenum int type,
11041114
11051115 @Alternate("glGetTexGeniv")
11061116 @GLreturn("params")
1107 @StripPostfix(value = "params", postfix = "v")
1117 @StripPostfix(value = "params", hasPostfix = false)
11081118 @DeprecatedGL
11091119 void glGetTexGeniv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params);
11101120
11141124
11151125 @Alternate("glGetTexGenfv")
11161126 @GLreturn("params")
1117 @StripPostfix(value = "params", postfix = "v")
1127 @StripPostfix(value = "params", hasPostfix = false)
11181128 @DeprecatedGL
11191129 void glGetTexGenfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params);
11201130
11241134
11251135 @Alternate("glGetTexGendv")
11261136 @GLreturn("params")
1127 @StripPostfix(value = "params", postfix = "v")
1137 @StripPostfix(value = "params", hasPostfix = false)
11281138 @DeprecatedGL
11291139 void glGetTexGendv2(@GLenum int coord, @GLenum int pname, @OutParameter DoubleBuffer params);
11301140
11331143
11341144 @Alternate("glGetTexEnviv")
11351145 @GLreturn("params")
1136 @StripPostfix(value = "params", postfix = "v")
1146 @StripPostfix(value = "params", hasPostfix = false)
11371147 void glGetTexEnviv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params);
11381148
11391149 @StripPostfix("params")
11411151
11421152 @Alternate("glGetTexEnvfv")
11431153 @GLreturn("params")
1144 @StripPostfix(value = "params", postfix = "v")
1154 @StripPostfix(value = "params", hasPostfix = false)
11451155 void glGetTexEnvfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params);
11461156
11471157 @Const
13031313 @GLfloat
13041314 @GLdouble Buffer pointer);
13051315
1316 @DeprecatedGL
1317 @Alternate("glNormalPointer")
1318 void glNormalPointer(@GLenum int type, @GLsizei int stride,
1319 @CachedReference
1320 @BufferObject(BufferKind.ArrayVBO)
1321 @Check
1322 @Const ByteBuffer pointer);
1323
13061324 @NoErrorCheck
13071325 @DeprecatedGL
13081326 void glNormal3b(byte nx, byte ny, byte nz);
13481366
13491367 @DeprecatedGL
13501368 void glRotatef(float angle, float x, float y, float z);
1369
1370 @DeprecatedGL
1371 void glRotated(double angle, double x, double y, double z);
13511372
13521373 @DeprecatedGL
13531374 int glRenderMode(@GLenum int mode);
14391460 @GLfloat
14401461 @GLdouble Buffer pointer);
14411462
1463 @DeprecatedGL
1464 @Alternate("glVertexPointer")
1465 void glVertexPointer(int size, @GLenum int type, @GLsizei int stride,
1466 @CachedReference
1467 @BufferObject(BufferKind.ArrayVBO)
1468 @Check
1469 @Const ByteBuffer pointer);
1470
14421471 @NoErrorCheck
14431472 @DeprecatedGL
14441473 void glVertex2f(float x, float y);
15731602 @GLfloat
15741603 @GLdouble Buffer pointer);
15751604
1605 @DeprecatedGL
1606 @Alternate("glTexCoordPointer")
1607 void glTexCoordPointer(int size, @GLenum int type, @GLsizei int stride,
1608 @CachedReference(index = "StateTracker.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
1609 @BufferObject(BufferKind.ArrayVBO)
1610 @Check
1611 @Const ByteBuffer pointer);
1612
15761613 @NoErrorCheck
15771614 @DeprecatedGL
15781615 void glTexCoord1f(float s);
4040 * The core OpenGL1.2.1 API, with the imaging subset.
4141 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3412 $
44 * $Id: GL12.java 3412 2010-09-26 23:43:24Z spasi $
43 * @version $Revision$
44 * $Id$
4545 */
4646
4747 public interface GL12 {
4040 * The core OpenGL1.3 API.
4141 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3460 $
44 * $Id: GL13.java 3460 2010-11-29 18:25:28Z spasi $
43 * @version $Revision$
44 * $Id$
4545 */
4646 @DeprecatedGL
4747 public interface GL13 {
160160 @GLvoid
161161 Buffer data);
162162
163 @Alternate("glCompressedTexImage1D")
164 void glCompressedTexImage1D2(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @GLsizei int imageSize,
165 @BufferObject(BufferKind.UnpackPBO)
166 @Check
167 @Const
168 @GLvoid
169 @Constant("0L")
170 Buffer data);
171
163172 void glCompressedTexImage2D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize,
164173 @BufferObject(BufferKind.UnpackPBO)
165174 @Check
167176 @GLvoid
168177 ByteBuffer data);
169178
179 @Alternate("glCompressedTexImage2D")
180 void glCompressedTexImage2D2(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLsizei int imageSize,
181 @BufferObject(BufferKind.UnpackPBO)
182 @Check
183 @Const
184 @GLvoid
185 @Constant("0L")
186 ByteBuffer data);
187
170188 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,
171189 @BufferObject(BufferKind.UnpackPBO)
172190 @Check
173191 @Const
174192 @GLvoid
193 ByteBuffer data);
194
195 @Alternate("glCompressedTexImage3D")
196 void glCompressedTexImage3D2(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLsizei int imageSize,
197 @BufferObject(BufferKind.UnpackPBO)
198 @Check
199 @Const
200 @GLvoid
201 @Constant("0L")
175202 ByteBuffer data);
176203
177204 void glCompressedTexSubImage1D(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
252279 @DeprecatedGL
253280 void glMultTransposeMatrixd(@Check("16") @Const DoubleBuffer m);
254281
255 void glSampleCoverage(@GLclampf float value, boolean invert);
282 void glSampleCoverage(float value, boolean invert);
256283 }
257284
4040 * The core OpenGL1.4 API.
4141 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 3460 $
44 * $Id: GL14.java 3460 2010-11-29 18:25:28Z spasi $
43 * @version $Revision$
44 * $Id$
4545 */
4646 @DeprecatedGL
4747 public interface GL14 {
9696
9797 void glBlendEquation(@GLenum int mode);
9898
99 void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
99 void glBlendColor(float red, float green, float blue, float alpha);
100100
101101 @DeprecatedGL
102102 void glFogCoordf(float coord);
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
3534 import org.lwjgl.util.generator.opengl.*;
3635
3736 import java.nio.Buffer;
9695 void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
9796
9897 @Alternate("glDeleteBuffers")
99 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
98 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
10099
101100 void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
102101
108107
109108 @GenerateAutos
110109 void glBufferData(@GLenum int target, @AutoSize("data") @GLsizeiptr long size,
110 @Check
111111 @Const
112112 @GLbyte
113113 @GLshort
157157 */
158158 @CachedResult
159159 @GLvoid
160 @AutoSize("GLChecks.getBufferObjectSize(caps, target)")
160 @AutoSize("glGetBufferParameteri(target, GL_BUFFER_SIZE)")
161161 ByteBuffer glMapBuffer(@GLenum int target, @GLenum int access);
162162
163163 boolean glUnmapBuffer(@GLenum int target);
165165 @StripPostfix("params")
166166 void glGetBufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
167167
168 /** @deprecated Will be removed in 3.0. Use {@link #glGetBufferParameteri} instead. */
168169 @Alternate("glGetBufferParameteriv")
169170 @GLreturn("params")
170171 @StripPostfix("params")
172 @Reuse(value = "GL15", method = "glGetBufferParameteri")
173 @Deprecated
171174 void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
172175
176 @Alternate("glGetBufferParameteriv")
177 @GLreturn("params")
178 @StripPostfix(value = "params", hasPostfix = false)
179 void glGetBufferParameteriv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
180
173181 @StripPostfix("pointer")
174 @AutoSize("GLChecks.getBufferObjectSize(caps, target)")
182 @AutoSize("glGetBufferParameteri(target, GL_BUFFER_SIZE)")
175183 void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer);
176184
177185 // -----------------------------------------------------------------
204212 void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
205213
206214 @Alternate("glDeleteQueries")
207 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
215 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
208216
209217 boolean glIsQuery(@GLuint int id);
210218
215223 @StripPostfix("params")
216224 void glGetQueryiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
217225
226 /** @deprecated Will be removed in 3.0. Use {@link #glGetQueryi} instead. */
218227 @Alternate("glGetQueryiv")
219228 @GLreturn("params")
220229 @StripPostfix("params")
230 @Reuse(value = "GL15", method = "glGetQueryi")
231 @Deprecated
221232 void glGetQueryiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
222233
234 @Alternate("glGetQueryiv")
235 @GLreturn("params")
236 @StripPostfix(value = "params", hasPostfix = false)
237 void glGetQueryiv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
238
223239 @StripPostfix("params")
224240 void glGetQueryObjectiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLint IntBuffer params);
225241
226242 @Alternate("glGetQueryObjectiv")
227243 @GLreturn("params")
228 @StripPostfix(value = "params", postfix = "v")
244 @StripPostfix(value = "params", hasPostfix = false)
229245 void glGetQueryObjectiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLint IntBuffer params);
230246
231247 @StripPostfix("params")
233249
234250 @Alternate("glGetQueryObjectuiv")
235251 @GLreturn("params")
236 @StripPostfix(value = "params", postfix = "v")
252 @StripPostfix(value = "params", hasPostfix = false)
237253 void glGetQueryObjectuiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
238254 }
107107 @Alternate(value = "glShaderSource", nativeAlt = true)
108108 void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count,
109109 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
110 @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length);
110 @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length);
111111
112112 int glCreateShader(@GLuint int type);
113113
188188 @StripPostfix("params")
189189 void glGetShaderiv(@GLuint int shader, @GLenum int pname, @OutParameter @Check IntBuffer params);
190190
191 /** @deprecated Will be removed in 3.0. Use {@link #glGetShaderi} instead. */
191192 @Alternate("glGetShaderiv")
192193 @GLreturn("params")
193194 @StripPostfix("params")
195 @Reuse(value = "GL20", method = "glGetShaderi")
196 @Deprecated
194197 void glGetShaderiv2(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params);
195198
199 @Alternate("glGetShaderiv")
200 @GLreturn("params")
201 @StripPostfix(value = "params", hasPostfix = false)
202 void glGetShaderiv3(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params);
203
196204 @StripPostfix("params")
197205 void glGetProgramiv(@GLuint int program, @GLenum int pname, @OutParameter @Check IntBuffer params);
198206
207 /** @deprecated Will be removed in 3.0. Use {@link #glGetProgrami} instead. */
199208 @Alternate("glGetProgramiv")
200209 @GLreturn("params")
201210 @StripPostfix("params")
211 @Reuse(value = "GL20", method = "glGetProgrami")
212 @Deprecated
202213 void glGetProgramiv2(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params);
214
215 @Alternate("glGetProgramiv")
216 @GLreturn("params")
217 @StripPostfix(value = "params", hasPostfix = false)
218 void glGetProgramiv3(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params);
203219
204220 void glGetShaderInfoLog(@GLuint int shader, @AutoSize("infoLog") @GLsizei int maxLength,
205221 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
208224 @Alternate("glGetShaderInfoLog")
209225 @GLreturn(value = "infoLog", maxLength = "maxLength")
210226 void glGetShaderInfoLog2(@GLuint int shader, @GLsizei int maxLength,
211 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
227 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
212228 @OutParameter @GLchar ByteBuffer infoLog);
213229
214230 void glGetProgramInfoLog(@GLuint int program, @AutoSize("infoLog") @GLsizei int maxLength,
218234 @Alternate("glGetProgramInfoLog")
219235 @GLreturn(value = "infoLog", maxLength = "maxLength")
220236 void glGetProgramInfoLog2(@GLuint int program, @GLsizei int maxLength,
221 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
237 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
222238 @OutParameter @GLchar ByteBuffer infoLog);
223239
224240 void glGetAttachedShaders(@GLuint int program, @AutoSize("shaders") @GLsizei int maxCount,
247263 @Alternate("glGetActiveUniform")
248264 @GLreturn(value = "name", maxLength = "maxLength")
249265 void glGetActiveUniform2(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
250 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
266 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
251267 @OutParameter @Check("2") IntBuffer sizeType,
252 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
268 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
253269 @OutParameter @GLchar ByteBuffer name);
254270
255271 /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
256272 @Alternate(value = "glGetActiveUniform", javaAlt = true)
257273 @GLreturn(value = "name", maxLength = "maxLength")
258274 void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
259 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
275 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
260276 @OutParameter @GLchar ByteBuffer name);
261277
262278 /** Overloads glGetActiveUniform. This version returns only the uniform size. */
263279 @Alternate(value = "glGetActiveUniform", javaAlt = true)
264280 @GLreturn(value = "size")
265 void glGetActiveUniformSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
266 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
281 void glGetActiveUniformSize(@GLuint int program, @GLuint int index, @Constant("1") @GLsizei int maxLength,
282 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
267283 @OutParameter IntBuffer size,
268 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
269 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
284 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
285 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
270286
271287 /** Overloads glGetActiveUniform. This version returns only the uniform type. */
272288 @Alternate(value = "glGetActiveUniform", javaAlt = true)
273289 @GLreturn(value = "type")
274290 void glGetActiveUniformType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
275 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
276 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
291 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
292 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
277293 @OutParameter @GLenum IntBuffer type,
278 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
294 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
279295
280296 @StripPostfix("params")
281297 void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params);
290306 @Alternate("glGetShaderSource")
291307 @GLreturn(value = "source", maxLength = "maxLength")
292308 void glGetShaderSource2(@GLuint int shader, @GLsizei int maxLength,
293 @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length,
309 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(source_length)") IntBuffer length,
294310 @OutParameter @GLchar ByteBuffer source);
295311
296312 // ------------------------------------------------------------------
350366 @GLfloat
351367 @GLdouble Buffer buffer);
352368
369 @Alternate("glVertexAttribPointer")
370 void glVertexAttribPointer(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride,
371 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
372 @BufferObject(BufferKind.ArrayVBO)
373 @Check
374 @Const ByteBuffer buffer);
375
353376 void glEnableVertexAttribArray(@GLuint int index);
354377
355378 void glDisableVertexAttribArray(@GLuint int index);
365388
366389 @StripPostfix("pointer")
367390 void glGetVertexAttribPointerv(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
391
392 @Alternate(value = "glGetVertexAttribPointerv", nativeAlt = true)
393 @StripPostfix("pointer")
394 void glGetVertexAttribPointerv2(@GLuint int index, @GLenum int pname, @OutParameter @Check("PointerBuffer.getPointerSize()") @GLvoid ByteBuffer pointer);
368395
369396 // -----------------------------------------------------------------
370397 // ----------------------[ ARB_vertex_shader ]----------------------
422449 @Alternate("glGetActiveAttrib")
423450 @GLreturn(value = "name", maxLength = "maxLength")
424451 void glGetActiveAttrib2(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
425 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
452 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
426453 @OutParameter @Check("2") IntBuffer sizeType,
427 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
454 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
428455 @OutParameter @GLchar ByteBuffer name);
429456
430457 /** Overloads glGetActiveAttrib. This version returns only the attrib name. */
431458 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
432459 @GLreturn(value = "name", maxLength = "maxLength")
433460 void glGetActiveAttrib(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
434 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
461 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
435462 @OutParameter @GLchar ByteBuffer name);
436463
437464 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
438465 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
439466 @GLreturn(value = "size")
440467 void glGetActiveAttribSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
441 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
468 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
442469 @OutParameter IntBuffer size,
443 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
444 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
470 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
471 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
445472
446473 /** Overloads glGetActiveAttrib. This version returns only the attrib type. */
447474 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
448475 @GLreturn(value = "type")
449476 void glGetActiveAttribType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength,
450 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
451 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
477 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
478 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
452479 @OutParameter @GLenum IntBuffer type,
453 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
480 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
454481
455482 int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
456483
508535 void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
509536
510537 @Alternate("glDrawBuffers")
511 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
538 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
512539
513540 // ----------------------------------------------------------------
514541 // ----------------------[ ARB_point_sprite ]----------------------
203203 void glVertexAttribI4usv(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
204204
205205 void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
206 @CachedReference
206 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
207207 @BufferObject(BufferKind.ArrayVBO)
208208 @Check
209209 @Const
318318 void glClampColor(@GLenum int target, @GLenum int clamp);
319319
320320 // ----------------------------------------------------------------------
321 // ----------------------[ NV_depth_buffer_float ]----------------------
321 // ----------------------[ ARB_depth_buffer_float ]----------------------
322322 // ----------------------------------------------------------------------
323323
324324 /**
327327 * and returned in the &lt;data&gt; parameter of GetTexLevelParameter and
328328 * GetRenderbufferParameterivEXT:
329329 */
330 int GL_DEPTH_COMPONENT32F = 0x8DAB;
331 int GL_DEPTH32F_STENCIL8 = 0x8DAC;
330 int GL_DEPTH_COMPONENT32F = 0x8CAC;
331 int GL_DEPTH32F_STENCIL8 = 0x8CAD;
332332
333333 /**
334334 * Accepted by the &lt;type&gt; parameter of DrawPixels, ReadPixels, TexImage1D,
527527 void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
528528
529529 @Alternate("glDeleteRenderbuffers")
530 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
530 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer);
531531
532532 void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
533533
540540 @StripPostfix("params")
541541 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
542542
543 /** @deprecated Will be removed in 3.0. Use {@link #glGetRenderbufferParameteri} instead. */
543544 @Alternate("glGetRenderbufferParameteriv")
544545 @GLreturn("params")
545546 @StripPostfix("params")
547 @Reuse(value = "GL30", method = "glGetRenderbufferParameteri")
548 @Deprecated
546549 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
547550
551 @Alternate("glGetRenderbufferParameteriv")
552 @GLreturn("params")
553 @StripPostfix(value = "params", hasPostfix = false)
554 void glGetRenderbufferParameteriv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
555
548556 boolean glIsFramebuffer(@GLuint int framebuffer);
549557
550558 void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer);
552560 void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
553561
554562 @Alternate("glDeleteFramebuffers")
555 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
563 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer);
556564
557565 void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
558566
574582 @StripPostfix("params")
575583 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
576584
585 /** @deprecated Will be removed in 3.0. Use {@link #glGetFramebufferAttachmentParameteri} instead. */
577586 @Alternate("glGetFramebufferAttachmentParameteriv")
578587 @GLreturn("params")
579588 @StripPostfix("params")
589 @Reuse(value = "GL30", method = "glGetFramebufferAttachmentParameteri")
590 @Deprecated
580591 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
592
593 @Alternate("glGetFramebufferAttachmentParameteriv")
594 @GLreturn("params")
595 @StripPostfix(value = "params", hasPostfix = false)
596 void glGetFramebufferAttachmentParameteriv3(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
581597
582598 void glGenerateMipmap(@GLenum int target);
583599
710726 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params);
711727
712728 @Alternate("glTexParameterIiv")
713 @StripPostfix(value = "param", postfix = "v")
714 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
729 @StripPostfix(value = "param", hasPostfix = false)
730 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
715731
716732 @StripPostfix("params")
717733 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
718734
719735 @Alternate("glTexParameterIuiv")
720 @StripPostfix(value = "param", postfix = "v")
721 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
736 @StripPostfix(value = "param", hasPostfix = false)
737 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
722738
723739 @StripPostfix("params")
724740 void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
725741
726742 @Alternate("glGetTexParameterIiv")
727743 @GLreturn("params")
728 @StripPostfix(value = "params", postfix = "v")
744 @StripPostfix(value = "params", hasPostfix = false)
729745 void glGetTexParameterIiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
730746
731747 @StripPostfix("params")
733749
734750 @Alternate("glGetTexParameterIuiv")
735751 @GLreturn("params")
736 @StripPostfix(value = "params", postfix = "v")
752 @StripPostfix(value = "params", hasPostfix = false)
737753 void glGetTexParameterIuiv2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
738754
739755 // -----------------------------------------------------------------
828844
829845 void glColorMaski(@GLuint int buf, boolean r, boolean g, boolean b, boolean a);
830846
831 @StripPostfix(value = "data", hasPostfix = false)
847 @StripPostfix(value = "data")
832848 void glGetBooleani_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data);
833849
834850 @Alternate("glGetBooleani_v")
835851 @GLreturn("data")
836 @StripPostfix(value = "data", hasPostfix = false)
852 @StripPostfix(value = "data")
837853 void glGetBooleani_v2(@GLenum int value, @GLuint int index, @OutParameter @GLboolean ByteBuffer data);
838854
839855 @StripPostfix("data")
859875 * CopyTexImage2D, and CompressedTexImage2D and the &lt;format&gt; parameter
860876 * of CompressedTexSubImage2D:
861877 */
862 int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
863 int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC;
864 int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD;
865 int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE;
878 int GL_COMPRESSED_RED_RGTC1 = 0x8DBB,
879 GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC,
880 GL_COMPRESSED_RG_RGTC2 = 0x8DBD,
881 GL_COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE;
866882
867883 // --------------------------------------------------------------
868884 // ----------------------[ ARB_texture_rg ]----------------------
906922 int GL_RG = 0x8227;
907923 int GL_RG_INTEGER = 0x8228;
908924
909 /**
910 * Accepted by the &lt;param&gt; parameter of the TexParameter{if}*
911 * functions when &lt;pname&gt; is DEPTH_TEXTURE_MODE:
912 */
913 int GL_RED = 0x1903;
914
915925 // ----------------------------------------------------------------------
916926 // ----------------------[ EXT_transform_feedback ]----------------------
917927 // ----------------------------------------------------------------------
9951005 @Alternate("glGetTransformFeedbackVarying")
9961006 @GLreturn(value = "name", maxLength = "bufSize")
9971007 void glGetTransformFeedbackVarying2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
998 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
1008 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
9991009 @OutParameter @GLsizei @Check("1") IntBuffer size,
10001010 @OutParameter @GLenum @Check("1") IntBuffer type,
10011011 @OutParameter @GLchar ByteBuffer name);
10181028
10191029 @Alternate("glDeleteVertexArrays")
10201030 @Code(" StateTracker.deleteVAO(caps, array);")
1021 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
1031 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array);
10221032
10231033 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
10241034
7575 // ----------------------[ EXT_copy_buffer ]----------------------
7676 // ---------------------------------------------------------------
7777
78 int GL_COPY_READ_BUFFER = 0x8F36;
79 int GL_COPY_WRITE_BUFFER = 0x8F37;
78 int GL_COPY_READ_BUFFER_BINDING = 0x8F36;
79 int GL_COPY_WRITE_BUFFER_BINDING = 0x8F37;
80
81 int GL_COPY_READ_BUFFER = GL_COPY_READ_BUFFER_BINDING;
82 int GL_COPY_WRITE_BUFFER = GL_COPY_WRITE_BUFFER_BINDING;
8083
8184 void glCopyBufferSubData(@GLenum int readtarget, @GLenum int writetarget, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
8285
247250 @GLenum int pname,
248251 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
249252
253 /** @deprecated Will be removed in 3.0. Use {@link #glGetActiveUniformsi} instead. */
250254 @Alternate("glGetActiveUniformsiv")
251255 @GLreturn("params")
252256 @StripPostfix("params")
257 @Reuse(value = "GL31", method = "glGetActiveUniformsi")
258 @Deprecated
253259 void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
254 @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer
260 @Constant(value = "MemoryUtil.getAddress(params.put(1, uniformIndex), 1)", keepParam = true) int uniformIndex, // Reuse params buffer
255261 @GLenum int pname,
256262 @OutParameter @GLint IntBuffer params);
263
264 @Alternate("glGetActiveUniformsiv")
265 @GLreturn("params")
266 @StripPostfix(value = "params", hasPostfix = false)
267 void glGetActiveUniformsiv2(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
268 @Constant(value = "MemoryUtil.getAddress(params.put(1, uniformIndex), 1)", keepParam = true) int uniformIndex, // Reuse params buffer
269 @GLenum int pname,
270 @OutParameter @GLint IntBuffer params);
257271
258272 void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize,
259273 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
262276 @Alternate("glGetActiveUniformName")
263277 @GLreturn(value = "uniformName", maxLength = "bufSize")
264278 void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize,
265 @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length,
279 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(uniformName_length)") IntBuffer length,
266280 @OutParameter @GLchar ByteBuffer uniformName);
267281
268282 @GLuint
276290 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
277291 @OutParameter @Check(value = "16") @GLint IntBuffer params);
278292
293 /** @deprecated Will be removed in 3.0. Use {@link #glGetActiveUniformBlocki} instead. */
279294 @Alternate("glGetActiveUniformBlockiv")
280295 @GLreturn("params")
281296 @StripPostfix("params")
297 @Reuse(value = "GL31", method = "glGetActiveUniformBlocki")
298 @Deprecated
282299 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
300 @OutParameter @GLint IntBuffer params);
301
302 @Alternate("glGetActiveUniformBlockiv")
303 @GLreturn("params")
304 @StripPostfix(value = "params", hasPostfix = false)
305 void glGetActiveUniformBlockiv3(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
283306 @OutParameter @GLint IntBuffer params);
284307
285308 void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize,
289312 @Alternate("glGetActiveUniformBlockName")
290313 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
291314 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
292 @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length,
315 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(uniformBlockName_length)") IntBuffer length,
293316 @OutParameter @GLchar ByteBuffer uniformBlockName);
294317
295318 void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding);
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.PointerWrapper;
35 import org.lwjgl.util.generator.Alternate;
3634 import org.lwjgl.util.generator.opengl.*;
3735
3836 import java.nio.Buffer;
4644 // ----------------------[ OpenGL 3.2 ]----------------------
4745 // ----------------------------------------------------------
4846
49 int GL_CONTEXT_PROFILE_MASK = 0x9126;
50 int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001;
47 int GL_CONTEXT_PROFILE_MASK = 0x9126;
48 int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001;
5149 int GL_CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002;
5250
53 int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122;
54 int GL_MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123;
51 int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122;
52 int GL_MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123;
5553 int GL_MAX_GEOMETRY_OUTPUT_COMPONENTS = 0x9124;
56 int GL_MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125;
57
58 // ---------------------------------------------------------------------
59 // ----------------------[ ARB_vertex_array_bgra ]----------------------
60 // ---------------------------------------------------------------------
61
62 int GL_BGRA = 0x80E1;
54 int GL_MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125;
55
56 @StripPostfix("params")
57 void glGetBufferParameteri64v(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") LongBuffer params);
58
59 /** @deprecated Will be removed in 3.0. Use {@link #glGetBufferParameteri64} instead. */
60 @Alternate("glGetBufferParameteri64v")
61 @GLreturn("params")
62 @StripPostfix("params")
63 @Reuse(value = "GL32", method = "glGetBufferParameteri64")
64 @Deprecated
65 void glGetBufferParameteri64v2(@GLenum int target, @GLenum int pname, @OutParameter LongBuffer params);
66
67 @Alternate("glGetBufferParameteri64v")
68 @GLreturn("params")
69 @StripPostfix(value = "params", hasPostfix = false)
70 void glGetBufferParameteri64v3(@GLenum int target, @GLenum int pname, @OutParameter LongBuffer params);
6371
6472 // -----------------------------------------------------------------------------
6573 // ----------------------[ ARB_draw_elements_base_vertex ]----------------------
94102
95103 /** Accepted by the &lt;mode&gt; parameter of ProvokingVertex: */
96104 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D;
97 int GL_LAST_VERTEX_CONVENTION = 0x8E4E;
105 int GL_LAST_VERTEX_CONVENTION = 0x8E4E;
98106
99107 /**
100108 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
101109 * GetFloatv, and GetDoublev:
102110 */
103 int GL_PROVOKING_VERTEX = 0x8E4F;
111 int GL_PROVOKING_VERTEX = 0x8E4F;
104112 int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C;
105113
106114 void glProvokingVertex(@GLenum int mode);
158166 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
159167 * and GetFloatv:
160168 */
161 int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59;
162 int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E;
163 int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F;
164 int GL_MAX_INTEGER_SAMPLES = 0x9110;
165 int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104;
169 int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59;
170 int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E;
171 int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F;
172 int GL_MAX_INTEGER_SAMPLES = 0x9110;
173 int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104;
166174 int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105;
167175
168176 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter */
169 int GL_TEXTURE_SAMPLES = 0x9106;
177 int GL_TEXTURE_SAMPLES = 0x9106;
170178 int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107;
171179
172180 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
173 int GL_SAMPLER_2D_MULTISAMPLE = 0x9108;
174 int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109;
175 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A;
176 int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B;
177 int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C;
181 int GL_SAMPLER_2D_MULTISAMPLE = 0x9108;
182 int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109;
183 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A;
184 int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B;
185 int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C;
178186 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D;
179187
180188 void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
216224 * GetProgramiv:
217225 */
218226 int GL_GEOMETRY_VERTICES_OUT = 0x8DDA;
219 int GL_GEOMETRY_INPUT_TYPE = 0x8DDB;
220 int GL_GEOMETRY_OUTPUT_TYPE = 0x8DDC;
227 int GL_GEOMETRY_INPUT_TYPE = 0x8DDB;
228 int GL_GEOMETRY_OUTPUT_TYPE = 0x8DDC;
221229
222230 /**
223231 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
224232 * GetFloatv, and GetDoublev:
225233 */
226 int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS = 0x8C29;
234 int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS = 0x8C29;
227235 //int GL_MAX_GEOMETRY_VARYING_COMPONENTS = 0x8DDD; -- Missing from 3.2 spec
228236 //int GL_MAX_VERTEX_VARYING_COMPONENTS = 0x8DDE; -- Missing from 3.2 spec
229 int GL_MAX_VARYING_COMPONENTS = 0x8B4B;
230 int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS = 0x8DDF;
231 int GL_MAX_GEOMETRY_OUTPUT_VERTICES = 0x8DE0;
237 int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS = 0x8DDF;
238 int GL_MAX_GEOMETRY_OUTPUT_VERTICES = 0x8DE0;
232239 int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 0x8DE1;
233240
234241 /**
236243 * MultiDrawArrays, DrawElements, MultiDrawElements, and
237244 * DrawRangeElements:
238245 */
239 int GL_LINES_ADJACENCY = 0xA;
240 int GL_LINE_STRIP_ADJACENCY = 0xB;
241 int GL_TRIANGLES_ADJACENCY = 0xC;
246 int GL_LINES_ADJACENCY = 0xA;
247 int GL_LINE_STRIP_ADJACENCY = 0xB;
248 int GL_TRIANGLES_ADJACENCY = 0xC;
242249 int GL_TRIANGLE_STRIP_ADJACENCY = 0xD;
243250
244251 /** Returned by CheckFramebufferStatusEXT: */
245252 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0x8DA8;
246 int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT = 0x8DA9;
247253
248254 /**
249255 * Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachment-
250256 * ParameterivEXT:
251257 */
252 int GL_FRAMEBUFFER_ATTACHMENT_LAYERED = 0x8DA7;
253 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4;
258 int GL_FRAMEBUFFER_ATTACHMENT_LAYERED = 0x8DA7;
254259
255260 /**
256261 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
269274 int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111;
270275
271276 /** Accepted as the &lt;pname&gt; parameter of GetSynciv: */
272 int GL_OBJECT_TYPE = 0x9112;
277 int GL_OBJECT_TYPE = 0x9112;
273278 int GL_SYNC_CONDITION = 0x9113;
274 int GL_SYNC_STATUS = 0x9114;
275 int GL_SYNC_FLAGS = 0x9115;
279 int GL_SYNC_STATUS = 0x9114;
280 int GL_SYNC_FLAGS = 0x9115;
276281
277282 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; OBJECT_TYPE: */
278283 int GL_SYNC_FENCE = 0x9116;
282287
283288 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_STATUS: */
284289 int GL_UNSIGNALED = 0x9118;
285 int GL_SIGNALED = 0x9119;
290 int GL_SIGNALED = 0x9119;
286291
287292 /** Accepted in the &lt;flags&gt; parameter of ClientWaitSync: */
288293 int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
291296 long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl;
292297
293298 /** Returned by ClientWaitSync: */
294 int GL_ALREADY_SIGNALED = 0x911A;
295 int GL_TIMEOUT_EXPIRED = 0x911B;
299 int GL_ALREADY_SIGNALED = 0x911A;
300 int GL_TIMEOUT_EXPIRED = 0x911B;
296301 int GL_CONDITION_SATISFIED = 0x911C;
297 int GL_WAIT_FAILED = 0x911D;
302 int GL_WAIT_FAILED = 0x911D;
298303
299304 @PointerWrapper("GLsync")
300305 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
317322 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer data);
318323
319324 @StripPostfix("data")
320 @Optional(reason = "NV's 3.2 implementation does not expose this (last driver checked: 19?.??)")
321325 void glGetInteger64i_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLint64 LongBuffer data);
322326
323327 @Alternate("glGetInteger64i_v")
330334 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
331335 @OutParameter IntBuffer values);
332336
337 /** @deprecated Will be removed in 3.0. Use {@link #glGetSynci} instead. */
333338 @Alternate("glGetSynciv")
334339 @GLreturn("values")
335340 @StripPostfix("values")
341 @Reuse(value = "GL32", method = "glGetSynci")
342 @Deprecated
336343 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
337 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
344 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
345 @OutParameter IntBuffer values);
346
347 @Alternate("glGetSynciv")
348 @GLreturn("values")
349 @StripPostfix(value = "values", hasPostfix = false)
350 void glGetSynciv3(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
351 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
338352 @OutParameter IntBuffer values);
339353 }
5252 * parameters of BlendFuncSeparate and BlendFuncSeparatei:
5353 */
5454 int GL_SRC1_COLOR = 0x88F9;
55 int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA;
5655 int GL_ONE_MINUS_SRC1_COLOR = 0x88FA;
5756 int GL_ONE_MINUS_SRC1_ALPHA = 0x88FB;
5857
101100 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
102101
103102 @Alternate("glDeleteSamplers")
104 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
103 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(caps, sampler)", keepParam = true) int sampler);
105104
106105 boolean glIsSampler(@GLuint int sampler);
107106
128127
129128 @Alternate("glGetSamplerParameteriv")
130129 @GLreturn("params")
131 @StripPostfix(value = "params", postfix = "v")
130 @StripPostfix(value = "params", hasPostfix = false)
132131 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
133132
134133 @StripPostfix("params")
136135
137136 @Alternate("glGetSamplerParameterfv")
138137 @GLreturn("params")
139 @StripPostfix(value = "params", postfix = "v")
138 @StripPostfix(value = "params", hasPostfix = false)
140139 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
141140
142141 @StripPostfix("params")
144143
145144 @Alternate("glGetSamplerParameterIiv")
146145 @GLreturn("params")
147 @StripPostfix(value = "params", postfix = "v")
146 @StripPostfix(value = "params", hasPostfix = false)
148147 void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
149148
150149 @StripPostfix("params")
152151
153152 @Alternate("glGetSamplerParameterIuiv")
154153 @GLreturn("params")
155 @StripPostfix(value = "params", postfix = "v")
154 @StripPostfix(value = "params", hasPostfix = false)
156155 void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
157156
158157 // -------------------------------------------------------------------
208207 @StripPostfix("params")
209208 void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
210209
210 /** @deprecated Will be removed in 3.0. Use {@link #glGetQueryObjecti64} instead. */
211211 @Alternate("glGetQueryObjecti64v")
212212 @GLreturn("params")
213213 @StripPostfix("params")
214 @Reuse(value = "GL33", method = "glGetQueryObjecti64")
215 @Deprecated
214216 void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
215217
218 @Alternate("glGetQueryObjecti64v")
219 @GLreturn("params")
220 @StripPostfix(value = "params", hasPostfix = false)
221 void glGetQueryObjecti64v3(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
222
216223 @StripPostfix("params")
217224 void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params);
218225
226 /** @deprecated Will be removed in 3.0. Use {@link #glGetQueryObjectui64} instead. */
219227 @Alternate("glGetQueryObjectui64v")
220228 @GLreturn("params")
221229 @StripPostfix("params")
230 @Reuse(value = "GL33", method = "glGetQueryObjectui64")
231 @Deprecated
222232 void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params);
233
234 @Alternate("glGetQueryObjectui64v")
235 @GLreturn("params")
236 @StripPostfix(value = "params", hasPostfix = false)
237 void glGetQueryObjectui64v3(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params);
223238
224239 // --------------------------------------------------------------------
225240 // ----------------------[ ARB_instanced_arrays ]----------------------
3939 import java.nio.FloatBuffer;
4040 import java.nio.IntBuffer;
4141
42 import com.sun.mirror.type.PrimitiveType;
42 import javax.lang.model.type.TypeKind;
4343
4444 public interface GL40 {
4545
7474 */
7575 int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43;
7676
77 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
78
79 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
77 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4 * 4") @Const @GLvoid ByteBuffer indirect);
78
79 @Alternate("glDrawArraysIndirect")
80 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @Const @GLvoid(TypeKind.INT) IntBuffer indirect);
81
82 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5 * 4") @Const @GLvoid ByteBuffer indirect);
83
84 @Alternate("glDrawElementsIndirect")
85 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @Const @GLvoid(TypeKind.INT) IntBuffer indirect);
8086
8187 // ---------------------------------------------------------------
8288 // ----------------------[ ARB_gpu_shader5 ]----------------------
183189 */
184190 int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37;
185191
186 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
187 void glMinSampleShading(@GLclampf float value);
192 void glMinSampleShading(float value);
188193
189194 // ---------------------------------------------------------------------
190195 // ----------------------[ ARB_shader_subroutine ]----------------------
207212 /** Accepted by the &lt;pname&gt; parameter of GetActiveSubroutineUniformiv: */
208213 int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A;
209214 int GL_COMPATIBLE_SUBROUTINES = 0x8E4B;
210 int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE;
211 int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH;
212215
213216 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
217
218 @Alternate("glGetSubroutineUniformLocation")
219 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @NullTerminated CharSequence name);
214220
215221 @GLuint
216222 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
223
224 @Alternate("glGetSubroutineIndex")
225 @GLuint
226 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @NullTerminated CharSequence name);
217227
218228 @StripPostfix("values")
219229 void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
220230 @OutParameter @Check("1") IntBuffer values);
221231
232 /** @deprecated Will be removed in 3.0. Use {@link #glGetActiveSubroutineUniformi} instead. */
222233 @Alternate("glGetActiveSubroutineUniformiv")
223234 @GLreturn("values")
224235 @StripPostfix("values")
236 @Reuse(value = "GL40", method = "glGetActiveSubroutineUniformi")
237 @Deprecated
225238 void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
239 @OutParameter IntBuffer values);
240
241 @Alternate("glGetActiveSubroutineUniformiv")
242 @GLreturn("values")
243 @StripPostfix(value = "values", hasPostfix = false)
244 void glGetActiveSubroutineUniformiv3(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
226245 @OutParameter IntBuffer values);
227246
228247 void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
232251 @Alternate("glGetActiveSubroutineUniformName")
233252 @GLreturn(value = "name", maxLength = "bufsize")
234253 void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
235 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
254 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
236255 @OutParameter @GLchar ByteBuffer name);
237256
238257 void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
242261 @Alternate("glGetActiveSubroutineName")
243262 @GLreturn(value = "name", maxLength = "bufsize")
244263 void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
245 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
264 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
246265 @OutParameter @GLchar ByteBuffer name);
247266
248267 @StripPostfix("indices")
251270 @StripPostfix("params")
252271 void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params);
253272
273 /** @deprecated Will be removed in 3.0. Use {@link #glGetUniformSubroutineui} instead. */
254274 @Alternate("glGetUniformSubroutineuiv")
255275 @GLreturn("params")
256276 @StripPostfix("params")
277 @Reuse(value = "GL40", method = "glGetUniformSubroutineui")
278 @Deprecated
257279 void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
280
281 @Alternate("glGetUniformSubroutineuiv")
282 @GLreturn("params")
283 @StripPostfix(value = "params", hasPostfix = false)
284 void glGetUniformSubroutineuiv3(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
258285
259286 @StripPostfix("values")
260287 void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values);
261288
289 /** @deprecated Will be removed in 3.0. Use {@link #glGetProgramStagei} instead. */
262290 @Alternate("glGetProgramStageiv")
263291 @GLreturn("values")
264292 @StripPostfix("values")
293 @Reuse(value = "GL40", method = "glGetProgramStagei")
294 @Deprecated
265295 void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values);
296
297 @Alternate("glGetProgramStageiv")
298 @GLreturn("values")
299 @StripPostfix(value = "values", hasPostfix = false)
300 void glGetProgramStageiv3(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values);
266301
267302 // -----------------------------------------------------------------------
268303 // ----------------------[ ARB_tessellation_shader ]----------------------
394429 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv,
395430 * and GetFloatv:
396431 */
397 int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23;
398 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24;
432 int GL_TRANSFORM_FEEDBACK_PAUSED = 0x8E23;
433 int GL_TRANSFORM_FEEDBACK_ACTIVE = 0x8E24;
434 int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = GL_TRANSFORM_FEEDBACK_PAUSED;
435 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = GL_TRANSFORM_FEEDBACK_ACTIVE;
399436 int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25;
400437
401438 void glBindTransformFeedback(@GLenum int target, @GLuint int id);
403440 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
404441
405442 @Alternate("glDeleteTransformFeedbacks")
406 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
443 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
407444
408445 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
409446
438475 @StripPostfix("params")
439476 void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
440477
478 /** @deprecated Will be removed in 3.0. Use {@link #glGetQueryIndexedi} instead. */
441479 @Alternate("glGetQueryIndexediv")
442480 @GLreturn("params")
443481 @StripPostfix("params")
482 @Reuse(value = "GL40", method = "glGetQueryIndexedi")
483 @Deprecated
444484 void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params);
445485
486 @Alternate("glGetQueryIndexediv")
487 @GLreturn("params")
488 @StripPostfix(value = "params", hasPostfix = false)
489 void glGetQueryIndexediv3(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params);
490
446491 }
4545 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
4646 * GetInteger64v, GetFloatv, and GetDoublev:
4747 */
48 int GL_SHADER_COMPILER = 0x8DFA,
49 GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
50 GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
51 GL_MAX_VARYING_VECTORS = 0x8DFC,
52 GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
53 GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
48 int GL_SHADER_COMPILER = 0x8DFA,
49 GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
50 GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
51 GL_MAX_VARYING_VECTORS = 0x8DFC,
52 GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
53 GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
5454 GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
5555
5656 /** Accepted by the &lt;type&gt; parameter of VertexAttribPointer: */
6060 * Accepted by the &lt;precisiontype&gt; parameter of
6161 * GetShaderPrecisionFormat:
6262 */
63 int GL_LOW_FLOAT = 0x8DF0,
63 int GL_LOW_FLOAT = 0x8DF0,
6464 GL_MEDIUM_FLOAT = 0x8DF1,
65 GL_HIGH_FLOAT = 0x8DF2,
66 GL_LOW_INT = 0x8DF3,
67 GL_MEDIUM_INT = 0x8DF4,
68 GL_HIGH_INT = 0x8DF5;
69
70 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
65 GL_HIGH_FLOAT = 0x8DF2,
66 GL_LOW_INT = 0x8DF3,
67 GL_MEDIUM_INT = 0x8DF4,
68 GL_HIGH_INT = 0x8DF5;
69
70 /** Accepted by the &lt;format&gt; parameter of most commands taking sized internal formats: */
71 int GL_RGB565 = 0x8D62;
72
7173 void glReleaseShaderCompiler();
7274
73 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
7475 void glShaderBinary(@AutoSize("shaders") @GLsizei int count, @Const @GLuint IntBuffer shaders,
7576 @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
7677
77 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
7878 void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype,
7979 @OutParameter @Check("2") IntBuffer range,
8080 @OutParameter @Check("1") IntBuffer precision);
8181
82 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
83 void glDepthRangef(@GLclampf float n, @GLclampf float f);
84
85 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
86 void glClearDepthf(@GLclampf float d);
82 void glDepthRangef(float n, float f);
83
84 void glClearDepthf(float d);
8785
8886 // ----------------------------------------------------------------------
8987 // ----------------------[ ARB_get_program_binary ]----------------------
103101 * GetInteger64v, GetFloatv and GetDoublev:
104102 */
105103 int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE,
106 GL_PROGRAM_BINARY_FORMATS = 0x87FF;
104 GL_PROGRAM_BINARY_FORMATS = 0x87FF;
107105
108106 void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize,
109107 @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
119117 // ---------------------------------------------------------------------------
120118
121119 /** Accepted by &lt;stages&gt; parameter to UseProgramStages: */
122 int GL_VERTEX_SHADER_BIT = 0x00000001,
123 GL_FRAGMENT_SHADER_BIT = 0x00000002,
124 GL_GEOMETRY_SHADER_BIT = 0x00000004,
125 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
120 int GL_VERTEX_SHADER_BIT = 0x00000001,
121 GL_FRAGMENT_SHADER_BIT = 0x00000002,
122 GL_GEOMETRY_SHADER_BIT = 0x00000004,
123 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
126124 GL_TESS_EVALUATION_SHADER_BIT = 0x00000010,
127 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
125 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
128126
129127 /**
130128 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
145143
146144 void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program);
147145
148 @StripPostfix(value = "strings", postfix = "v")
146 /** Single null-terminated source code string. */
147 @StripPostfix(value = "string", hasPostfix = false)
149148 @GLuint
150 int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings);
149 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated @Check @Const @Indirect @GLchar ByteBuffer string);
150
151 /** Multiple null-terminated source code strings, one after the other. */
152 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true)
153 @StripPostfix(value = "strings", hasPostfix = false)
154 @GLuint
155 int glCreateShaderProgramv2(@GLenum int type, @GLsizei int count, @NullTerminated("count") @Check @Const @Indirect @GLchar @PointerArray("count") ByteBuffer strings);
156
157 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true)
158 @StripPostfix(value = "strings", hasPostfix = false)
159 @GLuint
160 int glCreateShaderProgramv3(@GLenum int type, @Constant("strings.length") @GLsizei int count, @NullTerminated @Check("1") @PointerArray(value = "count") @Const @NativeType("GLchar") ByteBuffer[] strings);
151161
152162 @Alternate("glCreateShaderProgramv")
153 @StripPostfix(value = "string", postfix = "v")
163 @StripPostfix(value = "string", hasPostfix = false)
154164 @GLuint
155165 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string);
156166
157 @Alternate("glCreateShaderProgramv")
158 @StripPostfix(value = "strings", postfix = "v")
167 @Alternate(value = "glCreateShaderProgramv", nativeAlt = true, skipNative = true)
168 @StripPostfix(value = "strings", hasPostfix = false)
159169 @GLuint
160 int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count,
161 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
170 int glCreateShaderProgramv2(@GLenum int type, @Constant("strings.length") @GLsizei int count,
171 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
162172
163173 void glBindProgramPipeline(@GLuint int pipeline);
164174
165175 void glDeleteProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines);
166176
167177 @Alternate("glDeleteProgramPipelines")
168 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline);
178 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, pipeline)", keepParam = true) int pipeline);
169179
170180 void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
171181
180190
181191 @Alternate("glGetProgramPipelineiv")
182192 @GLreturn("params")
183 @StripPostfix("params")
193 @StripPostfix(value = "params", hasPostfix = false)
184194 void glGetProgramPipelineiv2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params);
185195
186196 void glProgramUniform1i(@GLuint int program, int location, int v0);
338348 @Alternate("glGetProgramPipelineInfoLog")
339349 @GLreturn(value = "infoLog", maxLength = "bufSize")
340350 void glGetProgramPipelineInfoLog2(@GLuint int pipeline, @GLsizei int bufSize,
341 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
351 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
342352 @OutParameter @GLchar ByteBuffer infoLog);
343353
344354 // -----------------------------------------------------------------------
345355 // ----------------------[ ARB_vertex_attrib_64bit ]----------------------
346356 // -----------------------------------------------------------------------
347357
348 /** Returned in the &lt;type&gt; parameter of GetActiveAttrib: */
349 int GL_DOUBLE_VEC2 = 0x8FFC;
350 int GL_DOUBLE_VEC3 = 0x8FFD;
351 int GL_DOUBLE_VEC4 = 0x8FFE;
352 int GL_DOUBLE_MAT2 = 0x8F46;
353 int GL_DOUBLE_MAT3 = 0x8F47;
354 int GL_DOUBLE_MAT4 = 0x8F48;
355 int GL_DOUBLE_MAT2x3 = 0x8F49;
356 int GL_DOUBLE_MAT2x4 = 0x8F4A;
357 int GL_DOUBLE_MAT3x2 = 0x8F4B;
358 int GL_DOUBLE_MAT3x4 = 0x8F4C;
359 int GL_DOUBLE_MAT4x2 = 0x8F4D;
360 int GL_DOUBLE_MAT4x3 = 0x8F4E;
361
362 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
363358 void glVertexAttribL1d(@GLuint int index, double x);
364359
365 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
366360 void glVertexAttribL2d(@GLuint int index, double x, double y);
367361
368 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
369362 void glVertexAttribL3d(@GLuint int index, double x, double y, double z);
370363
371 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
372364 void glVertexAttribL4d(@GLuint int index, double x, double y, double z, double w);
373365
374 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
375366 @StripPostfix("v")
376367 void glVertexAttribL1dv(@GLuint int index, @Const @Check("1") DoubleBuffer v);
377368
378 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
379369 @StripPostfix("v")
380370 void glVertexAttribL2dv(@GLuint int index, @Const @Check("2") DoubleBuffer v);
381371
382 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
383372 @StripPostfix("v")
384373 void glVertexAttribL3dv(@GLuint int index, @Const @Check("3") DoubleBuffer v);
385374
386 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
387375 @StripPostfix("v")
388376 void glVertexAttribL4dv(@GLuint int index, @Const @Check("4") DoubleBuffer v);
389377
390 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
391378 void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
392379 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
393380 @BufferObject(BufferKind.ArrayVBO)
394381 @Check @Const @GLdouble Buffer pointer);
395382
396 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
397383 @StripPostfix("params")
398384 void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
399385
405391 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
406392 * GetDoublev and GetInteger64v:
407393 */
408 int GL_MAX_VIEWPORTS = 0x825B,
409 GL_VIEWPORT_SUBPIXEL_BITS = 0x825C,
410 GL_VIEWPORT_BOUNDS_RANGE = 0x825D,
411 GL_LAYER_PROVOKING_VERTEX = 0x825E,
394 int GL_MAX_VIEWPORTS = 0x825B,
395 GL_VIEWPORT_SUBPIXEL_BITS = 0x825C,
396 GL_VIEWPORT_BOUNDS_RANGE = 0x825D,
397 GL_LAYER_PROVOKING_VERTEX = 0x825E,
412398 GL_VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F;
413
414 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
415 int GL_SCISSOR_BOX = 0x0C10;
416
417 /** Accepted by the &lt;pname&gt; parameter of GetFloati_v: */
418 int GL_VIEWPORT = 0x0BA2;
419
420 /** Accepted by the &lt;pname&gt; parameter of GetDoublei_v: */
421 int GL_DEPTH_RANGE = 0x0B70;
422
423 /** Accepted by the &lt;pname&gt; parameter of Enablei, Disablei, and IsEnabledi: */
424 int GL_SCISSOR_TEST = 0x0C11;
425399
426400 /**
427401 * Returned in the &lt;data&gt; parameter from a Get query with a &lt;pname&gt; of
428402 * LAYER_PROVOKING_VERTEX or VIEWPORT_INDEX_PROVOKING_VERTEX:
429403 */
430 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D,
431 GL_LAST_VERTEX_CONVENTION = 0x8E4E,
432 GL_PROVOKING_VERTEX = 0x8E4F,
433 GL_UNDEFINED_VERTEX = 0x8260;
404 int GL_UNDEFINED_VERTEX = 0x8260;
434405
435406 @StripPostfix("v")
436407 void glViewportArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v);
449420 void glScissorIndexedv(@GLuint int index, @Check("4") @Const IntBuffer v);
450421
451422 @StripPostfix("v")
452 void glDepthRangeArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const @GLclampd DoubleBuffer v);
453
454 void glDepthRangeIndexed(@GLuint int index, @GLclampd double n, @GLclampd double f);
423 void glDepthRangeArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer v);
424
425 void glDepthRangeIndexed(@GLuint int index, double n, double f);
455426
456427 @StripPostfix("data")
457428 void glGetFloati_v(@GLenum int target, @GLuint int index, @Check @OutParameter FloatBuffer data);
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37 import java.nio.IntBuffer;
38
39 public interface GL42 {
40
41 // ----------------------------------------------------------------------------
42 // ----------------------[ ARB_texture_compression_bptc ]----------------------
43 // ----------------------------------------------------------------------------
44
45 /**
46 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D, TexImage3D,
47 * CopyTexImage2D, CopyTexImage3D, CompressedTexImage2DARB, and
48 * CompressedTexImage3DARB and the &lt;format&gt; parameter of
49 * CompressedTexSubImage2DARB and CompressedTexSubImage3DARB:
50 */
51 int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
52 int GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 0x8E8D;
53 int GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 0x8E8E;
54 int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
55
56 // ------------------------------------------------------------------------------------
57 // ----------------------[ ARB_compressed_texture_pixel_storage ]----------------------
58 // ------------------------------------------------------------------------------------
59
60 /**
61 * Accepted by the &lt;pname&gt; parameter of PixelStore[fi], GetBooleanv,
62 * GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev:
63 */
64 int GL_UNPACK_COMPRESSED_BLOCK_WIDTH = 0x9127,
65 GL_UNPACK_COMPRESSED_BLOCK_HEIGHT = 0x9128,
66 GL_UNPACK_COMPRESSED_BLOCK_DEPTH = 0x9129,
67 GL_UNPACK_COMPRESSED_BLOCK_SIZE = 0x912A,
68 GL_PACK_COMPRESSED_BLOCK_WIDTH = 0x912B,
69 GL_PACK_COMPRESSED_BLOCK_HEIGHT = 0x912C,
70 GL_PACK_COMPRESSED_BLOCK_DEPTH = 0x912D,
71 GL_PACK_COMPRESSED_BLOCK_SIZE = 0x912E;
72
73 // --------------------------------------------------------------------------
74 // ----------------------[ ARB_shader_atomic_counters ]----------------------
75 // --------------------------------------------------------------------------
76
77 /** Accepted by the &lt;target&gt; parameter of BindBufferBase and BindBufferRange: */
78 int GL_ATOMIC_COUNTER_BUFFER = 0x92C0;
79
80 /**
81 * Accepted by the &lt;pname&gt; parameter of GetBooleani_v, GetIntegeri_v,
82 * GetFloati_v, GetDoublei_v, GetInteger64i_v, GetBooleanv, GetIntegerv,
83 * GetInteger64v, GetFloatv, GetDoublev, and GetActiveAtomicCounterBufferiv:
84 */
85 int GL_ATOMIC_COUNTER_BUFFER_BINDING = 0x92C1;
86
87 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_64v: */
88 int GL_ATOMIC_COUNTER_BUFFER_START = 0x92C2,
89 GL_ATOMIC_COUNTER_BUFFER_SIZE = 0x92C3;
90
91 /** Accepted by the &lt;pname&gt; parameter of GetActiveAtomicCounterBufferiv: */
92 int GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE = 0x92C4,
93 GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS = 0x92C5,
94 GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES = 0x92C6,
95 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER = 0x92C7,
96 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 0x92C8,
97 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x92C9,
98 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 0x92CA,
99 GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 0x92CB;
100
101 /**
102 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
103 * GetInteger64v, GetFloatv, and GetDoublev:
104 */
105 int GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS = 0x92CC,
106 GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS = 0x92CD,
107 GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS = 0x92CE,
108 GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS = 0x92CF,
109 GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS = 0x92D0,
110 GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS = 0x92D1,
111 GL_MAX_VERTEX_ATOMIC_COUNTERS = 0x92D2,
112 GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS = 0x92D3,
113 GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS = 0x92D4,
114 GL_MAX_GEOMETRY_ATOMIC_COUNTERS = 0x92D5,
115 GL_MAX_FRAGMENT_ATOMIC_COUNTERS = 0x92D6,
116 GL_MAX_COMBINED_ATOMIC_COUNTERS = 0x92D7,
117 GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE = 0x92D8,
118 GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = 0x92DC;
119
120 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
121 int GL_ACTIVE_ATOMIC_COUNTER_BUFFERS = 0x92D9;
122
123 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformsiv: */
124 int GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA;
125
126 /** Returned in &lt;params&gt; by GetActiveUniform and GetActiveUniformsiv: */
127 int GL_UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB;
128
129 @StripPostfix("params")
130 void glGetActiveAtomicCounterBufferiv(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @Check("1") @OutParameter IntBuffer params);
131
132 @Alternate("glGetActiveAtomicCounterBufferiv")
133 @StripPostfix("params")
134 @GLreturn("params")
135 void glGetActiveAtomicCounterBufferiv2(@GLuint int program, @GLuint int bufferIndex, @GLenum int pname, @OutParameter IntBuffer params);
136
137 // -------------------------------------------------------------------
138 // ----------------------[ ARB_texture_storage ]----------------------
139 // -------------------------------------------------------------------
140
141 /** Accepted by the &lt;value&gt; parameter of GetTexParameter{if}v: */
142 int GL_TEXTURE_IMMUTABLE_FORMAT = 0x912F;
143
144 void glTexStorage1D(@GLenum int target, @GLsizei int levels,
145 @GLenum int internalformat,
146 @GLsizei int width);
147
148 void glTexStorage2D(@GLenum int target, @GLsizei int levels,
149 @GLenum int internalformat,
150 @GLsizei int width, @GLsizei int height);
151
152 void glTexStorage3D(@GLenum int target, @GLsizei int levels,
153 @GLenum int internalformat,
154 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
155
156 // --------------------------------------------------------------------------------
157 // ----------------------[ ARB_transform_feedback_instanced ]----------------------
158 // --------------------------------------------------------------------------------
159
160 void glDrawTransformFeedbackInstanced(@GLenum int mode, @GLuint int id, @GLsizei int primcount);
161
162 void glDrawTransformFeedbackStreamInstanced(@GLenum int mode, @GLuint int id, @GLuint int stream, @GLsizei int primcount);
163
164 // -----------------------------------------------------------------
165 // ----------------------[ ARB_base_instance ]----------------------
166 // -----------------------------------------------------------------
167
168 void glDrawArraysInstancedBaseInstance(@GLenum int mode,
169 int first,
170 @GLsizei int count,
171 @GLsizei int primcount,
172 @GLuint int baseinstance);
173
174 void glDrawElementsInstancedBaseInstance(@GLenum int mode,
175 @AutoSize("indices") @GLsizei int count,
176 @AutoType("indices") @GLenum int type,
177 @Const
178 @BufferObject(BufferKind.ElementVBO)
179 @GLubyte
180 @GLushort
181 @GLuint Buffer indices,
182 @GLsizei int primcount,
183 @GLuint int baseinstance);
184
185 void glDrawElementsInstancedBaseVertexBaseInstance(@GLenum int mode,
186 @AutoSize("indices") @GLsizei int count,
187 @AutoType("indices") @GLenum int type,
188 @Const
189 @BufferObject(BufferKind.ElementVBO)
190 @GLubyte
191 @GLushort
192 @GLuint Buffer indices,
193 @GLsizei int primcount,
194 int basevertex,
195 @GLuint int baseinstance);
196
197 // ---------------------------------------------------------------------------
198 // ----------------------[ ARB_shader_image_load_store ]----------------------
199 // ---------------------------------------------------------------------------
200
201 /**
202 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
203 * GetFloatv, GetDoublev, and GetInteger64v:
204 */
205 int GL_MAX_IMAGE_UNITS = 0x8F38,
206 GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39,
207 GL_MAX_IMAGE_SAMPLES = 0x906D,
208 GL_MAX_VERTEX_IMAGE_UNIFORMS = 0x90CA,
209 GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS = 0x90CB,
210 GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS = 0x90CC,
211 GL_MAX_GEOMETRY_IMAGE_UNIFORMS = 0x90CD,
212 GL_MAX_FRAGMENT_IMAGE_UNIFORMS = 0x90CE,
213 GL_MAX_COMBINED_IMAGE_UNIFORMS = 0x90CF;
214
215 /** Accepted by the &lt;target&gt; parameter of GetIntegeri_v and GetBooleani_v: */
216 int GL_IMAGE_BINDING_NAME = 0x8F3A,
217 GL_IMAGE_BINDING_LEVEL = 0x8F3B,
218 GL_IMAGE_BINDING_LAYERED = 0x8F3C,
219 GL_IMAGE_BINDING_LAYER = 0x8F3D,
220 GL_IMAGE_BINDING_ACCESS = 0x8F3E,
221 GL_IMAGE_BINDING_FORMAT = 0x906E;
222
223 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrier: */
224 int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT = 0x00000001,
225 GL_ELEMENT_ARRAY_BARRIER_BIT = 0x00000002,
226 GL_UNIFORM_BARRIER_BIT = 0x00000004,
227 GL_TEXTURE_FETCH_BARRIER_BIT = 0x00000008,
228 GL_SHADER_IMAGE_ACCESS_BARRIER_BIT = 0x00000020,
229 GL_COMMAND_BARRIER_BIT = 0x00000040,
230 GL_PIXEL_BUFFER_BARRIER_BIT = 0x00000080,
231 GL_TEXTURE_UPDATE_BARRIER_BIT = 0x00000100,
232 GL_BUFFER_UPDATE_BARRIER_BIT = 0x00000200,
233 GL_FRAMEBUFFER_BARRIER_BIT = 0x00000400,
234 GL_TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800,
235 GL_ATOMIC_COUNTER_BARRIER_BIT = 0x00001000,
236 GL_ALL_BARRIER_BITS = 0xFFFFFFFF;
237
238 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
239 int GL_IMAGE_1D = 0x904C,
240 GL_IMAGE_2D = 0x904D,
241 GL_IMAGE_3D = 0x904E,
242 GL_IMAGE_2D_RECT = 0x904F,
243 GL_IMAGE_CUBE = 0x9050,
244 GL_IMAGE_BUFFER = 0x9051,
245 GL_IMAGE_1D_ARRAY = 0x9052,
246 GL_IMAGE_2D_ARRAY = 0x9053,
247 GL_IMAGE_CUBE_MAP_ARRAY = 0x9054,
248 GL_IMAGE_2D_MULTISAMPLE = 0x9055,
249 GL_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9056,
250 GL_INT_IMAGE_1D = 0x9057,
251 GL_INT_IMAGE_2D = 0x9058,
252 GL_INT_IMAGE_3D = 0x9059,
253 GL_INT_IMAGE_2D_RECT = 0x905A,
254 GL_INT_IMAGE_CUBE = 0x905B,
255 GL_INT_IMAGE_BUFFER = 0x905C,
256 GL_INT_IMAGE_1D_ARRAY = 0x905D,
257 GL_INT_IMAGE_2D_ARRAY = 0x905E,
258 GL_INT_IMAGE_CUBE_MAP_ARRAY = 0x905F,
259 GL_INT_IMAGE_2D_MULTISAMPLE = 0x9060,
260 GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9061,
261 GL_UNSIGNED_INT_IMAGE_1D = 0x9062,
262 GL_UNSIGNED_INT_IMAGE_2D = 0x9063,
263 GL_UNSIGNED_INT_IMAGE_3D = 0x9064,
264 GL_UNSIGNED_INT_IMAGE_2D_RECT = 0x9065,
265 GL_UNSIGNED_INT_IMAGE_CUBE = 0x9066,
266 GL_UNSIGNED_INT_IMAGE_BUFFER = 0x9067,
267 GL_UNSIGNED_INT_IMAGE_1D_ARRAY = 0x9068,
268 GL_UNSIGNED_INT_IMAGE_2D_ARRAY = 0x9069,
269 GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY = 0x906A,
270 GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE = 0x906B,
271 GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x906C;
272
273 /**
274 * Accepted by the &lt;value&gt; parameter of GetTexParameteriv, GetTexParameterfv,
275 * GetTexParameterIiv, and GetTexParameterIuiv:
276 */
277 int GL_IMAGE_FORMAT_COMPATIBILITY_TYPE = 0x90C7;
278
279 /**
280 * Returned in the &lt;data&gt; parameter of GetTexParameteriv, GetTexParameterfv,
281 * GetTexParameterIiv, and GetTexParameterIuiv when &lt;value&gt; is
282 * IMAGE_FORMAT_COMPATIBILITY_TYPE:
283 */
284 int GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE = 0x90C8,
285 IMAGE_FORMAT_COMPATIBILITY_BY_CLASS = 0x90C9;
286
287 void glBindImageTexture(@GLuint int unit, @GLuint int texture, int level,
288 boolean layered, int layer, @GLenum int access,
289 @GLenum int format);
290
291 void glMemoryBarrier(@GLbitfield int barriers);
292
293 // -------------------------------------------------------------------------
294 // ----------------------[ ARB_internal_format_query ]----------------------
295 // -------------------------------------------------------------------------
296
297 /** Accepted by the &lt;pname&gt; parameter of GetInternalformativ: */
298 int GL_NUM_SAMPLE_COUNTS = 0x9380;
299
300 @StripPostfix("params")
301 void glGetInternalformativ(@GLenum int target, @GLenum int internalformat,
302 @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
303
304 @Alternate("glGetInternalformativ")
305 @StripPostfix("params")
306 @GLreturn("params")
307 void glGetInternalformativ2(@GLenum int target, @GLenum int internalformat,
308 @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter IntBuffer params);
309
310 // ------------------------------------------------------------------------
311 // ----------------------[ ARB_map_buffer_alignment ]----------------------
312 // ------------------------------------------------------------------------
313
314 /**
315 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
316 * GetInteger64v, GetFloatv, and GetDoublev:
317 */
318 int GL_MIN_MAP_BUFFER_ALIGNMENT = 0x90BC;
319
320 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.LongBuffer;
39 import javax.lang.model.type.TypeKind;
40
41
42 public interface GL43 {
43
44 /** No. of supported Shading Language Versions. Accepted by the &lt;pname&gt; parameter of GetIntegerv. */
45 int GL_NUM_SHADING_LANGUAGE_VERSIONS = 0x82E9;
46
47 /** Vertex attrib array has unconverted doubles. Accepted by the &lt;pname&gt; parameter of GetVertexAttribiv. */
48 int GL_VERTEX_ATTRIB_ARRAY_LONG = 0x874E;
49
50 // ---------------------------------------------------------------------
51 // ----------------------[ ARB_ES3_compatibility ]----------------------
52 // ---------------------------------------------------------------------
53
54 /** Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D */
55 int GL_COMPRESSED_RGB8_ETC2 = 0x9274,
56 GL_COMPRESSED_SRGB8_ETC2 = 0x9275,
57 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
58 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
59 GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
60 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
61 GL_COMPRESSED_R11_EAC = 0x9270,
62 GL_COMPRESSED_SIGNED_R11_EAC = 0x9271,
63 GL_COMPRESSED_RG11_EAC = 0x9272,
64 GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
65
66 /** Accepted by the &lt;target&gt; parameter of Enable and Disable: */
67 int GL_PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69;
68
69 /**
70 * Accepted by the &lt;target&gt; parameter of BeginQuery, EndQuery,
71 * GetQueryIndexediv and GetQueryiv:
72 */
73 int GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A;
74
75 /** Accepted by the &lt;value&gt; parameter of the GetInteger* functions: */
76 int GL_MAX_ELEMENT_INDEX = 0x8D6B;
77
78 // -----------------------------------------------------------------------
79 // ----------------------[ ARB_clear_buffer_object ]----------------------
80 // -----------------------------------------------------------------------
81
82 void glClearBufferData(@GLenum int target,
83 @GLenum int internalformat,
84 @GLenum int format,
85 @GLenum int type,
86 @Check("1") @Const @GLvoid ByteBuffer data);
87
88 void glClearBufferSubData(@GLenum int target,
89 @GLenum int internalformat,
90 @GLintptr long offset,
91 @GLsizeiptr long size,
92 @GLenum int format,
93 @GLenum int type,
94 @Check("1") @Const @GLvoid ByteBuffer data);
95
96 // ------------------------------------------------------------------
97 // ----------------------[ ARB_compute_shader ]----------------------
98 // ------------------------------------------------------------------
99
100 /**
101 * Accepted by the &lt;type&gt; parameter of CreateShader and returned in the
102 * &lt;params&gt; parameter by GetShaderiv:
103 */
104 int GL_COMPUTE_SHADER = 0x91B9;
105
106 /**
107 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv,
108 * GetDoublev and GetInteger64v:
109 */
110 int GL_MAX_COMPUTE_UNIFORM_BLOCKS = 0x91BB,
111 GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS = 0x91BC,
112 GL_MAX_COMPUTE_IMAGE_UNIFORMS = 0x91BD,
113 GL_MAX_COMPUTE_SHARED_MEMORY_SIZE = 0x8262,
114 GL_MAX_COMPUTE_UNIFORM_COMPONENTS = 0x8263,
115 GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS = 0x8264,
116 GL_MAX_COMPUTE_ATOMIC_COUNTERS = 0x8265,
117 GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS = 0x8266,
118 GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS = 0x90EB;
119
120 /**
121 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleani_v,
122 * GetFloati_v, GetDoublei_v and GetInteger64i_v:
123 */
124
125 int GL_MAX_COMPUTE_WORK_GROUP_COUNT = 0x91BE,
126 GL_MAX_COMPUTE_WORK_GROUP_SIZE = 0x91BF;
127
128 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
129 int GL_COMPUTE_WORK_GROUP_SIZE = 0x8267;
130
131 /** Accepted by the &lt;pname&gt; parameter of GetActiveUniformBlockiv: */
132 int GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER = 0x90EC;
133
134 /** Accepted by the &lt;pname&gt; parameter of GetActiveAtomicCounterBufferiv: */
135 int GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER = 0x90ED;
136
137 /**
138 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
139 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
140 * GetBufferPointerv:
141 */
142 int GL_DISPATCH_INDIRECT_BUFFER = 0x90EE;
143
144 /**
145 * Accepted by the &lt;value&gt; parameter of GetIntegerv, GetBooleanv,
146 * GetInteger64v, GetFloatv, and GetDoublev:
147 */
148 int GL_DISPATCH_INDIRECT_BUFFER_BINDING = 0x90EF;
149
150 /** Accepted by the &lt;stages&gt; parameter of UseProgramStages: */
151 int GL_COMPUTE_SHADER_BIT = 0x00000020;
152
153 void glDispatchCompute(@GLuint int num_groups_x,
154 @GLuint int num_groups_y,
155 @GLuint int num_groups_z);
156
157 void glDispatchComputeIndirect(@GLintptr long indirect);
158
159 // --------------------------------------------------------------
160 // ----------------------[ ARB_copy_image ]----------------------
161 // --------------------------------------------------------------
162
163 void glCopyImageSubData(
164 @GLuint int srcName, @GLenum int srcTarget, int srcLevel,
165 int srcX, int srcY, int srcZ,
166 @GLuint int dstName, @GLenum int dstTarget, int dstLevel,
167 int dstX, int dstY, int dstZ,
168 @GLsizei int srcWidth, @GLsizei int srcHeight, @GLsizei int srcDepth);
169
170 // ----------------------------------------------------------------
171 // ----------------------[ KHR_debug_output ]----------------------
172 // ----------------------[ ARB_debug_output2 ]---------------------
173 // ----------------------[ ARB_debug_group ]-----------------------
174 // ----------------------[ ARB_debug_label ]-----------------------
175 // ----------------------------------------------------------------
176
177 /**
178 * Tokens accepted by the &lt;target&gt; parameters of Enable, Disable, and
179 * IsEnabled:
180 */
181 int GL_DEBUG_OUTPUT = 0x92E0,
182 GL_DEBUG_OUTPUT_SYNCHRONOUS = 0x8242;
183
184 /** Returned by GetIntegerv when &lt;pname&gt; is CONTEXT_FLAGS: */
185 int GL_CONTEXT_FLAG_DEBUG_BIT = 0x00000002;
186
187 /**
188 * Tokens accepted by the &lt;value&gt; parameters of GetBooleanv, GetIntegerv,
189 * GetFloatv, GetDoublev and GetInteger64v:
190 */
191 int GL_MAX_DEBUG_MESSAGE_LENGTH = 0x9143,
192 GL_MAX_DEBUG_LOGGED_MESSAGES = 0x9144,
193 GL_DEBUG_LOGGED_MESSAGES = 0x9145,
194 GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243,
195 GL_MAX_DEBUG_GROUP_STACK_DEPTH = 0x826C,
196 GL_DEBUG_GROUP_STACK_DEPTH = 0x826D,
197 GL_MAX_LABEL_LENGTH = 0x82E8;
198
199 /** Tokens accepted by the &lt;pname&gt; parameter of GetPointerv: */
200 int GL_DEBUG_CALLBACK_FUNCTION = 0x8244,
201 GL_DEBUG_CALLBACK_USER_PARAM = 0x8245;
202
203 /**
204 * Tokens accepted or provided by the &lt;source&gt; parameters of
205 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;sources&gt;
206 * parameter of GetDebugMessageLog:
207 */
208 int GL_DEBUG_SOURCE_API = 0x8246,
209 GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
210 GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
211 GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
212 GL_DEBUG_SOURCE_APPLICATION = 0x824A,
213 GL_DEBUG_SOURCE_OTHER = 0x824B;
214
215 /**
216 * Tokens accepted or provided by the &lt;type&gt; parameters of
217 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;types&gt;
218 * parameter of GetDebugMessageLog:
219 */
220 int GL_DEBUG_TYPE_ERROR = 0x824C,
221 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
222 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
223 GL_DEBUG_TYPE_PORTABILITY = 0x824F,
224 GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
225 GL_DEBUG_TYPE_OTHER = 0x8251,
226 GL_DEBUG_TYPE_MARKER = 0x8268;
227
228 /**
229 * Tokens accepted or provided by the &lt;type&gt; parameters of
230 * DebugMessageControl and DEBUGPROC, and the &lt;types&gt; parameter of
231 * GetDebugMessageLog:
232 */
233 int GL_DEBUG_TYPE_PUSH_GROUP = 0x8269,
234 GL_DEBUG_TYPE_POP_GROUP = 0x826A;
235
236 /**
237 * Tokens accepted or provided by the &lt;severity&gt; parameters of
238 * DebugMessageControl, DebugMessageInsert and DEBUGPROC callback functions,
239 * and the &lt;severities&gt; parameter of GetDebugMessageLog:
240 */
241 int GL_DEBUG_SEVERITY_HIGH = 0x9146,
242 GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
243 GL_DEBUG_SEVERITY_LOW = 0x9148,
244 GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
245
246 /**
247 * Tokens accepted or provided by the &lt;identifier&gt; parameters of
248 * ObjectLabel and GetObjectLabel:
249 */
250 int GL_BUFFER = 0x82E0,
251 GL_SHADER = 0x82E1,
252 GL_PROGRAM = 0x82E2,
253 GL_QUERY = 0x82E3,
254 GL_PROGRAM_PIPELINE = 0x82E4,
255 GL_SAMPLER = 0x82E6,
256 GL_DISPLAY_LIST = 0x82E7;
257
258 // -----------------------------
259
260 void glDebugMessageControl(@GLenum int source,
261 @GLenum int type,
262 @GLenum int severity,
263 @AutoSize(value = "ids", canBeNull = true) @GLsizei int count,
264 @Check(canBeNull = true) @Const @GLuint IntBuffer ids,
265 boolean enabled);
266
267 void glDebugMessageInsert(@GLenum int source,
268 @GLenum int type,
269 @GLuint int id,
270 @GLenum int severity,
271 @AutoSize("buf") @GLsizei int length,
272 @Const @GLchar ByteBuffer buf);
273
274 @Alternate("glDebugMessageInsert")
275 void glDebugMessageInsert(@GLenum int source,
276 @GLenum int type,
277 @GLuint int id,
278 @GLenum int severity,
279 @Constant("buf.length()") @GLsizei int length,
280 CharSequence buf);
281
282 /**
283 * The {@code KHRDebugCallback.Handler} implementation passed to this method will be used for
284 * KHR_debug messages. If callback is null, any previously registered handler for the current
285 * thread will be unregistered and stop receiving messages.
286 *
287 * @param callback the callback function to use
288 */
289 @Code(
290 // Create a GlobalRef to the callback object and register it with the current context.
291 javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" +
292 "\t\tCallbackUtil.registerContextCallbackKHR(userParam);"
293 )
294 void glDebugMessageCallback(@PointerWrapper(value = "GLDEBUGPROC", canBeNull = true) KHRDebugCallback callback,
295 @Constant("userParam") @PointerWrapper("GLvoid *") long userParam);
296
297 @GLuint
298 int glGetDebugMessageLog(@GLuint int count,
299 @AutoSize(value = "messageLog", canBeNull = true) @GLsizei int bufsize,
300 @Check(value = "count", canBeNull = true) @GLenum IntBuffer sources,
301 @Check(value = "count", canBeNull = true) @GLenum IntBuffer types,
302 @Check(value = "count", canBeNull = true) @GLuint IntBuffer ids,
303 @Check(value = "count", canBeNull = true) @GLenum IntBuffer severities,
304 @Check(value = "count", canBeNull = true) @GLsizei IntBuffer lengths,
305 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer messageLog);
306
307 void glPushDebugGroup(@GLenum int source, @GLuint int id, @AutoSize("message") @GLsizei int length,
308 @Const @GLchar ByteBuffer message);
309
310 @Alternate("glPushDebugGroup")
311 void glPushDebugGroup(@GLenum int source, @GLuint int id, @Constant("message.length()") @GLsizei int length,
312 CharSequence message);
313
314 void glPopDebugGroup();
315
316 void glObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
317 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
318
319 @Alternate("glObjectLabel")
320 void glObjectLabel(@GLenum int identifier, @GLuint int name, @Constant("label.length()") @GLsizei int length,
321 CharSequence label);
322
323 void glGetObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize("label") @GLsizei int bufSize,
324 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
325 @OutParameter @GLchar ByteBuffer label);
326
327 @Alternate("glGetObjectLabel")
328 @GLreturn(value = "label", maxLength = "bufSize")
329 void glGetObjectLabel2(@GLenum int identifier, @GLuint int name, @GLsizei int bufSize,
330 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
331 @OutParameter @GLchar ByteBuffer label);
332
333 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
334 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
335
336 @Alternate("glObjectPtrLabel")
337 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @Constant("label.length()") @GLsizei int length,
338 CharSequence label);
339
340 void glGetObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize("label") @GLsizei int bufSize,
341 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
342 @OutParameter @GLchar ByteBuffer label);
343
344 @Alternate("glGetObjectPtrLabel")
345 @GLreturn(value = "label", maxLength = "bufSize")
346 void glGetObjectPtrLabel2(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @GLsizei int bufSize,
347 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
348 @OutParameter @GLchar ByteBuffer label);
349
350 // -----------------------------------------------------------------------------
351 // ----------------------[ ARB_explicit_uniform_location ]----------------------
352 // -----------------------------------------------------------------------------
353
354 /**
355 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
356 * GetFloatv, GetDoublev, and GetInteger64v:
357 */
358 int GL_MAX_UNIFORM_LOCATIONS = 0x826E;
359
360 // -----------------------------------------------------------------------------
361 // ----------------------[ ARB_framebuffer_no_attachment ]----------------------
362 // -----------------------------------------------------------------------------
363
364 /**
365 * Accepted by the &lt;pname&gt; parameter of FramebufferParameteri,
366 * GetFramebufferParameteriv, NamedFramebufferParameteriEXT, and
367 * GetNamedFramebufferParameterivEXT:
368 */
369 int GL_FRAMEBUFFER_DEFAULT_WIDTH = 0x9310,
370 GL_FRAMEBUFFER_DEFAULT_HEIGHT = 0x9311,
371 GL_FRAMEBUFFER_DEFAULT_LAYERS = 0x9312,
372 GL_FRAMEBUFFER_DEFAULT_SAMPLES = 0x9313,
373 GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314;
374
375 /**
376 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv,
377 * GetInteger64v, GetFloatv, and GetDoublev:
378 */
379 int GL_MAX_FRAMEBUFFER_WIDTH = 0x9315,
380 GL_MAX_FRAMEBUFFER_HEIGHT = 0x9316,
381 GL_MAX_FRAMEBUFFER_LAYERS = 0x9317,
382 GL_MAX_FRAMEBUFFER_SAMPLES = 0x9318;
383
384 void glFramebufferParameteri(@GLenum int target, @GLenum int pname, int param);
385
386 @StripPostfix("params")
387 void glGetFramebufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
388
389 @Alternate("glGetFramebufferParameteriv")
390 @GLreturn("params")
391 @StripPostfix(value = "params", hasPostfix = false)
392 void glGetFramebufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
393
394 // -----------------------------------------------------------------------------
395 // ----------------------[ ARB_internalformat_query2 ]----------------------
396 // -----------------------------------------------------------------------------
397
398 /**
399 * Accepted by the &lt;pname&gt; parameter of GetInternalformativ
400 * and GetInternalformati64v:
401 */
402 int GL_INTERNALFORMAT_SUPPORTED = 0x826F,
403 GL_INTERNALFORMAT_PREFERRED = 0x8270,
404 GL_INTERNALFORMAT_RED_SIZE = 0x8271,
405 GL_INTERNALFORMAT_GREEN_SIZE = 0x8272,
406 GL_INTERNALFORMAT_BLUE_SIZE = 0x8273,
407 GL_INTERNALFORMAT_ALPHA_SIZE = 0x8274,
408 GL_INTERNALFORMAT_DEPTH_SIZE = 0x8275,
409 GL_INTERNALFORMAT_STENCIL_SIZE = 0x8276,
410 GL_INTERNALFORMAT_SHARED_SIZE = 0x8277,
411 GL_INTERNALFORMAT_RED_TYPE = 0x8278,
412 GL_INTERNALFORMAT_GREEN_TYPE = 0x8279,
413 GL_INTERNALFORMAT_BLUE_TYPE = 0x827A,
414 GL_INTERNALFORMAT_ALPHA_TYPE = 0x827B,
415 GL_INTERNALFORMAT_DEPTH_TYPE = 0x827C,
416 GL_INTERNALFORMAT_STENCIL_TYPE = 0x827D,
417 GL_MAX_WIDTH = 0x827E,
418 GL_MAX_HEIGHT = 0x827F,
419 GL_MAX_DEPTH = 0x8280,
420 GL_MAX_LAYERS = 0x8281,
421 GL_MAX_COMBINED_DIMENSIONS = 0x8282,
422 GL_COLOR_COMPONENTS = 0x8283,
423 GL_DEPTH_COMPONENTS = 0x8284,
424 GL_STENCIL_COMPONENTS = 0x8285,
425 GL_COLOR_RENDERABLE = 0x8286,
426 GL_DEPTH_RENDERABLE = 0x8287,
427 GL_STENCIL_RENDERABLE = 0x8288,
428 GL_FRAMEBUFFER_RENDERABLE = 0x8289,
429 GL_FRAMEBUFFER_RENDERABLE_LAYERED = 0x828A,
430 GL_FRAMEBUFFER_BLEND = 0x828B,
431 GL_READ_PIXELS = 0x828C,
432 GL_READ_PIXELS_FORMAT = 0x828D,
433 GL_READ_PIXELS_TYPE = 0x828E,
434 GL_TEXTURE_IMAGE_FORMAT = 0x828F,
435 GL_TEXTURE_IMAGE_TYPE = 0x8290,
436 GL_GET_TEXTURE_IMAGE_FORMAT = 0x8291,
437 GL_GET_TEXTURE_IMAGE_TYPE = 0x8292,
438 GL_MIPMAP = 0x8293,
439 GL_MANUAL_GENERATE_MIPMAP = 0x8294,
440 GL_AUTO_GENERATE_MIPMAP = 0x8295,
441 GL_COLOR_ENCODING = 0x8296,
442 GL_SRGB_READ = 0x8297,
443 GL_SRGB_WRITE = 0x8298,
444 GL_SRGB_DECODE_ARB = 0x8299,
445 GL_FILTER = 0x829A,
446 GL_VERTEX_TEXTURE = 0x829B,
447 GL_TESS_CONTROL_TEXTURE = 0x829C,
448 GL_TESS_EVALUATION_TEXTURE = 0x829D,
449 GL_GEOMETRY_TEXTURE = 0x829E,
450 GL_FRAGMENT_TEXTURE = 0x829F,
451 GL_COMPUTE_TEXTURE = 0x82A0,
452 GL_TEXTURE_SHADOW = 0x82A1,
453 GL_TEXTURE_GATHER = 0x82A2,
454 GL_TEXTURE_GATHER_SHADOW = 0x82A3,
455 GL_SHADER_IMAGE_LOAD = 0x82A4,
456 GL_SHADER_IMAGE_STORE = 0x82A5,
457 GL_SHADER_IMAGE_ATOMIC = 0x82A6,
458 GL_IMAGE_TEXEL_SIZE = 0x82A7,
459 GL_IMAGE_COMPATIBILITY_CLASS = 0x82A8,
460 GL_IMAGE_PIXEL_FORMAT = 0x82A9,
461 GL_IMAGE_PIXEL_TYPE = 0x82AA,
462 GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST = 0x82AC,
463 GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST = 0x82AD,
464 GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE = 0x82AE,
465 GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE = 0x82AF,
466 GL_TEXTURE_COMPRESSED_BLOCK_WIDTH = 0x82B1,
467 GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT = 0x82B2,
468 GL_TEXTURE_COMPRESSED_BLOCK_SIZE = 0x82B3,
469 GL_CLEAR_BUFFER = 0x82B4,
470 GL_TEXTURE_VIEW = 0x82B5,
471 GL_VIEW_COMPATIBILITY_CLASS = 0x82B6;
472
473 /**
474 * Returned as possible responses for various &lt;pname&gt; queries
475 * to GetInternalformativ and GetInternalformati64v
476 */
477 int GL_FULL_SUPPORT = 0x82B7,
478 GL_CAVEAT_SUPPORT = 0x82B8,
479 GL_IMAGE_CLASS_4_X_32 = 0x82B9,
480 GL_IMAGE_CLASS_2_X_32 = 0x82BA,
481 GL_IMAGE_CLASS_1_X_32 = 0x82BB,
482 GL_IMAGE_CLASS_4_X_16 = 0x82BC,
483 GL_IMAGE_CLASS_2_X_16 = 0x82BD,
484 GL_IMAGE_CLASS_1_X_16 = 0x82BE,
485 GL_IMAGE_CLASS_4_X_8 = 0x82BF,
486 GL_IMAGE_CLASS_2_X_8 = 0x82C0,
487 GL_IMAGE_CLASS_1_X_8 = 0x82C1,
488 GL_IMAGE_CLASS_11_11_10 = 0x82C2,
489 GL_IMAGE_CLASS_10_10_10_2 = 0x82C3,
490 GL_VIEW_CLASS_128_BITS = 0x82C4,
491 GL_VIEW_CLASS_96_BITS = 0x82C5,
492 GL_VIEW_CLASS_64_BITS = 0x82C6,
493 GL_VIEW_CLASS_48_BITS = 0x82C7,
494 GL_VIEW_CLASS_32_BITS = 0x82C8,
495 GL_VIEW_CLASS_24_BITS = 0x82C9,
496 GL_VIEW_CLASS_16_BITS = 0x82CA,
497 GL_VIEW_CLASS_8_BITS = 0x82CB,
498 GL_VIEW_CLASS_S3TC_DXT1_RGB = 0x82CC,
499 GL_VIEW_CLASS_S3TC_DXT1_RGBA = 0x82CD,
500 GL_VIEW_CLASS_S3TC_DXT3_RGBA = 0x82CE,
501 GL_VIEW_CLASS_S3TC_DXT5_RGBA = 0x82CF,
502 GL_VIEW_CLASS_RGTC1_RED = 0x82D0,
503 GL_VIEW_CLASS_RGTC2_RG = 0x82D1,
504 GL_VIEW_CLASS_BPTC_UNORM = 0x82D2,
505 GL_VIEW_CLASS_BPTC_FLOAT = 0x82D3;
506
507 @StripPostfix("params")
508 void glGetInternalformati64v(@GLenum int target, @GLenum int internalformat,
509 @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter @GLint64 LongBuffer params);
510
511 @Alternate("glGetInternalformati64v")
512 @GLreturn("params")
513 @StripPostfix(value = "params", hasPostfix = false)
514 void glGetInternalformati64v2(@GLenum int target, @GLenum int internalformat,
515 @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter @GLint64 LongBuffer params);
516
517 // ----------------------------------------------------------------------
518 // ----------------------[ ARB_invalidate_subdata ]----------------------
519 // ----------------------------------------------------------------------
520
521 void glInvalidateTexSubImage(@GLuint int texture, int level,
522 int xoffset, int yoffset, int zoffset,
523 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
524
525 void glInvalidateTexImage(@GLuint int texture, int level);
526
527 void glInvalidateBufferSubData(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
528
529 void glInvalidateBufferData(@GLuint int buffer);
530
531 void glInvalidateFramebuffer(@GLenum int target,
532 @AutoSize("attachments") @GLsizei int numAttachments,
533 @Const @GLenum IntBuffer attachments);
534
535 void glInvalidateSubFramebuffer(@GLenum int target,
536 @AutoSize("attachments") @GLsizei int numAttachments,
537 @Const @GLenum IntBuffer attachments,
538 int x, int y, @GLsizei int width, @GLsizei int height);
539
540 // -----------------------------------------------------------------------
541 // ----------------------[ ARB_multi_draw_indirect ]----------------------
542 // -----------------------------------------------------------------------
543
544 void glMultiDrawArraysIndirect(@GLenum int mode,
545 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
546 @GLsizei int primcount,
547 @GLsizei int stride);
548
549 @Alternate("glMultiDrawArraysIndirect")
550 void glMultiDrawArraysIndirect(@GLenum int mode,
551 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 4 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
552 @GLsizei int primcount,
553 @GLsizei int stride);
554
555 void glMultiDrawElementsIndirect(@GLenum int mode,
556 @GLenum int type,
557 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 * 4 : stride) * primcount") @Const @GLvoid ByteBuffer indirect,
558 @GLsizei int primcount,
559 @GLsizei int stride);
560
561 @Alternate("glMultiDrawElementsIndirect")
562 void glMultiDrawElementsIndirect(@GLenum int mode,
563 @GLenum int type,
564 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * primcount") @Const @GLvoid(TypeKind.INT) IntBuffer indirect,
565 @GLsizei int primcount,
566 @GLsizei int stride);
567
568 // ---------------------------------------------------------------------------
569 // ----------------------[ ARB_program_interface_query ]----------------------
570 // ---------------------------------------------------------------------------
571
572 /**
573 * Accepted by the &lt;programInterface&gt; parameter of GetProgramInterfaceiv,
574 * GetProgramResourceIndex, GetProgramResourceName, GetProgramResourceiv,
575 * GetProgramResourceLocation, and GetProgramResourceLocationIndex:
576 */
577 int GL_UNIFORM = 0x92E1,
578 GL_UNIFORM_BLOCK = 0x92E2,
579 GL_PROGRAM_INPUT = 0x92E3,
580 GL_PROGRAM_OUTPUT = 0x92E4,
581 GL_BUFFER_VARIABLE = 0x92E5,
582 GL_SHADER_STORAGE_BLOCK = 0x92E6,
583 GL_VERTEX_SUBROUTINE = 0x92E8,
584 GL_TESS_CONTROL_SUBROUTINE = 0x92E9,
585 GL_TESS_EVALUATION_SUBROUTINE = 0x92EA,
586 GL_GEOMETRY_SUBROUTINE = 0x92EB,
587 GL_FRAGMENT_SUBROUTINE = 0x92EC,
588 GL_COMPUTE_SUBROUTINE = 0x92ED,
589 GL_VERTEX_SUBROUTINE_UNIFORM = 0x92EE,
590 GL_TESS_CONTROL_SUBROUTINE_UNIFORM = 0x92EF,
591 GL_TESS_EVALUATION_SUBROUTINE_UNIFORM = 0x92F0,
592 GL_GEOMETRY_SUBROUTINE_UNIFORM = 0x92F1,
593 GL_FRAGMENT_SUBROUTINE_UNIFORM = 0x92F2,
594 GL_COMPUTE_SUBROUTINE_UNIFORM = 0x92F3,
595 GL_TRANSFORM_FEEDBACK_VARYING = 0x92F4;
596
597 /** Accepted by the &lt;pname&gt; parameter of GetProgramInterfaceiv: */
598 int GL_ACTIVE_RESOURCES = 0x92F5,
599 GL_MAX_NAME_LENGTH = 0x92F6,
600 GL_MAX_NUM_ACTIVE_VARIABLES = 0x92F7,
601 GL_MAX_NUM_COMPATIBLE_SUBROUTINES = 0x92F8;
602
603 /** Accepted in the &lt;props&gt; array of GetProgramResourceiv: */
604 int GL_NAME_LENGTH = 0x92F9,
605 GL_TYPE = 0x92FA,
606 GL_ARRAY_SIZE = 0x92FB,
607 GL_OFFSET = 0x92FC,
608 GL_BLOCK_INDEX = 0x92FD,
609 GL_ARRAY_STRIDE = 0x92FE,
610 GL_MATRIX_STRIDE = 0x92FF,
611 GL_IS_ROW_MAJOR = 0x9300,
612 GL_ATOMIC_COUNTER_BUFFER_INDEX = 0x9301,
613 GL_BUFFER_BINDING = 0x9302,
614 GL_BUFFER_DATA_SIZE = 0x9303,
615 GL_NUM_ACTIVE_VARIABLES = 0x9304,
616 GL_ACTIVE_VARIABLES = 0x9305,
617 GL_REFERENCED_BY_VERTEX_SHADER = 0x9306,
618 GL_REFERENCED_BY_TESS_CONTROL_SHADER = 0x9307,
619 GL_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x9308,
620 GL_REFERENCED_BY_GEOMETRY_SHADER = 0x9309,
621 GL_REFERENCED_BY_FRAGMENT_SHADER = 0x930A,
622 GL_REFERENCED_BY_COMPUTE_SHADER = 0x930B,
623 GL_TOP_LEVEL_ARRAY_SIZE = 0x930C,
624 GL_TOP_LEVEL_ARRAY_STRIDE = 0x930D,
625 GL_LOCATION = 0x930E,
626 GL_LOCATION_INDEX = 0x930F,
627 GL_IS_PER_PATCH = 0x92E7;
628
629 @StripPostfix("params")
630 void glGetProgramInterfaceiv(@GLuint int program, @GLenum int programInterface,
631 @GLenum int pname, @Check("1") @OutParameter IntBuffer params);
632
633 @Alternate("glGetProgramInterfaceiv")
634 @GLreturn("params")
635 @StripPostfix(value = "params", hasPostfix = false)
636 void glGetProgramInterfaceiv2(@GLuint int program, @GLenum int programInterface,
637 @GLenum int pname, @OutParameter IntBuffer params);
638
639 @GLuint
640 int glGetProgramResourceIndex(@GLuint int program, @GLenum int programInterface,
641 @NullTerminated @Const @GLchar ByteBuffer name);
642
643 @Alternate("glGetProgramResourceIndex")
644 @GLuint
645 int glGetProgramResourceIndex(@GLuint int program, @GLenum int programInterface,
646 @NullTerminated CharSequence name);
647
648 void glGetProgramResourceName(@GLuint int program, @GLenum int programInterface,
649 @GLuint int index, @AutoSize(value = "name", canBeNull = true) @GLsizei int bufSize, @Check(value = "1", canBeNull = true) @OutParameter @GLsizei IntBuffer length,
650 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer name);
651
652 @Alternate("glGetProgramResourceName")
653 @GLreturn(value = "name", maxLength = "bufSize")
654 void glGetProgramResourceName2(@GLuint int program, @GLenum int programInterface,
655 @GLuint int index, @GLsizei int bufSize,
656 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
657 @OutParameter @GLchar ByteBuffer name);
658
659 @StripPostfix("params")
660 void glGetProgramResourceiv(@GLuint int program, @GLenum int programInterface,
661 @GLuint int index, @AutoSize("props") @GLsizei int propCount,
662 @Const @GLenum IntBuffer props, @AutoSize("params") @GLsizei int bufSize,
663 @Check(value = "1", canBeNull = true) @OutParameter @GLsizei IntBuffer length, @OutParameter IntBuffer params);
664
665 int glGetProgramResourceLocation(@GLuint int program, @GLenum int programInterface,
666 @NullTerminated @Const @GLchar ByteBuffer name);
667
668 @Alternate("glGetProgramResourceLocation")
669 int glGetProgramResourceLocation(@GLuint int program, @GLenum int programInterface,
670 @NullTerminated CharSequence name);
671
672 int glGetProgramResourceLocationIndex(@GLuint int program, @GLenum int programInterface,
673 @NullTerminated @Const @GLchar ByteBuffer name);
674
675 @Alternate("glGetProgramResourceLocationIndex")
676 int glGetProgramResourceLocationIndex(@GLuint int program, @GLenum int programInterface,
677 @NullTerminated CharSequence name);
678
679 // --------------------------------------------------------------------------------
680 // ----------------------[ ARB_shader_storage_buffer_object ]----------------------
681 // --------------------------------------------------------------------------------
682
683 /**
684 * Accepted by the &lt;target&gt; parameters of BindBuffer, BufferData,
685 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
686 * GetBufferPointerv:
687 */
688 int GL_SHADER_STORAGE_BUFFER = 0x90D2;
689
690 /**
691 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetIntegeri_v,
692 * GetBooleanv, GetInteger64v, GetFloatv, GetDoublev, GetBooleani_v,
693 * GetIntegeri_v, GetFloati_v, GetDoublei_v, and GetInteger64i_v:
694 */
695 int GL_SHADER_STORAGE_BUFFER_BINDING = 0x90D3;
696
697 /**
698 * Accepted by the &lt;pname&gt; parameter of GetIntegeri_v, GetBooleani_v,
699 * GetIntegeri_v, GetFloati_v, GetDoublei_v, and GetInteger64i_v:
700 */
701 int GL_SHADER_STORAGE_BUFFER_START = 0x90D4,
702 GL_SHADER_STORAGE_BUFFER_SIZE = 0x90D5;
703
704 /**
705 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv,
706 * GetInteger64v, GetFloatv, and GetDoublev:
707 */
708 int GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS = 0x90D6,
709 GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS = 0x90D7,
710 GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS = 0x90D8,
711 GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS = 0x90D9,
712 GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS = 0x90DA,
713 GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS = 0x90DB,
714 GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS = 0x90DC,
715 GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 0x90DD,
716 GL_MAX_SHADER_STORAGE_BLOCK_SIZE = 0x90DE,
717 GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT = 0x90DF;
718
719 /** Accepted in the &lt;barriers&gt; bitfield in glMemoryBarrier: */
720 int GL_SHADER_STORAGE_BARRIER_BIT = 0x2000;
721
722 /**
723 * Alias for the existing token
724 * MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS:
725 */
726 int GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES = 0x8F39;
727
728 void glShaderStorageBlockBinding(@GLuint int program, @GLuint int storageBlockIndex,
729 @GLuint int storageBlockBinding);
730
731 // ---------------------------------------------------------------------
732 // ----------------------[ ARB_stencil_texturing ]----------------------
733 // ---------------------------------------------------------------------
734
735 /** Accepted by the &lt;pname&gt; parameter of TexParameter* and GetTexParameter*: */
736 int GL_DEPTH_STENCIL_TEXTURE_MODE = 0x90EA;
737
738 // ------------------------------------------------------------------------
739 // ----------------------[ ARB_texture_buffer_range ]----------------------
740 // ------------------------------------------------------------------------
741
742 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter: */
743 int GL_TEXTURE_BUFFER_OFFSET = 0x919D,
744 GL_TEXTURE_BUFFER_SIZE = 0x919E;
745
746 /**
747 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
748 * and GetDoublev:
749 */
750 int GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT = 0x919F;
751
752 void glTexBufferRange(@GLenum int target,
753 @GLenum int internalformat,
754 @GLuint int buffer,
755 @GLintptr long offset,
756 @GLsizeiptr long size);
757
758 // -------------------------------------------------------------------------------
759 // ----------------------[ ARB_texture_storage_multisample ]----------------------
760 // -------------------------------------------------------------------------------
761
762 void glTexStorage2DMultisample(@GLenum int target,
763 @GLsizei int samples,
764 @GLenum int internalformat,
765 @GLsizei int width,
766 @GLsizei int height,
767 boolean fixedsamplelocations);
768
769 void glTexStorage3DMultisample(@GLenum int target,
770 @GLsizei int samples,
771 @GLenum int internalformat,
772 @GLsizei int width,
773 @GLsizei int height,
774 @GLsizei int depth,
775 boolean fixedsamplelocations);
776
777 // ----------------------------------------------------------------
778 // ----------------------[ ARB_texture_view ]----------------------
779 // ----------------------------------------------------------------
780
781 /**
782 * Accepted by the &lt;pname&gt; parameters of GetTexParameterfv and
783 * GetTexParameteriv:
784 */
785 int GL_TEXTURE_VIEW_MIN_LEVEL = 0x82DB,
786 GL_TEXTURE_VIEW_NUM_LEVELS = 0x82DC,
787 GL_TEXTURE_VIEW_MIN_LAYER = 0x82DD,
788 GL_TEXTURE_VIEW_NUM_LAYERS = 0x82DE,
789 GL_TEXTURE_IMMUTABLE_LEVELS = 0x82DF;
790
791 void glTextureView(@GLuint int texture, @GLenum int target, @GLuint int origtexture,
792 @GLenum int internalformat,
793 @GLuint int minlevel, @GLuint int numlevels,
794 @GLuint int minlayer, @GLuint int numlayers);
795
796 // -------------------------------------------------------------------------
797 // ----------------------[ ARB_vertex_attrib_binding ]----------------------
798 // -------------------------------------------------------------------------
799
800 /** Accepted by the &lt;pname&gt; parameter of GetVertexAttrib*v: */
801 int GL_VERTEX_ATTRIB_BINDING = 0x82D4,
802 GL_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D5;
803
804 /**
805 * Accepted by the &lt;target&gt; parameter of GetBooleani_v, GetIntegeri_v,
806 * GetFloati_v, GetDoublei_v, and GetInteger64i_v:
807 */
808 int GL_VERTEX_BINDING_DIVISOR = 0x82D6,
809 GL_VERTEX_BINDING_OFFSET = 0x82D7,
810 GL_VERTEX_BINDING_STRIDE = 0x82D8;
811
812 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv, ... */
813 int GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D9,
814 GL_MAX_VERTEX_ATTRIB_BINDINGS = 0x82DA;
815
816 void glBindVertexBuffer(@GLuint int bindingindex, @GLuint int buffer, @GLintptr long offset,
817 @GLsizei int stride);
818
819 void glVertexAttribFormat(@GLuint int attribindex, int size, @GLenum int type,
820 boolean normalized, @GLuint int relativeoffset);
821
822 void glVertexAttribIFormat(@GLuint int attribindex, int size, @GLenum int type,
823 @GLuint int relativeoffset);
824
825 void glVertexAttribLFormat(@GLuint int attribindex, int size, @GLenum int type,
826 @GLuint int relativeoffset);
827
828 void glVertexAttribBinding(@GLuint int attribindex, @GLuint int bindingindex);
829
830 void glVertexBindingDivisor(@GLuint int bindingindex, @GLuint int divisor);
831
832 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.Buffer;
38 import java.nio.IntBuffer;
39
40 public interface GL44 {
41
42 /** Implementation-dependent state which constrains the maximum value of stride parameters to vertex array pointer-setting commands. */
43 int GL_MAX_VERTEX_ATTRIB_STRIDE = 0x82E5;
44
45 // ------------------------------------------------------------------
46 // ----------------------[ ARB_buffer_storage ]----------------------
47 // ------------------------------------------------------------------
48
49 /**
50 * Accepted in the &lt;flags&gt; parameter of BufferStorage and
51 * NamedBufferStorageEXT:
52 */
53 int GL_MAP_PERSISTENT_BIT = 0x0040,
54 GL_MAP_COHERENT_BIT = 0x0080,
55 GL_DYNAMIC_STORAGE_BIT = 0x0100,
56 GL_CLIENT_STORAGE_BIT = 0x0200;
57
58 /** Accepted by the &lt;pname&gt; parameter of GetBufferParameter{i|i64}v:\ */
59
60 int GL_BUFFER_IMMUTABLE_STORAGE = 0x821F,
61 GL_BUFFER_STORAGE_FLAGS = 0x8220;
62
63 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrier: */
64 int GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT = 0x00004000;
65
66 void glBufferStorage(@GLenum int target,
67 @AutoSize("data") @GLsizeiptr long size,
68 @Const
69 @GLbyte
70 @GLshort
71 @GLint
72 @GLuint64
73 @GLfloat
74 @GLdouble Buffer data,
75 @GLbitfield int flags);
76
77 @Alternate("glBufferStorage")
78 void glBufferStorage2(@GLenum int target,
79 @GLsizeiptr long size,
80 @Constant("0L") @Const Buffer data,
81 @GLbitfield int flags);
82
83 // -----------------------------------------------------------------
84 // ----------------------[ ARB_clear_texture ]----------------------
85 // -----------------------------------------------------------------
86
87 /**
88 * Accepted by the &lt;pname&gt; parameter for GetInternalformativ and
89 * GetInternalformati64v:
90 */
91 int GL_CLEAR_TEXTURE = 0x9365;
92
93 void glClearTexImage(@GLuint int texture, int level,
94 @GLenum int format, @GLenum int type,
95 @Check(value = "1", canBeNull = true)
96 @Const
97 @GLbyte
98 @GLshort
99 @GLint
100 @GLuint64
101 @GLfloat
102 @GLdouble Buffer data);
103
104 void glClearTexSubImage(@GLuint int texture, int level,
105 int xoffset, int yoffset, int zoffset,
106 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
107 @GLenum int format, @GLenum int type,
108 @Check(value = "1", canBeNull = true)
109 @Const
110 @GLbyte
111 @GLshort
112 @GLint
113 @GLuint64
114 @GLfloat
115 @GLdouble Buffer data);
116
117 // --------------------------------------------------------------------
118 // ----------------------[ ARB_enhanced_layouts ]----------------------
119 // --------------------------------------------------------------------
120
121 /** Accepted in the &lt;props&gt; array of GetProgramResourceiv: */
122 int GL_LOCATION_COMPONENT = 0x934A,
123 GL_TRANSFORM_FEEDBACK_BUFFER_INDEX = 0x934B,
124 GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE = 0x934C;
125
126 // --------------------------------------------------------------
127 // ----------------------[ ARB_multi_bind ]----------------------
128 // --------------------------------------------------------------
129
130 void glBindBuffersBase(@GLenum int target, @GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers);
131
132 void glBindBuffersRange(@GLenum int target, @GLuint int first, @GLsizei int count,
133 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
134 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
135 @Check(value = "count", canBeNull = true) @Const @GLsizeiptr PointerBuffer sizes);
136
137 void glBindTextures(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer textures);
138
139 void glBindSamplers(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer samplers);
140
141 void glBindImageTextures(@GLuint int first, @GLsizei int count, @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer textures);
142
143 void glBindVertexBuffers(@GLuint int first, @GLsizei int count,
144 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
145 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
146 @Check(value = "count", canBeNull = true) @Const @GLsizei IntBuffer strides);
147
148 // -----------------------------------------------------------------------
149 // ----------------------[ ARB_query_buffer_object ]----------------------
150 // -----------------------------------------------------------------------
151
152 /**
153 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv, GetQueryObjectuiv,
154 * GetQueryObjecti64v and GetQueryObjectui64v:
155 */
156 int GL_QUERY_RESULT_NO_WAIT = 0x9194;
157
158 /**
159 * Accepted by the &lt;target&gt; parameter of BindBuffer, BufferData,
160 * BufferSubData, MapBuffer, UnmapBuffer, MapBufferRange, GetBufferSubData,
161 * GetBufferParameteriv, GetBufferParameteri64v, GetBufferPointerv,
162 * ClearBufferSubData, and the &lt;readtarget&gt; and &lt;writetarget&gt; parameters of
163 * CopyBufferSubData:
164 */
165 int GL_QUERY_BUFFER = 0x9192;
166
167 /**
168 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
169 * and GetDoublev:
170 */
171 int GL_QUERY_BUFFER_BINDING = 0x9193;
172
173 /** Accepted in the &lt;barriers&gt; bitfield in MemoryBarrier: */
174 int GL_QUERY_BUFFER_BARRIER_BIT = 0x00008000;
175
176 // --------------------------------------------------------------------------------
177 // ----------------------[ ARB_texture_mirror_clamp_to_edge ]----------------------
178 // --------------------------------------------------------------------------------
179
180 /**
181 * Accepted by the &lt;param&gt; parameter of TexParameter{if}, SamplerParameter{if}
182 * and SamplerParameter{if}v, and by the &lt;params&gt; parameter of
183 * TexParameter{if}v, TexParameterI{i ui}v and SamplerParameterI{i ui}v when
184 * their &lt;pname&gt; parameter is TEXTURE_WRAP_S, TEXTURE_WRAP_T, or
185 * TEXTURE_WRAP_R:
186 */
187 int GL_MIRROR_CLAMP_TO_EDGE = 0x8743;
188
189 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.*;
38
39 public interface GL45 {
40
41 // ----------------------------------------------------------------
42 // ----------------------[ ARB_clip_control ]----------------------
43 // ----------------------------------------------------------------
44
45 /** Accepted by the &lt;depth&gt; parameter of ClipControl: */
46 int GL_NEGATIVE_ONE_TO_ONE = 0x935E,
47 GL_ZERO_TO_ONE = 0x935F;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
51 * GetFloatv, and GetDoublev:
52 */
53 int GL_CLIP_ORIGIN = 0x935C,
54 GL_CLIP_DEPTH_MODE = 0x935D;
55
56 void glClipControl(@GLenum int origin, @GLenum int depth);
57
58 // -------------------------------------------------------------------------------
59 // ----------------------[ ARB_conditional_render_inverted ]----------------------
60 // -------------------------------------------------------------------------------
61
62 /** Accepted by the &lt;mode&gt; parameter of BeginConditionalRender: */
63 int GL_QUERY_WAIT_INVERTED = 0x8E17,
64 GL_QUERY_NO_WAIT_INVERTED = 0x8E18,
65 GL_QUERY_BY_REGION_WAIT_INVERTED = 0x8E19,
66 GL_QUERY_BY_REGION_NO_WAIT_INVERTED = 0x8E1A;
67
68 // -----------------------------------------------------------------
69 // ----------------------[ ARB_cull_distance ]----------------------
70 // -----------------------------------------------------------------
71
72 /** Accepted by the &lt;pname&gt; parameter of GetBooeleanv, GetDoublev, GetFloatv GetIntegerv, and GetInteger64v: */
73 int GL_MAX_CULL_DISTANCES = 0x82F9,
74 GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 0x82FA;
75
76 // -----------------------------------------------------------------------
77 // ----------------------[ ARB_direct_state_access ]----------------------
78 // -----------------------------------------------------------------------
79
80 /**
81 * Accepted by the &lt;pname&gt; parameter of GetTextureParameter{if}v and
82 * GetTextureParameterI{i ui}v:
83 */
84 int GL_TEXTURE_TARGET = 0x1006;
85
86 /** Accepted by the &lt;pname&gt; parameter of GetQueryObjectiv: */
87 int GL_QUERY_TARGET = 0x82EA;
88
89 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
90 int GL_TEXTURE_BINDING = 0x82EB;
91
92 // Transform Feedback object functions
93
94 void glCreateTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
95
96 @Alternate("glCreateTransformFeedbacks")
97 @GLreturn("ids")
98 void glCreateTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
99
100 void glTransformFeedbackBufferBase(@GLuint int xfb, @GLuint int index, @GLuint int buffer);
101
102 void glTransformFeedbackBufferRange(@GLuint int xfb, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
103
104 @StripPostfix("param")
105 void glGetTransformFeedbackiv(@GLuint int xfb, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
106
107 @Alternate("glGetTransformFeedbackiv")
108 @GLreturn("param")
109 @StripPostfix(value = "param", hasPostfix = false)
110 void glGetTransformFeedbackiv2(@GLuint int xfb, @GLenum int pname, @OutParameter IntBuffer param);
111
112 @StripPostfix("param")
113 void glGetTransformFeedbacki_v(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @Check("1") IntBuffer param);
114
115 @Alternate("glGetTransformFeedbacki_v")
116 @GLreturn("param")
117 @StripPostfix(value = "param", postfix = "_v")
118 void glGetTransformFeedbacki_v2(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter IntBuffer param);
119
120 @StripPostfix("param")
121 void glGetTransformFeedbacki64_v(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @Check("1") @GLint64 LongBuffer param);
122
123 @Alternate("glGetTransformFeedbacki64_v")
124 @GLreturn("param")
125 @StripPostfix(value = "param", postfix = "_v")
126 void glGetTransformFeedbacki64_v2(@GLuint int xfb, @GLenum int pname, @GLuint int index, @OutParameter @GLint64 LongBuffer param);
127
128 // Buffer object functions
129
130 void glCreateBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
131
132 @Alternate("glCreateBuffers")
133 @GLreturn("buffers")
134 void glCreateBuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
135
136 void glNamedBufferStorage(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
137 @Const
138 @GLbyte
139 @GLshort
140 @GLint
141 @GLuint64
142 @GLfloat
143 @GLdouble Buffer data,
144 @GLbitfield int flags);
145
146 @Alternate("glNamedBufferStorage")
147 void glNamedBufferStorage2(@GLuint int buffer, @GLsizeiptr long size, @Constant("0L") @Const Buffer data, @GLbitfield int flags);
148
149 @GenerateAutos
150 void glNamedBufferData(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size,
151 @Check
152 @Const
153 @GLbyte
154 @GLshort
155 @GLint
156 @GLfloat
157 @GLdouble Buffer data,
158 @GLenum int usage);
159
160 void glNamedBufferSubData(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
161 @Check
162 @Const
163 @GLbyte
164 @GLshort
165 @GLint
166 @GLfloat
167 @GLdouble Buffer data);
168
169 void glCopyNamedBufferSubData(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readOffset, @GLintptr long writeOffset, @GLsizeiptr long size);
170
171 void glClearNamedBufferData(@GLuint int buffer, @GLenum int internalformat, @GLenum int format, @GLenum int type, @Check("1") @Const @GLvoid ByteBuffer data);
172
173 void glClearNamedBufferSubData(@GLuint int buffer, @GLenum int internalformat, @GLintptr long offset, @GLsizeiptr long size, @GLenum int format, @GLenum int type, @Check("1") @Const @GLvoid ByteBuffer data);
174
175 /**
176 * Maps a buffer object's data store.
177 * <p/>
178 * <b>LWJGL note</b>: This method comes in 2 flavors:
179 * <ol>
180 * <li>{@link #glMapNamedBuffer(int, int, ByteBuffer)} - Calls {@link #glGetNamedBufferParameteri} to retrieve the buffer size and the {@code old_buffer} parameter is reused if the returned size and pointer match the buffer capacity and address, respectively.</li>
181 * <li>{@link #glMapNamedBuffer(int, int, int, ByteBuffer)} - The buffer size is explicitly specified and the {@code old_buffer} parameter is reused if {@code size} and the returned pointer match the buffer capacity and address, respectively. This is the most efficient method.</li>
182 * </ol>
183 *
184 * @param buffer the buffer object being mapped
185 * @param access the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store
186 */
187 @CachedResult
188 @GLvoid
189 @AutoSize("glGetNamedBufferParameteri(buffer, GL15.GL_BUFFER_SIZE)")
190 ByteBuffer glMapNamedBuffer(@GLuint int buffer, @GLenum int access);
191
192 @CachedResult(isRange = true)
193 @GLvoid
194 @AutoSize("length")
195 ByteBuffer glMapNamedBufferRange(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
196
197 boolean glUnmapNamedBuffer(@GLuint int buffer);
198
199 void glFlushMappedNamedBufferRange(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
200
201 @StripPostfix("params")
202 void glGetNamedBufferParameteriv(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params);
203
204 @Alternate("glGetNamedBufferParameteriv")
205 @GLreturn("params")
206 @StripPostfix(value = "params", hasPostfix = false)
207 void glGetNamedBufferParameteriv2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params);
208
209 @StripPostfix("params")
210 void glGetNamedBufferParameteri64v(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
211
212 @Alternate("glGetNamedBufferParameteri64v")
213 @GLreturn("params")
214 @StripPostfix(value = "params", hasPostfix = false)
215 void glGetNamedBufferParameteri64v2(@GLuint int buffer, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
216
217 @StripPostfix("params")
218 @AutoSize("glGetNamedBufferParameteri(buffer, GL15.GL_BUFFER_SIZE)")
219 void glGetNamedBufferPointerv(@GLuint int buffer, @GLenum int pname, @Result @GLvoid ByteBuffer params);
220
221 void glGetNamedBufferSubData(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
222 @OutParameter
223 @Check
224 @GLbyte
225 @GLshort
226 @GLint
227 @GLfloat
228 @GLdouble Buffer data);
229
230 // Framebuffer object functions
231
232 void glCreateFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
233
234 @Alternate("glCreateFramebuffers")
235 @GLreturn("framebuffers")
236 void glCreateFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
237
238 void glNamedFramebufferRenderbuffer(@GLuint int framebuffer, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
239
240 void glNamedFramebufferParameteri(@GLuint int framebuffer, @GLenum int pname, int param);
241
242 void glNamedFramebufferTexture(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level);
243
244 void glNamedFramebufferTextureLayer(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer);
245
246 void glNamedFramebufferDrawBuffer(@GLuint int framebuffer, @GLenum int mode);
247
248 void glNamedFramebufferDrawBuffers(@GLuint int framebuffer, @AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs);
249
250 void glNamedFramebufferReadBuffer(@GLuint int framebuffer, @GLenum int mode);
251
252 void glInvalidateNamedFramebufferData(@GLuint int framebuffer, @AutoSize("attachments") @GLsizei int numAttachments, @Const @GLenum IntBuffer attachments);
253
254 void glInvalidateNamedFramebufferSubData(@GLuint int framebuffer, @AutoSize("attachments") @GLsizei int numAttachments, @Const @GLenum IntBuffer attachments, int x, int y, @GLsizei int width, @GLsizei int height);
255
256 @StripPostfix("value")
257 void glClearNamedFramebufferiv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("1") IntBuffer value);
258
259 @StripPostfix("value")
260 void glClearNamedFramebufferuiv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("4") @GLuint IntBuffer value);
261
262 @StripPostfix("value")
263 void glClearNamedFramebufferfv(@GLuint int framebuffer, @GLenum int buffer, int drawbuffer, @Const @Check("1") FloatBuffer value);
264
265 void glClearNamedFramebufferfi(@GLuint int framebuffer, @GLenum int buffer, float depth, int stencil);
266
267 void glBlitNamedFramebuffer(
268 @GLuint int readFramebuffer, @GLuint int drawFramebuffer,
269 int srcX0, int srcY0, int srcX1, int srcY1,
270 int dstX0, int dstY0, int dstX1, int dstY1,
271 @GLbitfield int mask, @GLenum int filter);
272
273 @GLenum
274 int glCheckNamedFramebufferStatus(@GLuint int framebuffer, @GLenum int target);
275
276 @StripPostfix("params")
277 void glGetNamedFramebufferParameteriv(@GLuint int framebuffer, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
278
279 @Alternate("glGetNamedFramebufferParameteriv")
280 @GLreturn("params")
281 @StripPostfix("params")
282 void glGetNamedFramebufferParameteriv2(@GLuint int framebuffer, @GLenum int pname, @OutParameter IntBuffer params);
283
284 @StripPostfix("params")
285 void glGetNamedFramebufferAttachmentParameteriv(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
286
287 @Alternate("glGetNamedFramebufferAttachmentParameteriv")
288 @GLreturn("params")
289 @StripPostfix("params")
290 void glGetNamedFramebufferAttachmentParameteriv2(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
291
292 // Renderbuffer object functions
293
294 void glCreateRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
295
296 @Alternate("glCreateRenderbuffers")
297 @GLreturn("renderbuffers")
298 void glCreateRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
299
300 void glNamedRenderbufferStorage(@GLuint int renderbuffer, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
301
302 void glNamedRenderbufferStorageMultisample(@GLuint int renderbuffer, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
303
304 @StripPostfix("params")
305 void glGetNamedRenderbufferParameteriv(@GLuint int renderbuffer, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
306
307 @Alternate("glGetNamedRenderbufferParameteriv")
308 @GLreturn("params")
309 @StripPostfix("params")
310 void glGetNamedRenderbufferParameteriv2(@GLuint int renderbuffer, @GLenum int pname, @OutParameter IntBuffer params);
311
312 // Texture object functions
313
314 void glCreateTextures(@GLenum int target, @AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
315
316 @Alternate("glCreateTextures")
317 @GLreturn("textures")
318 void glCreateTextures2(@GLenum int target, @Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
319
320 void glTextureBuffer(@GLuint int texture, @GLenum int internalformat, @GLuint int buffer);
321
322 void glTextureBufferRange(@GLuint int texture, @GLenum int internalformat, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
323
324 void glTextureStorage1D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width);
325
326 void glTextureStorage2D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
327
328 void glTextureStorage3D(@GLuint int texture, @GLsizei int levels, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth);
329
330 void glTextureStorage2DMultisample(@GLuint int texture, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, boolean fixedsamplelocations);
331
332 void glTextureStorage3DMultisample(@GLuint int texture, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, boolean fixedsamplelocations);
333
334 void glTextureSubImage1D(@GLuint int texture, int level, int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type,
335 @BufferObject(BufferKind.UnpackPBO)
336 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)")
337 @Const
338 @GLbyte
339 @GLshort
340 @GLint
341 @GLfloat
342 @GLdouble Buffer pixels);
343
344 void glTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
345 @BufferObject(BufferKind.UnpackPBO)
346 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
347 @Const
348 @GLbyte
349 @GLshort
350 @GLint
351 @GLfloat
352 @GLdouble Buffer pixels);
353
354 void glTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type,
355 @BufferObject(BufferKind.UnpackPBO)
356 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
357 @Const
358 @GLbyte
359 @GLshort
360 @GLint
361 @GLfloat
362 @GLdouble Buffer pixels);
363
364 void glCompressedTextureSubImage1D(@GLuint int texture, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
365 @BufferObject(BufferKind.UnpackPBO)
366 @Check
367 @Const
368 @GLvoid
369 ByteBuffer data);
370
371 void glCompressedTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize,
372 @BufferObject(BufferKind.UnpackPBO)
373 @Check
374 @Const
375 @GLvoid
376 ByteBuffer data);
377
378 void glCompressedTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLsizei int imageSize,
379 @BufferObject(BufferKind.UnpackPBO)
380 @Check
381 @Const
382 @GLvoid
383 ByteBuffer data);
384
385 void glCopyTextureSubImage1D(@GLuint int texture, int level, int xoffset, int x, int y, @GLsizei int width);
386
387 void glCopyTextureSubImage2D(@GLuint int texture, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height);
388
389 void glCopyTextureSubImage3D(@GLuint int texture, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
390
391 void glTextureParameterf(@GLuint int texture, @GLenum int pname, float param);
392
393 @StripPostfix("params")
394 void glTextureParameterfv(@GLuint int texture, @GLenum int pname, @Const @Check("4") FloatBuffer params);
395
396 void glTextureParameteri(@GLuint int texture, @GLenum int pname, int param);
397
398 @StripPostfix("params")
399 void glTextureParameterIiv(@GLuint int texture, @GLenum int pname, @Const @Check("1") IntBuffer params);
400
401 @StripPostfix("params")
402 void glTextureParameterIuiv(@GLuint int texture, @GLenum int pname, @Const @Check("1") @GLuint IntBuffer params);
403
404 @StripPostfix("params")
405 void glTextureParameteriv(@GLuint int texture, @GLenum int pname, @Const @Check("4") IntBuffer params);
406
407 void glGenerateTextureMipmap(@GLuint int texture);
408
409 void glBindTextureUnit(@GLuint int unit, @GLuint int texture);
410
411 void glGetTextureImage(@GLuint int texture, int level, @GLenum int format, @GLenum int type, @AutoSize("pixels") @GLsizei int bufSize,
412 @OutParameter
413 @BufferObject(BufferKind.PackPBO)
414 @GLbyte
415 @GLshort
416 @GLint
417 @GLfloat
418 @GLdouble Buffer pixels);
419
420 void glGetCompressedTextureImage(@GLuint int texture, int level, @AutoSize("pixels") @GLsizei int bufSize,
421 @OutParameter
422 @BufferObject(BufferKind.PackPBO)
423 @Check
424 @GLbyte
425 @GLshort
426 @GLint Buffer pixels);
427
428 @StripPostfix("params")
429 void glGetTextureLevelParameterfv(@GLuint int texture, int level, @GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
430
431 @Alternate("glGetTextureLevelParameterfv")
432 @GLreturn("params")
433 @StripPostfix(value = "params", hasPostfix = false)
434 void glGetTextureLevelParameterfv2(@GLuint int texture, int level, @GLenum int pname, @OutParameter FloatBuffer params);
435
436 @StripPostfix("params")
437 void glGetTextureLevelParameteriv(@GLuint int texture, int level, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
438
439 @Alternate("glGetTextureLevelParameteriv")
440 @GLreturn("params")
441 @StripPostfix(value = "params", hasPostfix = false)
442 void glGetTextureLevelParameteriv2(@GLuint int texture, int level, @GLenum int pname, @OutParameter IntBuffer params);
443
444 @StripPostfix("params")
445 void glGetTextureParameterfv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
446
447 @Alternate("glGetTextureParameterfv")
448 @GLreturn("params")
449 @StripPostfix(value = "params", hasPostfix = false)
450 void glGetTextureParameterfv2(@GLuint int texture, @GLenum int pname, @OutParameter FloatBuffer params);
451
452 @StripPostfix("params")
453 void glGetTextureParameterIiv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
454
455 @Alternate("glGetTextureParameterIiv")
456 @GLreturn("params")
457 @StripPostfix(value = "params", hasPostfix = false)
458 void glGetTextureParameterIiv2(@GLuint int texture, @GLenum int pname, @OutParameter IntBuffer params);
459
460 @StripPostfix("params")
461 void glGetTextureParameterIuiv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
462
463 @Alternate("glGetTextureParameterIuiv")
464 @GLreturn("params")
465 @StripPostfix(value = "params", hasPostfix = false)
466 void glGetTextureParameterIuiv2(@GLuint int texture, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
467
468 @StripPostfix("params")
469 void glGetTextureParameteriv(@GLuint int texture, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
470
471 @Alternate("glGetTextureParameteriv")
472 @GLreturn("params")
473 @StripPostfix(value = "params", hasPostfix = false)
474 void glGetTextureParameteriv2(@GLuint int texture, @GLenum int pname, @OutParameter IntBuffer params);
475
476 // Vertex Array object functions
477
478 void glCreateVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
479
480 @Alternate("glCreateVertexArrays")
481 @GLreturn("arrays")
482 void glCreateVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
483
484 void glDisableVertexArrayAttrib(@GLuint int vaobj, @GLuint int index);
485
486 void glEnableVertexArrayAttrib(@GLuint int vaobj, @GLuint int index);
487
488 void glVertexArrayElementBuffer(@GLuint int vaobj, @GLuint int buffer);
489
490 void glVertexArrayVertexBuffer(@GLuint int vaobj, @GLuint int bindingindex, @GLuint int buffer, @GLintptr long offset, @GLsizei int stride);
491
492 void glVertexArrayVertexBuffers(@GLuint int vaobj, @GLuint int first, @GLsizei int count,
493 @Check(value = "count", canBeNull = true) @Const @GLuint IntBuffer buffers,
494 @Check(value = "count", canBeNull = true) @Const @GLintptr PointerBuffer offsets,
495 @Check(value = "count", canBeNull = true) @Const @GLsizei IntBuffer strides);
496
497 void glVertexArrayAttribFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, boolean normalized, @GLuint int relativeoffset);
498
499 void glVertexArrayAttribIFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, @GLuint int relativeoffset);
500
501 void glVertexArrayAttribLFormat(@GLuint int vaobj, @GLuint int attribindex, int size, @GLenum int type, @GLuint int relativeoffset);
502
503 void glVertexArrayAttribBinding(@GLuint int vaobj, @GLuint int attribindex, @GLuint int bindingindex);
504
505 void glVertexArrayBindingDivisor(@GLuint int vaobj, @GLuint int bindingindex, @GLuint int divisor);
506
507 @StripPostfix("param")
508 void glGetVertexArrayiv(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
509
510 @Alternate("glGetVertexArrayiv")
511 @GLreturn("param")
512 @StripPostfix("param")
513 void glGetVertexArrayiv2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
514
515 @StripPostfix("param")
516 void glGetVertexArrayIndexediv(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer param);
517
518 @Alternate("glGetVertexArrayIndexediv")
519 @GLreturn("param")
520 @StripPostfix("param")
521 void glGetVertexArrayIndexediv2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
522
523 @StripPostfix("param")
524 void glGetVertexArrayIndexed64iv(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer param);
525
526 @Alternate("glGetVertexArrayIndexed64iv")
527 @GLreturn("param")
528 @StripPostfix("param")
529 void glGetVertexArrayIndexed64iv2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @GLint64 LongBuffer param);
530
531 // Sampler object functions
532
533 void glCreateSamplers(@AutoSize("samplers") @GLsizei int n, @OutParameter @GLuint IntBuffer samplers);
534
535 @Alternate("glCreateSamplers")
536 @GLreturn("samplers")
537 void glCreateSamplers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer samplers);
538
539 // Program Pipeline object functions
540
541 void glCreateProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
542
543 @Alternate("glCreateProgramPipelines")
544 @GLreturn("pipelines")
545 void glCreateProgramPipelines2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
546
547 // Query object functions
548
549 void glCreateQueries(@GLenum int target, @AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
550
551 @Alternate("glCreateQueries")
552 @GLreturn("ids")
553 void glCreateQueries2(@GLenum int target, @Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
554
555 // -----------------------------------------------------------------------
556 // ----------------------[ ARB_ES3_1_compatibility ]----------------------
557 // -----------------------------------------------------------------------
558
559 void glMemoryBarrierByRegion(@GLbitfield int barriers);
560
561 // -------------------------------------------------------------------------
562 // ----------------------[ ARB_get_texture_sub_image ]----------------------
563 // -------------------------------------------------------------------------
564
565 void glGetTextureSubImage(
566 @GLuint int texture, int level, int xoffset, int yoffset, int zoffset,
567 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
568 @GLenum int format, @GLenum int type,
569 @AutoSize("pixels") @GLsizei int bufSize,
570 @OutParameter
571 @BufferObject(BufferKind.PackPBO)
572 @GLbyte
573 @GLshort
574 @GLint
575 @GLfloat
576 @GLdouble Buffer pixels
577 );
578
579 void glGetCompressedTextureSubImage(
580 @GLuint int texture, int level, int xoffset, int yoffset, int zoffset,
581 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
582 @AutoSize("pixels") @GLsizei int bufSize,
583 @OutParameter
584 @BufferObject(BufferKind.PackPBO)
585 @GLbyte
586 @GLshort
587 @GLint
588 @GLfloat
589 @GLdouble Buffer pixels
590 );
591
592 // -------------------------------------------------------------------
593 // ----------------------[ ARB_texture_barrier ]----------------------
594 // -------------------------------------------------------------------
595
596 void glTextureBarrier();
597
598 // -------------------------------------------------------------------------
599 // ----------------------[ KHR_context_flush_control ]----------------------
600 // -------------------------------------------------------------------------
601
602 /**
603 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetFloatv, GetBooleanv
604 * GetDoublev and GetInteger64v:
605 */
606 int GL_CONTEXT_RELEASE_BEHAVIOR = 0x82FB;
607
608 /**
609 * Returned in &lt;data&gt; by GetIntegerv, GetFloatv, GetBooleanv
610 * GetDoublev and GetInteger64v when &lt;pname&gt; is
611 * GL_CONTEXT_RELEASE_BEHAVIOR:
612 */
613 int GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x82FC;
614
615 // --------------------------------------------------------------
616 // ----------------------[ KHR_robustness ]----------------------
617 // --------------------------------------------------------------
618
619 /** Returned by GetGraphicsResetStatus: */
620 int GL_GUILTY_CONTEXT_RESET = 0x8253,
621 GL_INNOCENT_CONTEXT_RESET = 0x8254,
622 GL_UNKNOWN_CONTEXT_RESET = 0x8255;
623
624 /**
625 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
626 * and GetFloatv:
627 */
628 int GL_CONTEXT_ROBUST_ACCESS = 0x90F3,
629 GL_RESET_NOTIFICATION_STRATEGY = 0x8256;
630
631 /**
632 * Returned by GetIntegerv and related simple queries when &lt;value&gt; is
633 * RESET_NOTIFICATION_STRATEGY:
634 */
635 int GL_LOSE_CONTEXT_ON_RESET = 0x8252,
636 GL_NO_RESET_NOTIFICATION = 0x8261;
637
638 /** Returned by GetError: */
639 int GL_CONTEXT_LOST = 0x0507;
640
641 @GLenum
642 int glGetGraphicsResetStatus();
643
644 void glReadnPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @AutoSize("pixels") @GLsizei int bufSize,
645 @OutParameter
646 @BufferObject(BufferKind.PackPBO)
647 @GLbyte
648 @GLshort
649 @GLint
650 @GLfloat
651 @GLdouble Buffer pixels);
652
653 @StripPostfix("params")
654 void glGetnUniformfv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter FloatBuffer params);
655
656 @StripPostfix("params")
657 void glGetnUniformiv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
658
659 @StripPostfix("params")
660 void glGetnUniformuiv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter @GLuint IntBuffer params);
661
662 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 GREMEDY_frame_terminator {
34
35 void glFrameTerminatorGREMEDY();
36
37 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface INTEL_map_texture {
40
41 /** Accepted by the &lt;pname&gt; parameter of TexParameteri, for target TEXTURE_2D */
42 int GL_TEXTURE_MEMORY_LAYOUT_INTEL = 0x83FF;
43
44 /**
45 * Accepted by the &lt;params&gt; when &lt;pname&gt; is set to
46 * &lt;TEXTURE_MEMORY_LAYOUT_INTEL&gt;:
47 */
48 int GL_LAYOUT_DEFAULT_INTEL = 0,
49 GL_LAYOUT_LINEAR_INTEL = 1,
50 GL_LAYOUT_LINEAR_CPU_CACHED_INTEL = 2;
51
52 /**
53 * The length parameter does not exist in the native API. It used by LWJGL to return a ByteBuffer
54 * with a proper capacity.
55 */
56 @CachedResult(isRange = true)
57 @GLvoid
58 @AutoSize("length")
59 ByteBuffer glMapTexture2DINTEL(@GLuint int texture, int level, @Helper(passToNative = true) @GLsizeiptr long length, @GLbitfield int access,
60 @Check("1") @OutParameter IntBuffer stride, @Check("1") @OutParameter @GLenum IntBuffer layout);
61
62 void glUnmapTexture2DINTEL(@GLuint int texture, int level);
63
64 void glSyncTextureINTEL(@GLuint int texture);
65
66 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 KHR_context_flush_control {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetIntegerv, GetFloatv, GetBooleanv
37 * GetDoublev and GetInteger64v:
38 */
39 int GL_CONTEXT_RELEASE_BEHAVIOR = 0x82FB;
40
41 /**
42 * Returned in &lt;data&gt; by GetIntegerv, GetFloatv, GetBooleanv
43 * GetDoublev and GetInteger64v when &lt;pname&gt; is
44 * GL_CONTEXT_RELEASE_BEHAVIOR:
45 */
46 int GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x82FC;
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 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface KHR_debug {
40
41 /**
42 * Tokens accepted by the &lt;target&gt; parameters of Enable, Disable, and
43 * IsEnabled:
44 */
45 int GL_DEBUG_OUTPUT = 0x92E0,
46 GL_DEBUG_OUTPUT_SYNCHRONOUS = 0x8242;
47
48 /** Returned by GetIntegerv when &lt;pname&gt; is CONTEXT_FLAGS: */
49 int GL_CONTEXT_FLAG_DEBUG_BIT = 0x00000002;
50
51 /**
52 * Tokens accepted by the &lt;value&gt; parameters of GetBooleanv, GetIntegerv,
53 * GetFloatv, GetDoublev and GetInteger64v:
54 */
55 int GL_MAX_DEBUG_MESSAGE_LENGTH = 0x9143,
56 GL_MAX_DEBUG_LOGGED_MESSAGES = 0x9144,
57 GL_DEBUG_LOGGED_MESSAGES = 0x9145,
58 GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243,
59 GL_MAX_DEBUG_GROUP_STACK_DEPTH = 0x826C,
60 GL_DEBUG_GROUP_STACK_DEPTH = 0x826D,
61 GL_MAX_LABEL_LENGTH = 0x82E8;
62
63 /** Tokens accepted by the &lt;pname&gt; parameter of GetPointerv: */
64 int GL_DEBUG_CALLBACK_FUNCTION = 0x8244,
65 GL_DEBUG_CALLBACK_USER_PARAM = 0x8245;
66
67 /**
68 * Tokens accepted or provided by the &lt;source&gt; parameters of
69 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;sources&gt;
70 * parameter of GetDebugMessageLog:
71 */
72 int GL_DEBUG_SOURCE_API = 0x8246,
73 GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
74 GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
75 GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
76 GL_DEBUG_SOURCE_APPLICATION = 0x824A,
77 GL_DEBUG_SOURCE_OTHER = 0x824B;
78
79 /**
80 * Tokens accepted or provided by the &lt;type&gt; parameters of
81 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;types&gt;
82 * parameter of GetDebugMessageLog:
83 */
84 int GL_DEBUG_TYPE_ERROR = 0x824C,
85 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
86 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
87 GL_DEBUG_TYPE_PORTABILITY = 0x824F,
88 GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
89 GL_DEBUG_TYPE_OTHER = 0x8251,
90 GL_DEBUG_TYPE_MARKER = 0x8268;
91
92 /**
93 * Tokens accepted or provided by the &lt;type&gt; parameters of
94 * DebugMessageControl and DEBUGPROC, and the &lt;types&gt; parameter of
95 * GetDebugMessageLog:
96 */
97 int GL_DEBUG_TYPE_PUSH_GROUP = 0x8269,
98 GL_DEBUG_TYPE_POP_GROUP = 0x826A;
99
100 /**
101 * Tokens accepted or provided by the &lt;severity&gt; parameters of
102 * DebugMessageControl, DebugMessageInsert and DEBUGPROC callback functions,
103 * and the &lt;severities&gt; parameter of GetDebugMessageLog:
104 */
105 int GL_DEBUG_SEVERITY_HIGH = 0x9146,
106 GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
107 GL_DEBUG_SEVERITY_LOW = 0x9148,
108 GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
109
110 /**
111 * Tokens accepted or provided by the &lt;identifier&gt; parameters of
112 * ObjectLabel and GetObjectLabel:
113 */
114 int GL_BUFFER = 0x82E0,
115 GL_SHADER = 0x82E1,
116 GL_PROGRAM = 0x82E2,
117 GL_QUERY = 0x82E3,
118 GL_PROGRAM_PIPELINE = 0x82E4,
119 GL_SAMPLER = 0x82E6,
120 GL_DISPLAY_LIST = 0x82E7;
121
122 // -----------------------------
123
124 @Reuse("GL43")
125 void glDebugMessageControl(@GLenum int source,
126 @GLenum int type,
127 @GLenum int severity,
128 @AutoSize(value = "ids", canBeNull = true) @GLsizei int count,
129 @Check(canBeNull = true) @Const @GLuint IntBuffer ids,
130 boolean enabled);
131
132 @Reuse("GL43")
133 void glDebugMessageInsert(@GLenum int source,
134 @GLenum int type,
135 @GLuint int id,
136 @GLenum int severity,
137 @AutoSize("buf") @GLsizei int length,
138 @Const @GLchar ByteBuffer buf);
139
140 @Reuse("GL43")
141 @Alternate("glDebugMessageInsert")
142 void glDebugMessageInsert(@GLenum int source,
143 @GLenum int type,
144 @GLuint int id,
145 @GLenum int severity,
146 @Constant("buf.length()") @GLsizei int length,
147 CharSequence buf);
148
149 /**
150 * The {@code KHRDebugCallback.Handler} implementation passed to this method will be used for
151 * KHR_debug messages. If callback is null, any previously registered handler for the current
152 * thread will be unregistered and stop receiving messages.
153 *
154 * @param callback the callback function to use
155 */
156 @Reuse("GL43")
157 void glDebugMessageCallback(@PointerWrapper(value = "GLDEBUGPROC", canBeNull = true) KHRDebugCallback callback,
158 @Constant("userParam") @PointerWrapper("GLvoid *") long userParam);
159
160 @Reuse("GL43")
161 @GLuint
162 int glGetDebugMessageLog(@GLuint int count,
163 @AutoSize(value = "messageLog", canBeNull = true) @GLsizei int bufsize,
164 @Check(value = "count", canBeNull = true) @GLenum IntBuffer sources,
165 @Check(value = "count", canBeNull = true) @GLenum IntBuffer types,
166 @Check(value = "count", canBeNull = true) @GLuint IntBuffer ids,
167 @Check(value = "count", canBeNull = true) @GLenum IntBuffer severities,
168 @Check(value = "count", canBeNull = true) @GLsizei IntBuffer lengths,
169 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer messageLog);
170
171 // Not really useful and a pain to implement in Java
172 // void glGetPointerv(@GLenum int pname, void** params);
173
174 @Reuse("GL43")
175 void glPushDebugGroup(@GLenum int source, @GLuint int id, @AutoSize("message") @GLsizei int length,
176 @Const @GLchar ByteBuffer message);
177
178 @Reuse("GL43")
179 @Alternate("glPushDebugGroup")
180 void glPushDebugGroup(@GLenum int source, @GLuint int id, @Constant("message.length()") @GLsizei int length,
181 CharSequence message);
182
183 @Reuse("GL43")
184 void glPopDebugGroup();
185
186 @Reuse("GL43")
187 void glObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
188 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
189
190 @Reuse("GL43")
191 @Alternate("glObjectLabel")
192 void glObjectLabel(@GLenum int identifier, @GLuint int name, @Constant("label.length()") @GLsizei int length,
193 CharSequence label);
194
195 @Reuse("GL43")
196 void glGetObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize("label") @GLsizei int bufSize,
197 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
198 @OutParameter @GLchar ByteBuffer label);
199
200 @Reuse("GL43")
201 @Alternate("glGetObjectLabel")
202 @GLreturn(value = "label", maxLength = "bufSize")
203 void glGetObjectLabel2(@GLenum int identifier, @GLuint int name, @GLsizei int bufSize,
204 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
205 @OutParameter @GLchar ByteBuffer label);
206
207 @Reuse("GL43")
208 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
209 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
210
211 @Reuse("GL43")
212 @Alternate("glObjectPtrLabel")
213 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @Constant("label.length()") @GLsizei int length,
214 CharSequence label);
215
216 @Reuse("GL43")
217 void glGetObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize("label") @GLsizei int bufSize,
218 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
219 @OutParameter @GLchar ByteBuffer label);
220
221 @Reuse("GL43")
222 @Alternate("glGetObjectPtrLabel")
223 @GLreturn(value = "label", maxLength = "bufSize")
224 void glGetObjectPtrLabel2(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @GLsizei int bufSize,
225 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
226 @OutParameter @GLchar ByteBuffer label);
227
228 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 KHR_robust_buffer_access_behavior {
34 }
0 /*
1 * Copyright (c) 2002-2014 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37 import java.nio.FloatBuffer;
38 import java.nio.IntBuffer;
39
40 @Extension(postfix = "")
41 public interface KHR_robustness {
42
43 /** Returned by GetGraphicsResetStatus: */
44 int GL_GUILTY_CONTEXT_RESET = 0x8253,
45 GL_INNOCENT_CONTEXT_RESET = 0x8254,
46 GL_UNKNOWN_CONTEXT_RESET = 0x8255;
47
48 /**
49 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
50 * and GetFloatv:
51 */
52 int GL_CONTEXT_ROBUST_ACCESS = 0x90F3,
53 GL_RESET_NOTIFICATION_STRATEGY = 0x8256;
54
55 /**
56 * Returned by GetIntegerv and related simple queries when &lt;value&gt; is
57 * RESET_NOTIFICATION_STRATEGY:
58 */
59 int GL_LOSE_CONTEXT_ON_RESET = 0x8252,
60 GL_NO_RESET_NOTIFICATION = 0x8261;
61
62 /** Returned by GetError: */
63 int GL_CONTEXT_LOST = 0x0507;
64
65 @Reuse("GL45")
66 @GLenum
67 int glGetGraphicsResetStatus();
68
69 @Reuse("GL45")
70 void glReadnPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @AutoSize("pixels") @GLsizei int bufSize,
71 @OutParameter
72 @BufferObject(BufferKind.PackPBO)
73 @GLbyte
74 @GLshort
75 @GLint
76 @GLfloat
77 @GLdouble Buffer pixels);
78
79 @StripPostfix("params")
80 @Reuse("GL45")
81 void glGetnUniformfv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter FloatBuffer params);
82
83 @StripPostfix("params")
84 @Reuse("GL45")
85 void glGetnUniformiv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
86
87 @StripPostfix("params")
88 @Reuse("GL45")
89 void glGetnUniformuiv(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter @GLuint IntBuffer params);
90
91 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 KHR_texture_compression_astc_ldr {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D,
37 * CompressedTexSubImage2D, TexStorage2D, TextureStorage2D, TexStorage3D,
38 * and TextureStorage3D:
39 */
40 int GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
41 GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
42 GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
43 GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3,
44 GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4,
45 GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5,
46 GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6,
47 GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7,
48 GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8,
49 GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9,
50 GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA,
51 GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB,
52 GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC,
53 GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD,
54 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0,
55 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1,
56 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2,
57 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3,
58 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4,
59 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5,
60 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6,
61 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7,
62 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8,
63 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9,
64 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA,
65 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB,
66 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC,
67 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
68
69 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.BufferKind;
34 import org.lwjgl.util.generator.BufferObject;
35 import org.lwjgl.util.generator.Check;
36 import org.lwjgl.util.generator.Const;
37 import org.lwjgl.util.generator.opengl.GLenum;
38 import org.lwjgl.util.generator.opengl.GLsizei;
39 import org.lwjgl.util.generator.opengl.GLvoid;
40
41 import java.nio.ByteBuffer;
42
43 public interface NV_bindless_multi_draw_indirect {
44
45 void glMultiDrawArraysIndirectBindlessNV(@GLenum int mode,
46 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 20 + 24 * vertexBufferCount : stride) * drawCount") @Const @GLvoid ByteBuffer indirect,
47 @GLsizei int drawCount,
48 @GLsizei int stride,
49 int vertexBufferCount);
50
51 void glMultiDrawElementsIndirectBindlessNV(@GLenum int mode,
52 @GLenum int type,
53 @BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 48 + 24 * vertexBufferCount : stride) * drawCount") @Const @GLvoid ByteBuffer indirect,
54 @GLsizei int drawCount,
55 @GLsizei int stride,
56 int vertexBufferCount);
57
58 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Const;
35 import org.lwjgl.util.generator.StripPostfix;
36 import org.lwjgl.util.generator.opengl.GLenum;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
39 import org.lwjgl.util.generator.opengl.GLuint64;
40
41 import java.nio.LongBuffer;
42
43 public interface NV_bindless_texture {
44
45 @GLuint64
46 long glGetTextureHandleNV(@GLuint int texture);
47
48 @GLuint64
49 long glGetTextureSamplerHandleNV(@GLuint int texture, @GLuint int sampler);
50
51 void glMakeTextureHandleResidentNV(@GLuint64 long handle);
52
53 void glMakeTextureHandleNonResidentNV(@GLuint64 long handle);
54
55 @GLuint64
56 long glGetImageHandleNV(@GLuint int texture, int level, boolean layered,
57 int layer, @GLenum int format);
58
59 void glMakeImageHandleResidentNV(@GLuint64 long handle, @GLenum int access);
60
61 void glMakeImageHandleNonResidentNV(@GLuint64 long handle);
62
63 void glUniformHandleui64NV(int location, @GLuint64 long value);
64
65 @StripPostfix("value")
66 void glUniformHandleui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64 LongBuffer value);
67
68 void glProgramUniformHandleui64NV(@GLuint int program, int location,
69 @GLuint64 long value);
70
71 @StripPostfix("values")
72 void glProgramUniformHandleui64vNV(@GLuint int program, int location,
73 @AutoSize("values") @GLsizei int count, @Const @GLuint64 LongBuffer values);
74
75 boolean glIsTextureHandleResidentNV(@GLuint64 long handle);
76
77 boolean glIsImageHandleResidentNV(@GLuint64 long handle);
78
79 }
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLenum;
34
35 public interface NV_blend_equation_advanced {
36
37 /**
38 * Accepted by the &lt;cap&gt; parameter of Disable, Enable, and IsEnabled, and by
39 * the &lt;pname&gt; parameter of GetIntegerv, GetBooleanv, GetFloatv, GetDoublev
40 * and GetInteger64v:
41 */
42 int GL_BLEND_ADVANCED_COHERENT_NV = 0x9285;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of BlendParameteriNV, GetBooleanv,
46 * GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev:
47 */
48 int GL_BLEND_PREMULTIPLIED_SRC_NV = 0x9280,
49 GL_BLEND_OVERLAP_NV = 0x9281;
50
51 /**
52 * Accepted by the &lt;value&gt; parameter of BlendParameteriNV when &lt;pname&gt; is
53 * BLEND_OVERLAP_NV:
54 */
55 int GL_UNCORRELATED_NV = 0x9282,
56 GL_DISJOINT_NV = 0x9283,
57 GL_CONJOINT_NV = 0x9284;
58
59 /** Accepted by the &lt;mode&gt; parameter of BlendEquation and BlendEquationi: */
60 int GL_SRC_NV = 0x9286,
61 GL_DST_NV = 0x9287,
62 GL_SRC_OVER_NV = 0x9288,
63 GL_DST_OVER_NV = 0x9289,
64 GL_SRC_IN_NV = 0x928A,
65 GL_DST_IN_NV = 0x928B,
66 GL_SRC_OUT_NV = 0x928C,
67 GL_DST_OUT_NV = 0x928D,
68 GL_SRC_ATOP_NV = 0x928E,
69 GL_DST_ATOP_NV = 0x928F,
70 GL_MULTIPLY_NV = 0x9294,
71 GL_SCREEN_NV = 0x9295,
72 GL_OVERLAY_NV = 0x9296,
73 GL_DARKEN_NV = 0x9297,
74 GL_LIGHTEN_NV = 0x9298,
75 GL_COLORDODGE_NV = 0x9299,
76 GL_COLORBURN_NV = 0x929A,
77 GL_HARDLIGHT_NV = 0x929B,
78 GL_SOFTLIGHT_NV = 0x929C,
79 GL_DIFFERENCE_NV = 0x929E,
80 GL_EXCLUSION_NV = 0x92A0,
81 GL_INVERT_RGB_NV = 0x92A3,
82 GL_LINEARDODGE_NV = 0x92A4,
83 GL_LINEARBURN_NV = 0x92A5,
84 GL_VIVIDLIGHT_NV = 0x92A6,
85 GL_LINEARLIGHT_NV = 0x92A7,
86 GL_PINLIGHT_NV = 0x92A8,
87 GL_HARDMIX_NV = 0x92A9,
88 GL_HSL_HUE_NV = 0x92AD,
89 GL_HSL_SATURATION_NV = 0x92AE,
90 GL_HSL_COLOR_NV = 0x92AF,
91 GL_HSL_LUMINOSITY_NV = 0x92B0,
92 GL_PLUS_NV = 0x9291,
93 GL_PLUS_CLAMPED_NV = 0x92B1,
94 GL_PLUS_CLAMPED_ALPHA_NV = 0x92B2,
95 GL_PLUS_DARKER_NV = 0x9292,
96 GL_MINUS_NV = 0x929F,
97 GL_MINUS_CLAMPED_NV = 0x92B3,
98 GL_CONTRAST_NV = 0x92A1,
99 GL_INVERT_OVG_NV = 0x92B4;
100
101 void glBlendParameteriNV(@GLenum int pname, int value);
102
103 void glBlendBarrierNV();
104 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_compute_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_COMPUTE_PROGRAM_NV = 0x90FB;
45
46 /**
47 * Accepted by the &lt;target&gt; parameter of ProgramBufferParametersfvNV,
48 * ProgramBufferParametersIivNV, and ProgramBufferParametersIuivNV,
49 * BindBufferRangeNV, BindBufferOffsetNV, BindBufferBaseNV, and BindBuffer
50 * and the &lt;value&gt; parameter of GetIntegerIndexedvEXT:
51 */
52 int GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV = 0x90FC;
53
54 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_deep_texture3D {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetDoublev, GetIntegerv
37 * and GetFloatv:
38 */
39 int GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV = 0x90D0,
40 GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV = 0x90D1;
41
42 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.opengl.GLfloat;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface NV_draw_texture {
37
38 void glDrawTextureNV(@GLuint int texture, @GLuint int sampler,
39 @GLfloat float x0, @GLfloat float y0,
40 @GLfloat float x1, @GLfloat float y1,
41 @GLfloat float z,
42 @GLfloat float s0, @GLfloat float t0,
43 @GLfloat float s1, @GLfloat float t1);
44
45 }
5353 void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences);
5454
5555 @Alternate("glDeleteFencesNV")
56 void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
56 void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, fence)", keepParam = true) int fence);
5757
5858 void glSetFenceNV(@GLuint int fence, @GLenum int condition);
5959
0 /*
1 * Copyright (c) 2002-2013 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_mem_extended {
34
35 }
126126
127127 // -------------
128128
129 @Dependent("EXT_direct_state_access")
129 @Dependent("GL_EXT_direct_state_access")
130130 void glProgramUniform1i64NV(@GLuint int program, int location, @GLint64EXT long x);
131131
132 @Dependent("EXT_direct_state_access")
132 @Dependent("GL_EXT_direct_state_access")
133133 void glProgramUniform2i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y);
134134
135 @Dependent("EXT_direct_state_access")
135 @Dependent("GL_EXT_direct_state_access")
136136 void glProgramUniform3i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z);
137137
138 @Dependent("EXT_direct_state_access")
138 @Dependent("GL_EXT_direct_state_access")
139139 void glProgramUniform4i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w);
140140
141 @Dependent("EXT_direct_state_access")
141 @Dependent("GL_EXT_direct_state_access")
142142 @StripPostfix("value")
143143 void glProgramUniform1i64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
144144
145 @Dependent("EXT_direct_state_access")
145 @Dependent("GL_EXT_direct_state_access")
146146 @StripPostfix("value")
147147 void glProgramUniform2i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
148148
149 @Dependent("EXT_direct_state_access")
149 @Dependent("GL_EXT_direct_state_access")
150150 @StripPostfix("value")
151151 void glProgramUniform3i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
152152
153 @Dependent("EXT_direct_state_access")
153 @Dependent("GL_EXT_direct_state_access")
154154 @StripPostfix("value")
155155 void glProgramUniform4i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
156156
157 @Dependent("EXT_direct_state_access")
157 @Dependent("GL_EXT_direct_state_access")
158158 void glProgramUniform1ui64NV(@GLuint int program, int location, @GLuint64EXT long x);
159159
160 @Dependent("EXT_direct_state_access")
160 @Dependent("GL_EXT_direct_state_access")
161161 void glProgramUniform2ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y);
162162
163 @Dependent("EXT_direct_state_access")
163 @Dependent("GL_EXT_direct_state_access")
164164 void glProgramUniform3ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z);
165165
166 @Dependent("EXT_direct_state_access")
166 @Dependent("GL_EXT_direct_state_access")
167167 void glProgramUniform4ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w);
168168
169 @Dependent("EXT_direct_state_access")
169 @Dependent("GL_EXT_direct_state_access")
170170 @StripPostfix("value")
171171 void glProgramUniform1ui64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
172172
173 @Dependent("EXT_direct_state_access")
173 @Dependent("GL_EXT_direct_state_access")
174174 @StripPostfix("value")
175175 void glProgramUniform2ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
176176
177 @Dependent("EXT_direct_state_access")
177 @Dependent("GL_EXT_direct_state_access")
178178 @StripPostfix("value")
179179 void glProgramUniform3ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
180180
181 @Dependent("EXT_direct_state_access")
181 @Dependent("GL_EXT_direct_state_access")
182182 @StripPostfix("value")
183183 void glProgramUniform4ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
184184
3838
3939 import java.nio.*;
4040
41 @Dependent
4142 public interface NV_half_float {
4243
4344 /**
9192 @NoErrorCheck
9293 void glMultiTexCoord4hNV(@GLenum int target, @GLhalf short s, @GLhalf short t, @GLhalf short r, @GLhalf short q);
9394
95 @Dependent("GL_EXT_fog_coord")
9496 @NoErrorCheck
9597 void glFogCoordhNV(@GLhalf short fog);
9698
99 @Dependent("GL_EXT_secondary_color")
97100 @NoErrorCheck
98101 void glSecondaryColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue);
99102
100 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
103 @Dependent("GL_EXT_vertex_weighting")
101104 @NoErrorCheck
102105 void glVertexWeighthNV(@GLhalf short weight);
103106
104 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
107 @Dependent("GL_NV_vertex_program")
105108 @NoErrorCheck
106109 void glVertexAttrib1hNV(@GLuint int index, @GLhalf short x);
107110
108 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
111 @Dependent("GL_NV_vertex_program")
109112 @NoErrorCheck
110113 void glVertexAttrib2hNV(@GLuint int index, @GLhalf short x, @GLhalf short y);
111114
112 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
115 @Dependent("GL_NV_vertex_program")
113116 @NoErrorCheck
114117 void glVertexAttrib3hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z);
115118
116 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
119 @Dependent("GL_NV_vertex_program")
117120 @NoErrorCheck
118121 void glVertexAttrib4hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w);
119122
120 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
123 @Dependent("GL_NV_vertex_program")
121124 @NoErrorCheck
122125 @StripPostfix("attribs")
123126 void glVertexAttribs1hvNV(@GLuint int index, @AutoSize("attribs") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
124127
125 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
128 @Dependent("GL_NV_vertex_program")
126129 @NoErrorCheck
127130 @StripPostfix("attribs")
128131 void glVertexAttribs2hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 1") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
129132
130 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
133 @Dependent("GL_NV_vertex_program")
131134 @NoErrorCheck
132135 @StripPostfix("attribs")
133136 void glVertexAttribs3hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " / 3") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
134137
135 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
138 @Dependent("GL_NV_vertex_program")
136139 @NoErrorCheck
137140 @StripPostfix("attribs")
138141 void glVertexAttribs4hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 2") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
5858 void glDeleteOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @Const @GLuint IntBuffer piIDs);
5959
6060 @Alternate("glDeleteOcclusionQueriesNV")
61 void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, piID), 0", keepParam = true) int piID);
61 void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, piID)", keepParam = true) int piID);
6262
6363 boolean glIsOcclusionQueryNV(@GLuint int id);
6464
7171
7272 @Alternate("glGetOcclusionQueryuivNV")
7373 @GLreturn("params")
74 @StripPostfix(value = "params", postfix = "v")
74 @StripPostfix(value = "params", hasPostfix = false)
7575 void glGetOcclusionQueryuivNV2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
7676
7777 @StripPostfix("params")
7979
8080 @Alternate("glGetOcclusionQueryivNV")
8181 @GLreturn("params")
82 @StripPostfix(value = "params", postfix = "v")
82 @StripPostfix(value = "params", hasPostfix = false)
8383 void glGetOcclusionQueryivNV2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
8484 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.FloatBuffer;
38 import java.nio.IntBuffer;
39
40 public interface NV_path_rendering {
41
42 /**
43 * Accepted in elements of the &lt;commands&gt; array parameter of
44 * PathCommandsNV and PathSubCommandsNV:
45 */
46 int GL_CLOSE_PATH_NV = 0x00,
47 GL_MOVE_TO_NV = 0x02,
48 GL_RELATIVE_MOVE_TO_NV = 0x03,
49 GL_LINE_TO_NV = 0x04,
50 GL_RELATIVE_LINE_TO_NV = 0x05,
51 GL_HORIZONTAL_LINE_TO_NV = 0x06,
52 GL_RELATIVE_HORIZONTAL_LINE_TO_NV = 0x07,
53 GL_VERTICAL_LINE_TO_NV = 0x08,
54 GL_RELATIVE_VERTICAL_LINE_TO_NV = 0x09,
55 GL_QUADRATIC_CURVE_TO_NV = 0x0A,
56 GL_RELATIVE_QUADRATIC_CURVE_TO_NV = 0x0B,
57 GL_CUBIC_CURVE_TO_NV = 0x0C,
58 GL_RELATIVE_CUBIC_CURVE_TO_NV = 0x0D,
59 GL_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0E,
60 GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0F,
61 GL_SMOOTH_CUBIC_CURVE_TO_NV = 0x10,
62 GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV = 0x11,
63 GL_SMALL_CCW_ARC_TO_NV = 0x12,
64 GL_RELATIVE_SMALL_CCW_ARC_TO_NV = 0x13,
65 GL_SMALL_CW_ARC_TO_NV = 0x14,
66 GL_RELATIVE_SMALL_CW_ARC_TO_NV = 0x15,
67 GL_LARGE_CCW_ARC_TO_NV = 0x16,
68 GL_RELATIVE_LARGE_CCW_ARC_TO_NV = 0x17,
69 GL_LARGE_CW_ARC_TO_NV = 0x18,
70 GL_RELATIVE_LARGE_CW_ARC_TO_NV = 0x19,
71 GL_CIRCULAR_CCW_ARC_TO_NV = 0xF8,
72 GL_CIRCULAR_CW_ARC_TO_NV = 0xFA,
73 GL_CIRCULAR_TANGENT_ARC_TO_NV = 0xFC,
74 GL_ARC_TO_NV = 0xFE,
75 GL_RELATIVE_ARC_TO_NV = 0xFF;
76
77 /** Accepted by the &lt;format&gt; parameter of PathStringNV: */
78 int GL_PATH_FORMAT_SVG_NV = 0x9070,
79 GL_PATH_FORMAT_PS_NV = 0x9071;
80
81 /**
82 * Accepted by the &lt;fontTarget&gt; parameter of PathGlyphsNV and
83 * PathGlyphRangeNV:
84 */
85 int GL_STANDARD_FONT_NAME_NV = 0x9072,
86 GL_SYSTEM_FONT_NAME_NV = 0x9073,
87 GL_FILE_NAME_NV = 0x9074;
88
89 /**
90 * Accepted by the &lt;handleMissingGlyph&gt; parameter of PathGlyphsNV and
91 * PathGlyphRangeNV:
92 */
93 int GL_SKIP_MISSING_GLYPH_NV = 0x90A9,
94 GL_USE_MISSING_GLYPH_NV = 0x90AA;
95
96 /**
97 * Accepted by the &lt;pname&gt; parameter of PathParameterfNV,
98 * PathParameterfvNV, GetPathParameterfvNV, PathParameteriNV,
99 * PathParameterivNV, and GetPathParameterivNV:
100 */
101 int GL_PATH_STROKE_WIDTH_NV = 0x9075,
102 GL_PATH_INITIAL_END_CAP_NV = 0x9077,
103 GL_PATH_TERMINAL_END_CAP_NV = 0x9078,
104 GL_PATH_JOIN_STYLE_NV = 0x9079,
105 GL_PATH_MITER_LIMIT_NV = 0x907A,
106 GL_PATH_INITIAL_DASH_CAP_NV = 0x907C,
107 GL_PATH_TERMINAL_DASH_CAP_NV = 0x907D,
108 GL_PATH_DASH_OFFSET_NV = 0x907E,
109 GL_PATH_CLIENT_LENGTH_NV = 0x907F,
110 GL_PATH_DASH_OFFSET_RESET_NV = 0x90B4,
111
112 GL_PATH_FILL_MODE_NV = 0x9080,
113 GL_PATH_FILL_MASK_NV = 0x9081,
114 GL_PATH_FILL_COVER_MODE_NV = 0x9082,
115 GL_PATH_STROKE_COVER_MODE_NV = 0x9083,
116 GL_PATH_STROKE_MASK_NV = 0x9084;
117
118 /**
119 * Accepted by the &lt;pname&gt; parameter of PathParameterfNV and
120 * PathParameterfvNV:
121 */
122 int GL_PATH_END_CAPS_NV = 0x9076,
123 GL_PATH_DASH_CAPS_NV = 0x907B;
124
125 /**
126 * Accepted by the &lt;fillMode&gt; parameter of StencilFillPathNV and
127 * StencilFillPathInstancedNV:
128 */
129 int GL_COUNT_UP_NV = 0x9088,
130 GL_COUNT_DOWN_NV = 0x9089;
131
132 /**
133 * Accepted by the &lt;color&gt; parameter of PathColorGenNV,
134 * GetPathColorGenivNV, and GetPathColorGenfvNV:
135 */
136 int GL_PRIMARY_COLOR = 0x8577, // from OpenGL 1.3
137 GL_PRIMARY_COLOR_NV = 0x852C, // from NV_register_combiners
138 GL_SECONDARY_COLOR_NV = 0x852D; // from NV_register_combiners
139
140 /**
141 * Accepted by the &lt;genMode&gt; parameter of PathColorGenNV and
142 * PathTexGenNV:
143 */
144 int GL_PATH_OBJECT_BOUNDING_BOX_NV = 0x908A;
145
146 /**
147 * Accepted by the &lt;coverMode&gt; parameter of CoverFillPathNV and
148 * CoverFillPathInstancedNV:
149 */
150 int GL_CONVEX_HULL_NV = 0x908B,
151 GL_BOUNDING_BOX_NV = 0x908D;
152
153 /**
154 * Accepted by the &lt;transformType&gt; parameter of
155 * StencilFillPathInstancedNV, StencilStrokePathInstancedNV,
156 * CoverFillPathInstancedNV, and CoverStrokePathInstancedNV:
157 */
158 int GL_TRANSLATE_X_NV = 0x908E,
159 GL_TRANSLATE_Y_NV = 0x908F,
160 GL_TRANSLATE_2D_NV = 0x9090,
161 GL_TRANSLATE_3D_NV = 0x9091,
162 GL_AFFINE_2D_NV = 0x9092,
163 GL_AFFINE_3D_NV = 0x9094,
164 GL_TRANSPOSE_AFFINE_2D_NV = 0x9096,
165 GL_TRANSPOSE_AFFINE_3D_NV = 0x9098;
166
167 /**
168 * Accepted by the &lt;type&gt; or &lt;pathNameType&gt; parameter of CallLists,
169 * StencilFillPathInstancedNV, StencilStrokePathInstancedNV,
170 * CoverFillPathInstancedNV, CoverStrokePathInstancedNV,
171 * GetPathMetricsNV, and GetPathSpacingNV:
172 */
173 int GL_UTF8_NV = 0x909A,
174 GL_UTF16_NV = 0x909B;
175
176 /** Accepted by the &lt;coverMode&gt; parameter of CoverFillPathInstancedNV: */
177 int GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV = 0x909C;
178
179 /**
180 * Accepted by the &lt;pname&gt; parameter of GetPathParameterfvNV and
181 * GetPathParameterivNV:
182 */
183 int GL_PATH_COMMAND_COUNT_NV = 0x909D,
184 GL_PATH_COORD_COUNT_NV = 0x909E,
185 GL_PATH_DASH_ARRAY_COUNT_NV = 0x909F,
186 GL_PATH_COMPUTED_LENGTH_NV = 0x90A0,
187 GL_PATH_FILL_BOUNDING_BOX_NV = 0x90A1,
188 GL_PATH_STROKE_BOUNDING_BOX_NV = 0x90A2;
189
190 /**
191 * Accepted by the &lt;value&gt; parameter of PathParameterfNV,
192 * PathParameterfvNV, PathParameteriNV, and PathParameterivNV
193 * when &lt;pname&gt; is one of PATH_END_CAPS_NV, PATH_INTIAL_END_CAP_NV,
194 * PATH_TERMINAL_END_CAP_NV, PATH_DASH_CAPS_NV, PATH_INITIAL_DASH_CAP_NV,
195 * and PATH_TERMINAL_DASH_CAP_NV:
196 */
197 int GL_SQUARE_NV = 0x90A3,
198 GL_ROUND_NV = 0x90A4,
199 GL_TRIANGULAR_NV = 0x90A5;
200
201 /**
202 * Accepted by the &lt;value&gt; parameter of PathParameterfNV,
203 * PathParameterfvNV, PathParameteriNV, and PathParameterivNV
204 * when &lt;pname&gt; is PATH_JOIN_STYLE_NV:
205 */
206 int GL_BEVEL_NV = 0x90A6,
207 GL_MITER_REVERT_NV = 0x90A7,
208 GL_MITER_TRUNCATE_NV = 0x90A8;
209
210 /**
211 * Accepted by the &lt;value&gt; parameter of PathParameterfNV,
212 * PathParameterfvNV, PathParameteriNV, and PathParameterivNV when
213 * &lt;pname&gt; is PATH_DASH_OFFSET_RESET_NV
214 */
215 int GL_MOVE_TO_RESETS_NV = 0x90B5,
216 GL_MOVE_TO_CONTINUES_NV = 0x90B6;
217
218 /** Accepted by the &lt;fontStyle&gt; parameter of PathStringNV: */
219 int GL_BOLD_BIT_NV = 0x01,
220 GL_ITALIC_BIT_NV = 0x02;
221
222 /**
223 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
224 * GetInteger64v, GetFloatv, and GetDoublev:
225 */
226 int GL_PATH_ERROR_POSITION_NV = 0x90AB,
227
228 GL_PATH_FOG_GEN_MODE_NV = 0x90AC,
229
230 GL_PATH_STENCIL_FUNC_NV = 0x90B7,
231 GL_PATH_STENCIL_REF_NV = 0x90B8,
232 GL_PATH_STENCIL_VALUE_MASK_NV = 0x90B9,
233
234 GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV = 0x90BD,
235 GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV = 0x90BE,
236
237 GL_PATH_COVER_DEPTH_FUNC_NV = 0x90BF;
238
239 /**
240 * Accepted as a bit within the &lt;metricQueryMask&gt; parameter of
241 * GetPathMetricRangeNV or GetPathMetricsNV:
242 */
243
244 int GL_GLYPH_WIDTH_BIT_NV = 0x01, // per-glyph metrics
245 GL_GLYPH_HEIGHT_BIT_NV = 0x02,
246 GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV = 0x04,
247 GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV = 0x08,
248 GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV = 0x10,
249 GL_GLYPH_VERTICAL_BEARING_X_BIT_NV = 0x20,
250 GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV = 0x40,
251 GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV = 0x80,
252 GL_GLYPH_HAS_KERNING_NV = 0x100,
253 GL_FONT_X_MIN_BOUNDS_NV = 0x00010000, // per-font face metrics
254 GL_FONT_Y_MIN_BOUNDS_NV = 0x00020000,
255 GL_FONT_X_MAX_BOUNDS_NV = 0x00040000,
256 GL_FONT_Y_MAX_BOUNDS_NV = 0x00080000,
257 GL_FONT_UNITS_PER_EM_NV = 0x00100000,
258 GL_FONT_ASCENDER_NV = 0x00200000,
259 GL_FONT_DESCENDER_NV = 0x00400000,
260 GL_FONT_HEIGHT_NV = 0x00800000,
261 GL_FONT_MAX_ADVANCE_WIDTH_NV = 0x01000000,
262 GL_FONT_MAX_ADVANCE_HEIGHT_NV = 0x02000000,
263 GL_FONT_UNDERLINE_POSITION_NV = 0x04000000,
264 GL_FONT_UNDERLINE_THICKNESS_NV = 0x08000000,
265 GL_FONT_HAS_KERNING_NV = 0x10000000;
266
267 /** Accepted by the &lt;pathListMode&gt; parameter of GetPathSpacingNV: */
268 int GL_ACCUM_ADJACENT_PAIRS_NV = 0x90AD,
269 GL_ADJACENT_PAIRS_NV = 0x90AE,
270 GL_FIRST_TO_REST_NV = 0x90AF;
271
272 /**
273 * Accepted by the &lt;pname&gt; parameter of GetPathColorGenivNV,
274 * GetPathColorGenfvNV, GetPathTexGenivNV and GetPathTexGenfvNV:
275 */
276 int GL_PATH_GEN_MODE_NV = 0x90B0,
277 GL_PATH_GEN_COEFF_NV = 0x90B1,
278 GL_PATH_GEN_COLOR_FORMAT_NV = 0x90B2,
279 GL_PATH_GEN_COMPONENTS_NV = 0x90B3;
280
281 void glPathCommandsNV(@GLuint int path,
282 @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands,
283 @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
284 @Const @GLvoid ByteBuffer coords);
285
286 void glPathCoordsNV(@GLuint int path,
287 @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
288 @Const @GLvoid ByteBuffer coords);
289
290 void glPathSubCommandsNV(@GLuint int path,
291 @GLsizei int commandStart, @GLsizei int commandsToDelete,
292 @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands,
293 @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
294 @Const @GLvoid ByteBuffer coords);
295
296 void glPathSubCoordsNV(@GLuint int path,
297 @GLsizei int coordStart,
298 @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
299 @Const @GLvoid ByteBuffer coords);
300
301 void glPathStringNV(@GLuint int path, @GLenum int format,
302 @AutoSize("pathString") @GLsizei int length, @Const @GLvoid ByteBuffer pathString);
303
304 void glPathGlyphsNV(@GLuint int firstPathName,
305 @GLenum int fontTarget,
306 @NullTerminated @Const @GLvoid ByteBuffer fontName,
307 @GLbitfield int fontStyle,
308 @AutoSize(value = "charcodes", expression = " / GLChecks.calculateBytesPerCharCode(type)") @GLsizei int numGlyphs, @GLenum int type,
309 @Const @GLvoid ByteBuffer charcodes,
310 @GLenum int handleMissingGlyphs,
311 @GLuint int pathParameterTemplate,
312 float emScale);
313
314 void glPathGlyphRangeNV(@GLuint int firstPathName,
315 @GLenum int fontTarget,
316 @NullTerminated @Const @GLvoid ByteBuffer fontName,
317 @GLbitfield int fontStyle,
318 @GLuint int firstGlyph,
319 @GLsizei int numGlyphs,
320 @GLenum int handleMissingGlyphs,
321 @GLuint int pathParameterTemplate,
322 float emScale);
323
324 void glWeightPathsNV(@GLuint int resultPath,
325 @AutoSize("paths") @GLsizei int numPaths,
326 @Const @GLuint IntBuffer paths, @Check("paths.remaining()") @Const FloatBuffer weights);
327
328 void glCopyPathNV(@GLuint int resultPath, @GLuint int srcPath);
329
330 void glInterpolatePathsNV(@GLuint int resultPath,
331 @GLuint int pathA, @GLuint int pathB,
332 float weight);
333
334 void glTransformPathNV(@GLuint int resultPath,
335 @GLuint int srcPath,
336 @GLenum int transformType,
337 @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
338
339 @StripPostfix("value")
340 void glPathParameterivNV(@GLuint int path, @GLenum int pname, @Check("4") @Const IntBuffer value);
341
342 void glPathParameteriNV(@GLuint int path, @GLenum int pname, int value);
343
344 @StripPostfix("value")
345 void glPathParameterfvNV(@GLuint int path, @GLenum int pname, @Check("4") @Const FloatBuffer value);
346
347 void glPathParameterfNV(@GLuint int path, @GLenum int pname, float value);
348
349 void glPathDashArrayNV(@GLuint int path,
350 @AutoSize("dashArray") @GLsizei int dashCount, @Const FloatBuffer dashArray);
351
352 // PATH NAME MANAGEMENT
353
354 @GLuint
355 int glGenPathsNV(@GLsizei int range);
356
357 void glDeletePathsNV(@GLuint int path, @GLsizei int range);
358
359 boolean glIsPathNV(@GLuint int path);
360
361 // PATH STENCILING
362
363 void glPathStencilFuncNV(@GLenum int func, int ref, @GLuint int mask);
364
365 void glPathStencilDepthOffsetNV(float factor, int units);
366
367 void glStencilFillPathNV(@GLuint int path,
368 @GLenum int fillMode, @GLuint int mask);
369
370 void glStencilStrokePathNV(@GLuint int path,
371 int reference, @GLuint int mask);
372
373 void glStencilFillPathInstancedNV(@AutoSize(value="paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
374 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
375 @GLuint int pathBase,
376 @GLenum int fillMode, @GLuint int mask,
377 @GLenum int transformType,
378 @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
379
380 void glStencilStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
381 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
382 @GLuint int pathBase,
383 int reference, @GLuint int mask,
384 @GLenum int transformType,
385 @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
386
387 // PATH COVERING
388
389 void glPathCoverDepthFuncNV(@GLenum int zfunc);
390
391 void glPathColorGenNV(@GLenum int color,
392 @GLenum int genMode,
393 @GLenum int colorFormat, @Check(value = "GLChecks.calculatePathColorGenCoeffsCount(genMode, colorFormat)", canBeNull = true) @Const FloatBuffer coeffs);
394
395 void glPathTexGenNV(@GLenum int texCoordSet,
396 @GLenum int genMode,
397 @AutoSize(value="coeffs", expression="GLChecks.calculatePathTextGenCoeffsPerComponent(coeffs, genMode)", useExpression = true, canBeNull = true) int components, @Check(canBeNull = true) @Const FloatBuffer coeffs);
398
399 void glPathFogGenNV(@GLenum int genMode);
400
401 void glCoverFillPathNV(@GLuint int path, @GLenum int coverMode);
402
403 void glCoverStrokePathNV(@GLuint int name, @GLenum int coverMode);
404
405 void glCoverFillPathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
406 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
407 @GLuint int pathBase,
408 @GLenum int coverMode,
409 @GLenum int transformType,
410 @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
411
412 void glCoverStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
413 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
414 @GLuint int pathBase,
415 @GLenum int coverMode,
416 @GLenum int transformType,
417 @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
418
419 // PATH QUERIES
420
421 @StripPostfix("value")
422 void glGetPathParameterivNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter IntBuffer value);
423
424 @Alternate("glGetPathParameterivNV")
425 @GLreturn("value")
426 @StripPostfix(value = "value", hasPostfix = false)
427 void glGetPathParameterivNV2(@GLuint int name, @GLenum int param, @OutParameter IntBuffer value);
428
429 void glGetPathParameterfvNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter FloatBuffer value);
430
431 @Alternate("glGetPathParameterfvNV")
432 @GLreturn("value")
433 @StripPostfix(value = "value", hasPostfix = false)
434 void glGetPathParameterfvNV2(@GLuint int name, @GLenum int param, @OutParameter FloatBuffer value);
435
436 void glGetPathCommandsNV(@GLuint int name, @Check @OutParameter @GLubyte ByteBuffer commands);
437
438 void glGetPathCoordsNV(@GLuint int name, @Check @OutParameter FloatBuffer coords);
439
440 void glGetPathDashArrayNV(@GLuint int name, @Check @OutParameter FloatBuffer dashArray);
441
442 void glGetPathMetricsNV(@GLbitfield int metricQueryMask,
443 @AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
444 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
445 @GLuint int pathBase,
446 @GLsizei int stride,
447 @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics);
448
449 void glGetPathMetricRangeNV(@GLbitfield int metricQueryMask,
450 @GLuint int fistPathName,
451 @GLsizei int numPaths,
452 @GLsizei int stride,
453 @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics);
454
455 @Code("\t\tint numPaths = paths.remaining() / GLChecks.calculateBytesPerPathName(pathNameType);")
456 void glGetPathSpacingNV(@GLenum int pathListMode,
457 @AutoSize(value = "paths", expression = "numPaths", useExpression = true) @GLsizei int numPaths,
458 @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
459 @GLuint int pathBase,
460 float advanceScale,
461 float kerningScale,
462 @GLenum int transformType,
463 @Check("numPaths - 1") @OutParameter FloatBuffer returnedSpacing);
464
465 @StripPostfix("value")
466 void glGetPathColorGenivNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter IntBuffer value);
467
468 @Alternate("glGetPathColorGenivNV")
469 @GLreturn("value")
470 @StripPostfix(value = "value", hasPostfix = false)
471 void glGetPathColorGenivNV2(@GLenum int color, @GLenum int pname, @OutParameter IntBuffer value);
472
473 @StripPostfix("value")
474 void glGetPathColorGenfvNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value);
475
476 @Alternate("glGetPathColorGenfvNV")
477 @GLreturn("value")
478 @StripPostfix(value = "value", hasPostfix = false)
479 void glGetPathColorGenfvNV2(@GLenum int color, @GLenum int pname, @OutParameter FloatBuffer value);
480
481 @StripPostfix("value")
482 void glGetPathTexGenivNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter IntBuffer value);
483
484 @Alternate("glGetPathTexGenivNV")
485 @GLreturn("value")
486 @StripPostfix(value = "value", hasPostfix = false)
487 void glGetPathTexGenivNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter IntBuffer value);
488
489 @StripPostfix("value")
490 void glGetPathTexGenfvNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value);
491
492 @Alternate("glGetPathTexGenfvNV")
493 @GLreturn("value")
494 @StripPostfix(value = "value", hasPostfix = false)
495 void glGetPathTexGenfvNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter FloatBuffer value);
496
497 boolean glIsPointInFillPathNV(@GLuint int path,
498 @GLuint int mask, float x, float y);
499
500 boolean glIsPointInStrokePathNV(@GLuint int path,
501 float x, float y);
502
503 float glGetPathLengthNV(@GLuint int path,
504 @GLsizei int startSegment, @GLsizei int numSegments);
505
506 boolean glPointAlongPathNV(@GLuint int path,
507 @GLsizei int startSegment, @GLsizei int numSegments,
508 float distance,
509 @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer x,
510 @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer y,
511 @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentX,
512 @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentY);
513
514 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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.Alternate;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.OutParameter;
36 import org.lwjgl.util.generator.StripPostfix;
37 import org.lwjgl.util.generator.opengl.*;
38
39 import java.nio.IntBuffer;
40 import java.nio.LongBuffer;
41
42 public interface NV_present_video {
43
44 /**
45 * Accepted by the &lt;type&gt; parameter of PresentFrameKeyedNV and
46 * PresentFrameDualFillNV:
47 */
48 int GL_FRAME_NV = 0x8E26,
49 FIELDS_NV = 0x8E27;
50
51 /**
52 * Accepted by the &lt;pname&gt; parameter of GetVideoivNV, GetVideouivNV,
53 * GetVideoi64vNV, GetVideoui64vNV:
54 */
55 int GL_CURRENT_TIME_NV = 0x8E28,
56 GL_NUM_FILL_STREAMS_NV = 0x8E29;
57
58 /** Accepted by the &lt;target&gt; parameter of GetQueryiv: */
59 int GL_PRESENT_TIME_NV = 0x8E2A,
60 GL_PRESENT_DURATION_NV = 0x8E2B;
61
62 /** Accepted by the &lt;attribute&gt; parameter of NVPresentVideoUtil.glQueryContextNV: */
63 int GL_NUM_VIDEO_SLOTS_NV = 0x20F0; // GLX_NUM_VIDEO_SLOTS_NV & WGL_NUM_VIDEO_SLOTS_NV
64
65 void glPresentFrameKeyedNV(@GLuint int video_slot,
66 @GLuint64EXT long minPresentTime,
67 @GLuint int beginPresentTimeId,
68 @GLuint int presentDurationId,
69 @GLenum int type,
70 @GLenum int target0, @GLuint int fill0, @GLuint int key0,
71 @GLenum int target1, @GLuint int fill1, @GLuint int key1);
72
73 void glPresentFrameDualFillNV(@GLuint int video_slot,
74 @GLuint64EXT long minPresentTime,
75 @GLuint int beginPresentTimeId,
76 @GLuint int presentDurationId,
77 @GLenum int type,
78 @GLenum int target0, @GLuint int fill0,
79 @GLenum int target1, @GLuint int fill1,
80 @GLenum int target2, @GLuint int fill2,
81 @GLenum int target3, @GLuint int fill3);
82
83 @StripPostfix("params")
84 void glGetVideoivNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
85
86 @Alternate("glGetVideoivNV")
87 @GLreturn("params")
88 @StripPostfix(value = "params", hasPostfix = false)
89 void glGetVideoivNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter IntBuffer params);
90
91 @StripPostfix("params")
92 void glGetVideouivNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
93
94 @Alternate("glGetVideouivNV")
95 @GLreturn("params")
96 @StripPostfix(value = "params", hasPostfix = false)
97 void glGetVideouivNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
98
99 @StripPostfix("params")
100 void glGetVideoi64vNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params);
101
102 @Alternate("glGetVideoi64vNV")
103 @GLreturn("params")
104 @StripPostfix(value = "params", hasPostfix = false)
105 void glGetVideoi64vNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLint64EXT LongBuffer params);
106
107 @StripPostfix("params")
108 void glGetVideoui64vNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
109
110 @Alternate("glGetVideoui64vNV")
111 @GLreturn("params")
112 @StripPostfix(value = "params", hasPostfix = false)
113 void glGetVideoui64vNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
114
115 }
6868 void glDeleteProgramsNV(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
6969
7070 @Alternate("glDeleteProgramsNV")
71 void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program);
71 void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, program)", keepParam = true) int program);
7272
7373 void glGenProgramsNV(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
7474
7979 @StripPostfix("params")
8080 void glGetProgramivNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLint IntBuffer params);
8181
82 /** @deprecated Will be removed in 3.0. Use {@link #glGetProgramiNV} instead. */
8283 @Alternate("glGetProgramivNV")
8384 @GLreturn("params")
8485 @StripPostfix("params")
86 @Reuse(value = "NVProgram", method = "glGetProgramiNV")
87 @Deprecated
8588 void glGetProgramivNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLint IntBuffer params);
89
90 @Alternate("glGetProgramivNV")
91 @GLreturn("params")
92 @StripPostfix(value = "params", hasPostfix = false)
93 void glGetProgramivNV3(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLint IntBuffer params);
8694
8795 void glGetProgramStringNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLubyte Buffer paramString);
8896
8997 @Alternate("glGetProgramStringNV")
90 @Code("\t\tint programLength = glGetProgramNV(programID, GL_PROGRAM_LENGTH_NV);")
98 @Code("\t\tint programLength = glGetProgramiNV(programID, GL_PROGRAM_LENGTH_NV);")
9199 @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true)
92100 void glGetProgramStringNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString);
93101
100108 void glRequestResidentProgramsNV(@AutoSize("programIDs") @GLsizei int n, @GLuint IntBuffer programIDs);
101109
102110 @Alternate("glRequestResidentProgramsNV")
103 void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, programID), 0", keepParam = true) int programID);
111 void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, programID)", keepParam = true) int programID);
104112 }
105113
111111
112112 @Alternate("glGetCombinerInputParameterfvNV")
113113 @GLreturn("params")
114 @StripPostfix(value = "params", postfix = "v")
114 @StripPostfix(value = "params", hasPostfix = false)
115115 void glGetCombinerInputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params);
116116
117117 @StripPostfix("params")
119119
120120 @Alternate("glGetCombinerInputParameterivNV")
121121 @GLreturn("params")
122 @StripPostfix(value = "params", postfix = "v")
122 @StripPostfix(value = "params", hasPostfix = false)
123123 void glGetCombinerInputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params);
124124
125125 @StripPostfix("params")
127127
128128 @Alternate("glGetCombinerOutputParameterfvNV")
129129 @GLreturn("params")
130 @StripPostfix(value = "params", postfix = "v")
130 @StripPostfix(value = "params", hasPostfix = false)
131131 void glGetCombinerOutputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter FloatBuffer params);
132132
133133 @StripPostfix("params")
135135
136136 @Alternate("glGetCombinerOutputParameterivNV")
137137 @GLreturn("params")
138 @StripPostfix(value = "params", postfix = "v")
138 @StripPostfix(value = "params", hasPostfix = false)
139139 void glGetCombinerOutputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter IntBuffer params);
140140
141141 @StripPostfix("params")
143143
144144 @Alternate("glGetFinalCombinerInputParameterfvNV")
145145 @GLreturn("params")
146 @StripPostfix(value = "params", postfix = "v")
146 @StripPostfix(value = "params", hasPostfix = false)
147147 void glGetFinalCombinerInputParameterfvNV2(@GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params);
148148
149149 @StripPostfix("params")
151151
152152 @Alternate("glGetFinalCombinerInputParameterivNV")
153153 @GLreturn("params")
154 @StripPostfix(value = "params", postfix = "v")
154 @StripPostfix(value = "params", hasPostfix = false)
155155 void glGetFinalCombinerInputParameterivNV2(@GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params);
156156 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_atomic_counters {
34 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_atomic_float {
34
35 }
6767
6868 @Alternate("glGetBufferParameterui64vNV")
6969 @GLreturn("params")
70 @StripPostfix("params")
70 @StripPostfix(value = "params", hasPostfix = false)
7171 void glGetBufferParameterui64vNV2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
7272
7373 @StripPostfix("params")
7575
7676 @Alternate("glGetNamedBufferParameterui64vNV")
7777 @GLreturn("params")
78 @StripPostfix("params")
78 @StripPostfix(value = "params", hasPostfix = false)
7979 void glGetNamedBufferParameterui64vNV2(@GLuint int buffer, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params);
8080
8181 @StripPostfix("result")
8383
8484 @Alternate("glGetIntegerui64vNV")
8585 @GLreturn("result")
86 @StripPostfix("result")
86 @StripPostfix(value = "result", hasPostfix = false)
8787 void glGetIntegerui64vNV2(@GLenum int value, @OutParameter @GLuint64EXT LongBuffer result);
8888
8989 void glUniformui64NV(int location, @GLuint64EXT long value);
3535 /** Accepted by the &lt;barriers&gt; parameter of MemoryBarrierNV: */
3636 int GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV = 0x00000010;
3737
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
4238 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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_storage_buffer_object {
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.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface NV_texture_multisample {
38
39 /** Accepted by the &lt;pname&gt; parameter of GetTexLevelParameter: */
40
41 int GL_TEXTURE_COVERAGE_SAMPLES_NV = 0x9045,
42 GL_TEXTURE_COLOR_SAMPLES_NV = 0x9046;
43
44 void glTexImage2DMultisampleCoverageNV(@GLenum int target,
45 @GLsizei int coverageSamples, @GLsizei int colorSamples,
46 int internalFormat,
47 @GLsizei int width, @GLsizei int height,
48 boolean fixedSampleLocations);
49
50 void glTexImage3DMultisampleCoverageNV(@GLenum int target,
51 @GLsizei int coverageSamples, @GLsizei int colorSamples,
52 int internalFormat,
53 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
54 boolean fixedSampleLocations);
55
56 void glTextureImage2DMultisampleNV(@GLuint int texture, @GLenum int target,
57 @GLsizei int samples, int internalFormat,
58 @GLsizei int width, @GLsizei int height,
59 boolean fixedSampleLocations);
60
61 void glTextureImage3DMultisampleNV(@GLuint int texture, @GLenum int target,
62 @GLsizei int samples, int internalFormat,
63 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
64 boolean fixedSampleLocations);
65
66 void glTextureImage2DMultisampleCoverageNV(@GLuint int texture, @GLenum int target,
67 @GLsizei int coverageSamples, @GLsizei int colorSamples,
68 int internalFormat,
69 @GLsizei int width, @GLsizei int height,
70 boolean fixedSampleLocations);
71
72 void glTextureImage3DMultisampleCoverageNV(@GLuint int texture, @GLenum int target,
73 @GLsizei int coverageSamples, @GLsizei int colorSamples,
74 int internalFormat,
75 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
76 boolean fixedSampleLocations);
77
78 }
119119
120120 void glBindBufferBaseNV(@GLenum int target, @GLuint int index, @GLuint int buffer);
121121
122 void glTransformFeedbackAttribsNV(@AutoSize("attribs") @GLsizei int count, @Const IntBuffer attribs, @GLenum int bufferMode);
122 void glTransformFeedbackAttribsNV(@Constant("attribs.remaining() / 3") @GLsizei int count, @Check("3") @Const IntBuffer attribs, @GLenum int bufferMode);
123123
124124 void glTransformFeedbackVaryingsNV(@GLuint int program, @AutoSize("locations") @GLsizei int count, @Const IntBuffer locations, @GLenum int bufferMode);
125125
142142 @Alternate("glGetActiveVaryingNV")
143143 @GLreturn(value = "name", maxLength = "bufSize")
144144 void glGetActiveVaryingNV2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
145 @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length,
145 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
146146 @OutParameter @Check("2") IntBuffer sizeType,
147 @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type,
147 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") IntBuffer type,
148148 @OutParameter @GLchar ByteBuffer name);
149149
150150 /** Overloads glGetActiveVaryingNV. This version returns only the varying name. */
151151 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
152152 @GLreturn(value = "name", maxLength = "bufSize")
153153 void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
154 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
154 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
155155 @OutParameter @GLchar ByteBuffer name);
156156
157157 /** Overloads glGetActiveVaryingNV. This version returns only the varying size. */
158158 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
159159 @GLreturn(value = "size")
160160 void glGetActiveVaryingSizeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize,
161 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
161 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
162162 @OutParameter IntBuffer size,
163 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
164 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
163 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
164 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
165165
166166 /** Overloads glGetActiveVaryingNV. This version returns only the varying type. */
167167 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
168168 @GLreturn(value = "type")
169169 void glGetActiveVaryingTypeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize,
170 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
171 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
170 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
171 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
172172 @OutParameter @GLenum IntBuffer type,
173 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
173 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
174174
175175 void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
176176
5858 void glDeleteTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
5959
6060 @Alternate("glDeleteTransformFeedbacksNV")
61 void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
61 void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
6262
6363 void glGenTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
6464
9191 @StripPostfix("params")
9292 void glGetVertexAttribLui64vNV(@GLuint int index, @GLenum int pname, @OutParameter @GLuint64EXT @Check("4") LongBuffer params);
9393
94 @Dependent("NV_vertex_buffer_unified_memory")
94 @Dependent("GL_NV_vertex_buffer_unified_memory")
9595 void glVertexAttribLFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride);
9696
9797 }
101101
102102 void glVertexAttribIFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride);
103103
104 @StripPostfix("result")
104 @StripPostfix(value = "result", postfix = "i64i_v")
105105 void glGetIntegerui64i_vNV(@GLenum int value, @GLuint int index, @OutParameter @Check("1") @GLuint64EXT LongBuffer result);
106106
107107 @Alternate("glGetIntegerui64i_vNV")
108108 @GLreturn("result")
109 @StripPostfix("result")
109 @StripPostfix(value = "result", postfix = "i_v")
110110 void glGetIntegerui64i_vNV2(@GLenum int value, @GLuint int index, @OutParameter @GLuint64EXT LongBuffer result);
111111
112112 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.DoubleBuffer;
37 import java.nio.FloatBuffer;
38 import java.nio.IntBuffer;
39 import java.nio.LongBuffer;
40
41 public interface NV_video_capture {
42
43 /**
44 * Accepted by the &lt;target&gt; parameters of BindBufferARB, BufferDataARB,
45 * BufferSubDataARB, MapBufferARB, UnmapBufferARB, GetBufferSubDataARB,
46 * GetBufferParameterivARB, and GetBufferPointervARB:
47 */
48 int GL_VIDEO_BUFFER_NV = 0x9020;
49
50 /**
51 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
52 * GetFloatv, and GetDoublev:
53 */
54 int GL_VIDEO_BUFFER_BINDING_NV = 0x9021;
55
56 /**
57 * Accepted by the &lt;frame_region&gt; parameter of
58 * BindVideoCaptureStreamBufferNV, and BindVideoCaptureStreamTextureNV:
59 */
60 int GL_FIELD_UPPER_NV = 0x9022,
61 GL_FIELD_LOWER_NV = 0x9023;
62
63 /** Accepted by the &lt;pname&gt; parameter of GetVideoCaptureivNV: */
64 int GL_NUM_VIDEO_CAPTURE_STREAMS_NV = 0x9024,
65 GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV = 0x9025;
66
67 /**
68 * Accepted by the &lt;pname&gt; parameter of
69 * GetVideoCaptureStream{i,f,d}vNV:
70 */
71 int GL_LAST_VIDEO_CAPTURE_STATUS_NV = 0x9027,
72 GL_VIDEO_BUFFER_PITCH_NV = 0x9028,
73 GL_VIDEO_CAPTURE_FRAME_WIDTH_NV = 0x9038,
74 GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV = 0x9039,
75 GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV = 0x903A,
76 GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV = 0x903B,
77 GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV = 0x9026;
78
79 /**
80 * Accepted by the &lt;pname&gt; parameter of
81 * GetVideoCaptureStream{i,f,d}vNV and as the &lt;pname&gt; parameter of
82 * VideoCaptureStreamParameter{i,f,d}vNV:
83 */
84 int GL_VIDEO_COLOR_CONVERSION_MATRIX_NV = 0x9029,
85 GL_VIDEO_COLOR_CONVERSION_MAX_NV = 0x902A,
86 GL_VIDEO_COLOR_CONVERSION_MIN_NV = 0x902B,
87 GL_VIDEO_COLOR_CONVERSION_OFFSET_NV = 0x902C,
88 GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV = 0x902D,
89 GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV = 0x903C;
90 /** Returned by VideoCaptureNV: */
91 int GL_PARTIAL_SUCCESS_NV = 0x902E;
92
93 /**
94 * Returned by VideoCaptureNV and GetVideoCaptureStream{i,f,d}vNV
95 * when &lt;pname&gt; is LAST_VIDEO_CAPTURE_STATUS_NV:
96 */
97 int GL_SUCCESS_NV = 0x902F,
98 GL_FAILURE_NV = 0x9030;
99
100 /**
101 * Accepted in the &lt;params&gt; parameter of
102 * VideoCaptureStreamParameter{i,f,d}vNV when &lt;pname&gt; is
103 * VIDEO_BUFFER_INTERNAL_FORMAT_NV and returned by
104 * GetVideoCaptureStream{i,f,d}vNV when &lt;pname&gt; is
105 * VIDEO_BUFFER_INTERNAL_FORMAT_NV:
106 */
107 int GL_YCBYCR8_422_NV = 0x9031,
108 GL_YCBAYCR8A_4224_NV = 0x9032,
109 GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV = 0x9033,
110 GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV = 0x9034,
111 GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV = 0x9035,
112 GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV = 0x9036,
113 GL_Z4Y12Z4CB12Z4CR12_444_NV = 0x9037;
114
115 /*
116 * Accepted in the attribute list of the GLX reply to the
117 * glXEnumerateVideoCaptureDevicesNV command:
118 */
119 /*int GLX_DEVICE_ID_NV = 0x20CD;*/
120
121 /** Accepted by the &lt;attribute&gt; parameter of NVPresentVideoUtil.glQueryContextNV: */
122 int GL_NUM_VIDEO_CAPTURE_SLOTS_NV = 0x20CF;
123
124 /**
125 * Accepted by the &lt;attribute&gt; parameter of
126 * glQueryVideoCaptureDeviceNV:
127 */
128 int GL_UNIQUE_ID_NV = 0x20CE;
129
130 void glBeginVideoCaptureNV(@GLuint int video_capture_slot);
131
132 void glBindVideoCaptureStreamBufferNV(@GLuint int video_capture_slot,
133 @GLuint int stream, @GLenum int frame_region,
134 @GLintptrARB long offset);
135
136 void glBindVideoCaptureStreamTextureNV(@GLuint int video_capture_slot,
137 @GLuint int stream, @GLenum int frame_region,
138 @GLenum int target, @GLuint int texture);
139
140 void glEndVideoCaptureNV(@GLuint int video_capture_slot);
141
142 @StripPostfix("params")
143 void glGetVideoCaptureivNV(@GLuint int video_capture_slot, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
144
145 @Alternate("glGetVideoCaptureivNV")
146 @GLreturn("params")
147 @StripPostfix(value = "params", hasPostfix = false)
148 void glGetVideoCaptureivNV2(@GLuint int video_capture_slot, @GLenum int pname, @OutParameter IntBuffer params);
149
150 @StripPostfix("params")
151 void glGetVideoCaptureStreamivNV(@GLuint int video_capture_slot,
152 @GLuint int stream, @GLenum int pname,
153 @OutParameter @Check("1") IntBuffer params);
154
155 @Alternate("glGetVideoCaptureStreamivNV")
156 @GLreturn("params")
157 @StripPostfix(value = "params", hasPostfix = false)
158 void glGetVideoCaptureStreamivNV2(@GLuint int video_capture_slot,
159 @GLuint int stream, @GLenum int pname,
160 @OutParameter IntBuffer params);
161
162 @StripPostfix("params")
163 void glGetVideoCaptureStreamfvNV(@GLuint int video_capture_slot,
164 @GLuint int stream, @GLenum int pname,
165 @OutParameter @Check("1") FloatBuffer params);
166
167 @Alternate("glGetVideoCaptureStreamfvNV")
168 @GLreturn("params")
169 @StripPostfix(value = "params", hasPostfix = false)
170 void glGetVideoCaptureStreamfvNV2(@GLuint int video_capture_slot,
171 @GLuint int stream, @GLenum int pname,
172 @OutParameter FloatBuffer params);
173
174 @StripPostfix("params")
175 void glGetVideoCaptureStreamdvNV(@GLuint int video_capture_slot,
176 @GLuint int stream, @GLenum int pname,
177 @OutParameter @Check("1") DoubleBuffer params);
178
179 @Alternate("glGetVideoCaptureStreamdvNV")
180 @GLreturn("params")
181 @StripPostfix(value = "params", hasPostfix = false)
182 void glGetVideoCaptureStreamdvNV2(@GLuint int video_capture_slot,
183 @GLuint int stream, @GLenum int pname,
184 @OutParameter DoubleBuffer params);
185
186 @GLenum
187 int glVideoCaptureNV(@GLuint int video_capture_slot,
188 @OutParameter @Check("1") @GLuint IntBuffer sequence_num,
189 @OutParameter @Check("1") @GLuint64EXT LongBuffer capture_time);
190
191 @StripPostfix("params")
192 void glVideoCaptureStreamParameterivNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") IntBuffer params);
193
194 @StripPostfix("params")
195 void glVideoCaptureStreamParameterfvNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") FloatBuffer params);
196
197 @StripPostfix("params")
198 void glVideoCaptureStreamParameterdvNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") DoubleBuffer params);
199
200 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface AMD_compressed_3DC_texture {
34
35 /**
36 * Accepted by the &lt;internalFormat&gt; parameter of CompressedTexImage2D and
37 * CompressedTexImage3DOES:
38 */
39 int GL_3DC_X_AMD = 0x87F9,
40 GL_3DC_XY_AMD = 0x87FA;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface AMD_compressed_ATC_texture {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D and
37 * CompressedTexImage3DOES.
38 */
39 int GL_ATC_RGB_AMD = 0x8C92,
40 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93,
41 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE;
42
43 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface AMD_performance_monitor {
40
41 /** Accepted by the &lt;pame&gt; parameter of GetPerfMonitorCounterInfoAMD */
42 int GL_COUNTER_TYPE_AMD = 0x8BC0;
43 int GL_COUNTER_RANGE_AMD = 0x8BC1;
44
45 /**
46 * Returned as a valid value in &lt;data&gt; parameter of
47 * GetPerfMonitorCounterInfoAMD if &lt;pname&gt; = COUNTER_TYPE_AMD
48 */
49 int GL_UNSIGNED_INT64_AMD = 0x8BC2;
50 int GL_PERCENTAGE_AMD = 0x8BC3;
51
52 /** Accepted by the &lt;pname&gt; parameter of GetPerfMonitorCounterDataAMD */
53
54 int GL_PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4;
55 int GL_PERFMON_RESULT_SIZE_AMD = 0x8BC5;
56 int GL_PERFMON_RESULT_AMD = 0x8BC6;
57
58 void glGetPerfMonitorGroupsAMD(@OutParameter @Check(value = "1", canBeNull = true) @GLint IntBuffer numGroups,
59 @AutoSize("groups") @GLsizei int groupsSize, @GLuint IntBuffer groups);
60
61 void glGetPerfMonitorCountersAMD(@GLuint int group,
62 @OutParameter @Check(value = "1") @GLint IntBuffer numCounters,
63 @OutParameter @Check(value = "1") @GLint IntBuffer maxActiveCounters,
64 @AutoSize("counters") @GLsizei int countersSize,
65 @GLuint IntBuffer counters);
66
67 void glGetPerfMonitorGroupStringAMD(@GLuint int group,
68 @AutoSize("groupString") @GLsizei int bufSize,
69 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
70 @OutParameter @GLchar ByteBuffer groupString);
71
72 @Alternate("glGetPerfMonitorGroupStringAMD")
73 @GLreturn(value = "groupString", maxLength = "bufSize")
74 void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize,
75 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(groupString_length)") IntBuffer length,
76 @OutParameter @GLchar ByteBuffer groupString);
77
78 void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize,
79 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
80 @OutParameter @GLchar ByteBuffer counterString);
81
82 @Alternate("glGetPerfMonitorCounterStringAMD")
83 @GLreturn(value = "counterString", maxLength = "bufSize")
84 void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize,
85 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(counterString_length)") IntBuffer length,
86 @OutParameter @GLchar ByteBuffer counterString);
87
88 void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data);
89
90 void glGenPerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors);
91
92 @Alternate("glGenPerfMonitorsAMD")
93 @GLreturn("monitors")
94 void glGenPerfMonitorsAMD2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors);
95
96 void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors);
97
98 @Alternate("glDeletePerfMonitorsAMD")
99 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(monitor)", keepParam = true) int monitor);
100
101 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList);
102
103 @Alternate("glSelectPerfMonitorCountersAMD")
104 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(counter)", keepParam = true) int counter);
105
106 void glBeginPerfMonitorAMD(@GLuint int monitor);
107
108 void glEndPerfMonitorAMD(@GLuint int monitor);
109
110 void glGetPerfMonitorCounterDataAMD(@GLuint int monitor, @GLenum int pname, @AutoSize("data") @GLsizei int dataSize,
111 @OutParameter @GLuint IntBuffer data,
112 @OutParameter @GLint @Check(value = "1", canBeNull = true) IntBuffer bytesWritten);
113
114 @Alternate("glGetPerfMonitorCounterDataAMD")
115 @GLreturn("data")
116 void glGetPerfMonitorCounterDataAMD2(@GLuint int monitor, @GLenum int pname, @Constant("4") @GLsizei int dataSize,
117 @OutParameter @GLuint IntBuffer data,
118 @OutParameter @GLint @Constant("0L") IntBuffer bytesWritten);
119
120 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface AMD_program_binary_Z400 {
34
35 /** Accepted by the &lt;binaryFormat&gt; parameter of ProgramBinaryOES: */
36 int GL_Z400_BINARY_AMD = 0x8740;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLbitfield;
34 import org.lwjgl.util.generator.opengl.GLenum;
35
36 public interface ANGLE_framebuffer_blit {
37
38 /**
39 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
40 * CheckFramebufferStatus, FramebufferTexture2D, FramebufferTexture3DOES,
41 * FramebufferRenderbuffer, and
42 * GetFramebufferAttachmentParameteriv:
43 */
44 int GL_READ_FRAMEBUFFER_ANGLE = 0x8CA8,
45 GL_DRAW_FRAMEBUFFER_ANGLE = 0x8CA9;
46
47 /** Accepted by the &lt;pname&gt; parameters of GetIntegerv and GetFloatv: */
48 int GL_DRAW_FRAMEBUFFER_BINDING_ANGLE = 0x8CA6, // alias FRAMEBUFFER_BINDING
49 GL_READ_FRAMEBUFFER_BINDING_ANGLE = 0x8CAA;
50
51 void glBlitFramebufferANGLE(int srcX0, int srcY0, int srcX1, int srcY1,
52 int dstX0, int dstY0, int dstX1, int dstY1,
53 @GLbitfield int mask, @GLenum int filter);
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35
36 public interface ANGLE_framebuffer_multisample {
37
38 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
39 int GL_RENDERBUFFER_SAMPLES_ANGLE = 0x8CAB;
40
41 /** Returned by CheckFramebufferStatus: */
42 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE = 0x8D56;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
46 * and GetFloatv:
47 */
48 int GL_MAX_SAMPLES_ANGLE = 0x8D57;
49
50 void glRenderbufferStorageMultisampleANGLE(
51 @GLenum int target, @GLsizei int samples,
52 @GLenum int internalformat,
53 @GLsizei int width, @GLsizei int height);
54 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35
36 public interface APPLE_framebuffer_multisample {
37
38 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
39 int GL_RENDERBUFFER_SAMPLES_APPLE = 0x8CAB;
40
41 /** Returned by CheckFramebufferStatus: */
42 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE = 0x8D56;
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
46 * GetFloatv:
47 */
48 int GL_MAX_SAMPLES_APPLE = 0x8D57;
49
50 /**
51 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
52 * CheckFramebufferStatus, FramebufferTexture2D, FramebufferRenderbuffer, and
53 * GetFramebufferAttachmentParameteriv:
54 */
55 int GL_READ_FRAMEBUFFER_APPLE = 0x8CA8,
56 GL_DRAW_FRAMEBUFFER_APPLE = 0x8CA9;
57
58 /**
59 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
60 * GetFloatv:
61 */
62 int GL_DRAW_FRAMEBUFFER_BINDING_APPLE = 0x8CA6, // FRAMEBUFFER_BINDING
63 GL_READ_FRAMEBUFFER_BINDING_APPLE = 0x8CAA;
64
65 void glRenderbufferStorageMultisampleAPPLE(
66 @GLenum int target, @GLsizei int samples,
67 @GLenum int internalformat,
68 @GLsizei int width, @GLsizei int height);
69
70 void glResolveMultisampleFramebufferAPPLE();
71
72 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
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.opengles;
32
33 import org.lwjgl.opengl.GLSync;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.IntBuffer;
38 import java.nio.LongBuffer;
39
40 public interface APPLE_sync {
41
42 /** Accepted as the &lt;pname&gt; parameter of GetInteger64vAPPLE: */
43 int GL_MAX_SERVER_WAIT_TIMEOUT_APPLE = 0x9111;
44
45 /** Accepted as the &lt;pname&gt; parameter of GetSyncivAPPLE: */
46 int GL_OBJECT_TYPE_APPLE = 0x9112,
47 SYNC_CONDITION_APPLE = 0x9113,
48 SYNC_STATUS_APPLE = 0x9114,
49 SYNC_FLAGS_APPLE = 0x9115;
50
51 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; OBJECT_TYPE_APPLE: */
52 int GL_SYNC_FENCE_APPLE = 0x9116;
53
54 /** Returned in &lt;values&gt; for GetSyncivAPPLE &lt;pname&gt; SYNC_CONDITION_APPLE: */
55 int GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE = 0x9117;
56
57 /** Returned in &lt;values&gt; for GetSyncivAPPLE &lt;pname&gt; SYNC_STATUS_APPLE: */
58 int GL_UNSIGNALED_APPLE = 0x9118,
59 SIGNALED_APPLE = 0x9119;
60
61 /** Accepted in the &lt;flags&gt; parameter of ClientWaitSyncAPPLE: */
62 int GL_SYNC_FLUSH_COMMANDS_BIT_APPLE = 0x00000001;
63
64 /** Accepted in the &lt;timeout&gt; parameter of WaitSyncAPPLE: */
65 long GL_TIMEOUT_IGNORED_APPLE = 0xFFFFFFFFFFFFFFFFl;
66
67 /** Returned by ClientWaitSyncAPPLE: */
68 int GL_ALREADY_SIGNALED_APPLE = 0x911A,
69 TIMEOUT_EXPIRED_APPLE = 0x911B,
70 CONDITION_SATISFIED_APPLE = 0x911C,
71 WAIT_FAILED_APPLE = 0x911D;
72
73 /**
74 * Accepted by the &lt;type&gt; parameter of LabelObjectEXT and
75 * GetObjectLabelEXT:
76 */
77 int GL_SYNC_OBJECT_APPLE = 0x8A53;
78
79 @PointerWrapper("GLsync")
80 org.lwjgl.opengl.GLSync glFenceSyncAPPLE(@GLenum int condition, @GLbitfield int flags);
81
82 boolean glIsSyncAPPLE(@PointerWrapper("GLsync") org.lwjgl.opengl.GLSync sync);
83
84 void glDeleteSyncAPPLE(@PointerWrapper("GLsync") org.lwjgl.opengl.GLSync sync);
85
86 @GLenum
87 int glClientWaitSyncAPPLE(@PointerWrapper("GLsync") org.lwjgl.opengl.GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
88
89 void glWaitSyncAPPLE(@PointerWrapper("GLsync") org.lwjgl.opengl.GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
90
91 @StripPostfix("params")
92 void glGetInteger64vAPPLE(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
93
94 @Alternate("glGetInteger64vAPPLE")
95 @GLreturn("params")
96 @StripPostfix(value = "params", hasPostfix = false)
97 void glGetInteger64vAPPLE2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params);
98
99 @StripPostfix("values")
100 void glGetSyncivAPPLE(@PointerWrapper("GLsync") org.lwjgl.opengl.GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
101 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
102 @OutParameter IntBuffer values);
103
104 @Alternate("glGetSyncivAPPLE")
105 @GLreturn("values")
106 @StripPostfix(value = "values", hasPostfix = false)
107 void glGetSyncivAPPLE2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
108 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
109 @OutParameter IntBuffer values);
110
111 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface APPLE_texture_format_BGRA8888 {
34
35 /** Accepted by the &lt;format&gt; parameters of TexImage2D and TexSubImage2D: */
36 int GL_BGRA_EXT = 0x80E1;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface APPLE_texture_max_level {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of TexParameteri, TexParameterf,
37 * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv:
38 */
39 int GL_TEXTURE_MAX_LEVEL_APPLE = 0x813D;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Alternate;
34 import org.lwjgl.util.generator.AutoSize;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.Constant;
37 import org.lwjgl.util.generator.opengl.GLenum;
38 import org.lwjgl.util.generator.opengl.GLsizei;
39
40 import java.nio.IntBuffer;
41
42 public interface ARB_draw_buffers {
43
44 /** Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv: */
45 int GL_MAX_DRAW_BUFFERS_ARB = 0x8824,
46 GL_DRAW_BUFFER0_ARB = 0x8825,
47 GL_DRAW_BUFFER1_ARB = 0x8826,
48 GL_DRAW_BUFFER2_ARB = 0x8827,
49 GL_DRAW_BUFFER3_ARB = 0x8828,
50 GL_DRAW_BUFFER4_ARB = 0x8829,
51 GL_DRAW_BUFFER5_ARB = 0x882A,
52 GL_DRAW_BUFFER6_ARB = 0x882B,
53 GL_DRAW_BUFFER7_ARB = 0x882C,
54 GL_DRAW_BUFFER8_ARB = 0x882D,
55 GL_DRAW_BUFFER9_ARB = 0x882E,
56 GL_DRAW_BUFFER10_ARB = 0x882F,
57 GL_DRAW_BUFFER11_ARB = 0x8830,
58 GL_DRAW_BUFFER12_ARB = 0x8831,
59 GL_DRAW_BUFFER13_ARB = 0x8832,
60 GL_DRAW_BUFFER14_ARB = 0x8833,
61 GL_DRAW_BUFFER15_ARB = 0x8834;
62
63 void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
64
65 @Alternate("glDrawBuffersARB")
66 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
67
68 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
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:
39 */
40 int GL_HALF_FLOAT_ARB = 0x140B;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
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-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface ARM_mali_shader_binary {
34
35 /** Accepted by the &lt;binaryFormat&gt; parameter of ShaderBinary: */
36 int GL_MALI_SHADER_BINARY_ARM = 0x8F60;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface ARM_rgba8 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorage: */
36 int GL_RGBA8_OES = 0x8058;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface DMP_shader_binary {
34
35 /** Accepted by the &lt;binaryformat&gt; parameter of ShaderBinary: */
36 int GL_SHADER_BINARY_DMP = 0x9250;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_Cg_shader {
34
35 /**
36 * You can pass GL_CG_VERTEX_SHADER_EXT to glCreateShader instead of GL_VERTEX_SHADER to create a vertex shader
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 glCreateShader instead of GL_FRAGMENT_SHADER 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 GL_CG_FRAGMENT_SHADER_EXT = 0x890F;
43
44 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_bgra {
34
35 /**
36 * Accepted by the &lt;format&gt; parameter of DrawPixels, GetTexImage,
37 * ReadPixels, TexImage1D, and TexImage2D:
38 */
39 int GL_BGR_EXT = 0x80E0,
40 GL_BGRA_EXT = 0x80E1;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
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 GL_MIN_EXT = 0x8007,
40 GL_MAX_EXT = 0x8008;
41
42 void glBlendEquationEXT(@GLenum int mode);
43
44 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_color_buffer_half_float {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorage and
37 * RenderbufferStorageMultisampleAPPLE:
38 */
39 int GL_RGBA16F_EXT = 0x881A,
40 GL_RGB16F_EXT = 0x881B,
41 GL_RG16F_EXT = 0x822F,
42 GL_R16F_EXT = 0x822D;
43
44 /** Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachmentParameteriv: */
45 int GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 0x8211;
46
47 /** Returned in &lt;params&gt; by GetFramebufferAttachmentParameteriv: */
48 int GL_UNSIGNED_NORMALIZED_EXT = 0x8C17;
49
50 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLsizei;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface EXT_copy_texture_levels {
37
38 void glCopyTextureLevelsAPPLE(@GLuint int destinationTexture, @GLuint int sourceTexture,
39 int sourceBaseLevel, @GLsizei int sourceLevelCount);
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface EXT_debug_label {
40
41 /**
42 * Accepted by the &lt;type&gt; parameter of LabelObjectEXT and
43 * GetObjectLabelEXT:
44 */
45 int GL_BUFFER_OBJECT_EXT = 0x9151,
46 GL_SHADER_OBJECT_EXT = 0x8B48,
47 GL_PROGRAM_OBJECT_EXT = 0x8B40,
48 GL_VERTEX_ARRAY_OBJECT_EXT = 0x9154,
49 GL_QUERY_OBJECT_EXT = 0x9153,
50 GL_PROGRAM_PIPELINE_OBJECT_EXT = 0x8A4F;
51
52 void glLabelObjectEXT(@GLenum int type, @GLuint int object,
53 @AutoSize("label") @GLsizei int length,
54 @Const @GLchar ByteBuffer label);
55
56 @Alternate("glLabelObjectEXT")
57 void glLabelObjectEXT(@GLenum int type, @GLuint int object,
58 @Constant("label.length()") @GLsizei int length,
59 CharSequence label);
60
61 void glGetObjectLabelEXT(@GLenum int type, @GLuint int object,
62 @AutoSize(value = "label", canBeNull = true) @GLsizei int bufSize,
63 @Check(value = "1", canBeNull = true) @OutParameter @GLsizei IntBuffer length,
64 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer label);
65
66 @Alternate("glGetObjectLabelEXT")
67 @GLreturn(value = "label", maxLength = "bufSize")
68 void glGetObjectLabelEXT2(@GLenum int type, @GLuint int object,
69 @GLsizei int bufSize,
70 @Constant("MemoryUtil.getAddress0(label_length)") @OutParameter @GLsizei IntBuffer length,
71 @OutParameter @GLchar ByteBuffer label);
72
73 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Alternate;
34 import org.lwjgl.util.generator.AutoSize;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.Constant;
37 import org.lwjgl.util.generator.opengl.GLchar;
38 import org.lwjgl.util.generator.opengl.GLsizei;
39
40 import java.nio.ByteBuffer;
41
42 public interface EXT_debug_marker {
43
44 void glInsertEventMarkerEXT(@AutoSize("marker") @GLsizei int length, @Const @GLchar ByteBuffer marker);
45
46 @Alternate("glInsertEventMarkerEXT")
47 void glInsertEventMarkerEXT(@Constant("marker.length()") @GLsizei int length, CharSequence marker);
48
49 void glPushGroupMarkerEXT(@AutoSize("marker") @GLsizei int length, @Const @GLchar ByteBuffer marker);
50
51 @Alternate("glPushGroupMarkerEXT")
52 void glPushGroupMarkerEXT(@Constant("marker.length()") @GLsizei int length, CharSequence marker);
53
54 void glPopGroupMarkerEXT();
55
56 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Const;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37
38 import java.nio.IntBuffer;
39
40 public interface EXT_discard_framebuffer {
41
42 /**
43 * Accepted in the &lt;attachments&gt; parameter of DiscardFramebufferEXT when the
44 * default framebuffer is bound to &lt;target&gt;:
45 */
46 int GL_COLOR_EXT = 0x1800,
47 GL_DEPTH_EXT = 0x1801,
48 GL_STENCIL_EXT = 0x1802;
49
50 void glDiscardFramebufferEXT(@GLenum int target, @AutoSize("attachments") @GLsizei int numAttachments, @Const @GLenum IntBuffer attachments);
51
52 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_frag_depth {
34
35 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.CachedResult;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.ByteBuffer;
38
39 public interface EXT_map_buffer_range {
40
41 /** Accepted by the &lt;access&gt; parameter of MapBufferRangeEXT: */
42 int GL_MAP_READ_BIT_EXT = 0x0001,
43 GL_MAP_WRITE_BIT_EXT = 0x0002,
44 GL_MAP_INVALIDATE_RANGE_BIT_EXT = 0x0004,
45 GL_MAP_INVALIDATE_BUFFER_BIT_EXT = 0x0008,
46 GL_MAP_FLUSH_EXPLICIT_BIT_EXT = 0x0010,
47 GL_MAP_UNSYNCHRONIZED_BIT_EXT = 0x0020;
48
49 /**
50 * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null,
51 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
52 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
53 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this:
54 * <p/>
55 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer);
56 * <p/>
57 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
58 *
59 * @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.
60 *
61 * @return A ByteBuffer representing the mapped buffer memory.
62 */
63 @CachedResult(isRange = true)
64 @GLvoid
65 @AutoSize("length")
66 ByteBuffer glMapBufferRangeEXT(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
67
68 void glFlushMappedBufferRangeEXT(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
69
70 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLint;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38
39 import java.nio.IntBuffer;
40
41 public interface EXT_multi_draw_arrays {
42
43 void glMultiDrawArraysEXT(@GLenum int mode, @GLint IntBuffer first, @Check("first.remaining()") @GLsizei IntBuffer count, @AutoSize("first") @GLsizei int primcount);
44
45 //void glMultiDrawElementsEXT(GLenum mode, GLsizei*count, GLenum type, const GLvoid**indices, GLsizei primcount)
46
47 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface EXT_multisampled_render_to_texture {
38
39 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
40 int GL_RENDERBUFFER_SAMPLES_EXT = 0x9133;
41
42 /** Returned by CheckFramebufferStatus: */
43 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x9134;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
47 * and GetFloatv:
48 */
49 int GL_MAX_SAMPLES_EXT = 0x9135;
50
51 /** Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachmentParameteriv: */
52 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT = 0x8D6C;
53
54 void glRenderbufferStorageMultisampleEXT(
55 @GLenum int target, @GLsizei int samples,
56 @GLenum int internalformat,
57 @GLsizei int width, @GLsizei int height);
58
59 void glFramebufferTexture2DMultisampleEXT(
60 @GLenum int target, @GLenum int attachment,
61 @GLenum int textarget, @GLuint int texture,
62 int level, @GLsizei int samples);
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.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 import java.nio.IntBuffer;
39
40 public interface EXT_multiview_draw_buffers {
41
42 /** Accepted by the &lt;location&gt; parameter of DrawBuffersIndexedEXT: */
43 int GL_COLOR_ATTACHMENT_EXT = 0x90F0,
44 GL_MULTIVIEW_EXT = 0x90F1;
45
46 /** Accepted by the &lt;target&gt; parameter of GetIntegeri_EXT: */
47 int GL_DRAW_BUFFER_EXT = 0x0C01,
48 GL_READ_BUFFER_EXT = 0x0C02;
49
50 /** Accepted by the &lt;target&gt; parameter of GetInteger: */
51 int GL_MAX_MULTIVIEW_BUFFERS_EXT = 0x90F2;
52
53 void glReadBufferIndexedEXT(@GLenum int src, int index);
54
55 void glDrawBuffersIndexedEXT(@AutoSize("indices") int n, @Check("indices.remaining()") @Const @GLenum IntBuffer location,
56 @Const IntBuffer indices);
57
58 @StripPostfix("data")
59 void glGetIntegeri_vEXT(@GLenum int target, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
60
61 @Alternate("glGetIntegeri_vEXT")
62 @GLreturn("data")
63 @StripPostfix("data")
64 void glGetIntegeri_vEXT2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
65
66 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.IntBuffer;
40
41 public interface EXT_occlusion_query_boolean {
42
43 /**
44 * Accepted by the &lt;target&gt; parameter of BeginQueryEXT, EndQueryEXT,
45 * and GetQueryivEXT:
46 */
47 int GL_ANY_SAMPLES_PASSED_EXT = 0x8C2F,
48 GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8D6A;
49
50 /** Accepted by the &lt;pname&gt; parameter of GetQueryivEXT: */
51 int GL_CURRENT_QUERY_EXT = 0x8865;
52
53 /**
54 * Accepted by the &lt;pname&gt; parameter of GetQueryObjectivEXT and
55 * GetQueryObjectuivEXT:
56 */
57 int GL_QUERY_RESULT_EXT = 0x8866,
58 GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867;
59
60 void glGenQueriesEXT(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
61
62 @Alternate("glGenQueriesEXT")
63 @GLreturn("ids")
64 void glGenQueriesEXT2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
65
66 void glDeleteQueriesEXT(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
67
68 @Alternate("glDeleteQueriesEXT")
69 void glDeleteQueriesEXT(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
70
71 boolean glIsQueryEXT(@GLuint int id);
72
73 void glBeginQueryEXT(@GLenum int target, @GLuint int id);
74
75 void glEndQueryEXT(@GLenum int target);
76
77 @StripPostfix("params")
78 void glGetQueryivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
79
80 @Alternate("glGetQueryivEXT")
81 @GLreturn("params")
82 @StripPostfix(value = "params", hasPostfix = false)
83 void glGetQueryivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
84
85 @StripPostfix("params")
86 void glGetQueryObjectuivEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
87
88 @Alternate("glGetQueryObjectuivEXT")
89 @GLreturn("params")
90 @StripPostfix(value = "params", hasPostfix = false)
91 void glGetQueryObjectuivEXT2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params);
92
93 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
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 * RenderbufferStorage:
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:
46 */
47 int GL_UNSIGNED_INT_10F_11F_11F_REV_EXT = 0x8C3B;
48
49 /** Accepted by the &lt;pname&gt; parameters of GetIntegerv and GetFloatv: */
50 int GL_RGBA_SIGNED_COMPONENTS_EXT = 0x8C3C;
51
52 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_read_format_bgra {
34
35 /** Accepted by the &lt;format&gt; parameter of ReadPixels: */
36 int GL_BGRA_EXT = 0x80E1;
37
38 /** Accepted by the &lt;type&gt; parameter of ReadPixels: */
39 int GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT = 0x8365,
40 GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT = 0x8366;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.OutParameter;
35 import org.lwjgl.util.generator.StripPostfix;
36 import org.lwjgl.util.generator.opengl.*;
37
38 import java.nio.Buffer;
39 import java.nio.FloatBuffer;
40 import java.nio.IntBuffer;
41
42 public interface EXT_robustness {
43
44 /** Returned by GetGraphicsResetStatusEXT: */
45 int GL_NO_ERROR = 0x0000,
46 GL_GUILTY_CONTEXT_RESET_EXT = 0x8253,
47 GL_INNOCENT_CONTEXT_RESET_EXT = 0x8254,
48 GL_UNKNOWN_CONTEXT_RESET_EXT = 0x8255;
49
50 /**
51 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
52 * and GetFloatv:
53 */
54 int GL_CONTEXT_ROBUST_ACCESS_EXT = 0x90F3,
55 GL_RESET_NOTIFICATION_STRATEGY_EXT = 0x8256;
56
57 /**
58 * Returned by GetIntegerv and related simple queries when &lt;value&gt; is
59 * RESET_NOTIFICATION_STRATEGY_EXT :
60 */
61 int GL_LOSE_CONTEXT_ON_RESET_EXT = 0x8252,
62 GL_NO_RESET_NOTIFICATION_EXT = 0x8261;
63
64 @GLenum
65 int glGetGraphicsResetStatusEXT();
66
67 void glReadnPixelsEXT(int x, int y, @GLsizei int width, @GLsizei int height,
68 @GLenum int format, @GLenum int type, @AutoSize("data") @GLsizei int bufSize,
69 @OutParameter @GLbyte @GLshort @GLint @GLfloat Buffer data);
70
71 @StripPostfix("params")
72 void glGetnUniformfvEXT(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter FloatBuffer params);
73
74 @StripPostfix("params")
75 void glGetnUniformivEXT(@GLuint int program, int location, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
76
77 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_sRGB {
34
35 /**
36 * Accepted by the &lt;format&gt; and &lt;internalformat&gt; parameter of TexImage2D, and
37 * TexImage3DOES. These are also accepted by &lt;format&gt; parameter of
38 * TexSubImage2D and TexSubImage3DOES:
39 */
40 int GL_SRGB_EXT = 0x8C40,
41 GL_SRGB_ALPHA_EXT = 0x8C42;
42
43 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorage: */
44 int GL_SRGB8_ALPHA8_EXT = 0x8C43;
45
46 /** Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachmentParameteriv: */
47 int GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210;
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.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.FloatBuffer;
38 import java.nio.IntBuffer;
39
40 public interface EXT_separate_shader_objects {
41
42 /** Accepted by &lt;stages&gt; parameter to UseProgramStagesEXT: */
43 int GL_VERTEX_SHADER_BIT_EXT = 0x00000001,
44 GL_FRAGMENT_SHADER_BIT_EXT = 0x00000002,
45 GL_ALL_SHADER_BITS_EXT = 0xFFFFFFFF;
46
47 /**
48 * Accepted by the &lt;pname&gt; parameter of ProgramParameteriEXT and
49 * GetProgramiv:
50 */
51 int GL_PROGRAM_SEPARABLE_EXT = 0x8258;
52
53 /** Accepted by &lt;type&gt; parameter to GetProgramPipelineivEXT: */
54 int GL_ACTIVE_PROGRAM_EXT = 0x8259;
55
56 /**
57 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
58 * GetFloatv:
59 */
60 int GL_PROGRAM_PIPELINE_BINDING_EXT = 0x825A;
61
62 void glUseProgramStagesEXT(@GLuint int pipeline, @GLbitfield int stages, @GLuint int program);
63
64 void glActiveShaderProgramEXT(@GLuint int pipeline, @GLuint int program);
65
66 /** Single null-terminated source code string. */
67 @StripPostfix(value = "string", hasPostfix = false)
68 @GLuint
69 int glCreateShaderProgramvEXT(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated @Check @Const @Indirect @GLchar ByteBuffer string);
70
71 /** Multiple null-terminated source code strings, one after the other. */
72 @Alternate(value = "glCreateShaderProgramvEXT", nativeAlt = true)
73 @StripPostfix(value = "strings", hasPostfix = false)
74 @GLuint
75 int glCreateShaderProgramvEXT2(@GLenum int type, @GLsizei int count, @NullTerminated("count") @Check @Const @Indirect @GLchar @PointerArray("count") ByteBuffer strings);
76
77 @Alternate(value = "glCreateShaderProgramvEXT", nativeAlt = true)
78 @StripPostfix(value = "strings", hasPostfix = false)
79 @GLuint
80 int glCreateShaderProgramvEXT3(@GLenum int type, @Constant("strings.length") @GLsizei int count, @NullTerminated @Check("1") @PointerArray(value = "count") @Const @NativeType("GLchar") ByteBuffer[] strings);
81
82 @Alternate("glCreateShaderProgramvEXT")
83 @StripPostfix(value = "string", hasPostfix = false)
84 @GLuint
85 int glCreateShaderProgramvEXT(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string);
86
87 @Alternate(value = "glCreateShaderProgramvEXT", nativeAlt = true, skipNative = true)
88 @StripPostfix(value = "strings", hasPostfix = false)
89 @GLuint
90 int glCreateShaderProgramvEXT2(@GLenum int type, @Constant("strings.length") @GLsizei int count,
91 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
92
93 void glBindProgramPipelineEXT(@GLuint int pipeline);
94
95 void glDeleteProgramPipelinesEXT(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines);
96
97 @Alternate("glDeleteProgramPipelinesEXT")
98 void glDeleteProgramPipelinesEXT(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(pipeline)", keepParam = true) int pipeline);
99
100 void glGenProgramPipelinesEXT(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
101
102 @Alternate("glGenProgramPipelinesEXT")
103 @GLreturn("pipelines")
104 void glGenProgramPipelinesEXT2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
105
106 boolean glIsProgramPipelineEXT(@GLuint int pipeline);
107
108 void glProgramParameteriEXT(@GLuint int program, @GLenum int pname, int value);
109
110 @StripPostfix("params")
111 void glGetProgramPipelineivEXT(@GLuint int pipeline, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
112
113 @Alternate("glGetProgramPipelineivEXT")
114 @GLreturn("params")
115 @StripPostfix(value = "params", hasPostfix = false)
116 void glGetProgramPipelineivEXT2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params);
117
118 void glProgramUniform1iEXT(@GLuint int program, int location, int v0);
119
120 void glProgramUniform2iEXT(@GLuint int program, int location, int v0, int v1);
121
122 void glProgramUniform3iEXT(@GLuint int program, int location, int v0, int v1, int v2);
123
124 void glProgramUniform4iEXT(@GLuint int program, int location, int v0, int v1, int v2, int v3);
125
126 void glProgramUniform1fEXT(@GLuint int program, int location, float v0);
127
128 void glProgramUniform2fEXT(@GLuint int program, int location, float v0, float v1);
129
130 void glProgramUniform3fEXT(@GLuint int program, int location, float v0, float v1, float v2);
131
132 void glProgramUniform4fEXT(@GLuint int program, int location, float v0, float v1, float v2, float v3);
133
134 @StripPostfix("value")
135 void glProgramUniform1ivEXT(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value);
136
137 @StripPostfix("value")
138 void glProgramUniform2ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
139
140 @StripPostfix("value")
141 void glProgramUniform3ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
142
143 @StripPostfix("value")
144 void glProgramUniform4ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
145
146 @StripPostfix("value")
147 void glProgramUniform1fvEXT(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const FloatBuffer value);
148
149 @StripPostfix("value")
150 void glProgramUniform2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value);
151
152 @StripPostfix("value")
153 void glProgramUniform3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value);
154
155 @StripPostfix("value")
156 void glProgramUniform4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value);
157
158 @StripPostfix("value")
159 void glProgramUniformMatrix2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
160
161 @StripPostfix("value")
162 void glProgramUniformMatrix3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
163
164 @StripPostfix("value")
165 void glProgramUniformMatrix4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
166
167 void glValidateProgramPipelineEXT(@GLuint int pipeline);
168
169 void glGetProgramPipelineInfoLogEXT(@GLuint int pipeline, @AutoSize("infoLog") @GLsizei int bufSize,
170 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
171 @OutParameter @GLchar ByteBuffer infoLog);
172
173 @Alternate("glGetProgramPipelineInfoLogEXT")
174 @GLreturn(value = "infoLog", maxLength = "bufSize")
175 void glGetProgramPipelineInfoLogEXT2(@GLuint int pipeline, @GLsizei int bufSize,
176 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
177 @OutParameter @GLchar ByteBuffer infoLog);
178
179 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_shader_framebuffer_fetch {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
37 * and GetDoublev:
38 */
39 int GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT = 0x8A52;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_shader_texture_lod {
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.opengles;
32
33 public interface EXT_shadow_samplers {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of TexParameterf, TexParameteri,
37 * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv:
38 */
39 int GL_TEXTURE_COMPARE_MODE_EXT = 0x884C,
40 GL_TEXTURE_COMPARE_FUNC_EXT = 0x884D;
41
42 /**
43 * Accepted by the &lt;param&gt; parameter of TexParameterf, TexParameteri,
44 * TexParameterfv, and TexParameteriv when the &lt;pname&gt; parameter is
45 * TEXTURE_COMPARE_MODE_EXT:
46 */
47 int GL_COMPARE_REF_TO_TEXTURE_EXT = 0x884E;
48
49 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.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 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 GL_TEXTURE_BINDING_2D_ARRAY_EXT = 0x8C1D,
64 GL_MAX_ARRAY_TEXTURE_LAYERS_EXT = 0x88FF;
65
66 /**
67 * Accepted by the &lt;pname&gt; parameter of
68 * GetFramebufferAttachmentParameterivEXT:
69 */
70 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT = 0x8CD4;
71
72 /** Returned by the &lt;type&gt; parameter of GetActiveUniform: */
73 int GL_SAMPLER_1D_ARRAY_EXT = 0x8DC0,
74 GL_SAMPLER_2D_ARRAY_EXT = 0x8DC1;
75
76 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
77
78 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "EXT", className = "EXTTextureCompressionDXT1")
36 public interface EXT_texture_compression_dxt1 {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D
40 * and the &lt;format&gt; parameter of CompressedTexSubImage2D:
41 */
42 int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
43 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
44
45 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
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 GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT = 0x8C71,
45 GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C72,
46 GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C73;
47
48 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "EXT", className = "EXTTextureCompressionS3TC")
36 public interface EXT_texture_compression_s3tc {
37
38 /**
39 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D, CopyTexImage2D,
40 * and CompressedTexImage2D and the &lt;format&gt; parameter of
41 * CompressedTexSubImage2D:
42 */
43 int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
44 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1,
45 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
46 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
47
48 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_texture_filter_anisotropic {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameters of GetTexParameterfv,
37 * GetTexParameteriv, TexParameterf, TexParameterfv, TexParameteri,
38 * and TexParameteriv:
39 */
40 int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
41
42 /**
43 * Accepted by the &lt;pname&gt; parameters of GetBooleanv,
44 * GetFloatv, and GetIntegerv:
45 */
46 int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
47
48 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_texture_format_BGRA8888 {
34
35 /**
36 * Accepted by the &lt;format> and &lt;internalformat&gt; parameters of TexImage2D
37 * and the &lt;format&gt; parameter of TexSubImage2D:
38 */
39 int GL_BGRA_EXT = 0x80E1;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "EXT", className = "EXTTextureLODBias")
36 public interface EXT_texture_lod_bias {
37
38 /**
39 * Accepted by the &lt;target&gt; parameters of GetTexEnvfv, GetTexEnviv,
40 * TexEnvi, TexEnvf, Texenviv, and TexEnvfv:
41 */
42 int GL_TEXTURE_FILTER_CONTROL_EXT = 0x8500;
43
44 /**
45 * When the &lt;target&gt; parameter of GetTexEnvfv, GetTexEnviv, TexEnvi,
46 * TexEnvf, TexEnviv, and TexEnvfv is TEXTURE_FILTER_CONTROL_EXT, then
47 * the value of &lt;pname&gt; may be:
48 */
49 int GL_TEXTURE_LOD_BIAS_EXT = 0x8501;
50
51 /**
52 * Accepted by the &lt;pname&gt; parameters of GetBooleanv, GetIntegerv,
53 * GetFloatv, and GetDoublev:
54 */
55 int GL_MAX_TEXTURE_LOD_BIAS_EXT = 0x84FD;
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.opengles;
32
33 public interface EXT_texture_rg {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of TexImage2D and CopyTexImage2D,
37 * and the &lt;format&gt; parameter of TexImage2D, TexSubImage2D, and ReadPixels:
38 */
39 int GL_RED_EXT = 0x1903,
40 GL_RG_EXT = 0x8227;
41
42 /**
43 * Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorage and
44 * RenderbufferStorageMultisampleAPPLE:
45 */
46 int GL_R8_EXT = 0x8229,
47 GL_RG8_EXT = 0x822B;
48
49 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface EXT_texture_storage {
38
39 /** Accepted by the &lt;value&gt; parameter of GetTexParameter{if}v: */
40
41 int GL_TEXTURE_IMMUTABLE_FORMAT_EXT = 0x912F;
42 /**
43 * Accepted by the &lt;internalformat&gt; parameter of TexStorage* when
44 * implemented on OpenGL ES:
45 */
46 int GL_ALPHA8_EXT = 0x803C,
47 GL_LUMINANCE8_EXT = 0x8040,
48 GL_LUMINANCE8_ALPHA8_EXT = 0x8045,
49 GL_RGBA32F_EXT = 0x8814,
50 GL_RGB32F_EXT = 0x8815,
51 GL_ALPHA32F_EXT = 0x8816,
52 GL_LUMINANCE32F_EXT = 0x8818,
53 GL_LUMINANCE_ALPHA32F_EXT = 0x8819,
54 GL_RGBA16F_EXT = 0x881A,
55 GL_RGB16F_EXT = 0x881B,
56 GL_ALPHA16F_EXT = 0x881C,
57 GL_LUMINANCE16F_EXT = 0x881E,
58 GL_LUMINANCE_ALPHA16F_EXT = 0x881F,
59 GL_RGB10_A2_EXT = 0x8059,
60 GL_RGB10_EXT = 0x8052,
61 GL_BGRA8_EXT = 0x93A1;
62
63 void glTexStorage1DEXT(@GLenum int target, @GLsizei int levels,
64 @GLenum int internalformat,
65 @GLsizei int width);
66
67 void glTexStorage2DEXT(@GLenum int target, @GLsizei int levels,
68 @GLenum int internalformat,
69 @GLsizei int width, @GLsizei int height);
70
71 void glTexStorage3DEXT(@GLenum int target, @GLsizei int levels,
72 @GLenum int internalformat,
73 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
74
75 void glTextureStorage1DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
76 @GLenum int internalformat,
77 @GLsizei int width);
78
79 void glTextureStorage2DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
80 @GLenum int internalformat,
81 @GLsizei int width, @GLsizei int height);
82
83 void glTextureStorage3DEXT(@GLuint int texture, @GLenum int target, @GLsizei int levels,
84 @GLenum int internalformat,
85 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
86
87 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_texture_type_2_10_10_10_REV {
34
35 /** Accepted by the &lt;type&gt; parameter of TexImage2D and TexImage3D: */
36 int GL_UNSIGNED_INT_2_10_10_10_REV_EXT = 0x8368;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface EXT_unpack_subimage {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameters of PixelStorei, GetIntegerv, and
37 * GetFloatv:
38 */
39 int GL_UNPACK_ROW_LENGTH = 0x0CF2,
40 GL_UNPACK_SKIP_ROWS = 0x0CF3,
41 GL_UNPACK_SKIP_PIXELS = 0x0CF4;
42
43 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37 import java.nio.ByteBuffer;
38 import java.nio.FloatBuffer;
39 import java.nio.IntBuffer;
40
41 public interface GLES20 {
42
43 /** ClearBufferMask */
44 int GL_DEPTH_BUFFER_BIT = 0x00000100,
45 GL_STENCIL_BUFFER_BIT = 0x00000400,
46 GL_COLOR_BUFFER_BIT = 0x00004000;
47
48 /** Boolean */
49 int GL_FALSE = 0,
50 GL_TRUE = 1;
51
52 /** BeginMode */
53 int GL_POINTS = 0x0000,
54 GL_LINES = 0x0001,
55 GL_LINE_LOOP = 0x0002,
56 GL_LINE_STRIP = 0x0003,
57 GL_TRIANGLES = 0x0004,
58 GL_TRIANGLE_STRIP = 0x0005,
59 GL_TRIANGLE_FAN = 0x0006;
60
61 /** BlendingFactorDest */
62 int GL_ZERO = 0,
63 GL_ONE = 1,
64 GL_SRC_COLOR = 0x0300,
65 GL_ONE_MINUS_SRC_COLOR = 0x0301,
66 GL_SRC_ALPHA = 0x0302,
67 GL_ONE_MINUS_SRC_ALPHA = 0x0303,
68 GL_DST_ALPHA = 0x0304,
69 GL_ONE_MINUS_DST_ALPHA = 0x0305;
70
71 /** BlendingFactorSrc */
72 int
73 /* GL_ZERO */
74 /* GL_ONE */
75 GL_DST_COLOR = 0x0306,
76 GL_ONE_MINUS_DST_COLOR = 0x0307,
77 GL_SRC_ALPHA_SATURATE = 0x0308;
78 /* GL_SRC_ALPHA */
79 /* GL_ONE_MINUS_SRC_ALPHA */
80 /* GL_DST_ALPHA */
81 /* GL_ONE_MINUS_DST_ALPHA */
82
83 /** BlendEquationSeparate */
84 int GL_FUNC_ADD = 0x8006,
85 GL_BLEND_EQUATION = 0x8009,
86 GL_BLEND_EQUATION_RGB = 0x8009, /* same as BLEND_EQUATION */
87 GL_BLEND_EQUATION_ALPHA = 0x883D;
88
89 /** BlendSubtract */
90 int GL_FUNC_SUBTRACT = 0x800A,
91 GL_FUNC_REVERSE_SUBTRACT = 0x800B;
92
93 /** Separate Blend Functions */
94 int GL_BLEND_DST_RGB = 0x80C8,
95 GL_BLEND_SRC_RGB = 0x80C9,
96 GL_BLEND_DST_ALPHA = 0x80CA,
97 GL_BLEND_SRC_ALPHA = 0x80CB,
98 GL_CONSTANT_COLOR = 0x8001,
99 GL_ONE_MINUS_CONSTANT_COLOR = 0x8002,
100 GL_CONSTANT_ALPHA = 0x8003,
101 GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
102 GL_BLEND_COLOR = 0x8005;
103
104 /** Buffer Objects */
105 int GL_ARRAY_BUFFER = 0x8892,
106 GL_ELEMENT_ARRAY_BUFFER = 0x8893,
107 GL_ARRAY_BUFFER_BINDING = 0x8894,
108 GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
109 GL_STREAM_DRAW = 0x88E0,
110 GL_STATIC_DRAW = 0x88E4,
111 GL_DYNAMIC_DRAW = 0x88E8,
112 GL_BUFFER_SIZE = 0x8764,
113 GL_BUFFER_USAGE = 0x8765,
114 GL_CURRENT_VERTEX_ATTRIB = 0x8626;
115
116 /** CullFaceMode */
117 int GL_FRONT = 0x0404,
118 GL_BACK = 0x0405,
119 GL_FRONT_AND_BACK = 0x0408;
120
121 /** DepthFunction */
122 /* GL_NEVER */
123 /* GL_LESS */
124 /* GL_EQUAL */
125 /* GL_LEQUAL */
126 /* GL_GREATER */
127 /* GL_NOTEQUAL */
128 /* GL_GEQUAL */
129 /* GL_ALWAYS */
130
131 /** EnableCap */
132 int GL_TEXTURE_2D = 0x0DE1,
133 GL_CULL_FACE = 0x0B44,
134 GL_BLEND = 0x0BE2,
135 GL_DITHER = 0x0BD0,
136 GL_STENCIL_TEST = 0x0B90,
137 GL_DEPTH_TEST = 0x0B71,
138 GL_SCISSOR_TEST = 0x0C11,
139 GL_POLYGON_OFFSET_FILL = 0x8037,
140 GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
141 GL_SAMPLE_COVERAGE = 0x80A0;
142
143 /** ErrorCode */
144 int GL_NO_ERROR = 0,
145 GL_INVALID_ENUM = 0x0500,
146 GL_INVALID_VALUE = 0x0501,
147 GL_INVALID_OPERATION = 0x0502,
148 GL_OUT_OF_MEMORY = 0x0505;
149
150 /** FrontFaceDirection */
151 int GL_CW = 0x0900,
152 GL_CCW = 0x0901;
153
154 /** GetPName */
155 int GL_LINE_WIDTH = 0x0B21,
156 GL_ALIASED_POINT_SIZE_RANGE = 0x846D,
157 GL_ALIASED_LINE_WIDTH_RANGE = 0x846E,
158 GL_CULL_FACE_MODE = 0x0B45,
159 GL_FRONT_FACE = 0x0B46,
160 GL_DEPTH_RANGE = 0x0B70,
161 GL_DEPTH_WRITEMASK = 0x0B72,
162 GL_DEPTH_CLEAR_VALUE = 0x0B73,
163 GL_DEPTH_FUNC = 0x0B74,
164 GL_STENCIL_CLEAR_VALUE = 0x0B91,
165 GL_STENCIL_FUNC = 0x0B92,
166 GL_STENCIL_FAIL = 0x0B94,
167 GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95,
168 GL_STENCIL_PASS_DEPTH_PASS = 0x0B96,
169 GL_STENCIL_REF = 0x0B97,
170 GL_STENCIL_VALUE_MASK = 0x0B93,
171 GL_STENCIL_WRITEMASK = 0x0B98,
172 GL_STENCIL_BACK_FUNC = 0x8800,
173 GL_STENCIL_BACK_FAIL = 0x8801,
174 GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
175 GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
176 GL_STENCIL_BACK_REF = 0x8CA3,
177 GL_STENCIL_BACK_VALUE_MASK = 0x8CA4,
178 GL_STENCIL_BACK_WRITEMASK = 0x8CA5,
179 GL_VIEWPORT = 0x0BA2,
180 GL_SCISSOR_BOX = 0x0C10,
181 /* GL_SCISSOR_TEST */
182 GL_COLOR_CLEAR_VALUE = 0x0C22,
183 GL_COLOR_WRITEMASK = 0x0C23,
184 GL_UNPACK_ALIGNMENT = 0x0CF5,
185 GL_PACK_ALIGNMENT = 0x0D05,
186 GL_MAX_TEXTURE_SIZE = 0x0D33,
187 GL_MAX_VIEWPORT_DIMS = 0x0D3A,
188 GL_SUBPIXEL_BITS = 0x0D50,
189 GL_RED_BITS = 0x0D52,
190 GL_GREEN_BITS = 0x0D53,
191 GL_BLUE_BITS = 0x0D54,
192 GL_ALPHA_BITS = 0x0D55,
193 GL_DEPTH_BITS = 0x0D56,
194 GL_STENCIL_BITS = 0x0D57,
195 GL_POLYGON_OFFSET_UNITS = 0x2A00,
196 /* GL_POLYGON_OFFSET_FILL */
197 GL_POLYGON_OFFSET_FACTOR = 0x8038,
198 GL_TEXTURE_BINDING_2D = 0x8069,
199 GL_SAMPLE_BUFFERS = 0x80A8,
200 GL_SAMPLES = 0x80A9,
201 GL_SAMPLE_COVERAGE_VALUE = 0x80AA,
202 GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
203
204 /** GetTextureParameter */
205 int
206 /* GL_TEXTURE_MAG_FILTER */
207 /* GL_TEXTURE_MIN_FILTER */
208 /* GL_TEXTURE_WRAP_S */
209 /* GL_TEXTURE_WRAP_T */
210 GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
211 GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
212
213 /** HintMode */
214 int GL_DONT_CARE = 0x1100,
215 GL_FASTEST = 0x1101,
216 GL_NICEST = 0x1102;
217
218 /** HintTarget */
219 int GL_GENERATE_MIPMAP_HINT = 0x8192;
220
221 /** DataType */
222 int GL_BYTE = 0x1400,
223 GL_UNSIGNED_BYTE = 0x1401,
224 GL_SHORT = 0x1402,
225 GL_UNSIGNED_SHORT = 0x1403,
226 GL_INT = 0x1404,
227 GL_UNSIGNED_INT = 0x1405,
228 GL_FLOAT = 0x1406,
229 GL_FIXED = 0x140C;
230
231 /** PixelFormat */
232 int GL_DEPTH_COMPONENT = 0x1902,
233 GL_ALPHA = 0x1906,
234 GL_RGB = 0x1907,
235 GL_RGBA = 0x1908,
236 GL_LUMINANCE = 0x1909,
237 GL_LUMINANCE_ALPHA = 0x190A;
238
239 /** PixelType */
240 int
241 /* GL_UNSIGNED_BYTE */
242 GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033,
243 GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034,
244 GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
245
246 /** Shaders */
247 int GL_FRAGMENT_SHADER = 0x8B30,
248 GL_VERTEX_SHADER = 0x8B31,
249 GL_MAX_VERTEX_ATTRIBS = 0x8869,
250 GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
251 GL_MAX_VARYING_VECTORS = 0x8DFC,
252 GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
253 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
254 GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872,
255 GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
256 GL_SHADER_TYPE = 0x8B4F,
257 GL_DELETE_STATUS = 0x8B80,
258 GL_LINK_STATUS = 0x8B82,
259 GL_VALIDATE_STATUS = 0x8B83,
260 GL_ATTACHED_SHADERS = 0x8B85,
261 GL_ACTIVE_UNIFORMS = 0x8B86,
262 GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
263 GL_ACTIVE_ATTRIBUTES = 0x8B89,
264 GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
265 GL_SHADING_LANGUAGE_VERSION = 0x8B8C,
266 GL_CURRENT_PROGRAM = 0x8B8D;
267
268 /** StencilFunction */
269 int GL_NEVER = 0x0200,
270 GL_LESS = 0x0201,
271 GL_EQUAL = 0x0202,
272 GL_LEQUAL = 0x0203,
273 GL_GREATER = 0x0204,
274 GL_NOTEQUAL = 0x0205,
275 GL_GEQUAL = 0x0206,
276 GL_ALWAYS = 0x0207;
277
278 /** StencilOp */
279 int
280 /* GL_ZERO */
281 GL_KEEP = 0x1E00,
282 GL_REPLACE = 0x1E01,
283 GL_INCR = 0x1E02,
284 GL_DECR = 0x1E03,
285 GL_INVERT = 0x150A,
286 GL_INCR_WRAP = 0x8507,
287 GL_DECR_WRAP = 0x8508;
288
289 /** StringName */
290 int GL_VENDOR = 0x1F00,
291 GL_RENDERER = 0x1F01,
292 GL_VERSION = 0x1F02,
293 GL_EXTENSIONS = 0x1F03;
294
295 /** TextureMagFilter */
296 int GL_NEAREST = 0x2600,
297 GL_LINEAR = 0x2601;
298
299 /** TextureMinFilter */
300 int
301 /* GL_NEAREST */
302 /* GL_LINEAR */
303 GL_NEAREST_MIPMAP_NEAREST = 0x2700,
304 GL_LINEAR_MIPMAP_NEAREST = 0x2701,
305 GL_NEAREST_MIPMAP_LINEAR = 0x2702,
306 GL_LINEAR_MIPMAP_LINEAR = 0x2703;
307
308 /** TextureParameterName */
309 int GL_TEXTURE_MAG_FILTER = 0x2800,
310 GL_TEXTURE_MIN_FILTER = 0x2801,
311 GL_TEXTURE_WRAP_S = 0x2802,
312 GL_TEXTURE_WRAP_T = 0x2803;
313
314 /** TextureTarget */
315 int
316 /* GL_TEXTURE_2D */
317 GL_TEXTURE = 0x1702,
318 GL_TEXTURE_CUBE_MAP = 0x8513,
319 GL_TEXTURE_BINDING_CUBE_MAP = 0x8514,
320 GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
321 GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
322 GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
323 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
324 GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
325 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
326 GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
327
328 /** TextureUnit */
329 int GL_TEXTURE0 = 0x84C0,
330 GL_TEXTURE1 = 0x84C1,
331 GL_TEXTURE2 = 0x84C2,
332 GL_TEXTURE3 = 0x84C3,
333 GL_TEXTURE4 = 0x84C4,
334 GL_TEXTURE5 = 0x84C5,
335 GL_TEXTURE6 = 0x84C6,
336 GL_TEXTURE7 = 0x84C7,
337 GL_TEXTURE8 = 0x84C8,
338 GL_TEXTURE9 = 0x84C9,
339 GL_TEXTURE10 = 0x84CA,
340 GL_TEXTURE11 = 0x84CB,
341 GL_TEXTURE12 = 0x84CC,
342 GL_TEXTURE13 = 0x84CD,
343 GL_TEXTURE14 = 0x84CE,
344 GL_TEXTURE15 = 0x84CF,
345 GL_TEXTURE16 = 0x84D0,
346 GL_TEXTURE17 = 0x84D1,
347 GL_TEXTURE18 = 0x84D2,
348 GL_TEXTURE19 = 0x84D3,
349 GL_TEXTURE20 = 0x84D4,
350 GL_TEXTURE21 = 0x84D5,
351 GL_TEXTURE22 = 0x84D6,
352 GL_TEXTURE23 = 0x84D7,
353 GL_TEXTURE24 = 0x84D8,
354 GL_TEXTURE25 = 0x84D9,
355 GL_TEXTURE26 = 0x84DA,
356 GL_TEXTURE27 = 0x84DB,
357 GL_TEXTURE28 = 0x84DC,
358 GL_TEXTURE29 = 0x84DD,
359 GL_TEXTURE30 = 0x84DE,
360 GL_TEXTURE31 = 0x84DF,
361 GL_ACTIVE_TEXTURE = 0x84E0;
362
363 /** TextureWrapMode */
364 int GL_REPEAT = 0x2901,
365 GL_CLAMP_TO_EDGE = 0x812F,
366 GL_MIRRORED_REPEAT = 0x8370;
367
368 /** Uniform Types */
369 int GL_FLOAT_VEC2 = 0x8B50,
370 GL_FLOAT_VEC3 = 0x8B51,
371 GL_FLOAT_VEC4 = 0x8B52,
372 GL_INT_VEC2 = 0x8B53,
373 GL_INT_VEC3 = 0x8B54,
374 GL_INT_VEC4 = 0x8B55,
375 GL_BOOL = 0x8B56,
376 GL_BOOL_VEC2 = 0x8B57,
377 GL_BOOL_VEC3 = 0x8B58,
378 GL_BOOL_VEC4 = 0x8B59,
379 GL_FLOAT_MAT2 = 0x8B5A,
380 GL_FLOAT_MAT3 = 0x8B5B,
381 GL_FLOAT_MAT4 = 0x8B5C,
382 GL_SAMPLER_2D = 0x8B5E,
383 GL_SAMPLER_CUBE = 0x8B60;
384
385 /** Vertex Arrays */
386 int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
387 GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
388 GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
389 GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
390 GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
391 GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
392 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
393
394 /** Read Format */
395 int GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
396 GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
397
398 /** Shader Source */
399 int GL_COMPILE_STATUS = 0x8B81,
400 GL_INFO_LOG_LENGTH = 0x8B84,
401 GL_SHADER_SOURCE_LENGTH = 0x8B88,
402 GL_SHADER_COMPILER = 0x8DFA;
403
404 /** Shader Binary */
405 int GL_SHADER_BINARY_FORMATS = 0x8DF8,
406 GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9;
407
408 /** Shader Precision-Specified Types */
409 int GL_LOW_FLOAT = 0x8DF0,
410 GL_MEDIUM_FLOAT = 0x8DF1,
411 GL_HIGH_FLOAT = 0x8DF2,
412 GL_LOW_INT = 0x8DF3,
413 GL_MEDIUM_INT = 0x8DF4,
414 GL_HIGH_INT = 0x8DF5;
415
416 /** Framebuffer Object. */
417 int GL_FRAMEBUFFER = 0x8D40,
418 GL_RENDERBUFFER = 0x8D41,
419 GL_RGBA4 = 0x8056,
420 GL_RGB5_A1 = 0x8057,
421 GL_RGB565 = 0x8D62,
422 GL_DEPTH_COMPONENT16 = 0x81A5,
423 GL_STENCIL_INDEX = 0x1901,
424 GL_STENCIL_INDEX8 = 0x8D48,
425 GL_RENDERBUFFER_WIDTH = 0x8D42,
426 GL_RENDERBUFFER_HEIGHT = 0x8D43,
427 GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
428 GL_RENDERBUFFER_RED_SIZE = 0x8D50,
429 GL_RENDERBUFFER_GREEN_SIZE = 0x8D51,
430 GL_RENDERBUFFER_BLUE_SIZE = 0x8D52,
431 GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53,
432 GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54,
433 GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55,
434 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
435 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
436 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
437 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
438 GL_COLOR_ATTACHMENT0 = 0x8CE0,
439 GL_DEPTH_ATTACHMENT = 0x8D00,
440 GL_STENCIL_ATTACHMENT = 0x8D20,
441 GL_NONE = 0,
442 GL_FRAMEBUFFER_COMPLETE = 0x8CD5,
443 GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
444 GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
445 GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
446 GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
447 GL_FRAMEBUFFER_BINDING = 0x8CA6,
448 GL_RENDERBUFFER_BINDING = 0x8CA7,
449 GL_MAX_RENDERBUFFER_SIZE = 0x84E8,
450 GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506;
451
452 void glActiveTexture(@GLenum int texture);
453
454 void glAttachShader(@GLuint int program, @GLuint int shader);
455
456 void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name);
457
458 @Alternate("glBindAttribLocation")
459 void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated CharSequence name);
460
461 @Code(" StateTracker.bindBuffer(target, buffer);")
462 void glBindBuffer(@GLenum int target, @GLuint int buffer);
463
464 void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer);
465
466 void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer);
467
468 void glBindTexture(@GLenum int target, @GLuint int texture);
469
470 void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
471
472 void glBlendEquation(@GLenum int mode);
473
474 void glBlendEquationSeparate(@GLenum int modeRGB, @GLenum int modeAlpha);
475
476 void glBlendFunc(@GLenum int sfactor, @GLenum int dfactor);
477
478 void glBlendFuncSeparate(@GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha);
479
480 @GenerateAutos
481 void glBufferData(@GLenum int target, @AutoSize("data") @GLsizeiptr long size,
482 @Check @Const @GLbyte @GLshort @GLint @GLfloat Buffer data, @GLenum int usage);
483
484 void glBufferSubData(@GLenum int target, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size,
485 @Check @Const @GLbyte @GLshort @GLint @GLfloat Buffer data);
486
487 @GLenum
488 int glCheckFramebufferStatus(@GLenum int target);
489
490 void glClear(@GLbitfield int mask);
491
492 void glClearColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
493
494 void glClearDepthf(@GLclampf float depth);
495
496 void glClearStencil(@GLint int s);
497
498 void glColorMask(@GLboolean boolean red, @GLboolean boolean green, @GLboolean boolean blue, @GLboolean boolean alpha);
499
500 void glCompileShader(@GLuint int shader);
501
502 void glCompressedTexImage2D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize,
503 @Check @Const @GLvoid ByteBuffer data);
504
505 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,
506 @Check @Const @GLvoid ByteBuffer data);
507
508 void glCopyTexImage2D(@GLenum int target, @GLint int level, @GLenum int internalformat, @GLint int x, @GLint int y, @GLsizei int width, @GLsizei int height, @GLint int border);
509
510 void glCopyTexSubImage2D(@GLenum int target, @GLint int level, @GLint int xoffset, @GLint int yoffset, @GLint int x, @GLint int y, @GLsizei int width, @GLsizei int height);
511
512 @GLuint
513 int glCreateProgram();
514
515 @GLuint
516 int glCreateShader(@GLenum int type);
517
518 void glCullFace(@GLenum int mode);
519
520 void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
521
522 @Alternate("glDeleteBuffers")
523 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
524
525 void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
526
527 @Alternate("glDeleteFramebuffers")
528 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer);
529
530 void glDeleteProgram(@GLuint int program);
531
532 void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
533
534 @Alternate("glDeleteRenderbuffers")
535 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer);
536
537 void glDeleteShader(@GLuint int shader);
538
539 void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures);
540
541 @Alternate("glDeleteTextures")
542 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(texture)", keepParam = true) int texture);
543
544 void glDepthFunc(@GLenum int func);
545
546 void glDepthMask(@GLboolean boolean flag);
547
548 void glDepthRangef(@GLclampf float zNear, @GLclampf float zFar);
549
550 void glDetachShader(@GLuint int program, @GLuint int shader);
551
552 void glDisable(@GLenum int cap);
553
554 void glDisableVertexAttribArray(@GLuint int index);
555
556 void glDrawArrays(@GLenum int mode, @GLint int first, @GLsizei int count);
557
558 void glDrawElements(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
559 @BufferObject(BufferKind.ElementVBO) @Const @GLubyte @GLushort @GLuint Buffer indices);
560
561 void glEnable(@GLenum int cap);
562
563 void glEnableVertexAttribArray(@GLuint int index);
564
565 void glFinish();
566
567 void glFlush();
568
569 void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
570
571 void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, @GLint int level);
572
573 void glFrontFace(@GLenum int mode);
574
575 void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
576
577 @Alternate("glGenBuffers")
578 @GLreturn("buffers")
579 void glGenBuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
580
581 void glGenerateMipmap(@GLenum int target);
582
583 void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
584
585 @Alternate("glGenFramebuffers")
586 @GLreturn("framebuffers")
587 void glGenFramebuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers);
588
589 void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
590
591 @Alternate("glGenRenderbuffers")
592 @GLreturn("renderbuffers")
593 void glGenRenderbuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers);
594
595 void glGenTextures(@AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
596
597 @Alternate("glGenTextures")
598 @GLreturn("textures")
599 void glGenTextures2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer textures);
600
601 void glGetActiveAttrib(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
602 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
603 @OutParameter @Check("1") IntBuffer size,
604 @OutParameter @Check("1") @GLenum IntBuffer type,
605 @OutParameter @GLchar ByteBuffer name);
606
607 /** Overloads glGetActiveAttrib. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
608 @Alternate("glGetActiveAttrib")
609 @GLreturn(value = "name", maxLength = "bufsize")
610 void glGetActiveAttrib2(@GLuint int program, @GLuint int index, @GLsizei int bufsize,
611 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
612 @OutParameter @Check("2") IntBuffer sizeType,
613 @OutParameter @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") @GLenum IntBuffer type,
614 @OutParameter @GLchar ByteBuffer name);
615
616 /** Overloads glGetActiveAttrib. This version returns only the attrib name. */
617 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
618 @GLreturn(value = "name", maxLength = "bufsize")
619 void glGetActiveAttrib(@GLuint int program, @GLuint int index, @GLsizei int bufsize,
620 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length,
621 @OutParameter @GLchar ByteBuffer name);
622
623 /** Overloads glGetActiveAttrib. This version returns only the attrib size. */
624 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
625 @GLreturn(value = "size")
626 void glGetActiveAttribSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufsize,
627 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
628 @OutParameter IntBuffer size,
629 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
630 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
631
632 /** Overloads glGetActiveAttrib. This version returns only the attrib type. */
633 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
634 @GLreturn(value = "type")
635 void glGetActiveAttribType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufsize,
636 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
637 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
638 @OutParameter @GLenum IntBuffer type,
639 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
640
641 void glGetActiveUniform(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
642 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
643 @OutParameter @Check("1") @GLsizei IntBuffer size,
644 @OutParameter @Check("1") @GLenum IntBuffer type,
645 @OutParameter @GLchar ByteBuffer name);
646
647 /** Overloads glGetActiveUniform. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */
648 @Alternate("glGetActiveUniform")
649 @GLreturn(value = "name", maxLength = "bufsize")
650 void glGetActiveUniform2(@GLuint int program, @GLuint int index, @GLsizei int bufsize,
651 @OutParameter @Constant("MemoryUtil.getAddress0(name_length)") @GLsizei IntBuffer length,
652 @OutParameter @Check("2") IntBuffer sizeType,
653 @OutParameter @Constant("MemoryUtil.getAddress(sizeType, sizeType.position() + 1)") @GLenum IntBuffer type,
654 @OutParameter @GLchar ByteBuffer name);
655
656 /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */
657 @Alternate(value = "glGetActiveUniform", javaAlt = true)
658 @GLreturn(value = "name", maxLength = "bufsize")
659 void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int bufsize,
660 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length,
661 @OutParameter @GLchar ByteBuffer name);
662
663 /** Overloads glGetActiveUniform. This version returns only the uniform size. */
664 @Alternate(value = "glGetActiveUniform", javaAlt = true)
665 @GLreturn(value = "size")
666 void glGetActiveUniformSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufsize,
667 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
668 @OutParameter IntBuffer size,
669 @OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
670 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
671
672 /** Overloads glGetActiveUniform. This version returns only the uniform type. */
673 @Alternate(value = "glGetActiveUniform", javaAlt = true)
674 @GLreturn(value = "type")
675 void glGetActiveUniformType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufsize,
676 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
677 @OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
678 @OutParameter @GLenum IntBuffer type,
679 @OutParameter @GLchar @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
680
681 void glGetAttachedShaders(@GLuint int program, @AutoSize("shaders") @GLsizei int maxCount,
682 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer count,
683 @OutParameter @GLuint IntBuffer shaders);
684
685 int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
686
687 @Alternate("glGetAttribLocation")
688 int glGetAttribLocation(@GLuint int program, @NullTerminated CharSequence name);
689
690 @StripPostfix("params")
691 void glGetBooleanv(@GLenum int pname, @OutParameter @Check("1") @GLboolean ByteBuffer params);
692
693 @Alternate("glGetBooleanv")
694 @GLreturn("params")
695 @StripPostfix("params")
696 void glGetBooleanv2(@GLenum int pname, @OutParameter @GLboolean ByteBuffer params);
697
698 @StripPostfix("params")
699 void glGetBufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
700
701 /** @deprecated Will be removed in 3.0. Use {@link #glGetBufferParameteri} instead. */
702 @Alternate("glGetBufferParameteriv")
703 @GLreturn("params")
704 @StripPostfix("params")
705 @Reuse(value = "GLES20", method = "glGetBufferParameteri")
706 @Deprecated
707 void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
708
709 @Alternate("glGetBufferParameteriv")
710 @GLreturn("params")
711 @StripPostfix(value = "params", hasPostfix = false)
712 void glGetBufferParameteriv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
713
714 @NoErrorCheck
715 @GLenum
716 int glGetError();
717
718 @StripPostfix("params")
719 void glGetFloatv(@GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
720
721 @Alternate("glGetFloatv")
722 @GLreturn("params")
723 @StripPostfix("params")
724 void glGetFloatv2(@GLenum int pname, @OutParameter FloatBuffer params);
725
726 @StripPostfix("params")
727 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
728
729 /** @deprecated Will be removed in 3.0. Use {@link #glGetFramebufferAttachmentParameteri} instead. */
730 @Alternate("glGetFramebufferAttachmentParameteriv")
731 @GLreturn("params")
732 @StripPostfix("params")
733 @Reuse(value = "GLES20", method = "glGetFramebufferAttachmentParameteri")
734 @Deprecated
735 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
736
737 @Alternate("glGetFramebufferAttachmentParameteriv")
738 @GLreturn("params")
739 @StripPostfix(value = "params", hasPostfix = false)
740 void glGetFramebufferAttachmentParameteriv3(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
741
742 @StripPostfix("params")
743 void glGetIntegerv(@GLenum int pname, @OutParameter @Check("1") IntBuffer params);
744
745 @Alternate("glGetIntegerv")
746 @GLreturn("params")
747 @StripPostfix("params")
748 void glGetIntegerv2(@GLenum int pname, @OutParameter IntBuffer params);
749
750 @StripPostfix("params")
751 void glGetProgramiv(@GLuint int program, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
752
753 /** @deprecated Will be removed in 3.0. Use {@link #glGetProgrami} instead. */
754 @Alternate("glGetProgramiv")
755 @GLreturn("params")
756 @StripPostfix("params")
757 @Reuse(value = "GLES20", method = "glGetProgrami")
758 @Deprecated
759 void glGetProgramiv2(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params);
760
761 @Alternate("glGetProgramiv")
762 @GLreturn("params")
763 @StripPostfix(value = "params", hasPostfix = false)
764 void glGetProgramiv3(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params);
765
766 void glGetProgramInfoLog(@GLuint int program, @AutoSize("infoLog") @GLsizei int bufsize,
767 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
768 @OutParameter @GLchar ByteBuffer infoLog);
769
770 @Alternate("glGetProgramInfoLog")
771 @GLreturn(value = "infoLog", maxLength = "bufsize")
772 void glGetProgramInfoLog2(@GLuint int program, @GLsizei int bufsize,
773 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
774 @OutParameter @GLchar ByteBuffer infoLog);
775
776 @StripPostfix("params")
777 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
778
779 /** @deprecated Will be removed in 3.0. Use {@link #glGetRenderbufferParameteri} instead. */
780 @Alternate("glGetRenderbufferParameteriv")
781 @GLreturn("params")
782 @StripPostfix("params")
783 @Reuse(value = "GLES20", method = "glGetRenderbufferParameteri")
784 @Deprecated
785 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
786
787 @Alternate("glGetRenderbufferParameteriv")
788 @GLreturn("params")
789 @StripPostfix(value = "params", hasPostfix = false)
790 void glGetRenderbufferParameteriv3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
791
792 @StripPostfix("params")
793 void glGetShaderiv(@GLuint int shader, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
794
795 /** @deprecated Will be removed in 3.0. Use {@link #glGetShaderi} instead. */
796 @Alternate("glGetShaderiv")
797 @GLreturn("params")
798 @StripPostfix("params")
799 @Reuse(value = "GLES20", method = "glGetShaderi")
800 @Deprecated
801 void glGetShaderiv2(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params);
802
803 @Alternate("glGetShaderiv")
804 @GLreturn("params")
805 @StripPostfix(value = "params", hasPostfix = false)
806 void glGetShaderiv3(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params);
807
808 void glGetShaderInfoLog(@GLuint int shader, @AutoSize("infoLog") @GLsizei int bufsize,
809 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
810 @OutParameter @GLchar ByteBuffer infoLog);
811
812 @Alternate("glGetShaderInfoLog")
813 @GLreturn(value = "infoLog", maxLength = "bufsize")
814 void glGetShaderInfoLog2(@GLuint int shader, @GLsizei int bufsize,
815 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(infoLog_length)") IntBuffer length,
816 @OutParameter @GLchar ByteBuffer infoLog);
817
818 void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype, @OutParameter @GLint @Check("2") IntBuffer range, @OutParameter @Check("1") @GLint IntBuffer precision);
819
820 void glGetShaderSource(@GLuint int shader, @AutoSize("source") @GLsizei int bufsize,
821 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
822 @OutParameter @GLchar ByteBuffer source);
823
824 @Alternate("glGetShaderSource")
825 @GLreturn(value = "source", maxLength = "bufsize")
826 void glGetShaderSource2(@GLuint int shader, @GLsizei int bufsize,
827 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(source_length)") IntBuffer length,
828 @OutParameter @GLchar ByteBuffer source);
829
830 @Const
831 String glGetString(@GLenum int name);
832
833 @StripPostfix("params")
834 void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") FloatBuffer params);
835
836 @Alternate("glGetTexParameterfv")
837 @GLreturn("params")
838 @StripPostfix(value = "params", hasPostfix = false)
839 void glGetTexParameterfv2(@GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params);
840
841 @StripPostfix("params")
842 void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
843
844 @Alternate("glGetTexParameteriv")
845 @GLreturn("params")
846 @StripPostfix(value = "params", hasPostfix = false)
847 void glGetTexParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
848
849 @StripPostfix("params")
850 void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check("1") FloatBuffer params);
851
852 @StripPostfix("params")
853 void glGetUniformiv(@GLuint int program, int location, @OutParameter @Check("1") IntBuffer params);
854
855 /**
856 * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a
857 * <b>null-terminated</b> string.
858 *
859 * @param program
860 * @param name
861 */
862 int glGetUniformLocation(@GLuint int program, @NullTerminated @Check("1") @Const @GLchar ByteBuffer name);
863
864 @Alternate("glGetUniformLocation")
865 int glGetUniformLocation(@GLuint int program, @NullTerminated CharSequence name);
866
867 @StripPostfix("params")
868 void glGetVertexAttribfv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
869
870 @StripPostfix("params")
871 void glGetVertexAttribiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
872
873 @StripPostfix("pointer")
874 void glGetVertexAttribPointerv(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
875
876 void glHint(@GLenum int target, @GLenum int mode);
877
878 @GLboolean
879 boolean glIsBuffer(@GLuint int buffer);
880
881 @GLboolean
882 boolean glIsEnabled(@GLenum int cap);
883
884 @GLboolean
885 boolean glIsFramebuffer(@GLuint int framebuffer);
886
887 @GLboolean
888 boolean glIsProgram(@GLuint int program);
889
890 @GLboolean
891 boolean glIsRenderbuffer(@GLuint int renderbuffer);
892
893 @GLboolean
894 boolean glIsShader(@GLuint int shader);
895
896 @GLboolean
897 boolean glIsTexture(@GLuint int texture);
898
899 void glLineWidth(@GLfloat float width);
900
901 void glLinkProgram(@GLuint int program);
902
903 void glPixelStorei(@GLenum int pname, @GLint int param);
904
905 void glPolygonOffset(@GLfloat float factor, @GLfloat float units);
906
907 void glReadPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
908 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
909 @OutParameter @GLbyte @GLshort @GLint @GLfloat Buffer pixels);
910
911 void glReleaseShaderCompiler();
912
913 void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
914
915 void glSampleCoverage(@GLclampf float value, @GLboolean boolean invert);
916
917 void glScissor(@GLint int x, @GLint int y, @GLsizei int width, @GLsizei int height);
918
919 void glShaderBinary(@AutoSize("shaders") @GLsizei int n, @Const @GLuint IntBuffer shaders, @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
920
921 /**
922 * glShaderSource allows multiple, optionally null-terminated, source strings to define a shader program.
923 * <p/>
924 * This method uses just a single string, that should NOT be null-terminated.
925 *
926 * @param shader
927 * @param string
928 */
929 void glShaderSource(@GLuint int shader, @Constant("1") @GLsizei int count,
930 @Indirect @Const @Check @GLchar ByteBuffer string,
931 @AutoSize("string") @Indirect @Const @GLint int length);
932
933 @Alternate("glShaderSource")
934 void glShaderSource2(@GLuint int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length);
935
936 @Alternate(value = "glShaderSource", nativeAlt = true)
937 void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count,
938 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
939 @Constant("APIUtil.getLengths(strings)") @Const IntBuffer length);
940
941 void glStencilFunc(@GLenum int func, @GLint int ref, @GLuint int mask);
942
943 void glStencilFuncSeparate(@GLenum int face, @GLenum int func, @GLint int ref, @GLuint int mask);
944
945 void glStencilMask(@GLuint int mask);
946
947 void glStencilMaskSeparate(@GLenum int face, @GLuint int mask);
948
949 void glStencilOp(@GLenum int fail, @GLenum int zfail, @GLenum int zpass);
950
951 void glStencilOpSeparate(@GLenum int face, @GLenum int fail, @GLenum int zfail, @GLenum int zpass);
952
953 void glTexImage2D(@GLenum int target, int level, int internalformat, int width, int height, int border, @GLenum int format, @GLenum int type,
954 @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true)
955 @Const @GLbyte @GLshort @GLint @GLfloat Buffer pixels);
956
957 void glTexParameterf(@GLenum int target, @GLenum int pname, @GLfloat float param);
958
959 @StripPostfix("param")
960 void glTexParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param);
961
962 void glTexParameteri(@GLenum int target, @GLenum int pname, @GLint int param);
963
964 @StripPostfix("param")
965 void glTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param);
966
967 void glTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type,
968 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)")
969 @Const @GLbyte @GLshort @GLint @GLfloat Buffer pixels);
970
971 void glUniform1f(@GLint int location, @GLfloat float x);
972
973 @StripPostfix("v")
974 void glUniform1fv(int location, @AutoSize("v") @GLsizei int count, @Const FloatBuffer v);
975
976 void glUniform1i(@GLint int location, @GLint int x);
977
978 @StripPostfix("v")
979 void glUniform1iv(int location, @AutoSize("v") @GLsizei int count, @Const IntBuffer v);
980
981 void glUniform2f(@GLint int location, @GLfloat float x, @GLfloat float y);
982
983 @StripPostfix("v")
984 void glUniform2fv(int location, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const FloatBuffer v);
985
986 void glUniform2i(@GLint int location, @GLint int x, @GLint int y);
987
988 @StripPostfix("v")
989 void glUniform2iv(int location, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const IntBuffer v);
990
991 void glUniform3f(@GLint int location, @GLfloat float x, @GLfloat float y, @GLfloat float z);
992
993 @StripPostfix("v")
994 void glUniform3fv(int location, @AutoSize(value = "v", expression = " / 3") @GLsizei int count, @Const FloatBuffer v);
995
996 void glUniform3i(@GLint int location, @GLint int x, @GLint int y, @GLint int z);
997
998 @StripPostfix("v")
999 void glUniform3iv(int location, @AutoSize(value = "v", expression = " / 3") @GLsizei int count, @Const IntBuffer v);
1000
1001 void glUniform4f(@GLint int location, @GLfloat float x, @GLfloat float y, @GLfloat float z, @GLfloat float w);
1002
1003 @StripPostfix("v")
1004 void glUniform4fv(int location, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v);
1005
1006 void glUniform4i(@GLint int location, @GLint int x, @GLint int y, @GLint int z, @GLint int w);
1007
1008 @StripPostfix("v")
1009 void glUniform4iv(int location, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const IntBuffer v);
1010
1011 @StripPostfix("matrices")
1012 void glUniformMatrix2fv(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count, @GLboolean boolean transpose, @Const FloatBuffer matrices);
1013
1014 @StripPostfix("matrices")
1015 void glUniformMatrix3fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count, @GLboolean boolean transpose, @Const FloatBuffer matrices);
1016
1017 @StripPostfix("matrices")
1018 void glUniformMatrix4fv(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, @GLboolean boolean transpose, @Const FloatBuffer matrices);
1019
1020 void glUseProgram(@GLuint int program);
1021
1022 void glValidateProgram(@GLuint int program);
1023
1024 void glVertexAttrib1f(@GLuint int indx, @GLfloat float x);
1025
1026 @StripPostfix("values")
1027 void glVertexAttrib1fv(@GLuint int indx, @Const @Check("1") FloatBuffer values);
1028
1029 void glVertexAttrib2f(@GLuint int indx, @GLfloat float x, @GLfloat float y);
1030
1031 @StripPostfix("values")
1032 void glVertexAttrib2fv(@GLuint int indx, @Const @Check("2") FloatBuffer values);
1033
1034 void glVertexAttrib3f(@GLuint int indx, @GLfloat float x, @GLfloat float y, @GLfloat float z);
1035
1036 @StripPostfix("values")
1037 void glVertexAttrib3fv(@GLuint int indx, @Const @Check("3") FloatBuffer values);
1038
1039 void glVertexAttrib4f(@GLuint int indx, @GLfloat float x, @GLfloat float y, @GLfloat float z, @GLfloat float w);
1040
1041 @StripPostfix("values")
1042 void glVertexAttrib4fv(@GLuint int indx, @Const @Check("4") FloatBuffer values);
1043
1044 void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, @GLboolean boolean normalized, @GLsizei int stride,
1045 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
1046 @BufferObject(BufferKind.ArrayVBO) @Check @Const @GLubyte @GLbyte @GLshort @GLushort @GLint @GLuint @GLfloat Buffer buffer);
1047
1048 void glViewport(@GLint int x, @GLint int y, @GLsizei int width, @GLsizei int height);
1049 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.opengl.GLSync;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.*;
38
39 public interface GLES30 {
40
41 int GL_READ_BUFFER = 0x0C02;
42 int GL_UNPACK_ROW_LENGTH = 0x0CF2;
43 int GL_UNPACK_SKIP_ROWS = 0x0CF3;
44 int GL_UNPACK_SKIP_PIXELS = 0x0CF4;
45 int GL_PACK_ROW_LENGTH = 0x0D02;
46 int GL_PACK_SKIP_ROWS = 0x0D03;
47 int GL_PACK_SKIP_PIXELS = 0x0D04;
48 int GL_COLOR = 0x1800;
49 int GL_DEPTH = 0x1801;
50 int GL_STENCIL = 0x1802;
51 int GL_RED = 0x1903;
52 int GL_RGB8 = 0x8051;
53 int GL_RGBA8 = 0x8058;
54 int GL_RGB10_A2 = 0x8059;
55 int GL_TEXTURE_BINDING_3D = 0x806A;
56 int GL_PACK_SKIP_IMAGES = 0x806B;
57 int GL_PACK_IMAGE_HEIGHT = 0x806C;
58 int GL_UNPACK_SKIP_IMAGES = 0x806D;
59 int GL_UNPACK_IMAGE_HEIGHT = 0x806E;
60 int GL_TEXTURE_3D = 0x806F;
61 int GL_TEXTURE_WRAP_R = 0x8072;
62 int GL_MAX_3D_TEXTURE_SIZE = 0x8073;
63 int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
64 int GL_MAX_ELEMENTS_VERTICES = 0x80E8;
65 int GL_MAX_ELEMENTS_INDICES = 0x80E9;
66 int GL_TEXTURE_MIN_LOD = 0x813A;
67 int GL_TEXTURE_MAX_LOD = 0x813B;
68 int GL_TEXTURE_BASE_LEVEL = 0x813C;
69 int GL_TEXTURE_MAX_LEVEL = 0x813D;
70 int GL_MIN = 0x8007;
71 int GL_MAX = 0x8008;
72 int GL_DEPTH_COMPONENT24 = 0x81A6;
73 int GL_MAX_TEXTURE_LOD_BIAS = 0x84FD;
74 int GL_TEXTURE_COMPARE_MODE = 0x884C;
75 int GL_TEXTURE_COMPARE_FUNC = 0x884D;
76 int GL_CURRENT_QUERY = 0x8865;
77 int GL_QUERY_RESULT = 0x8866;
78 int GL_QUERY_RESULT_AVAILABLE = 0x8867;
79 int GL_BUFFER_MAPPED = 0x88BC;
80 int GL_BUFFER_MAP_POINTER = 0x88BD;
81 int GL_STREAM_READ = 0x88E1;
82 int GL_STREAM_COPY = 0x88E2;
83 int GL_STATIC_READ = 0x88E5;
84 int GL_STATIC_COPY = 0x88E6;
85 int GL_DYNAMIC_READ = 0x88E9;
86 int GL_DYNAMIC_COPY = 0x88EA;
87 int GL_MAX_DRAW_BUFFERS = 0x8824;
88 int GL_DRAW_BUFFER0 = 0x8825;
89 int GL_DRAW_BUFFER1 = 0x8826;
90 int GL_DRAW_BUFFER2 = 0x8827;
91 int GL_DRAW_BUFFER3 = 0x8828;
92 int GL_DRAW_BUFFER4 = 0x8829;
93 int GL_DRAW_BUFFER5 = 0x882A;
94 int GL_DRAW_BUFFER6 = 0x882B;
95 int GL_DRAW_BUFFER7 = 0x882C;
96 int GL_DRAW_BUFFER8 = 0x882D;
97 int GL_DRAW_BUFFER9 = 0x882E;
98 int GL_DRAW_BUFFER10 = 0x882F;
99 int GL_DRAW_BUFFER11 = 0x8830;
100 int GL_DRAW_BUFFER12 = 0x8831;
101 int GL_DRAW_BUFFER13 = 0x8832;
102 int GL_DRAW_BUFFER14 = 0x8833;
103 int GL_DRAW_BUFFER15 = 0x8834;
104 int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49;
105 int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A;
106 int GL_SAMPLER_3D = 0x8B5F;
107 int GL_SAMPLER_2D_SHADOW = 0x8B62;
108 int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B;
109 int GL_PIXEL_PACK_BUFFER = 0x88EB;
110 int GL_PIXEL_UNPACK_BUFFER = 0x88EC;
111 int GL_PIXEL_PACK_BUFFER_BINDING = 0x88ED;
112 int GL_PIXEL_UNPACK_BUFFER_BINDING = 0x88EF;
113 int GL_FLOAT_MAT2x3 = 0x8B65;
114 int GL_FLOAT_MAT2x4 = 0x8B66;
115 int GL_FLOAT_MAT3x2 = 0x8B67;
116 int GL_FLOAT_MAT3x4 = 0x8B68;
117 int GL_FLOAT_MAT4x2 = 0x8B69;
118 int GL_FLOAT_MAT4x3 = 0x8B6A;
119 int GL_SRGB = 0x8C40;
120 int GL_SRGB8 = 0x8C41;
121 int GL_SRGB8_ALPHA8 = 0x8C43;
122 int GL_COMPARE_REF_TO_TEXTURE = 0x884E;
123 int GL_MAJOR_VERSION = 0x821B;
124 int GL_MINOR_VERSION = 0x821C;
125 int GL_NUM_EXTENSIONS = 0x821D;
126 int GL_RGBA32F = 0x8814;
127 int GL_RGB32F = 0x8815;
128 int GL_RGBA16F = 0x881A;
129 int GL_RGB16F = 0x881B;
130 int GL_VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD;
131 int GL_MAX_ARRAY_TEXTURE_LAYERS = 0x88FF;
132 int GL_MIN_PROGRAM_TEXEL_OFFSET = 0x8904;
133 int GL_MAX_PROGRAM_TEXEL_OFFSET = 0x8905;
134 int GL_MAX_VARYING_COMPONENTS = 0x8B4B;
135 int GL_TEXTURE_2D_ARRAY = 0x8C1A;
136 int GL_TEXTURE_BINDING_2D_ARRAY = 0x8C1D;
137 int GL_R11F_G11F_B10F = 0x8C3A;
138 int GL_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B;
139 int GL_RGB9_E5 = 0x8C3D;
140 int GL_UNSIGNED_INT_5_9_9_9_REV = 0x8C3E;
141 int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH = 0x8C76;
142 int GL_TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F;
143 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80;
144 int GL_TRANSFORM_FEEDBACK_VARYINGS = 0x8C83;
145 int GL_TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84;
146 int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85;
147 int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88;
148 int GL_RASTERIZER_DISCARD = 0x8C89;
149 int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A;
150 int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B;
151 int GL_INTERLEAVED_ATTRIBS = 0x8C8C;
152 int GL_SEPARATE_ATTRIBS = 0x8C8D;
153 int GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E;
154 int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F;
155 int GL_RGBA32UI = 0x8D70;
156 int GL_RGB32UI = 0x8D71;
157 int GL_RGBA16UI = 0x8D76;
158 int GL_RGB16UI = 0x8D77;
159 int GL_RGBA8UI = 0x8D7C;
160 int GL_RGB8UI = 0x8D7D;
161 int GL_RGBA32I = 0x8D82;
162 int GL_RGB32I = 0x8D83;
163 int GL_RGBA16I = 0x8D88;
164 int GL_RGB16I = 0x8D89;
165 int GL_RGBA8I = 0x8D8E;
166 int GL_RGB8I = 0x8D8F;
167 int GL_RED_INTEGER = 0x8D94;
168 int GL_RGB_INTEGER = 0x8D98;
169 int GL_RGBA_INTEGER = 0x8D99;
170 int GL_SAMPLER_2D_ARRAY = 0x8DC1;
171 int GL_SAMPLER_2D_ARRAY_SHADOW = 0x8DC4;
172 int GL_SAMPLER_CUBE_SHADOW = 0x8DC5;
173 int GL_UNSIGNED_INT_VEC2 = 0x8DC6;
174 int GL_UNSIGNED_INT_VEC3 = 0x8DC7;
175 int GL_UNSIGNED_INT_VEC4 = 0x8DC8;
176 int GL_INT_SAMPLER_2D = 0x8DCA;
177 int GL_INT_SAMPLER_3D = 0x8DCB;
178 int GL_INT_SAMPLER_CUBE = 0x8DCC;
179 int GL_INT_SAMPLER_2D_ARRAY = 0x8DCF;
180 int GL_UNSIGNED_INT_SAMPLER_2D = 0x8DD2;
181 int GL_UNSIGNED_INT_SAMPLER_3D = 0x8DD3;
182 int GL_UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4;
183 int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7;
184 int GL_BUFFER_ACCESS_FLAGS = 0x911F;
185 int GL_BUFFER_MAP_LENGTH = 0x9120;
186 int GL_BUFFER_MAP_OFFSET = 0x9121;
187 int GL_DEPTH_COMPONENT32F = 0x8CAC;
188 int GL_DEPTH32F_STENCIL8 = 0x8CAD;
189 int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD;
190 int GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210;
191 int GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211;
192 int GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212;
193 int GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213;
194 int GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214;
195 int GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215;
196 int GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216;
197 int GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217;
198 int GL_FRAMEBUFFER_DEFAULT = 0x8218;
199 int GL_FRAMEBUFFER_UNDEFINED = 0x8219;
200 int GL_DEPTH_STENCIL_ATTACHMENT = 0x821A;
201 int GL_DEPTH_STENCIL = 0x84F9;
202 int GL_UNSIGNED_INT_24_8 = 0x84FA;
203 int GL_DEPTH24_STENCIL8 = 0x88F0;
204 int GL_UNSIGNED_NORMALIZED = 0x8C17;
205 int GL_DRAW_FRAMEBUFFER_BINDING = GLES20.GL_FRAMEBUFFER_BINDING;
206 int GL_READ_FRAMEBUFFER = 0x8CA8;
207 int GL_DRAW_FRAMEBUFFER = 0x8CA9;
208 int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA;
209 int GL_RENDERBUFFER_SAMPLES = 0x8CAB;
210 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4;
211 int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF;
212 int GL_COLOR_ATTACHMENT1 = 0x8CE1;
213 int GL_COLOR_ATTACHMENT2 = 0x8CE2;
214 int GL_COLOR_ATTACHMENT3 = 0x8CE3;
215 int GL_COLOR_ATTACHMENT4 = 0x8CE4;
216 int GL_COLOR_ATTACHMENT5 = 0x8CE5;
217 int GL_COLOR_ATTACHMENT6 = 0x8CE6;
218 int GL_COLOR_ATTACHMENT7 = 0x8CE7;
219 int GL_COLOR_ATTACHMENT8 = 0x8CE8;
220 int GL_COLOR_ATTACHMENT9 = 0x8CE9;
221 int GL_COLOR_ATTACHMENT10 = 0x8CEA;
222 int GL_COLOR_ATTACHMENT11 = 0x8CEB;
223 int GL_COLOR_ATTACHMENT12 = 0x8CEC;
224 int GL_COLOR_ATTACHMENT13 = 0x8CED;
225 int GL_COLOR_ATTACHMENT14 = 0x8CEE;
226 int GL_COLOR_ATTACHMENT15 = 0x8CEF;
227 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56;
228 int GL_MAX_SAMPLES = 0x8D57;
229 int GL_HALF_FLOAT = 0x140B;
230 int GL_MAP_READ_BIT = 0x0001;
231 int GL_MAP_WRITE_BIT = 0x0002;
232 int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004;
233 int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008;
234 int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010;
235 int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020;
236 int GL_RG = 0x8227;
237 int GL_RG_INTEGER = 0x8228;
238 int GL_R8 = 0x8229;
239 int GL_RG8 = 0x822B;
240 int GL_R16F = 0x822D;
241 int GL_R32F = 0x822E;
242 int GL_RG16F = 0x822F;
243 int GL_RG32F = 0x8230;
244 int GL_R8I = 0x8231;
245 int GL_R8UI = 0x8232;
246 int GL_R16I = 0x8233;
247 int GL_R16UI = 0x8234;
248 int GL_R32I = 0x8235;
249 int GL_R32UI = 0x8236;
250 int GL_RG8I = 0x8237;
251 int GL_RG8UI = 0x8238;
252 int GL_RG16I = 0x8239;
253 int GL_RG16UI = 0x823A;
254 int GL_RG32I = 0x823B;
255 int GL_RG32UI = 0x823C;
256 int GL_VERTEX_ARRAY_BINDING = 0x85B5;
257 int GL_R8_SNORM = 0x8F94;
258 int GL_RG8_SNORM = 0x8F95;
259 int GL_RGB8_SNORM = 0x8F96;
260 int GL_RGBA8_SNORM = 0x8F97;
261 int GL_SIGNED_NORMALIZED = 0x8F9C;
262 int GL_PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69;
263 int GL_COPY_READ_BUFFER = 0x8F36;
264 int GL_COPY_WRITE_BUFFER = 0x8F37;
265 int GL_COPY_READ_BUFFER_BINDING = GL_COPY_READ_BUFFER;
266 int GL_COPY_WRITE_BUFFER_BINDING = GL_COPY_WRITE_BUFFER;
267 int GL_UNIFORM_BUFFER = 0x8A11;
268 int GL_UNIFORM_BUFFER_BINDING = 0x8A28;
269 int GL_UNIFORM_BUFFER_START = 0x8A29;
270 int GL_UNIFORM_BUFFER_SIZE = 0x8A2A;
271 int GL_MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B;
272 int GL_MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D;
273 int GL_MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E;
274 int GL_MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F;
275 int GL_MAX_UNIFORM_BLOCK_SIZE = 0x8A30;
276 int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31;
277 int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33;
278 int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34;
279 int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35;
280 int GL_ACTIVE_UNIFORM_BLOCKS = 0x8A36;
281 int GL_UNIFORM_TYPE = 0x8A37;
282 int GL_UNIFORM_SIZE = 0x8A38;
283 int GL_UNIFORM_NAME_LENGTH = 0x8A39;
284 int GL_UNIFORM_BLOCK_INDEX = 0x8A3A;
285 int GL_UNIFORM_OFFSET = 0x8A3B;
286 int GL_UNIFORM_ARRAY_STRIDE = 0x8A3C;
287 int GL_UNIFORM_MATRIX_STRIDE = 0x8A3D;
288 int GL_UNIFORM_IS_ROW_MAJOR = 0x8A3E;
289 int GL_UNIFORM_BLOCK_BINDING = 0x8A3F;
290 int GL_UNIFORM_BLOCK_DATA_SIZE = 0x8A40;
291 int GL_UNIFORM_BLOCK_NAME_LENGTH = 0x8A41;
292 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42;
293 int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43;
294 int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44;
295 int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46;
296 int GL_INVALID_INDEX = 0xFFFFFFFF;
297 int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122;
298 int GL_MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125;
299 int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111;
300 int GL_OBJECT_TYPE = 0x9112;
301 int GL_SYNC_CONDITION = 0x9113;
302 int GL_SYNC_STATUS = 0x9114;
303 int GL_SYNC_FLAGS = 0x9115;
304 int GL_SYNC_FENCE = 0x9116;
305 int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117;
306 int GL_UNSIGNALED = 0x9118;
307 int GL_SIGNALED = 0x9119;
308 int GL_ALREADY_SIGNALED = 0x911A;
309 int GL_TIMEOUT_EXPIRED = 0x911B;
310 int GL_CONDITION_SATISFIED = 0x911C;
311 int GL_WAIT_FAILED = 0x911D;
312 int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
313 long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl;
314 int GL_VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE;
315 int GL_ANY_SAMPLES_PASSED = 0x8C2F;
316 int GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A;
317 int GL_SAMPLER_BINDING = 0x8919;
318 int GL_RGB10_A2UI = 0x906F;
319 int GL_TEXTURE_SWIZZLE_R = 0x8E42;
320 int GL_TEXTURE_SWIZZLE_G = 0x8E43;
321 int GL_TEXTURE_SWIZZLE_B = 0x8E44;
322 int GL_TEXTURE_SWIZZLE_A = 0x8E45;
323 int GL_GREEN = 0x1904;
324 int GL_BLUE = 0x1905;
325 int GL_INT_2_10_10_10_REV = 0x8D9F;
326 int GL_TRANSFORM_FEEDBACK = 0x8E22;
327 int GL_TRANSFORM_FEEDBACK_PAUSED = 0x8E23;
328 int GL_TRANSFORM_FEEDBACK_ACTIVE = 0x8E24;
329 int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25;
330 int GL_PROGRAM_BINARY_RETRIEVABLE_HINT = 0x8257;
331 int GL_PROGRAM_BINARY_LENGTH = 0x8741;
332 int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE;
333 int GL_PROGRAM_BINARY_FORMATS = 0x87FF;
334 int GL_COMPRESSED_R11_EAC = 0x9270;
335 int GL_COMPRESSED_SIGNED_R11_EAC = 0x9271;
336 int GL_COMPRESSED_RG11_EAC = 0x9272;
337 int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
338 int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
339 int GL_COMPRESSED_SRGB8_ETC2 = 0x9275;
340 int GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
341 int GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
342 int GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
343 int GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
344 int GL_TEXTURE_IMMUTABLE_FORMAT = 0x912F;
345 int GL_MAX_ELEMENT_INDEX = 0x8D6B;
346 int GL_NUM_SAMPLE_COUNTS = 0x9380;
347
348 void glReadBuffer(@GLenum int mode);
349
350 void glDrawRangeElements(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count,
351 @AutoType("indices")
352 @GLenum int type,
353 @BufferObject(BufferKind.ElementVBO)
354 @Const
355 @GLubyte
356 @GLushort
357 @GLuint Buffer indices);
358
359 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,
360 @BufferObject(BufferKind.UnpackPBO)
361 @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true)
362 @Const
363 @GLbyte
364 @GLshort
365 @GLint
366 @GLfloat Buffer pixels);
367
368 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,
369 @BufferObject(BufferKind.UnpackPBO)
370 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
371 @Const
372 @GLbyte
373 @GLshort
374 @GLint
375 @GLfloat Buffer pixels);
376
377 void glCopyTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
378
379 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,
380 @BufferObject(BufferKind.UnpackPBO)
381 @Check
382 @Const
383 @GLvoid
384 ByteBuffer data);
385
386 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,
387 @BufferObject(BufferKind.UnpackPBO)
388 @Check
389 @Const
390 @GLvoid
391 ByteBuffer data);
392
393 void glGenQueries(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
394
395 @Alternate("glGenQueries")
396 @GLreturn("ids")
397 void glGenQueries2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
398
399 void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
400
401 @Alternate("glDeleteQueries")
402 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
403
404 boolean glIsQuery(@GLuint int id);
405
406 void glBeginQuery(@GLenum int target, @GLuint int id);
407
408 void glEndQuery(@GLenum int target);
409
410 @StripPostfix("params")
411 void glGetQueryiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
412
413 @Alternate("glGetQueryiv")
414 @GLreturn("params")
415 @StripPostfix(value = "params", hasPostfix = false)
416 void glGetQueryiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
417
418 @StripPostfix("params")
419 void glGetQueryObjectuiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params);
420
421 @Alternate("glGetQueryObjectuiv")
422 @GLreturn("params")
423 @StripPostfix(value = "params", hasPostfix = false)
424 void glGetQueryObjectuiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params);
425
426 boolean glUnmapBuffer(@GLenum int target);
427
428 @StripPostfix("pointer")
429 @AutoSize("GLES20.glGetBufferParameteri(target, GLES20.GL_BUFFER_SIZE)")
430 void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer);
431
432 void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
433
434 @Alternate("glDrawBuffers")
435 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
436
437 @StripPostfix("matrices")
438 void glUniformMatrix2x3fv(int location, @AutoSize(value = "matrices", expression = " / (2 * 3)") @GLsizei int count,
439 boolean transpose, FloatBuffer matrices);
440
441 @StripPostfix("matrices")
442 void glUniformMatrix3x2fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 2)") @GLsizei int count,
443 boolean transpose, FloatBuffer matrices);
444
445 @StripPostfix("matrices")
446 void glUniformMatrix2x4fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count,
447 boolean transpose, FloatBuffer matrices);
448
449 @StripPostfix("matrices")
450 void glUniformMatrix4x2fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count,
451 boolean transpose, FloatBuffer matrices);
452
453 @StripPostfix("matrices")
454 void glUniformMatrix3x4fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 4)") @GLsizei int count,
455 boolean transpose, FloatBuffer matrices);
456
457 @StripPostfix("matrices")
458 void glUniformMatrix4x3fv(int location, @AutoSize(value = "matrices", expression = " / (4 * 3)") @GLsizei int count,
459 boolean transpose, FloatBuffer matrices);
460
461 /**
462 * Transfers a rectangle of pixel values from one
463 * region of the read framebuffer to another in the draw framebuffer.
464 * &lt;mask&gt; is the bitwise OR of a number of values indicating which
465 * buffers are to be copied. The values are COLOR_BUFFER_BIT,
466 * DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT.
467 * The pixels corresponding to these buffers are
468 * copied from the source rectangle, bound by the locations (srcX0,
469 * srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle,
470 * bound by the locations (dstX0, dstY0) and (dstX1, dstY1)
471 * inclusive.
472 * If the source and destination rectangle dimensions do not match,
473 * the source image is stretched to fit the destination
474 * rectangle. &lt;filter&gt; must be LINEAR or NEAREST and specifies the
475 * method of interpolation to be applied if the image is
476 * stretched.
477 */
478 void glBlitFramebuffer(
479 @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1,
480 @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1,
481 @GLbitfield int mask, @GLenum int filter);
482
483 /**
484 * Establishes the data storage, format, dimensions, and number of
485 * samples of a renderbuffer object's image.
486 */
487 void glRenderbufferStorageMultisample(
488 @GLenum int target, @GLsizei int samples,
489 @GLenum int internalformat,
490 @GLsizei int width, @GLsizei int height);
491
492 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
493
494 /**
495 * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null,
496 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
497 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
498 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this:
499 * <p/>
500 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer);
501 * <p/>
502 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
503 *
504 * @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.
505 *
506 * @return A ByteBuffer representing the mapped buffer memory.
507 */
508 @CachedResult(isRange = true)
509 @GLvoid
510 @AutoSize("length")
511 ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
512
513 void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
514
515 @Code(" StateTracker.bindVAO(array);")
516 void glBindVertexArray(@GLuint int array);
517
518 @Code(" StateTracker.deleteVAO(arrays);")
519 void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
520
521 @Alternate("glDeleteVertexArrays")
522 @Code(" StateTracker.deleteVAO(array);")
523 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array);
524
525 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
526
527 @Alternate("glGenVertexArrays")
528 @GLreturn("arrays")
529 void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
530
531 boolean glIsVertexArray(@GLuint int array);
532
533 @StripPostfix("data")
534 void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
535
536 @Alternate("glGetIntegeri_v")
537 @GLreturn("data")
538 @StripPostfix("data")
539 void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
540
541 void glBeginTransformFeedback(@GLenum int primitiveMode);
542
543 void glEndTransformFeedback();
544
545 void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
546
547 void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer);
548
549 void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count,
550 @Const @NullTerminated("count") @GLchar @PointerArray("count") ByteBuffer varyings,
551 @GLenum int bufferMode);
552
553 @Alternate("glTransformFeedbackVaryings")
554 void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count,
555 @Const @NullTerminated @PointerArray("count") CharSequence[] varyings,
556 @GLenum int bufferMode);
557
558 void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
559 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
560 @OutParameter @GLsizei @Check("1") IntBuffer size,
561 @OutParameter @GLenum @Check("1") IntBuffer type,
562 @OutParameter @GLchar ByteBuffer name);
563
564 @Alternate("glGetTransformFeedbackVarying")
565 @GLreturn(value = "name", maxLength = "bufSize")
566 void glGetTransformFeedbackVarying2(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
567 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length)") IntBuffer length,
568 @OutParameter @GLsizei @Check("1") IntBuffer size,
569 @OutParameter @GLenum @Check("1") IntBuffer type,
570 @OutParameter @GLchar ByteBuffer name);
571
572 void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
573 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
574 @BufferObject(BufferKind.ArrayVBO)
575 @Check
576 @Const
577 @GLbyte
578 @GLubyte
579 @GLshort
580 @GLushort
581 @GLint
582 @GLuint Buffer buffer);
583
584 @StripPostfix("params")
585 void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
586
587 @StripPostfix("params")
588 void glGetVertexAttribIuiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params);
589
590 @NoErrorCheck
591 void glVertexAttribI4i(@GLuint int index, int x, int y, int z, int w);
592
593 @NoErrorCheck
594 void glVertexAttribI4ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w);
595
596 @NoErrorCheck
597 @StripPostfix("v")
598 void glVertexAttribI4iv(@GLuint int index, @Check("4") @Const IntBuffer v);
599
600 @NoErrorCheck
601 @StripPostfix("v")
602 void glVertexAttribI4uiv(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v);
603
604 @StripPostfix("params")
605 void glGetUniformuiv(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params);
606
607 int glGetFragDataLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
608
609 @Alternate("glGetFragDataLocation")
610 int glGetFragDataLocation(@GLuint int program, @NullTerminated CharSequence name);
611
612 void glUniform1ui(int location, @GLuint int v0);
613
614 void glUniform2ui(int location, @GLuint int v0, @GLuint int v1);
615
616 void glUniform3ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2);
617
618 void glUniform4ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3);
619
620 @StripPostfix("value")
621 void glUniform1uiv(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value);
622
623 @StripPostfix("value")
624 void glUniform2uiv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value);
625
626 @StripPostfix("value")
627 void glUniform3uiv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value);
628
629 @StripPostfix("value")
630 void glUniform4uiv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value);
631
632 @StripPostfix("value")
633 void glClearBufferfv(@GLenum int buffer, int drawbuffer, @Const @Check("4") FloatBuffer value);
634
635 @StripPostfix("value")
636 void glClearBufferiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value);
637
638 @StripPostfix("value")
639 void glClearBufferuiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value);
640
641 void glClearBufferfi(@GLenum int buffer, int drawbuffer, float depth, int stencil);
642
643 String glGetStringi(@GLenum int name, @GLuint int index);
644
645 void glCopyBufferSubData(@GLenum int readtarget, @GLenum int writetarget, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
646
647 void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
648 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @PointerArray("uniformCount") ByteBuffer uniformNames,
649 @OutParameter @GLuint IntBuffer uniformIndices);
650
651 @Alternate("glGetUniformIndices")
652 void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount,
653 @Const @NullTerminated @PointerArray("uniformCount") CharSequence[] uniformNames,
654 @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices);
655
656 @StripPostfix("params")
657 void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
658 @Const @GLuint IntBuffer uniformIndices,
659 @GLenum int pname,
660 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
661
662 @Alternate("glGetActiveUniformsiv")
663 @GLreturn("params")
664 @StripPostfix(value = "params", hasPostfix = false)
665 void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount,
666 @Constant(value = "MemoryUtil.getAddress(params.put(1, uniformIndex), 1)", keepParam = true) int uniformIndex, // Reuse params buffer
667 @GLenum int pname,
668 @OutParameter @GLint IntBuffer params);
669
670 @GLuint
671 int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName);
672
673 @Alternate("glGetUniformBlockIndex")
674 @GLuint
675 int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName);
676
677 @StripPostfix("params")
678 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
679 @OutParameter @Check(value = "16") @GLint IntBuffer params);
680
681 @Alternate("glGetActiveUniformBlockiv")
682 @GLreturn("params")
683 @StripPostfix(value = "params", hasPostfix = false)
684 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
685 @OutParameter @GLint IntBuffer params);
686
687 void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize,
688 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
689 @OutParameter @GLchar ByteBuffer uniformBlockName);
690
691 @Alternate("glGetActiveUniformBlockName")
692 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
693 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
694 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(uniformBlockName_length)") IntBuffer length,
695 @OutParameter @GLchar ByteBuffer uniformBlockName);
696
697 void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding);
698
699 void glDrawArraysInstanced(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount);
700
701 void glDrawElementsInstanced(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
702 @BufferObject(BufferKind.ElementVBO)
703 @Const
704 @GLubyte
705 @GLushort
706 @GLuint Buffer indices, @GLsizei int primcount);
707
708 @PointerWrapper("GLsync")
709 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
710
711 boolean glIsSync(@PointerWrapper("GLsync") GLSync sync);
712
713 void glDeleteSync(@PointerWrapper("GLsync") GLSync sync);
714
715 @GLenum
716 int glClientWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
717
718 void glWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
719
720 @StripPostfix("data")
721 void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer data);
722
723 @Alternate("glGetInteger64v")
724 @GLreturn("data")
725 @StripPostfix("data")
726 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer data);
727
728 @StripPostfix("data")
729 void glGetInteger64i_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLint64 LongBuffer data);
730
731 @Alternate("glGetInteger64i_v")
732 @GLreturn("data")
733 @StripPostfix("data")
734 void glGetInteger64i_v2(@GLenum int value, @GLuint int index, @OutParameter @GLint64 LongBuffer data);
735
736 @StripPostfix("values")
737 void glGetSynciv(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
738 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
739 @OutParameter IntBuffer values);
740
741 @Alternate("glGetSynciv")
742 @GLreturn("values")
743 @StripPostfix(value = "values", hasPostfix = false)
744 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
745 @OutParameter @GLsizei @Constant("0L") IntBuffer length,
746 @OutParameter IntBuffer values);
747
748 @StripPostfix("params")
749 void glGetBufferParameteri64v(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") LongBuffer params);
750
751 @Alternate("glGetBufferParameteri64v")
752 @GLreturn("params")
753 @StripPostfix(value = "params", hasPostfix = false)
754 void glGetBufferParameteri64v2(@GLenum int target, @GLenum int pname, @OutParameter LongBuffer params);
755
756 void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
757
758 @Alternate("glGenSamplers")
759 @GLreturn("samplers")
760 void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
761
762 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
763
764 @Alternate("glDeleteSamplers")
765 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(sampler)", keepParam = true) int sampler);
766
767 boolean glIsSampler(@GLuint int sampler);
768
769 void glBindSampler(@GLenum int unit, @GLuint int sampler);
770
771 void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param);
772
773 void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param);
774
775 @StripPostfix("params")
776 void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
777
778 @StripPostfix("params")
779 void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params);
780
781 @StripPostfix("params")
782 void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
783
784 @Alternate("glGetSamplerParameteriv")
785 @GLreturn("params")
786 @StripPostfix(value = "params", hasPostfix = false)
787 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
788
789 @StripPostfix("params")
790 void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
791
792 @Alternate("glGetSamplerParameterfv")
793 @GLreturn("params")
794 @StripPostfix(value = "params", hasPostfix = false)
795 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
796
797 void glVertexAttribDivisor(@GLuint int index, @GLuint int divisor);
798
799 void glBindTransformFeedback(@GLenum int target, @GLuint int id);
800
801 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
802
803 @Alternate("glDeleteTransformFeedbacks")
804 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
805
806 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
807
808 @Alternate("glGenTransformFeedbacks")
809 @GLreturn("ids")
810 void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
811
812 boolean glIsTransformFeedback(@GLuint int id);
813
814 void glPauseTransformFeedback();
815
816 void glResumeTransformFeedback();
817
818 void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize,
819 @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
820 @Check("1") @GLenum IntBuffer binaryFormat,
821 @OutParameter @GLvoid ByteBuffer binary);
822
823 void glProgramBinary(@GLuint int program, @GLenum int binaryFormat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
824
825 void glProgramParameteri(@GLuint int program, @GLenum int pname, int value);
826
827 void glInvalidateFramebuffer(@GLenum int target,
828 @AutoSize("attachments") @GLsizei int numAttachments,
829 @Const @GLenum IntBuffer attachments);
830
831 void glInvalidateSubFramebuffer(@GLenum int target,
832 @AutoSize("attachments") @GLsizei int numAttachments,
833 @Const @GLenum IntBuffer attachments,
834 int x, int y, @GLsizei int width, @GLsizei int height);
835
836 void glTexStorage2D(@GLenum int target, @GLsizei int levels,
837 @GLenum int internalformat,
838 @GLsizei int width, @GLsizei int height);
839
840 void glTexStorage3D(@GLenum int target, @GLsizei int levels,
841 @GLenum int internalformat,
842 @GLsizei int width, @GLsizei int height, @GLsizei int depth);
843
844 @StripPostfix("params")
845 void glGetInternalformativ(@GLenum int target, @GLenum int internalformat,
846 @GLenum int pname, @AutoSize("params") @GLsizei int bufSize, @OutParameter IntBuffer params);
847
848 @Alternate("glGetInternalformativ")
849 @StripPostfix("params")
850 @GLreturn("params")
851 void glGetInternalformativ2(@GLenum int target, @GLenum int internalformat,
852 @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter IntBuffer params);
853
854 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
36
37 public interface IMG_multisampled_render_to_texture {
38
39 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameteriv: */
40 int GL_RENDERBUFFER_SAMPLES_IMG = 0x9133;
41
42 /** Returned by CheckFramebufferStatus: */
43 int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134;
44
45 /**
46 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
47 * GetFloatv, and GetDoublev:
48 */
49 int GL_MAX_SAMPLES_IMG = 0x9135;
50
51 /** Accepted by the &lt;pname&gt; parameter of GetFramebufferAttachmentParameteriv: */
52 int GL_TEXTURE_SAMPLES_IMG = 0x9136;
53
54 void glRenderbufferStorageMultisampleIMG(
55 @GLenum int target, @GLsizei int samples,
56 @GLenum int internalformat,
57 @GLsizei int width, @GLsizei int height);
58
59 void glFramebufferTexture2DMultisampleIMG(
60 @GLenum int target, @GLenum int attachment,
61 @GLenum int textarget, @GLuint int texture,
62 int level, @GLsizei int samples);
63
64 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface IMG_program_binary {
34
35 /** Accepted by the &lt;binaryFormat&gt; parameter of ProgramBinaryOES: */
36 int GL_SGX_PROGRAM_BINARY_IMG = 0x9130;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface IMG_read_format {
34
35 /** Accepted by the &lt;format&gt; parameter of ReadPixels: */
36 int GL_BGRA_IMG = 0x80E1,
37 GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG = 0x8365;
38
39 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface IMG_shader_binary {
34
35 /** Accepted by the &lt;binaryformat&gt; parameter of ShaderBinary: */
36 int GL_SGX_BINARY_IMG = 0x8C0A;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface IMG_texture_compression_pvrtc {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2DARB
37 * and the &lt;format&gt; parameter of CompressedTexSubImage2DARB:
38 */
39 int GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
40 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
41 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
42 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
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.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface KHR_debug {
40
41 /**
42 * Tokens accepted by the &lt;target&gt; parameters of Enable, Disable, and
43 * IsEnabled:
44 */
45 int GL_DEBUG_OUTPUT = 0x92E0,
46 GL_DEBUG_OUTPUT_SYNCHRONOUS = 0x8242;
47
48 /** Returned by GetIntegerv when &lt;pname&gt; is CONTEXT_FLAGS: */
49 int GL_CONTEXT_FLAG_DEBUG_BIT = 0x00000002;
50
51 /**
52 * Tokens accepted by the &lt;value&gt; parameters of GetBooleanv, GetIntegerv,
53 * GetFloatv, GetDoublev and GetInteger64v:
54 */
55 int GL_MAX_DEBUG_MESSAGE_LENGTH = 0x9143,
56 GL_MAX_DEBUG_LOGGED_MESSAGES = 0x9144,
57 GL_DEBUG_LOGGED_MESSAGES = 0x9145,
58 GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243,
59 GL_MAX_DEBUG_GROUP_STACK_DEPTH = 0x826C,
60 GL_DEBUG_GROUP_STACK_DEPTH = 0x826D,
61 GL_MAX_LABEL_LENGTH = 0x82E8;
62
63 /** Tokens accepted by the &lt;pname&gt; parameter of GetPointerv: */
64 int GL_DEBUG_CALLBACK_FUNCTION = 0x8244,
65 GL_DEBUG_CALLBACK_USER_PARAM = 0x8245;
66
67 /**
68 * Tokens accepted or provided by the &lt;source&gt; parameters of
69 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;sources&gt;
70 * parameter of GetDebugMessageLog:
71 */
72 int GL_DEBUG_SOURCE_API = 0x8246,
73 GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
74 GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
75 GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
76 GL_DEBUG_SOURCE_APPLICATION = 0x824A,
77 GL_DEBUG_SOURCE_OTHER = 0x824B;
78
79 /**
80 * Tokens accepted or provided by the &lt;type&gt; parameters of
81 * DebugMessageControl, DebugMessageInsert and DEBUGPROC, and the &lt;types&gt;
82 * parameter of GetDebugMessageLog:
83 */
84 int GL_DEBUG_TYPE_ERROR = 0x824C,
85 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
86 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
87 GL_DEBUG_TYPE_PORTABILITY = 0x824F,
88 GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
89 GL_DEBUG_TYPE_OTHER = 0x8251,
90 GL_DEBUG_TYPE_MARKER = 0x8268;
91
92 /**
93 * Tokens accepted or provided by the &lt;type&gt; parameters of
94 * DebugMessageControl and DEBUGPROC, and the &lt;types&gt; parameter of
95 * GetDebugMessageLog:
96 */
97 int GL_DEBUG_TYPE_PUSH_GROUP = 0x8269,
98 GL_DEBUG_TYPE_POP_GROUP = 0x826A;
99
100 /**
101 * Tokens accepted or provided by the &lt;severity&gt; parameters of
102 * DebugMessageControl, DebugMessageInsert and DEBUGPROC callback functions,
103 * and the &lt;severities&gt; parameter of GetDebugMessageLog:
104 */
105 int GL_DEBUG_SEVERITY_HIGH = 0x9146,
106 GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
107 GL_DEBUG_SEVERITY_LOW = 0x9148,
108 GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
109
110 /** Returned by GetError: */
111 int GL_STACK_UNDERFLOW = 0x0504,
112 GL_STACK_OVERFLOW = 0x0503;
113
114 /**
115 * Tokens accepted or provided by the &lt;identifier&gt; parameters of
116 * ObjectLabel and GetObjectLabel:
117 */
118 int GL_BUFFER = 0x82E0,
119 GL_SHADER = 0x82E1,
120 GL_PROGRAM = 0x82E2,
121 GL_QUERY = 0x82E3,
122 GL_PROGRAM_PIPELINE = 0x82E4,
123 GL_SAMPLER = 0x82E6,
124 GL_DISPLAY_LIST = 0x82E7;
125
126 // -----------------------------
127
128 void glDebugMessageControl(@GLenum int source,
129 @GLenum int type,
130 @GLenum int severity,
131 @AutoSize(value = "ids", canBeNull = true) @GLsizei int count,
132 @Check(canBeNull = true) @Const @GLuint IntBuffer ids,
133 boolean enabled);
134
135 void glDebugMessageInsert(@GLenum int source,
136 @GLenum int type,
137 @GLuint int id,
138 @GLenum int severity,
139 @AutoSize("buf") @GLsizei int length,
140 @Const @GLchar ByteBuffer buf);
141
142 @Alternate("glDebugMessageInsert")
143 void glDebugMessageInsert(@GLenum int source,
144 @GLenum int type,
145 @GLuint int id,
146 @GLenum int severity,
147 @Constant("buf.length()") @GLsizei int length,
148 CharSequence buf);
149
150 /**
151 * The {@code KHRDebugCallback.Handler} implementation passed to this method will be used for
152 * KHR_debug messages. If callback is null, any previously registered handler for the current
153 * thread will be unregistered and stop receiving messages.
154 *
155 * @param callback the callback function to use
156 */
157 @Code(
158 // Create a GlobalRef to the callback object and register it with the current context.
159 javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" +
160 "\t\tCallbackUtil.registerContextCallbackKHR(userParam);"
161 )
162 void glDebugMessageCallback(@PointerWrapper(value = "GLDEBUGPROC", canBeNull = true) KHRDebugCallback callback,
163 @Constant("userParam") @PointerWrapper("GLvoid *") long userParam);
164
165 @GLuint
166 int glGetDebugMessageLog(@GLuint int count,
167 @AutoSize(value = "messageLog", canBeNull = true) @GLsizei int bufsize,
168 @Check(value = "count", canBeNull = true) @GLenum IntBuffer sources,
169 @Check(value = "count", canBeNull = true) @GLenum IntBuffer types,
170 @Check(value = "count", canBeNull = true) @GLuint IntBuffer ids,
171 @Check(value = "count", canBeNull = true) @GLenum IntBuffer severities,
172 @Check(value = "count", canBeNull = true) @GLsizei IntBuffer lengths,
173 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer messageLog);
174
175 // Not really useful and a pain to implement in Java
176 // void glGetPointerv(@GLenum int pname, void** params);
177
178 void glPushDebugGroup(@GLenum int source, @GLuint int id, @AutoSize("message") @GLsizei int length,
179 @Const @GLchar ByteBuffer message);
180
181 @Alternate("glPushDebugGroup")
182 void glPushDebugGroup(@GLenum int source, @GLuint int id, @Constant("message.length()") @GLsizei int length,
183 CharSequence message);
184
185 void glPopDebugGroup();
186
187 void glObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
188 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
189
190 @Alternate("glObjectLabel")
191 void glObjectLabel(@GLenum int identifier, @GLuint int name, @Constant("label.length()") @GLsizei int length,
192 CharSequence label);
193
194 void glGetObjectLabel(@GLenum int identifier, @GLuint int name, @AutoSize("label") @GLsizei int bufSize,
195 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
196 @OutParameter @GLchar ByteBuffer label);
197
198 @Alternate("glGetObjectLabel")
199 @GLreturn(value = "label", maxLength = "bufSize")
200 void glGetObjectLabel2(@GLenum int identifier, @GLuint int name, @GLsizei int bufSize,
201 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
202 @OutParameter @GLchar ByteBuffer label);
203
204 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize(value = "label", canBeNull = true) @GLsizei int length,
205 @Check(canBeNull = true) @Const @GLchar ByteBuffer label);
206
207 @Alternate("glObjectPtrLabel")
208 void glObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @Constant("label.length()") @GLsizei int length,
209 CharSequence label);
210
211 void glGetObjectPtrLabel(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @AutoSize("label") @GLsizei int bufSize,
212 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
213 @OutParameter @GLchar ByteBuffer label);
214
215 @Alternate("glGetObjectPtrLabel")
216 @GLreturn(value = "label", maxLength = "bufSize")
217 void glGetObjectPtrLabel2(@PointerWrapper("GLvoid *") org.lwjgl.PointerWrapper ptr, @GLsizei int bufSize,
218 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(label_length)") IntBuffer length,
219 @OutParameter @GLchar ByteBuffer label);
220
221 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface KHR_texture_compression_astc_ldr {
34
35 /**
36 * Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D,
37 * CompressedTexSubImage2D, TexStorage2D, TextureStorage2D, TexStorage3D,
38 * and TextureStorage3D:
39 */
40 int GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
41 GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
42 GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
43 GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3,
44 GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4,
45 GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5,
46 GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6,
47 GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7,
48 GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8,
49 GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9,
50 GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA,
51 GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB,
52 GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC,
53 GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD,
54 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0,
55 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1,
56 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2,
57 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3,
58 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4,
59 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5,
60 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6,
61 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7,
62 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8,
63 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9,
64 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA,
65 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB,
66 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC,
67 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
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.opengles;
32
33 public interface NV_EGL_stream_consumer_external {
34
35 /** Accepted as a target in the &lt;target&gt; parameter of BindTexture: */
36 int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
37
38 /** Returned in the &lt;type&gt; parameter of GetActiveUniform: */
39 int GL_SAMPLER_EXTERNAL_OES = 0x8D66;
40
41 /** Accepted as &lt;value&gt; in GetIntegerv() and GetFloatv() queries: */
42 int GL_TEXTURE_BINDING_EXTERNAL_OES = 0x8D67;
43
44 /** Accepted as &lt;value&gt; in GetTexParameter*() queries: */
45 int GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8D68;
46
47 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34
35 public interface NV_coverage_sample {
36
37 /**
38 * Accepted by the &lt;attrib_list&gt; parameter of eglChooseConfig
39 * and eglCreatePbufferSurface, and by the &lt;attribute&gt;
40 * parameter of eglGetConfigAttrib:
41 */
42 int EGL_COVERAGE_BUFFERS_NV = 0x30E0,
43 EGL_COVERAGE_SAMPLES_NV = 0x30E1;
44
45 /**
46 * Accepted by the &lt;internalformat&gt; parameter of
47 * RenderbufferStorageEXT and the &lt;format&gt; parameter of ReadPixels:
48 */
49 int GL_COVERAGE_COMPONENT_NV = 0x8522;
50
51 /**
52 * Accepted by the &lt;internalformat&gt; parameter of
53 * RenderbufferStorageEXT:
54 */
55 int GL_COVERAGE_COMPONENT4_NV = 0x8523;
56
57 /** Accepted by the &lt;operation&gt; parameter of CoverageOperationNV: */
58 int GL_COVERAGE_ALL_FRAGMENTS_NV = 0x8524,
59 GL_COVERAGE_EDGE_FRAGMENTS_NV = 0x8525,
60 GL_COVERAGE_AUTOMATIC_NV = 0x8526;
61
62 /**
63 * Accepted by the &lt;attachment&gt; parameter of
64 * FramebufferRenderbuffer, and GetFramebufferAttachmentParameteriv:
65 */
66 int GL_COVERAGE_ATTACHMENT_NV = 0x8527;
67
68 /** Accepted by the &lt;buf&gt; parameter of Clear: */
69 int GL_COVERAGE_BUFFER_BIT_NV = 0x8000;
70
71 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv: */
72 int GL_COVERAGE_BUFFERS_NV = 0x8528,
73 GL_COVERAGE_SAMPLES_NV = 0x8529;
74
75 void glCoverageMaskNV(boolean mask);
76
77 void glCoverageOperationNV(@GLenum int operation);
78
79 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_depth_nonlinear {
34
35 /**
36 * Accepted as a valid sized internal format by all functions accepting
37 * sized internal formats with a base format of DEPTH_COMPONENT:
38 */
39 int GL_DEPTH_COMPONENT16_NONLINEAR_NV = 0x8553;
40
41 /**
42 * Accepted by the &lt;attrib_list&gt; parameter of eglChooseConfig,
43 * and by the &lt;attribute&gt; parameter of eglGetConfigAttrib:
44 */
45 int EGL_DEPTH_ENCODING_NV = 0x30E2;
46
47 /**
48 * Accepted as a value in the &lt;attrib_list&gt; parameter of eglChooseConfig
49 * and eglCreatePbufferSurface, and returned in the &lt;value&gt; parameter
50 * of eglGetConfigAttrib:
51 */
52 int EGL_DEPTH_ENCODING_NONE_NV = 0,
53 EGL_DEPTH_ENCODING_NONLINEAR_NV = 0x30E3;
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Alternate;
34 import org.lwjgl.util.generator.AutoSize;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.Constant;
37 import org.lwjgl.util.generator.opengl.GLenum;
38 import org.lwjgl.util.generator.opengl.GLsizei;
39
40 import java.nio.IntBuffer;
41
42 public interface NV_draw_buffers {
43
44 /**
45 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
46 * and GetDoublev:
47 */
48 int GL_MAX_DRAW_BUFFERS_NV = 0x8824,
49 GL_DRAW_BUFFER0_NV = 0x8825,
50 GL_DRAW_BUFFER1_NV = 0x8826,
51 GL_DRAW_BUFFER2_NV = 0x8827,
52 GL_DRAW_BUFFER3_NV = 0x8828,
53 GL_DRAW_BUFFER4_NV = 0x8829,
54 GL_DRAW_BUFFER5_NV = 0x882A,
55 GL_DRAW_BUFFER6_NV = 0x882B,
56 GL_DRAW_BUFFER7_NV = 0x882C,
57 GL_DRAW_BUFFER8_NV = 0x882D,
58 GL_DRAW_BUFFER9_NV = 0x882E,
59 GL_DRAW_BUFFER10_NV = 0x882F,
60 GL_DRAW_BUFFER11_NV = 0x8830,
61 GL_DRAW_BUFFER12_NV = 0x8831,
62 GL_DRAW_BUFFER13_NV = 0x8832,
63 GL_DRAW_BUFFER14_NV = 0x8833,
64 GL_DRAW_BUFFER15_NV = 0x8834;
65
66 /** Accepted by the &lt;bufs&gt; parameter of DrawBuffersNV: */
67 int GL_COLOR_ATTACHMENT0_NV = 0x8CE0,
68 GL_COLOR_ATTACHMENT1_NV = 0x8CE1,
69 GL_COLOR_ATTACHMENT2_NV = 0x8CE2,
70 GL_COLOR_ATTACHMENT3_NV = 0x8CE3,
71 GL_COLOR_ATTACHMENT4_NV = 0x8CE4,
72 GL_COLOR_ATTACHMENT5_NV = 0x8CE5,
73 GL_COLOR_ATTACHMENT6_NV = 0x8CE6,
74 GL_COLOR_ATTACHMENT7_NV = 0x8CE7,
75 GL_COLOR_ATTACHMENT8_NV = 0x8CE8,
76 GL_COLOR_ATTACHMENT9_NV = 0x8CE9,
77 GL_COLOR_ATTACHMENT10_NV = 0x8CEA,
78 GL_COLOR_ATTACHMENT11_NV = 0x8CEB,
79 GL_COLOR_ATTACHMENT12_NV = 0x8CEC,
80 GL_COLOR_ATTACHMENT13_NV = 0x8CED,
81 GL_COLOR_ATTACHMENT14_NV = 0x8CEE,
82 GL_COLOR_ATTACHMENT15_NV = 0x8CEF;
83
84 void glDrawBuffersNV(@AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs);
85
86 @Alternate("glDrawBuffersNV")
87 void glDrawBuffersNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buf)", keepParam = true) int buf);
88
89 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.opengl.*;
37
38 import java.nio.ByteBuffer;
39 import java.nio.FloatBuffer;
40
41 public interface NV_draw_path {
42
43 /** Accepted as the &lt;paramType&gt; parameter of PathParameterNV: */
44 int GL_PATH_QUALITY_NV = 0x8ED8,
45 GL_FILL_RULE_NV = 0x8ED9,
46 GL_STROKE_CAP0_STYLE_NV = 0x8EE0,
47 GL_STROKE_CAP1_STYLE_NV = 0x8EE1,
48 GL_STROKE_CAP2_STYLE_NV = 0x8EE2,
49 GL_STROKE_CAP3_STYLE_NV = 0x8EE3,
50 GL_STROKE_JOIN_STYLE_NV = 0x8EE8,
51 GL_STROKE_MITER_LIMIT_NV = 0x8EE9;
52
53 /** Values for the ILL_RULE_NV path parameter: */
54 int GL_EVEN_ODD_NV = 0x8EF0,
55 GL_NON_ZERO_NV = 0x8EF1;
56
57 /** Values for the CAP[0-3]_STYLE_NV path parameter: */
58 int GL_CAP_BUTT_NV = 0x8EF4,
59 GL_CAP_ROUND_NV = 0x8EF5,
60 GL_CAP_SQUARE_NV = 0x8EF6,
61 GL_CAP_TRIANGLE_NV = 0x8EF7;
62
63 /** Values for the JOIN_STYLE_NV path parameter: */
64 int GL_JOIN_MITER_NV = 0x8EFC,
65 GL_JOIN_ROUND_NV = 0x8EFD,
66 GL_JOIN_BEVEL_NV = 0x8EFE,
67 GL_JOIN_CLIPPED_MITER_NV = 0x8EFF;
68
69 /** Accepted as the &lt;target&gt; parameter of PathMatrixNV: */
70 int GL_MATRIX_PATH_TO_CLIP_NV = 0x8F04,
71 GL_MATRIX_STROKE_TO_PATH_NV = 0x8F05,
72 GL_MATRIX_PATH_COORD0_NV = 0x8F08,
73 GL_MATRIX_PATH_COORD1_NV = 0x8F09,
74 GL_MATRIX_PATH_COORD2_NV = 0x8F0A,
75 GL_MATRIX_PATH_COORD3_NV = 0x8F0B;
76
77 /** Accepted as the &lt;mode&gt; parameter of DrawPathbufferNV: */
78 int GL_FILL_PATH_NV = 0x8F18,
79 GL_STROKE_PATH_NV = 0x8F19;
80
81 /** Accepted as path commands by CreatePathNV: */
82 byte GL_MOVE_TO_NV = 0x00,
83 GL_LINE_TO_NV = 0x01,
84 GL_QUADRATIC_BEZIER_TO_NV = 0x02,
85 GL_CUBIC_BEZIER_TO_NV = 0x03,
86 GL_START_MARKER_NV = 0x20,
87 GL_CLOSE_NV = 0x21,
88 GL_STROKE_CAP0_NV = 0x40,
89 GL_STROKE_CAP1_NV = 0x41,
90 GL_STROKE_CAP2_NV = 0x42,
91 GL_STROKE_CAP3_NV = 0x43;
92
93 @GLuint
94 int glCreatePathNV(@GLenum int datatype, @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands);
95
96 void glDeletePathNV(@GLuint int path);
97
98 void glPathVerticesNV(@GLuint int path, @Const @Check @GLvoid ByteBuffer vertices);
99
100 void glPathParameterfNV(@GLuint int path, @GLenum int paramType, float param);
101
102 void glPathParameteriNV(@GLuint int path, @GLenum int paramType, int param);
103
104 @GLuint
105 int glCreatePathProgramNV();
106
107 void glPathMatrixNV(@GLenum int target, @Const @Check("16") FloatBuffer value);
108
109 void glDrawPathNV(@GLuint int path, @GLenum int mode);
110
111 @GLuint
112 int glCreatePathbufferNV(@GLsizei int capacity);
113
114 void glDeletePathbufferNV(@GLuint int buffer);
115
116 void glPathbufferPathNV(@GLuint int buffer, int index, @GLuint int path);
117
118 void glPathbufferPositionNV(@GLuint int buffer, int index, float x, float y);
119
120 void glDrawPathbufferNV(@GLuint int buffer, @GLenum int mode);
121
122 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLfloat;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface NV_draw_texture {
37
38 void glDrawTextureNV(@GLuint int texture, @GLuint int sampler,
39 @GLfloat float x0, @GLfloat float y0,
40 @GLfloat float x1, @GLfloat float y1,
41 @GLfloat float z,
42 @GLfloat float s0, @GLfloat float t0,
43 @GLfloat float s1, @GLfloat float t1);
44
45 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_fbo_color_attachments {
34
35 int GL_MAX_COLOR_ATTACHMENTS_NV = 0x8CDF,
36 GL_COLOR_ATTACHMENT0_NV = 0x8CE0,
37 GL_COLOR_ATTACHMENT1_NV = 0x8CE1,
38 GL_COLOR_ATTACHMENT2_NV = 0x8CE2,
39 GL_COLOR_ATTACHMENT3_NV = 0x8CE3,
40 GL_COLOR_ATTACHMENT4_NV = 0x8CE4,
41 GL_COLOR_ATTACHMENT5_NV = 0x8CE5,
42 GL_COLOR_ATTACHMENT6_NV = 0x8CE6,
43 GL_COLOR_ATTACHMENT7_NV = 0x8CE7,
44 GL_COLOR_ATTACHMENT8_NV = 0x8CE8,
45 GL_COLOR_ATTACHMENT9_NV = 0x8CE9,
46 GL_COLOR_ATTACHMENT10_NV = 0x8CEA,
47 GL_COLOR_ATTACHMENT11_NV = 0x8CEB,
48 GL_COLOR_ATTACHMENT12_NV = 0x8CEC,
49 GL_COLOR_ATTACHMENT13_NV = 0x8CED,
50 GL_COLOR_ATTACHMENT14_NV = 0x8CEE,
51 GL_COLOR_ATTACHMENT15_NV = 0x8CEF;
52
53 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.IntBuffer;
40
41 public interface NV_fence {
42
43 /** Accepted by the &lt;condition&gt; parameter of SetFenceNV: */
44 int GL_ALL_COMPLETED_NV = 0x84F2;
45
46 /** Accepted by the &lt;pname&gt; parameter of GetFenceivNV: */
47 int GL_FENCE_STATUS_NV = 0x84F3,
48 GL_FENCE_CONDITION_NV = 0x84F4;
49
50 void glGenFencesNV(@AutoSize("fences") @GLsizei int n, @OutParameter @GLuint IntBuffer fences);
51
52 @Alternate("glGenFencesNV")
53 @GLreturn("fences")
54 void glGenFencesNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer fences);
55
56 void glDeleteFencesNV(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences);
57
58 @Alternate("glDeleteFencesNV")
59 void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(fence)", keepParam = true) int fence);
60
61 void glSetFenceNV(@GLuint int fence, @GLenum int condition);
62
63 boolean glTestFenceNV(@GLuint int fence);
64
65 void glFinishFenceNV(@GLuint int fence);
66
67 boolean glIsFenceNV(@GLuint int fence);
68
69 void glGetFenceivNV(@GLuint int fence, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
70
71 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.*;
34
35 public interface NV_framebuffer_vertex_attrib_array {
36
37 int GL_FRAMEBUFFER_ATTACHABLE_NV = 0x852A,
38 GL_VERTEX_ATTRIB_ARRAY_NV = 0x852B,
39 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_SIZE_NV = 0x852C,
40 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_TYPE_NV = 0x852D,
41 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_NORMALIZED_NV = 0x852E,
42 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_OFFSET_NV = 0x852F,
43 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_WIDTH_NV = 0x8530,
44 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_STRIDE_NV = 0x8531,
45 GL_FRAMEBUFFER_ATTACHMENT_VERTEX_ATTRIB_ARRAY_HEIGHT_NV = 0x8532;
46
47 void glFramebufferVertexAttribArrayNV(@GLenum int target, @GLenum int attachment,
48 @GLenum int buffertarget, @GLuint int bufferobject,
49 @GLint int size, @GLenum int type, @GLboolean boolean normalized, @GLintptr long offset,
50 @GLsizeiptr long width, @GLsizeiptr long height, @GLsizei int stride);
51
52 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Alternate;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.OutParameter;
36 import org.lwjgl.util.generator.StripPostfix;
37 import org.lwjgl.util.generator.opengl.*;
38
39 import java.nio.Buffer;
40 import java.nio.ByteBuffer;
41 import java.nio.FloatBuffer;
42 import java.nio.IntBuffer;
43
44 public interface NV_get_tex_image {
45
46 int GL_TEXTURE_WIDTH_NV = 0x1000,
47 GL_TEXTURE_HEIGHT_NV = 0x1001,
48 GL_TEXTURE_INTERNAL_FORMAT_NV = 0x1003,
49 GL_TEXTURE_COMPONENTS_NV = GL_TEXTURE_INTERNAL_FORMAT_NV,
50 GL_TEXTURE_BORDER_NV = 0x1005,
51 GL_TEXTURE_RED_SIZE_NV = 0x805C,
52 GL_TEXTURE_GREEN_SIZE_NV = 0x805D,
53 GL_TEXTURE_BLUE_SIZE_NV = 0x805E,
54 GL_TEXTURE_ALPHA_SIZE_NV = 0x805F,
55 GL_TEXTURE_LUMINANCE_SIZE_NV = 0x8060,
56 GL_TEXTURE_INTENSITY_SIZE_NV = 0x8061,
57 GL_TEXTURE_DEPTH_NV = 0x8071,
58 GL_TEXTURE_COMPRESSED_IMAGE_SIZE_NV = 0x86A0,
59 GL_TEXTURE_COMPRESSED_NV = 0x86A1,
60 GL_TEXTURE_DEPTH_SIZE_NV = 0x884A;
61
62 void glGetTexImageNV(@GLenum int target, @GLint int level, @GLenum int format, @GLenum int type,
63 @OutParameter
64 @Check("GLChecks.calculateImageStorage(img, format, type, 1, 1, 1)")
65 @GLbyte
66 @GLshort
67 @GLint
68 @GLfloat Buffer img);
69
70 void glGetCompressedTexImageNV(@GLenum int target, @GLint int level, @OutParameter @Check @GLvoid ByteBuffer img);
71
72 @StripPostfix("params")
73 void glGetTexLevelParameterfvNV(@GLenum int target, @GLint int level, @GLenum int pname, @OutParameter @Check("1") @GLfloat FloatBuffer params);
74
75 @Alternate("glGetTexLevelParameterfvNV")
76 @GLreturn("params")
77 @StripPostfix(value = "params", hasPostfix = false)
78 void glGetTexLevelParameterfvNV2(@GLenum int target, @GLint int level, @GLenum int pname, @OutParameter @GLfloat FloatBuffer params);
79
80 @StripPostfix("params")
81 void glGetTexLevelParameterivNV(@GLenum int target, @GLint int level, @GLenum int pname, @OutParameter @Check("1") @GLint IntBuffer params);
82
83 @Alternate("glGetTexLevelParameterivNV")
84 @GLreturn("params")
85 @StripPostfix(value = "params", hasPostfix = false)
86 void glGetTexLevelParameterivNV2(@GLenum int target, @GLint int level, @GLenum int pname, @OutParameter @GLint IntBuffer params);
87
88 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_platform_binary {
34
35 /** Accepted by the &lt;binaryformat&gt; parameter of ShaderBinary: */
36 int GL_NVIDIA_PLATFORM_BINARY_NV = 0x890B;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34
35 public interface NV_read_buffer {
36
37 int GL_READ_BUFFER_NV = 0x0C02,
38 GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_NV = 0x8CDC;
39
40 void glReadBufferNV(@GLenum int mode);
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_read_depth_stencil {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_shader_framebuffer_fetch {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.EGLuint64NV;
34
35 public interface NV_system_time {
36
37 @EGLuint64NV
38 long glGetSystemTimeFrequencyNV();
39
40 @EGLuint64NV
41 long glGetSystemTimeNV();
42
43 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_texture_compression_s3tc_update {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface NV_texture_npot_2D_mipmap {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.PointerWrapper;
34 import org.lwjgl.util.generator.opengl.GLenum;
35
36 public interface OES_EGL_image {
37
38 void glEGLImageTargetTexture2DOES(@GLenum int target, @PointerWrapper("GLeglImageOES") EGLImageOES image);
39
40 void glEGLImageTargetRenderbufferStorageOES(@GLenum int target, @PointerWrapper("GLeglImageOES") EGLImageOES image);
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.PointerWrapper;
34 import org.lwjgl.util.generator.opengl.GLenum;
35
36 public interface OES_EGL_image_external {
37
38 /**
39 * Accepted as a target in the &lt;target&gt; parameter of BindTexture and
40 * EGLImageTargetTexture2DOES:
41 */
42 int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
43
44 /** Returned in the &lt;type&gt; parameter of GetActiveUniform: */
45 int GL_SAMPLER_EXTERNAL_OES = 0x8D66;
46
47 /** Accepted as &lt;value&gt; in GetIntegerv() and GetFloatv() queries: */
48 int GL_TEXTURE_BINDING_EXTERNAL_OES = 0x8D67;
49
50 /** Accepted as &lt;value&gt; in GetTexParameter*() queries: */
51 int GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8D68;
52
53 void glEGLImageTargetTexture2DOES(@GLenum int target, @PointerWrapper("GLeglImageOES") EGLImageOES image);
54
55 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Alias;
34
35 @Alias("OES_egl_sync")
36 public interface OES_EGL_sync {
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34
35 public interface OES_blend_equation_separate {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
39 * GetFloatv:
40 */
41 int GL_BLEND_EQUATION_RGB_OES = 0x8009,
42 GL_BLEND_EQUATION_ALPHA_OES = 0x883D;
43
44 void glBlendEquationSeparateOES(@GLenum int modeRGB, @GLenum int modeAlpha);
45
46 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34
35 public interface OES_blend_func_separate {
36
37 /**
38 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
39 * GetFloatv:
40 */
41 int GL_BLEND_DST_RGB_OES = 0x80C8,
42 BLEND_SRC_RGB_OES = 0x80C9,
43 BLEND_DST_ALPHA_OES = 0x80CA,
44 BLEND_SRC_ALPHA_OES = 0x80CB;
45
46 void glBlendFuncSeparateOES(@GLenum int sfactorRGB,
47 @GLenum int dfactorRGB,
48 @GLenum int sfactorAlpha,
49 @GLenum int dfactorAlpha);
50
51 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLenum;
34
35 public interface OES_blend_subtract {
36
37 /** Accepted by the &lt;mode&gt; parameter of BlendEquationOES: */
38 int GL_FUNC_ADD_OES = 0x8006,
39 GL_FUNC_SUBTRACT_OES = 0x800A,
40 GL_FUNC_REVERSE_SUBTRACT_OES = 0x800B;
41
42 /**
43 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
44 * and GetFloatv:
45 */
46 int GL_BLEND_EQUATION_OES = 0x8009;
47
48 void glBlendEquationOES(@GLenum int mode);
49
50 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_compressed_ETC1_RGB8_texture {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of CompressedTexImage2D: */
36 int GL_ETC1_RGB8_OES = 0x8D64;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_compressed_paletted_texture {
34
35 /** Accepted by the &lt;internalformat&gt; paramter of CompressedTexImage2D */
36 int GL_PALETTE4_RGB8_OES = 0x8B90,
37 GL_PALETTE4_RGBA8_OES = 0x8B91,
38 GL_PALETTE4_R5_G6_B5_OES = 0x8B92,
39 GL_PALETTE4_RGBA4_OES = 0x8B93,
40 GL_PALETTE4_RGB5_A1_OES = 0x8B94,
41 GL_PALETTE8_RGB8_OES = 0x8B95,
42 GL_PALETTE8_RGBA8_OES = 0x8B96,
43 GL_PALETTE8_R5_G6_B5_OES = 0x8B97,
44 GL_PALETTE8_RGBA4_OES = 0x8B98,
45 GL_PALETTE8_RGB5_A1_OES = 0x8B99;
46
47 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_depth24 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
36 int GL_DEPTH_COMPONENT24_OES = 0x81A6;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_depth32 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
36 int GL_DEPTH_COMPONENT32_OES = 0x81A7;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_depth_texture {
34
35 /**
36 * Accepted by the &lt;format&gt; parameter of TexImage2D and TexSubImage2D and
37 * &lt;internalFormat&gt; parameter of TexImage2D:
38 */
39 int GL_DEPTH_COMPONENT = 0x1902;
40
41 /** Accepted by the &lt;type&gt; parameter of TexImage2D, TexSubImage2D: */
42 int GL_UNSIGNED_SHORT = 0x1403,
43 GL_UNSIGNED_INT = 0x1405;
44
45 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_element_index_uint {
34
35 /** Accepted by the &lt;type&gt; parameter of DrawElements: */
36 int GL_UNSIGNED_INT = 0x1405;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_fbo_render_mipmap {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.IntBuffer;
40
41 public interface OES_framebuffer_object {
42
43 /**
44 * Accepted by the &lt;target&gt; parameter of BindFramebufferOES,
45 * CheckFramebufferStatusOES, FramebufferTexture{2D|3D}OES,
46 * FramebufferRenderbufferOES, and
47 * GetFramebufferAttachmentParameterivOES:
48 */
49 int GL_FRAMEBUFFER_OES = 0x8D40;
50
51 /**
52 * Accepted by the &lt;target&gt; parameter of BindRenderbufferOES,
53 * RenderbufferStorageOES, and GetRenderbufferParameterivOES, and
54 * returned by GetFramebufferAttachmentParameterivOES:
55 */
56 int GL_RENDERBUFFER_OES = 0x8D41;
57
58 /**
59 * Accepted by the &lt;internalformat&gt; parameter of
60 * RenderbufferStorageOES:
61 */
62 int GL_DEPTH_COMPONENT16_OES = 0x81A5,
63 GL_RGBA4_OES = 0x8056,
64 GL_RGB5_A1_OES = 0x8057,
65 GL_RGB565_OES = 0x8D62,
66 GL_STENCIL_INDEX1_OES = 0x8D46,
67 GL_STENCIL_INDEX4_OES = 0x8D47,
68 GL_STENCIL_INDEX8_OES = 0x8D48;
69
70 /** Accepted by the &lt;pname&gt; parameter of GetRenderbufferParameterivOES: */
71 int GL_RENDERBUFFER_WIDTH_OES = 0x8D42,
72 GL_RENDERBUFFER_HEIGHT_OES = 0x8D43,
73 GL_RENDERBUFFER_INTERNAL_FORMAT_OES = 0x8D44,
74 GL_RENDERBUFFER_RED_SIZE_OES = 0x8D50,
75 GL_RENDERBUFFER_GREEN_SIZE_OES = 0x8D51,
76 GL_RENDERBUFFER_BLUE_SIZE_OES = 0x8D52,
77 GL_RENDERBUFFER_ALPHA_SIZE_OES = 0x8D53,
78 GL_RENDERBUFFER_DEPTH_SIZE_OES = 0x8D54,
79 GL_RENDERBUFFER_STENCIL_SIZE_OES = 0x8D55;
80
81 /**
82 * Accepted by the &lt;pname&gt; parameter of
83 * GetFramebufferAttachmentParameterivOES:
84 */
85 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES = 0x8CD0,
86 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES = 0x8CD1,
87 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES = 0x8CD2,
88 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES = 0x8CD3,
89 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES = 0x8CD4;
90
91 /**
92 * Accepted by the &lt;attachment&gt; parameter of
93 * FramebufferTexture{2D|3D}OES, FramebufferRenderbufferOES, and
94 * GetFramebufferAttachmentParameterivOES
95 */
96 int GL_COLOR_ATTACHMENT0_OES = 0x8CE0,
97 GL_DEPTH_ATTACHMENT_OES = 0x8D00,
98 GL_STENCIL_ATTACHMENT_OES = 0x8D20;
99
100 /**
101 * Returned by GetFramebufferAttachmentParameterivOES when the
102 * &lt;pname&gt; parameter is FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES:
103 */
104 int GL_NONE_OES = 0;
105
106 /** Returned by CheckFramebufferStatusOES(): */
107 int GL_FRAMEBUFFER_COMPLETE_OES = 0x8CD5,
108 GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES = 0x8CD6,
109 GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES = 0x8CD7,
110 GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES = 0x8CD9,
111 GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES = 0x8CDA,
112 GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES = 0x8CDB,
113 GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES = 0x8CDC,
114 GL_FRAMEBUFFER_UNSUPPORTED_OES = 0x8CDD;
115
116 /** Accepted by GetIntegerv(): */
117 int GL_FRAMEBUFFER_BINDING_OES = 0x8CA6,
118 GL_RENDERBUFFER_BINDING_OES = 0x8CA7,
119 GL_MAX_RENDERBUFFER_SIZE_OES = 0x84E8;
120
121 /** Returned by GetError(): */
122 int GL_INVALID_FRAMEBUFFER_OPERATION_OES = 0x0506;
123
124 boolean glIsRenderbufferOES(@GLuint int renderbuffer);
125
126 void glBindRenderbufferOES(@GLenum int target, @GLuint int renderbuffer);
127
128 void glDeleteRenderbuffersOES(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
129
130 @Alternate("glDeleteRenderbuffersOES")
131 void glDeleteRenderbuffersOES(@Constant("1") int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer);
132
133 void glGenRenderbuffersOES(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
134
135 @Alternate("glGenRenderbuffersOES")
136 @GLreturn("renderbuffers")
137 void glGenRenderbuffersOES2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers);
138
139 void glRenderbufferStorageOES(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
140
141 @StripPostfix("params")
142 void glGetRenderbufferParameterivOES(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
143
144 /** @deprecated Will be removed in 3.0. Use {@link #glGetRenderbufferParameteriOES} instead. */
145 @Alternate("glGetRenderbufferParameterivOES")
146 @GLreturn("params")
147 @StripPostfix("params")
148 @Reuse(value = "OESFramebufferObject", method = "glGetRenderbufferParameteriOES")
149 @Deprecated
150 void glGetRenderbufferParameterivOES2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
151
152 @Alternate("glGetRenderbufferParameterivOES")
153 @GLreturn("params")
154 @StripPostfix(value = "params", hasPostfix = false)
155 void glGetRenderbufferParameterivOES3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
156
157 boolean glIsFramebufferOES(@GLuint int framebuffer);
158
159 void glBindFramebufferOES(@GLenum int target, @GLuint int framebuffer);
160
161 void glDeleteFramebuffersOES(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
162
163 @Alternate("glDeleteFramebuffersOES")
164 void glDeleteFramebuffersOES(@Constant("1") int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer);
165
166 void glGenFramebuffersOES(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
167
168 @Alternate("glGenFramebuffersOES")
169 @GLreturn("framebuffers")
170 void glGenFramebuffersOES2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers);
171
172 @GLenum
173 int glCheckFramebufferStatusOES(@GLenum int target);
174
175 void glFramebufferTexture2DOES(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level);
176
177 void glFramebufferRenderbufferOES(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer);
178
179 @StripPostfix("params")
180 void glGetFramebufferAttachmentParameterivOES(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
181
182 /** @deprecated Will be removed in 3.0. Use {@link #glGetFramebufferAttachmentParameteriOES} instead. */
183 @Alternate("glGetFramebufferAttachmentParameterivOES")
184 @GLreturn("params")
185 @StripPostfix("params")
186 @Reuse(value = "OESFramebufferObject", method = "glGetFramebufferAttachmentParameteriOES")
187 @Deprecated
188 void glGetFramebufferAttachmentParameterivOES2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
189
190 @Alternate("glGetFramebufferAttachmentParameterivOES")
191 @GLreturn("params")
192 @StripPostfix(value = "params", hasPostfix = false)
193 void glGetFramebufferAttachmentParameterivOES3(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params);
194
195 void glGenerateMipmapOES(@GLenum int target);
196
197 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.Const;
36 import org.lwjgl.util.generator.OutParameter;
37 import org.lwjgl.util.generator.opengl.GLenum;
38 import org.lwjgl.util.generator.opengl.GLsizei;
39 import org.lwjgl.util.generator.opengl.GLuint;
40 import org.lwjgl.util.generator.opengl.GLvoid;
41
42 import java.nio.ByteBuffer;
43 import java.nio.IntBuffer;
44
45 public interface OES_get_program_binary {
46
47 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
48 int GL_PROGRAM_BINARY_LENGTH_OES = 0x8741;
49
50 /**
51 * Accepted by the &lt;pname&lt; parameter of GetBooleanv, GetIntegerv, and
52 * GetFloatv:
53 */
54 int GL_NUM_PROGRAM_BINARY_FORMATS_OES = 0x87FE,
55 GL_PROGRAM_BINARY_FORMATS_OES = 0x87FF;
56
57 void glGetProgramBinaryOES(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize,
58 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
59 @OutParameter @Check("1") @GLenum IntBuffer binaryFormat,
60 @OutParameter @GLvoid ByteBuffer binary);
61
62 void glProgramBinaryOES(@GLuint int program, @GLenum int binaryFormat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") int length);
63
64 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLvoid;
36
37 import java.nio.ByteBuffer;
38
39 public interface OES_mapbuffer {
40
41 /** Accepted by the &lt;access&gt; parameter of MapBufferOES: */
42 int GL_WRITE_ONLY_OES = 0x88B9;
43
44 /** Accepted by the &lt;value&gt; parameter of GetBufferParameteriv: */
45 int GL_BUFFER_ACCESS_OES = 0x88BB,
46 GL_BUFFER_MAPPED_OES = 0x88BC;
47
48 /** Accepted by the &lt;pname&gt; parameter of GetBufferPointervOES: */
49 int GL_BUFFER_MAP_POINTER_OES = 0x88BD;
50
51 @StripPostfix("pointer")
52 @CachedResult
53 @AutoSize("GLES20.glGetBufferParameteri(target, GLES20.GL_BUFFER_SIZE)")
54 void glGetBufferPointervOES(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer);
55
56 /**
57 * glMapBufferOES maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null,
58 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null,
59 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object,
60 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBuffer like this:
61 * <p/>
62 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferOES(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferOES(..., ..., mapped_buffer);
63 * <p/>
64 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused.
65 * <p/>
66 * The version of this method without an explicit length argument calls glGetBufferParameter internally to
67 * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance.
68 * <p/>
69 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call
70 * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.<br>
71 * Security warning: The length argument should match the buffer object size. Reading from or writing to outside
72 * the memory region that corresponds to the mapped buffer object will cause native crashes.
73 *
74 * @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.
75 *
76 * @return A ByteBuffer representing the mapped buffer memory.
77 */
78 @CachedResult
79 @GLvoid
80 @AutoSize("GLES20.glGetBufferParameteri(target, GLES20.GL_BUFFER_SIZE)")
81 ByteBuffer glMapBufferOES(@GLenum int target, @GLenum int access);
82
83 boolean glUnmapBufferOES(@GLenum int target);
84
85 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_packed_depth_stencil {
34
35 /**
36 * Accepted by the &lt;format&gt; parameter of TexImage2D and TexSubImage2D and by the
37 * &lt;internalformat&gt; parameter of TexImage2D:
38 */
39 int GL_DEPTH_STENCIL_OES = 0x84F9;
40
41 /** Accepted by the &lt;type&gt; parameter of TexImage2D and TexSubImage2D: */
42 int GL_UNSIGNED_INT_24_8_OES = 0x84FA;
43
44 /**
45 * Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorage, and
46 * returned in the &lt;params&gt; parameter of GetRenderbufferParameteriv when
47 * &lt;pname&gt; is RENDERBUFFER_INTERNAL_FORMAT:
48 */
49 int GL_DEPTH24_STENCIL8_OES = 0x88F0;
50
51 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_required_internalformat {
34 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Extension;
34
35 @Extension(postfix = "OES", className = "OESRGB8RGBA8")
36 public interface OES_rgb8_rgba8 {
37
38 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
39 int GL_RGB8_OES = 0x8051,
40 GL_RGBA8_OES = 0x8058;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_standard_derivatives {
34
35 /**
36 * Accepted by the &lt;target&gt; parameter of Hint and by the &lt;pname&gt; parameter of
37 * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
38 */
39 int GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_stencil1 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
36 int GL_STENCIL_INDEX1_OES = 0x8D46;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_stencil4 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
36 int GL_STENCIL_INDEX4_OES = 0x8D47;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_stencil8 {
34
35 /** Accepted by the &lt;internalformat&gt; parameter of RenderbufferStorageOES: */
36 int GL_STENCIL_INDEX8_OES = 0x8D48;
37
38 }
0 /*
1 * Copyright (c) 2002-2012 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_surfaceless_context {
34
35 /** Returned by glCheckFramebufferStatusOES and glCheckFramebufferStatus: */
36 int GL_FRAMEBUFFER_UNDEFINED_OES = 0x8219;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.Check;
34 import org.lwjgl.util.generator.Const;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.Buffer;
38 import java.nio.ByteBuffer;
39
40 public interface OES_texture_3D {
41
42 /**
43 * Accepted by the &lt;target&gt; parameter of TexImage3DOES, TexSubImage3DOES,
44 * CopyTexSubImage3DOES, CompressedTexImage3DOES and
45 * CompressedTexSubImage3DOES, GetTexParameteriv, and GetTexParameterfv:
46 */
47 int GL_TEXTURE_3D_OES = 0x806F;
48
49 /**
50 * Accepted by the &lt;pname&gt; parameter of TexParameteriv, TexParameterfv,
51 * GetTexParameteriv, and GetTexParameterfv:
52 */
53 int GL_TEXTURE_WRAP_R_OES = 0x8072;
54
55 /**
56 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, and
57 * GetFloatv:
58 */
59 int GL_MAX_3D_TEXTURE_SIZE_OES = 0x8073,
60 GL_TEXTURE_BINDING_3D_OES = 0x806A;
61
62 void glTexImage3DOES(@GLenum int target, int level,
63 @GLenum int internalFormat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border,
64 @GLenum int format, @GLenum int type,
65 @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true)
66 @Const @GLbyte @GLshort @GLint @GLfloat Buffer pixels);
67
68 void glTexSubImage3DOES(@GLenum int target, int level,
69 int xoffset, int yoffset, int zoffset,
70 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
71 @GLenum int format, @GLenum int type,
72 @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)")
73 @Const @GLbyte @GLshort @GLint @GLfloat Buffer pixels);
74
75 void glCopyTexSubImage3DOES(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height);
76
77 void glCompressedTexImage3DOES(@GLenum int target, int level, @GLenum int internalformat,
78 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
79 int border, @GLsizei int imageSize,
80 @Check @Const @GLvoid ByteBuffer data);
81
82 void glCompressedTexSubImage3DOES(@GLenum int target, int level,
83 int xoffset, int yoffset, int zoffset,
84 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
85 @GLenum int format, @GLsizei int imageSize,
86 @Check @Const @GLvoid ByteBuffer data);
87
88 void glFramebufferTexture3DOES(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset);
89
90 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_texture_float {
34 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_texture_float_linear {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_texture_half_float {
34
35 /**
36 * Accepted by the &lt;type&gt; parameter of TexImage2D, TexSubImage2D,
37 * TexImage3D, and TexSubImage3D:
38 */
39 int GL_HALF_FLOAT_OES = 0x8D61;
40
41 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_texture_half_float_linear {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_texture_npot {
34
35 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLreturn;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37
38 import java.nio.IntBuffer;
39
40 public interface OES_vertex_array_object {
41
42 /** Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv: */
43 int GL_VERTEX_ARRAY_BINDING_OES = 0x85B5;
44
45 void glBindVertexArrayOES(@GLuint int array);
46
47 void glDeleteVertexArraysOES(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
48
49 @Alternate("glDeleteVertexArraysOES")
50 void glDeleteVertexArraysOES(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array);
51
52 void glGenVertexArraysOES(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
53
54 @Alternate("glGenVertexArraysOES")
55 @GLreturn("arrays")
56 void glGenVertexArraysOES2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
57
58 boolean glIsVertexArrayOES(@GLuint int array);
59
60 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_vertex_half_float {
34
35 /** Accepted by the &lt;type&gt; parameter of VertexAttribPointer: */
36 int GL_HALF_FLOAT_OES = 0x8D61;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface OES_vertex_type_10_10_10_2 {
34
35 /** Accepted by the &lt;type&gt; parameter of VertexAttribPointer */
36 int GL_UNSIGNED_INT_10_10_10_2_OES = 0x8DF6,
37 GL_INT_10_10_10_2_OES = 0x8DF7;
38
39 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface QCOM_binning_control {
34
35 /** Accepted by the &lt;target&gt; parameter of Hint: */
36 int GL_BINNING_CONTROL_HINT_QCOM = 0x8FB0;
37
38 /** Accepted by the &lt;hint&gt; parameter of Hint: */
39 int GL_CPU_OPTIMIZED_QCOM = 0x8FB1,
40 GL_GPU_OPTIMIZED_QCOM = 0x8FB2,
41 GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM = 0x8FB3,
42 GL_DONT_CARE = 0x1100;
43
44 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLchar;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 public interface QCOM_driver_control {
43
44 void glGetDriverControlsQCOM(@OutParameter @Check(value = "1", canBeNull = true) IntBuffer num,
45 @AutoSize(value = "driverControls", canBeNull = true) @GLsizei int size,
46 @OutParameter @Check(canBeNull = true) @GLuint IntBuffer driverControls);
47
48 void glGetDriverControlStringQCOM(@GLuint int driverControl,
49 @AutoSize(value = "driverControlString", canBeNull = true) @GLsizei int bufSize,
50 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
51 @OutParameter @Check(canBeNull = true) @GLchar ByteBuffer driverControlString);
52
53 @Alternate("glGetDriverControlStringQCOM")
54 @GLreturn(value = "driverControlString", maxLength = "bufSize")
55 void glGetDriverControlStringQCOM2(@GLuint int driverControl,
56 @GLsizei int bufSize,
57 @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(driverControlString_length)") IntBuffer length,
58 @OutParameter @GLchar ByteBuffer driverControlString);
59
60 void glEnableDriverControlQCOM(@GLuint int driverControl);
61
62 void glDisableDriverControlQCOM(@GLuint int driverControl);
63
64 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.OutParameter;
36 import org.lwjgl.util.generator.Result;
37 import org.lwjgl.util.generator.opengl.*;
38
39 import java.nio.Buffer;
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42
43 public interface QCOM_extended_get {
44
45 /** Accepted by the &lt;pname&gt; parameter of ExtGetTexLevelParameterivQCOM */
46 int GL_TEXTURE_WIDTH_QCOM = 0x8BD2,
47 GL_TEXTURE_HEIGHT_QCOM = 0x8BD3,
48 GL_TEXTURE_DEPTH_QCOM = 0x8BD4,
49 GL_TEXTURE_INTERNAL_FORMAT_QCOM = 0x8BD5,
50 GL_TEXTURE_FORMAT_QCOM = 0x8BD6,
51 GL_TEXTURE_TYPE_QCOM = 0x8BD7,
52 GL_TEXTURE_IMAGE_VALID_QCOM = 0x8BD8,
53 GL_TEXTURE_NUM_LEVELS_QCOM = 0x8BD9,
54 GL_TEXTURE_TARGET_QCOM = 0x8BDA,
55 GL_TEXTURE_OBJECT_VALID_QCOM = 0x8BDB;
56
57 /** Accepted by the &lt;pname&gt; parameter of ExtTexObjectStateOverrideiQCOM */
58 int GL_STATE_RESTORE = 0x8BDC;
59
60 void glExtGetTexturesQCOM(@OutParameter @Check("1") @GLuint IntBuffer textures,
61 @AutoSize("textures") int maxTextures,
62 @OutParameter @Check("1") IntBuffer numTextures);
63
64 void glExtGetBuffersQCOM(@OutParameter @Check("1") @GLuint IntBuffer buffers,
65 @AutoSize("buffers") int maxBuffers,
66 @OutParameter @Check("1") IntBuffer numBuffers);
67
68 void glExtGetRenderbuffersQCOM(@OutParameter @Check("1") @GLuint IntBuffer renderbuffers,
69 @AutoSize("renderbuffers") int maxRenderbuffers,
70 @OutParameter @Check("1") IntBuffer numRenderbuffers);
71
72 void glExtGetFramebuffersQCOM(@OutParameter @Check("1") @GLuint IntBuffer framebuffers,
73 @AutoSize("framebuffers") int maxFramebuffers,
74 @OutParameter @Check("1") IntBuffer numFramebuffers);
75
76 void glExtGetTexLevelParameterivQCOM(@GLuint int texture, @GLenum int face, int level,
77 @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
78
79 void glExtTexObjectStateOverrideiQCOM(@GLenum int target, @GLenum int pname, int param);
80
81 void glExtGetTexSubImageQCOM(@GLenum int target, int level,
82 int xoffset, int yoffset, int zoffset,
83 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
84 @GLenum int format, @GLenum int type,
85 @OutParameter
86 @Check("GLChecks.calculateImageStorage(texels, format, type, width, height, depth)")
87 @GLbyte
88 @GLshort
89 @GLint
90 @GLfloat Buffer texels);
91
92 void glExtGetBufferPointervQCOM(@GLenum int target, @Result @GLvoid ByteBuffer params);
93
94 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.Check;
35 import org.lwjgl.util.generator.OutParameter;
36 import org.lwjgl.util.generator.opengl.GLchar;
37 import org.lwjgl.util.generator.opengl.GLenum;
38 import org.lwjgl.util.generator.opengl.GLuint;
39
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42
43 public interface QCOM_extended_get2 {
44
45 void glExtGetShadersQCOM(@OutParameter @Check("1") @GLuint IntBuffer shaders,
46 @AutoSize("shaders") int maxShaders,
47 @OutParameter @Check("1") IntBuffer numShaders);
48
49 void glExtGetProgramsQCOM(@OutParameter @Check("1") @GLuint IntBuffer programs,
50 @AutoSize("programs") int maxPrograms,
51 @OutParameter @Check("1") IntBuffer numPrograms);
52
53 boolean glExtIsProgramBinaryQCOM(@GLuint int program);
54
55 void glExtGetProgramBinarySourceQCOM(@GLuint int program, @GLenum int shadertype,
56 @OutParameter @Check @GLchar ByteBuffer source, @OutParameter @Check("1") IntBuffer length);
57
58 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface QCOM_performance_monitor_global_mode {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Enable and Disable, and
37 * IsEnabled, and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
38 * and GetFloatv:
39 */
40 int GL_PERFMON_GLOBAL_MODE_QCOM = 0x8FA0;
41
42 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 import org.lwjgl.util.generator.opengl.GLbitfield;
34 import org.lwjgl.util.generator.opengl.GLuint;
35
36 public interface QCOM_tiled_rendering {
37
38 /**
39 * Accepted by the &lt;preserveMask&gt; parameter of StartTilingQCOM and
40 * EndTilingQCOM
41 */
42 int GL_COLOR_BUFFER_BIT0_QCOM = 0x00000001,
43 GL_COLOR_BUFFER_BIT1_QCOM = 0x00000002,
44 GL_COLOR_BUFFER_BIT2_QCOM = 0x00000004,
45 GL_COLOR_BUFFER_BIT3_QCOM = 0x00000008,
46 GL_COLOR_BUFFER_BIT4_QCOM = 0x00000010,
47 GL_COLOR_BUFFER_BIT5_QCOM = 0x00000020,
48 GL_COLOR_BUFFER_BIT6_QCOM = 0x00000040,
49 GL_COLOR_BUFFER_BIT7_QCOM = 0x00000080,
50 GL_DEPTH_BUFFER_BIT0_QCOM = 0x00000100,
51 GL_DEPTH_BUFFER_BIT1_QCOM = 0x00000200,
52 GL_DEPTH_BUFFER_BIT2_QCOM = 0x00000400,
53 GL_DEPTH_BUFFER_BIT3_QCOM = 0x00000800,
54 GL_DEPTH_BUFFER_BIT4_QCOM = 0x00001000,
55 GL_DEPTH_BUFFER_BIT5_QCOM = 0x00002000,
56 GL_DEPTH_BUFFER_BIT6_QCOM = 0x00004000,
57 GL_DEPTH_BUFFER_BIT7_QCOM = 0x00008000,
58 GL_STENCIL_BUFFER_BIT0_QCOM = 0x00010000,
59 GL_STENCIL_BUFFER_BIT1_QCOM = 0x00020000,
60 GL_STENCIL_BUFFER_BIT2_QCOM = 0x00040000,
61 GL_STENCIL_BUFFER_BIT3_QCOM = 0x00080000,
62 GL_STENCIL_BUFFER_BIT4_QCOM = 0x00100000,
63 GL_STENCIL_BUFFER_BIT5_QCOM = 0x00200000,
64 GL_STENCIL_BUFFER_BIT6_QCOM = 0x00400000,
65 GL_STENCIL_BUFFER_BIT7_QCOM = 0x00800000,
66 GL_MULTISAMPLE_BUFFER_BIT0_QCOM = 0x01000000,
67 GL_MULTISAMPLE_BUFFER_BIT1_QCOM = 0x02000000,
68 GL_MULTISAMPLE_BUFFER_BIT2_QCOM = 0x04000000,
69 GL_MULTISAMPLE_BUFFER_BIT3_QCOM = 0x08000000,
70 GL_MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000,
71 GL_MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000,
72 GL_MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000,
73 GL_MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000;
74
75 void glStartTilingQCOM(@GLuint int x, @GLuint int y, @GLuint int width, @GLuint int height,
76 @GLbitfield int preserveMask);
77
78 void glEndTilingQCOM(@GLbitfield int preserveMask);
79
80 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface QCOM_writeonly_rendering {
34
35 /** Accepted by the &lt;cap&gt; parameter of Enable, Disable. */
36 int GL_WRITEONLY_RENDERING_QCOM = 0x8823;
37
38 }
0 /*
1 * Copyright (c) 2002-2011 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl.opengles;
32
33 public interface VIV_shader_binary {
34
35 /** Accepted by the &lt;binaryformat&gt; parameter of ShaderBinary: */
36 int GL_SHADER_BINARY_VIV = 0x8FC4;
37
38 }