diff options
Diffstat (limited to 'ardor3d-jogl')
86 files changed, 1120 insertions, 988 deletions
diff --git a/ardor3d-jogl/.classpath b/ardor3d-jogl/.classpath deleted file mode 100644 index 1a5b322..0000000 --- a/ardor3d-jogl/.classpath +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry combineaccessrules="false" kind="src" path="/ardor3d-core"/> - <classpathentry exported="true" kind="lib" path="lib/jogl/gluegen-rt.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry exported="true" kind="lib" path="lib/jogl/jogl-all.jar"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/ardor3d-jogl/.project b/ardor3d-jogl/.project deleted file mode 100644 index 095e1c0..0000000 --- a/ardor3d-jogl/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>ardor3d-jogl</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/ardor3d-jogl/.settings/org.eclipse.core.resources.prefs b/ardor3d-jogl/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index dc6c01a..0000000 --- a/ardor3d-jogl/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Wed Jan 07 11:33:09 PST 2009 -eclipse.preferences.version=1 -encoding/<project>=UTF-8 diff --git a/ardor3d-jogl/.settings/org.eclipse.jdt.core.prefs b/ardor3d-jogl/.settings/org.eclipse.jdt.core.prefs index 7858c9b..19eadb6 100644 --- a/ardor3d-jogl/.settings/org.eclipse.jdt.core.prefs +++ b/ardor3d-jogl/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Tue Apr 06 11:30:42 CDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -17,6 +16,7 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/ardor3d-jogl/.settings/org.eclipse.jdt.ui.prefs b/ardor3d-jogl/.settings/org.eclipse.jdt.ui.prefs index f479490..7588391 100644 --- a/ardor3d-jogl/.settings/org.eclipse.jdt.ui.prefs +++ b/ardor3d-jogl/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ -#Sun Jan 04 11:43:23 CST 2009
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-amd64.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-amd64.jar Binary files differdeleted file mode 100644 index 98177cc..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-i586.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-i586.jar Binary files differdeleted file mode 100644 index 668bbbb..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-linux-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-macosx-universal.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-macosx-universal.jar Binary files differdeleted file mode 100644 index 11999bc..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-macosx-universal.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-amd64.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-amd64.jar Binary files differdeleted file mode 100644 index c9c75eb..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-i586.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-i586.jar Binary files differdeleted file mode 100644 index ccc064d..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-solaris-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-amd64.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-amd64.jar Binary files differdeleted file mode 100644 index 43c1a95..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-i586.jar b/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-i586.jar Binary files differdeleted file mode 100644 index b9aa134..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt-natives-windows-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/gluegen-rt.jar b/ardor3d-jogl/lib/jogl/gluegen-rt.jar Binary files differdeleted file mode 100644 index a9957e6..0000000 --- a/ardor3d-jogl/lib/jogl/gluegen-rt.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-amd64.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-amd64.jar Binary files differdeleted file mode 100644 index 0f914e2..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-i586.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-i586.jar Binary files differdeleted file mode 100644 index e969c9b..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-linux-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-macosx-universal.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-macosx-universal.jar Binary files differdeleted file mode 100644 index 32f1567..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-macosx-universal.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-amd64.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-amd64.jar Binary files differdeleted file mode 100644 index cee93dd..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-i586.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-i586.jar Binary files differdeleted file mode 100644 index 8f2dc08..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-solaris-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-amd64.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-amd64.jar Binary files differdeleted file mode 100644 index 8ca3682..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-amd64.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-i586.jar b/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-i586.jar Binary files differdeleted file mode 100644 index 1ff1289..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all-natives-windows-i586.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/jogl-all.jar b/ardor3d-jogl/lib/jogl/jogl-all.jar Binary files differdeleted file mode 100644 index 977f5f1..0000000 --- a/ardor3d-jogl/lib/jogl/jogl-all.jar +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-amd64/libgluegen-rt.so b/ardor3d-jogl/lib/jogl/native/linux-amd64/libgluegen-rt.so Binary files differdeleted file mode 100644 index e24d5e0..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-amd64/libgluegen-rt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-amd64/libjogl_desktop.so b/ardor3d-jogl/lib/jogl/native/linux-amd64/libjogl_desktop.so Binary files differdeleted file mode 100644 index f91d7c6..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-amd64/libjogl_desktop.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_awt.so b/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_awt.so Binary files differdeleted file mode 100644 index be10b14..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_awt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_x11.so b/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_x11.so Binary files differdeleted file mode 100644 index 53100af..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnativewindow_x11.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnewt.so b/ardor3d-jogl/lib/jogl/native/linux-amd64/libnewt.so Binary files differdeleted file mode 100644 index d757938..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-amd64/libnewt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-i586/libgluegen-rt.so b/ardor3d-jogl/lib/jogl/native/linux-i586/libgluegen-rt.so Binary files differdeleted file mode 100644 index b58b5e1..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-i586/libgluegen-rt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-i586/libjogl_desktop.so b/ardor3d-jogl/lib/jogl/native/linux-i586/libjogl_desktop.so Binary files differdeleted file mode 100644 index 1fe60d5..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-i586/libjogl_desktop.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_awt.so b/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_awt.so Binary files differdeleted file mode 100644 index 1a5446d..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_awt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_x11.so b/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_x11.so Binary files differdeleted file mode 100644 index 9e18ccd..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-i586/libnativewindow_x11.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/linux-i586/libnewt.so b/ardor3d-jogl/lib/jogl/native/linux-i586/libnewt.so Binary files differdeleted file mode 100644 index 9d00b7d..0000000 --- a/ardor3d-jogl/lib/jogl/native/linux-i586/libnewt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/macosx-universal/libgluegen-rt.jnilib b/ardor3d-jogl/lib/jogl/native/macosx-universal/libgluegen-rt.jnilib Binary files differdeleted file mode 100644 index 4d5eac6..0000000 --- a/ardor3d-jogl/lib/jogl/native/macosx-universal/libgluegen-rt.jnilib +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/macosx-universal/libjogl_desktop.jnilib b/ardor3d-jogl/lib/jogl/native/macosx-universal/libjogl_desktop.jnilib Binary files differdeleted file mode 100644 index ebc22dc..0000000 --- a/ardor3d-jogl/lib/jogl/native/macosx-universal/libjogl_desktop.jnilib +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_awt.jnilib b/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_awt.jnilib Binary files differdeleted file mode 100644 index 9060779..0000000 --- a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_awt.jnilib +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_macosx.jnilib b/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_macosx.jnilib Binary files differdeleted file mode 100644 index 9b5c146..0000000 --- a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnativewindow_macosx.jnilib +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnewt.jnilib b/ardor3d-jogl/lib/jogl/native/macosx-universal/libnewt.jnilib Binary files differdeleted file mode 100644 index 2396a03..0000000 --- a/ardor3d-jogl/lib/jogl/native/macosx-universal/libnewt.jnilib +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libgluegen-rt.so b/ardor3d-jogl/lib/jogl/native/solaris-amd64/libgluegen-rt.so Binary files differdeleted file mode 100644 index b949c18..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libgluegen-rt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libjogl_desktop.so b/ardor3d-jogl/lib/jogl/native/solaris-amd64/libjogl_desktop.so Binary files differdeleted file mode 100644 index 956e497..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libjogl_desktop.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_awt.so b/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_awt.so Binary files differdeleted file mode 100644 index 3e1f1d4..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_awt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_x11.so b/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_x11.so Binary files differdeleted file mode 100644 index 7bb9279..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnativewindow_x11.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnewt.so b/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnewt.so Binary files differdeleted file mode 100644 index 2b84891..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-amd64/libnewt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-i586/libgluegen-rt.so b/ardor3d-jogl/lib/jogl/native/solaris-i586/libgluegen-rt.so Binary files differdeleted file mode 100644 index 3d40b91..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-i586/libgluegen-rt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-i586/libjogl_desktop.so b/ardor3d-jogl/lib/jogl/native/solaris-i586/libjogl_desktop.so Binary files differdeleted file mode 100644 index cb9a072..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-i586/libjogl_desktop.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_awt.so b/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_awt.so Binary files differdeleted file mode 100644 index 48189d0..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_awt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_x11.so b/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_x11.so Binary files differdeleted file mode 100644 index 9693dc2..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnativewindow_x11.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnewt.so b/ardor3d-jogl/lib/jogl/native/solaris-i586/libnewt.so Binary files differdeleted file mode 100644 index 3ab2e58..0000000 --- a/ardor3d-jogl/lib/jogl/native/solaris-i586/libnewt.so +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-amd64/gluegen-rt.dll b/ardor3d-jogl/lib/jogl/native/windows-amd64/gluegen-rt.dll Binary files differdeleted file mode 100644 index 9ea63b1..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-amd64/gluegen-rt.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-amd64/jogl_desktop.dll b/ardor3d-jogl/lib/jogl/native/windows-amd64/jogl_desktop.dll Binary files differdeleted file mode 100644 index 2b27820..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-amd64/jogl_desktop.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_awt.dll b/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_awt.dll Binary files differdeleted file mode 100644 index bf67563..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_awt.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_win32.dll b/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_win32.dll Binary files differdeleted file mode 100644 index 044d080..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-amd64/nativewindow_win32.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-amd64/newt.dll b/ardor3d-jogl/lib/jogl/native/windows-amd64/newt.dll Binary files differdeleted file mode 100644 index aa7e2f9..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-amd64/newt.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-i586/gluegen-rt.dll b/ardor3d-jogl/lib/jogl/native/windows-i586/gluegen-rt.dll Binary files differdeleted file mode 100644 index 409fd66..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-i586/gluegen-rt.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-i586/jogl_desktop.dll b/ardor3d-jogl/lib/jogl/native/windows-i586/jogl_desktop.dll Binary files differdeleted file mode 100644 index 415602e..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-i586/jogl_desktop.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_awt.dll b/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_awt.dll Binary files differdeleted file mode 100644 index d3868c7..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_awt.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_win32.dll b/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_win32.dll Binary files differdeleted file mode 100644 index a9c0174..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-i586/nativewindow_win32.dll +++ /dev/null diff --git a/ardor3d-jogl/lib/jogl/native/windows-i586/newt.dll b/ardor3d-jogl/lib/jogl/native/windows-i586/newt.dll Binary files differdeleted file mode 100644 index 46f5f8e..0000000 --- a/ardor3d-jogl/lib/jogl/native/windows-i586/newt.dll +++ /dev/null diff --git a/ardor3d-jogl/pom.xml b/ardor3d-jogl/pom.xml index 56c0800..74b1a4d 100644 --- a/ardor3d-jogl/pom.xml +++ b/ardor3d-jogl/pom.xml @@ -1,52 +1,52 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.ardor3d</groupId>
- <artifactId>ardor3d</artifactId>
- <relativePath>../pom.xml</relativePath>
- <version>0.9-SNAPSHOT</version>
- </parent>
-
- <artifactId>ardor3d-jogl</artifactId>
- <packaging>bundle</packaging>
- <name>Ardor 3D JOGL</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ardor3d-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jogamp.gluegen</groupId>
- <artifactId>gluegen-rt-main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jogamp.jogl</groupId>
- <artifactId>jogl-all-main</artifactId>
- </dependency>
- <!--
- <dependency>
- <groupId>org.jogamp.joal</groupId>
- <artifactId>joal-main</artifactId>
- <version>2.0-rc11</version>
- </dependency>
- <dependency>
- <groupId>org.jogamp.jocl</groupId>
- <artifactId>jocl-main</artifactId>
- <version>2.0-rc11</version>
- </dependency> -->
- </dependencies>
-</project>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.ardor3d</groupId> + <artifactId>ardor3d</artifactId> + <relativePath>../pom.xml</relativePath> + <version>0.9-SNAPSHOT</version> + </parent> + + <artifactId>ardor3d-jogl</artifactId> + <packaging>bundle</packaging> + <name>Ardor 3D JOGL</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>ardor3d-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.jogamp.gluegen</groupId> + <artifactId>gluegen-rt-main</artifactId> + </dependency> + <dependency> + <groupId>org.jogamp.jogl</groupId> + <artifactId>jogl-all-main</artifactId> + </dependency> + <!-- + <dependency> + <groupId>org.jogamp.joal</groupId> + <artifactId>joal-main</artifactId> + <version>2.0-rc11</version> + </dependency> + <dependency> + <groupId>org.jogamp.jocl</groupId> + <artifactId>jocl-main</artifactId> + <version>2.0-rc11</version> + </dependency> --> + </dependencies> +</project> + diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java index c23b8a0..78ccd40 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java @@ -19,6 +19,11 @@ import com.ardor3d.util.Ardor3dException; public class CapsUtil { public static GLCapabilities getCapsForSettings(final DisplaySettings settings) { + return getCapsForSettings(settings, true, false, false, false); + } + + public static GLCapabilities getCapsForSettings(final DisplaySettings settings, final boolean onscreen, + final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested) { // Validate window dimensions. if (settings.getWidth() <= 0 || settings.getHeight() <= 0) { @@ -40,6 +45,25 @@ public class CapsUtil { caps.setSampleBuffers(settings.getSamples() != 0); caps.setStereo(settings.isStereo()); caps.setStencilBits(settings.getStencilBits()); + switch (settings.getColorDepth()) { + case 32: + case 24: + caps.setRedBits(8); + caps.setBlueBits(8); + caps.setGreenBits(8); + break; + case 16: + caps.setRedBits(4); + caps.setBlueBits(4); + caps.setGreenBits(4); + break; + } + caps.setOnscreen(onscreen); + if (!onscreen) { + caps.setBitmap(bitmapRequested); + caps.setPBuffer(pbufferRequested); + caps.setFBO(fboRequested); + } return caps; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java index 5c95cd8..58fef71 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java @@ -10,10 +10,12 @@ package com.ardor3d.framework.jogl; +import java.lang.reflect.InvocationTargetException; import java.util.concurrent.CountDownLatch; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; + import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; @@ -21,7 +23,7 @@ import com.ardor3d.framework.DisplaySettings; /** * FIXME there is still a deadlock when using several instances of this class in the same container, see JOGL bug 572 * Rather use JoglNewtAwtCanvas in this case. - * + * */ public class JoglAwtCanvas extends GLCanvas implements Canvas { @@ -31,12 +33,15 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { private boolean _inited = false; private final DisplaySettings _settings; - + private final JoglDrawerRunnable _drawerGLRunnable; + private final JoglInitializerRunnable _initializerRunnable; + public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) { super(CapsUtil.getCapsForSettings(settings)); _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); + _initializerRunnable = new JoglInitializerRunnable(this, settings); _settings = settings; _canvasRenderer = canvasRenderer; @@ -49,25 +54,23 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { @MainThread public void init() { - if (_inited) { + if (_inited) { return; } - - // Make the window visible to realize the OpenGL surface. - setVisible(true); - - // Request the focus here as it cannot work when the window is not visible - requestFocus(); - - _canvasRenderer.setContext(getContext()); - - invoke(true, new GLRunnable() { - @Override - public boolean run(GLAutoDrawable glAutoDrawable) { - _canvasRenderer.init(_settings, true);// true - do swap in renderer. - return true; + + // Calling setVisible(true) on the GLCanvas not from the AWT-EDT can freeze the Intel GPU under Windows + if (!SwingUtilities.isEventDispatchThread()) { + try { + SwingUtilities.invokeAndWait(_initializerRunnable); + } catch (final InterruptedException ex) { + ex.printStackTrace(); + } catch (final InvocationTargetException ex) { + ex.printStackTrace(); } - }); + } else { + _initializerRunnable.run(); + } + _inited = true; } @@ -77,7 +80,7 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { } if (isShowing()) { - invoke(true, _drawerGLRunnable); + invoke(true, _drawerGLRunnable); } if (latch != null) { latch.countDown(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java index e6d8b00..d77edb0 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java @@ -1,250 +1,253 @@ -/**
- * Copyright (c) 2008-2010 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import java.util.logging.Logger;
-
-import javax.media.opengl.DebugGL2;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-import javax.media.opengl.glu.GLU;
-
-import com.ardor3d.annotation.MainThread;
-import com.ardor3d.framework.CanvasRenderer;
-import com.ardor3d.framework.DisplaySettings;
-import com.ardor3d.framework.Scene;
-import com.ardor3d.math.ColorRGBA;
-import com.ardor3d.math.Vector3;
-import com.ardor3d.renderer.Camera;
-import com.ardor3d.renderer.ContextCapabilities;
-import com.ardor3d.renderer.ContextManager;
-import com.ardor3d.renderer.RenderContext;
-import com.ardor3d.renderer.Renderer;
-import com.ardor3d.renderer.Camera.ProjectionMode;
-import com.ardor3d.renderer.jogl.JoglContextCapabilities;
-import com.ardor3d.renderer.jogl.JoglRenderer;
-import com.ardor3d.util.Ardor3dException;
-
-public class JoglCanvasRenderer implements CanvasRenderer {
-
- private static final Logger LOGGER = Logger.getLogger(JoglCanvasRenderer.class.getName());
-
- protected Scene _scene;
- protected Camera _camera;
- protected boolean _doSwap;
- protected GLContext _context;
- protected JoglRenderer _renderer;
- protected int _frameClear = Renderer.BUFFER_COLOR_AND_DEPTH;
-
- private RenderContext _currentContext;
-
- /**
- * <code>true</code> if debugging (checking for error codes on each GL call) is desired.
- */
- private final boolean _useDebug;
-
- /**
- * <code>true</code> if debugging is currently enabled for this GLContext.
- */
- private boolean _debugEnabled = false;
-
- public JoglCanvasRenderer(final Scene scene) {
- this(scene, false);
- }
-
- public JoglCanvasRenderer(final Scene scene, final boolean useDebug) {
- _scene = scene;
- _useDebug = useDebug;
- }
-
- public void makeCurrentContext() throws Ardor3dException {
- int value = GLContext.CONTEXT_NOT_CURRENT;
- int attempt = 0;
- do {
- try {
- value = _context.makeCurrent();
- } catch(GLException gle) {
- gle.printStackTrace();
- } finally {
- attempt++;
- if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) {
- // failed, throw exception
- throw new Ardor3dException("Failed to claim OpenGL context.");
- }
- }
- try {
- Thread.sleep(5);
- } catch (final InterruptedException e1) {
- e1.printStackTrace();
- }
- }
- while(value == GLContext.CONTEXT_NOT_CURRENT);
- if (value == GLContext.CONTEXT_CURRENT_NEW) {
- ContextManager.getCurrentContext().contextLost();
-
- // Whenever the context is created or replaced, the GL chain
- // is lost. Debug will have to be added if desired.
- _debugEnabled = false;
- }
-
- ContextManager.switchContext(_context);
- }
-
- public void releaseCurrentContext() {
- if (_context.equals(GLContext.getCurrent())) {
- try {
- _context.release();
- } catch(GLException gle) {
- gle.printStackTrace();
- }
- }
- }
-
- @MainThread
- protected ContextCapabilities createContextCapabilities() {
- return new JoglContextCapabilities(_context.getGL());
- }
-
- @MainThread
- public void init(final DisplaySettings settings, final boolean doSwap) {
- _doSwap = doSwap;
- if (_context == null) {
- _context = GLDrawableFactory.getFactory(GLProfile.getMaxFixedFunc(true)).createExternalGLContext();
- }
-
- _context.makeCurrent();
-
- try {
-
- // Look up a shared context, if a shared JoglCanvasRenderer is given.
- RenderContext sharedContext = null;
- if (settings.getShareContext() != null) {
- sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext()
- .getContextKey());
- }
-
- final ContextCapabilities caps = createContextCapabilities();
- _currentContext = new RenderContext(_context, caps, sharedContext);
-
- ContextManager.addContext(_context, _currentContext);
- ContextManager.switchContext(_context);
-
- _renderer = new JoglRenderer();
-
- if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
- final GL gl = GLU.getCurrentGL();
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
-
- _renderer.setBackgroundColor(ColorRGBA.BLACK);
-
- if (_camera == null) {
- /** Set up how our camera sees. */
- _camera = new Camera(settings.getWidth(), settings.getHeight());
- _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, 1000);
- _camera.setProjectionMode(ProjectionMode.Perspective);
-
- final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f);
- final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f);
- final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
- final Vector3 dir = new Vector3(0.0f, 0f, -1.0f);
- /** Move our camera to a correct place and orientation. */
- _camera.setFrame(loc, left, up, dir);
- } else {
- // use new width and height to set ratio.
- _camera.setFrustumPerspective(_camera.getFovY(),
- (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), _camera
- .getFrustumFar());
- }
- } finally {
- _context.release();
- }
- }
-
- public GLContext getContext() {
- return _context;
- }
-
- public void setContext(final GLContext context) {
- _context = context;
- }
-
- public int MAX_CONTEXT_GRAB_ATTEMPTS = 10;
-
- @MainThread
- public boolean draw() {
-
- // set up context for rendering this canvas
- makeCurrentContext();
-
- // Enable Debugging if requested.
- if (_useDebug != _debugEnabled) {
- _context.setGL(new DebugGL2(_context.getGL().getGL2()));
- _debugEnabled = true;
-
- LOGGER.info("DebugGL Enabled");
- }
-
- // render stuff, first apply our camera if we have one
- if (_camera != null) {
- if (Camera.getCurrentCamera() != _camera) {
- _camera.update();
- }
- _camera.apply(_renderer);
- }
- _renderer.clearBuffers(_frameClear);
-
- final boolean drew = _scene.renderUnto(_renderer);
- _renderer.flushFrame(drew && _doSwap);
-
- // release the context if we're done (swapped and all)
- if (_doSwap) {
- releaseCurrentContext();
- }
-
- return drew;
- }
-
- public Camera getCamera() {
- return _camera;
- }
-
- public Scene getScene() {
- return _scene;
- }
-
- public void setScene(final Scene scene) {
- _scene = scene;
- }
-
- public Renderer getRenderer() {
- return _renderer;
- }
-
- public void setCamera(final Camera camera) {
- _camera = camera;
- }
-
- public RenderContext getRenderContext() {
- return _currentContext;
- }
-
- public int getFrameClear() {
- return _frameClear;
- }
-
- public void setFrameClear(final int buffers) {
- _frameClear = buffers;
- }
-}
+/** + * Copyright (c) 2008-2010 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.framework.jogl; + +import java.util.logging.Logger; + +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + +import com.ardor3d.annotation.MainThread; +import com.ardor3d.framework.CanvasRenderer; +import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.framework.Scene; +import com.ardor3d.math.ColorRGBA; +import com.ardor3d.math.Vector3; +import com.ardor3d.renderer.Camera; +import com.ardor3d.renderer.Camera.ProjectionMode; +import com.ardor3d.renderer.ContextCapabilities; +import com.ardor3d.renderer.ContextManager; +import com.ardor3d.renderer.RenderContext; +import com.ardor3d.renderer.Renderer; +import com.ardor3d.renderer.jogl.JoglContextCapabilities; +import com.ardor3d.renderer.jogl.JoglRenderer; +import com.ardor3d.util.Ardor3dException; + +public class JoglCanvasRenderer implements CanvasRenderer { + + private static final Logger LOGGER = Logger.getLogger(JoglCanvasRenderer.class.getName()); + + protected Scene _scene; + protected Camera _camera; + protected boolean _doSwap; + protected GLContext _context; + protected JoglRenderer _renderer; + protected int _frameClear = Renderer.BUFFER_COLOR_AND_DEPTH; + + private RenderContext _currentContext; + + /** + * <code>true</code> if debugging (checking for error codes on each GL call) is desired. + */ + private final boolean _useDebug; + + /** + * <code>true</code> if debugging is currently enabled for this GLContext. + */ + private boolean _debugEnabled = false; + + public JoglCanvasRenderer(final Scene scene) { + this(scene, false); + } + + public JoglCanvasRenderer(final Scene scene, final boolean useDebug) { + _scene = scene; + _useDebug = useDebug; + } + + public void makeCurrentContext() throws Ardor3dException { + int value = GLContext.CONTEXT_NOT_CURRENT; + int attempt = 0; + do { + try { + value = _context.makeCurrent(); + } catch (final GLException gle) { + gle.printStackTrace(); + } finally { + attempt++; + if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) { + // failed, throw exception + throw new Ardor3dException("Failed to claim OpenGL context."); + } + } + try { + Thread.sleep(5); + } catch (final InterruptedException e1) { + e1.printStackTrace(); + } + } while (value == GLContext.CONTEXT_NOT_CURRENT); + if (ContextManager.getCurrentContext() != null) { + if (value == GLContext.CONTEXT_CURRENT_NEW) { + ContextManager.getCurrentContext().contextLost(); + + // Whenever the context is created or replaced, the GL chain + // is lost. Debug will have to be added if desired. + _debugEnabled = false; + } + + if (ContextManager.getContextForKey(_context) != null) { + ContextManager.switchContext(_context); + } + } + } + + public void releaseCurrentContext() { + if (_context.equals(GLContext.getCurrent())) { + try { + _context.release(); + } catch (final GLException gle) { + gle.printStackTrace(); + } + } + } + + @MainThread + protected ContextCapabilities createContextCapabilities() { + return new JoglContextCapabilities(_context.getGL()); + } + + @MainThread + public void init(final DisplaySettings settings, final boolean doSwap) { + _doSwap = doSwap; + if (_context == null) { + _context = GLDrawableFactory.getFactory(GLProfile.getMaxFixedFunc(true)).createExternalGLContext(); + } + + makeCurrentContext(); + + try { + + // Look up a shared context, if a shared JoglCanvasRenderer is given. + RenderContext sharedContext = null; + if (settings.getShareContext() != null) { + sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext() + .getContextKey()); + } + + final ContextCapabilities caps = createContextCapabilities(); + _currentContext = new RenderContext(_context, caps, sharedContext); + + ContextManager.addContext(_context, _currentContext); + ContextManager.switchContext(_context); + + _renderer = new JoglRenderer(); + + if (settings.getSamples() != 0 && caps.isMultisampleSupported()) { + final GL gl = GLContext.getCurrentGL(); + gl.glEnable(GL.GL_MULTISAMPLE); + } + + _renderer.setBackgroundColor(ColorRGBA.BLACK); + + if (_camera == null) { + /** Set up how our camera sees. */ + _camera = new Camera(settings.getWidth(), settings.getHeight()); + _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, + 1000); + _camera.setProjectionMode(ProjectionMode.Perspective); + + final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f); + final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f); + final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f); + final Vector3 dir = new Vector3(0.0f, 0f, -1.0f); + /** Move our camera to a correct place and orientation. */ + _camera.setFrame(loc, left, up, dir); + } else { + // use new width and height to set ratio. + _camera.setFrustumPerspective(_camera.getFovY(), + (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), + _camera.getFrustumFar()); + } + } finally { + releaseCurrentContext(); + } + } + + public GLContext getContext() { + return _context; + } + + public void setContext(final GLContext context) { + _context = context; + } + + public int MAX_CONTEXT_GRAB_ATTEMPTS = 10; + + @MainThread + public boolean draw() { + + // set up context for rendering this canvas + makeCurrentContext(); + + // Enable Debugging if requested. + if (_useDebug != _debugEnabled) { + _context.setGL(new DebugGL2(_context.getGL().getGL2())); + _debugEnabled = true; + + LOGGER.info("DebugGL Enabled"); + } + + // render stuff, first apply our camera if we have one + if (_camera != null) { + if (Camera.getCurrentCamera() != _camera) { + _camera.update(); + } + _camera.apply(_renderer); + } + _renderer.clearBuffers(_frameClear); + + final boolean drew = _scene.renderUnto(_renderer); + _renderer.flushFrame(drew && _doSwap); + + // release the context if we're done (swapped and all) + if (_doSwap) { + releaseCurrentContext(); + } + + return drew; + } + + public Camera getCamera() { + return _camera; + } + + public Scene getScene() { + return _scene; + } + + public void setScene(final Scene scene) { + _scene = scene; + } + + public Renderer getRenderer() { + return _renderer; + } + + public void setCamera(final Camera camera) { + _camera = camera; + } + + public RenderContext getRenderContext() { + return _currentContext; + } + + public int getFrameClear() { + return _frameClear; + } + + public void setFrameClear(final int buffers) { + _frameClear = buffers; + } +} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java new file mode 100644 index 0000000..2a93f38 --- /dev/null +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2008-2010 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.framework.jogl; + +import com.ardor3d.framework.DisplaySettings; + +public class JoglInitializerRunnable implements Runnable { + + private final JoglAwtCanvas _joglAwtCanvas; + + private final DisplaySettings _settings; + + public JoglInitializerRunnable(final JoglAwtCanvas joglAwtCanvas, final DisplaySettings settings) { + _joglAwtCanvas = joglAwtCanvas; + _settings = settings; + } + + @Override + public void run() { + // Make the window visible to realize the OpenGL surface. + _joglAwtCanvas.setVisible(true); + // Force the realization + _joglAwtCanvas.display(); + if (!_joglAwtCanvas.getDelegatedDrawable().isRealized()) { + throw new RuntimeException("The heavyweight AWT drawable cannot be realized"); + } + // Request the focus here as it cannot work when the window is not visible + _joglAwtCanvas.requestFocus(); + // The OpenGL context has been created after the realization of the surface + _joglAwtCanvas.getCanvasRenderer().setContext(_joglAwtCanvas.getContext()); + // As the canvas renderer knows the OpenGL context, it can be initialized + _joglAwtCanvas.getCanvasRenderer().init(_settings, true); + } +}
\ No newline at end of file diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java index 3333d90..9490dea 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java @@ -12,10 +12,12 @@ package com.ardor3d.framework.jogl; import java.util.List; import java.util.concurrent.CountDownLatch; + import javax.media.nativewindow.util.Dimension; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLContext; import javax.media.opengl.GLRunnable; + import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.NativeCanvas; @@ -30,100 +32,105 @@ import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.ScreenModeUtil; - public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { - + private final JoglCanvasRenderer _canvasRenderer; private boolean _inited = false; private boolean _isClosing = false; private final DisplaySettings _settings; - + private final JoglDrawerRunnable _drawerGLRunnable; - + private final GLWindow _newtWindow; public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings) { - _newtWindow = GLWindow.create(CapsUtil.getCapsForSettings(settings)); + this(canvasRenderer, settings, true, false, false, false); + } + + public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings, + final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested, + final boolean fboRequested) { + _newtWindow = GLWindow.create(CapsUtil.getCapsForSettings(settings, onscreen, bitmapRequested, + pbufferRequested, fboRequested)); _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); _settings = settings; - _canvasRenderer = canvasRenderer; + _canvasRenderer = canvasRenderer; setAutoSwapBufferMode(false); } - + /** - * Applies all settings not related to OpenGL (screen resolution, - * screen size, etc...) + * Applies all settings not related to OpenGL (screen resolution, screen size, etc...) * */ private void applySettings() { _newtWindow.setUndecorated(_settings.isFullScreen()); - _newtWindow.setFullscreen(_settings.isFullScreen()); - //FIXME Ardor3D does not allow to change the resolution + _newtWindow.setFullscreen(_settings.isFullScreen()); + // FIXME Ardor3D does not allow to change the resolution /** - * uses the filtering relying on resolution with the size to fetch only the screen - * mode matching with the current resolution + * uses the filtering relying on resolution with the size to fetch only the screen mode matching with the + * current resolution */ if (_settings.isFullScreen()) { - Screen screen = _newtWindow.getScreen(); - List<ScreenMode> screenModes = screen.getScreenModes(); - //the resolution is provided by the user - Dimension dimension=new Dimension(_settings.getWidth(),_settings.getHeight()); - screenModes = ScreenModeUtil.filterByResolution(screenModes,dimension); + final Screen screen = _newtWindow.getScreen(); + List<ScreenMode> screenModes = screen.getScreenModes(); + // the resolution is provided by the user + final Dimension dimension = new Dimension(_settings.getWidth(), _settings.getHeight()); + screenModes = ScreenModeUtil.filterByResolution(screenModes, dimension); screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); if (_settings.getFrequency() > 0) { - screenModes = ScreenModeUtil.filterByRate(screenModes, _settings.getFrequency()); - } else { - screenModes = ScreenModeUtil.getHighestAvailableRate(screenModes); - } + screenModes = ScreenModeUtil.filterByRate(screenModes, _settings.getFrequency()); + } else { + screenModes = ScreenModeUtil.getHighestAvailableRate(screenModes); + } screen.setCurrentScreenMode(screenModes.get(0)); } } - - public void addKeyListener(KeyListener keyListener) { + + public void addKeyListener(final KeyListener keyListener) { _newtWindow.addKeyListener(keyListener); } - - public void addMouseListener(MouseListener mouseListener) { + + public void addMouseListener(final MouseListener mouseListener) { _newtWindow.addMouseListener(mouseListener); } - - public void addWindowListener(WindowListener windowListener) { + + public void addWindowListener(final WindowListener windowListener) { _newtWindow.addWindowListener(windowListener); } - + public GLContext getContext() { return _newtWindow.getContext(); } - + public int getWidth() { return _newtWindow.getWidth(); } - + public int getHeight() { return _newtWindow.getHeight(); } - + public int getX() { return _newtWindow.getX(); } - + public int getY() { return _newtWindow.getY(); } - + public boolean isVisible() { return _newtWindow.isVisible(); } - - public void setSize(int width, int height) { + + public void setSize(final int width, final int height) { _newtWindow.setTopLevelSize(width, height); } - - public void setVisible(boolean visible) { + + public void setVisible(final boolean visible) { _newtWindow.setVisible(visible); } - - public void setAutoSwapBufferMode(boolean autoSwapBufferModeEnabled) { + + public void setAutoSwapBufferMode(final boolean autoSwapBufferModeEnabled) { _newtWindow.setAutoSwapBufferMode(autoSwapBufferModeEnabled); } @@ -138,23 +145,23 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { public void windowDestroyNotify(final WindowEvent e) { _isClosing = true; } - -// public void windowResized(final WindowEvent e) { -// _newtWindow.invoke(true, new GLRunnable() { -// -// @Override -// public boolean run(GLAutoDrawable glAutoDrawable) { -// _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight()); -// _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(), -// (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(), -// _canvasRenderer._camera.getFrustumNear(), -// _canvasRenderer._camera.getFrustumFar()); -// return true; -// } -// }); -// } + + // public void windowResized(final WindowEvent e) { + // _newtWindow.invoke(true, new GLRunnable() { + // + // @Override + // public boolean run(GLAutoDrawable glAutoDrawable) { + // _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight()); + // _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(), + // (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(), + // _canvasRenderer._camera.getFrustumNear(), + // _canvasRenderer._camera.getFrustumFar()); + // return true; + // } + // }); + // } }); - + // Set the size very early to prevent the default one from being used (typically when exiting full screen mode) setSize(_settings.getWidth(), _settings.getHeight()); // Make the window visible to realize the OpenGL surface. @@ -162,12 +169,12 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { // Request the focus here as it cannot work when the window is not visible _newtWindow.requestFocus(); applySettings(); - + _canvasRenderer.setContext(getContext()); - + _newtWindow.invoke(true, new GLRunnable() { @Override - public boolean run(GLAutoDrawable glAutoDrawable) { + public boolean run(final GLAutoDrawable glAutoDrawable) { _canvasRenderer.init(_settings, true);// true - do swap in renderer. return true; } @@ -180,7 +187,7 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { init(); } - if (/*isShowing()*/isVisible()) { + if (/* isShowing() */isVisible()) { _newtWindow.invoke(true, _drawerGLRunnable); } if (latch != null) { @@ -208,10 +215,10 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { } @Override - public void setVSyncEnabled(final boolean enabled) { + public void setVSyncEnabled(final boolean enabled) { _newtWindow.invoke(true, new GLRunnable() { @Override - public boolean run(GLAutoDrawable glAutoDrawable) { + public boolean run(final GLAutoDrawable glAutoDrawable) { _newtWindow.getGL().setSwapInterval(enabled ? 1 : 0); return false; } @@ -219,20 +226,20 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { } @Override - public void setTitle(String title) { + public void setTitle(final String title) { _newtWindow.setTitle(title); } @Override - public void setIcon(Image[] iconImages) { - //FIXME not supported by NEWT + public void setIcon(final Image[] iconImages) { + // FIXME not supported by NEWT } @Override - public void moveWindowTo(int locX, int locY) { - _newtWindow.setPosition(locX, locY); + public void moveWindowTo(final int locX, final int locY) { + _newtWindow.setPosition(locX, locY); } - + @Override public GLWindow getNewtWindow() { return _newtWindow; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java index 6ecf6bb..182e769 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java @@ -10,9 +10,12 @@ package com.ardor3d.input.jogl; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.EnumMap; import java.util.EnumSet; import java.util.LinkedList; + import com.ardor3d.annotation.GuardedBy; import com.ardor3d.framework.jogl.NewtWindowContainer; import com.ardor3d.input.ButtonState; @@ -32,9 +35,6 @@ import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.opengl.GLWindow; -import static com.google.common.base.Preconditions.checkNotNull; - - public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { @GuardedBy("this") @@ -47,11 +47,11 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { protected MouseState _lastState = null; protected final GLWindow _newtWindow; - + protected final MouseManager _manager; - + protected boolean _consumeEvents = false; - + protected final Multiset<MouseButton> _clicks = EnumMultiset.create(MouseButton.class); protected final EnumMap<MouseButton, Long> _lastClickTime = Maps.newEnumMap(MouseButton.class); protected final EnumSet<MouseButton> _clickArmed = EnumSet.noneOf(MouseButton.class); @@ -82,7 +82,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { return _currentIterator; } - + private void expireClickEvents() { if (!_clicks.isEmpty()) { for (final MouseButton mb : MouseButton.values()) { @@ -92,9 +92,9 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } } } - + @Override - public synchronized void mousePressed(MouseEvent me) { + public synchronized void mousePressed(final MouseEvent me) { final MouseButton b = getButtonForEvent(me); if (_clickArmed.contains(b)) { _clicks.setCount(b, 0); @@ -115,7 +115,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } @Override - public synchronized void mouseReleased(MouseEvent me) { + public synchronized void mouseReleased(final MouseEvent me) { initState(me); if (_consumeEvents) { me.setAttachment(InputEvent.consumedTag); @@ -137,14 +137,14 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { addNewState(me, buttons, null); } - + @Override - public synchronized void mouseDragged(MouseEvent me) { - mouseMoved(me); + public synchronized void mouseDragged(final MouseEvent me) { + mouseMoved(me); } - + @Override - public synchronized void mouseMoved(MouseEvent me) { + public synchronized void mouseMoved(final MouseEvent me) { _clickArmed.clear(); _clicks.clear(); @@ -159,7 +159,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { // check the state against the "ignore next" values if (_ignoreX != Integer.MAX_VALUE // shortcut to prevent dx/dy calculations - && (_ignoreX == getDX(me) && _ignoreY == getDY(me))) { + && (_ignoreX == getDX(me) && _ignoreY == getDY(me))) { // we matched, so we'll consider this a "mouse pointer reset move" // so reset ignore to let the next move event through. @@ -197,11 +197,11 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { _ignoreX = Integer.MAX_VALUE; _ignoreY = Integer.MAX_VALUE; } - } + } } @Override - public void mouseWheelMoved(MouseEvent me) { + public void mouseWheelMoved(final MouseEvent me) { initState(me); addNewState(me, _lastState.getButtonStates(), null); @@ -209,24 +209,24 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { me.setAttachment(InputEvent.consumedTag); } } - + private void initState(final MouseEvent mouseEvent) { if (_lastState == null) { _lastState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), 0, 0, 0, null, null); } } - + private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap, final Multiset<MouseButton> clicks) { final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent), - getDY(mouseEvent), mouseEvent.getWheelRotation(), enumMap, clicks); + getDY(mouseEvent), (int) mouseEvent.getWheelRotation(), enumMap, clicks); synchronized (JoglNewtMouseWrapper.this) { _upcomingEvents.add(newState); } _lastState = newState; - } - + } + private int getDX(final MouseEvent me) { return me.getX() - _lastState.getX(); } @@ -234,7 +234,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { private int getDY(final MouseEvent me) { return getArdor3DY(me) - _lastState.getY(); } - + /** * @param e * our mouseEvent @@ -244,16 +244,16 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { private int getArdor3DY(final MouseEvent me) { return _newtWindow.getHeight() - me.getY(); } - + private void setStateForButton(final MouseEvent e, final EnumMap<MouseButton, ButtonState> buttons, final ButtonState buttonState) { final MouseButton button = getButtonForEvent(e); buttons.put(button, buttonState); } - + private MouseButton getButtonForEvent(final MouseEvent me) { MouseButton button; - switch(me.getButton()) { + switch (me.getButton()) { case MouseEvent.BUTTON1: button = MouseButton.LEFT; break; @@ -268,9 +268,9 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } return button; } - + private class JoglNewtMouseIterator extends AbstractIterator<MouseState> implements PeekingIterator<MouseState> { - + @Override protected MouseState computeNext() { synchronized (JoglNewtMouseWrapper.this) { @@ -281,25 +281,25 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } } } - + @Override - public synchronized void mouseClicked(MouseEvent me) { + public synchronized void mouseClicked(final MouseEvent me) { // Yes, we could use the click count here, but in the interests of this working the same way as SWT and Native, // we // will do it the same way they do it. - + } @Override - public synchronized void mouseEntered(MouseEvent me) { - // ignore this + public synchronized void mouseEntered(final MouseEvent me) { + // ignore this } @Override - public synchronized void mouseExited(MouseEvent me) { - // ignore this - } - + public synchronized void mouseExited(final MouseEvent me) { + // ignore this + } + public boolean isConsumeEvents() { return _consumeEvents; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 7bc4e01..bfb39bd 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java @@ -74,10 +74,11 @@ public class JoglContextCapabilities extends ContextCapabilities { _geometryShader4Supported = gl.isExtensionAvailable("GL_ARB_geometry_shader4") && _glslSupported; - _geometryInstancingSupported = gl.isExtensionAvailable("GL_EXT_draw_instanced") || gl.isExtensionAvailable("GL_VERSION_3_0"); - + _geometryInstancingSupported = gl.isExtensionAvailable("GL_EXT_draw_instanced") + || gl.isExtensionAvailable("GL_VERSION_3_0"); + _tessellationShadersSupported = gl.isExtensionAvailable("GL_ARB_tessellation_shader") && _glslSupported; - + if (_glslSupported) { gl.glGetIntegerv(GL2.GL_MAX_VERTEX_ATTRIBS_ARB, buf); _maxGLSLVertexAttribs = buf.get(0); @@ -89,6 +90,10 @@ public class JoglContextCapabilities extends ContextCapabilities { // FBO _fboSupported = gl.isExtensionAvailable("GL_EXT_framebuffer_object"); if (_fboSupported) { + + _supportsFBOMultisample = gl.isExtensionAvailable("GL_EXT_framebuffer_multisample"); + _supportsFBOBlit = gl.isExtensionAvailable("GL_EXT_framebuffer_blit"); + if (gl.isExtensionAvailable("GL_ARB_draw_buffers")) { gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, buf); _maxFBOColorAttachments = buf.get(0); @@ -122,11 +127,11 @@ public class JoglContextCapabilities extends ContextCapabilities { // Check for support of multitextures. _supportsMultiTexture = gl.isExtensionAvailable("GL_ARB_multitexture"); - // Support for texture formats - _supportsFloatTextures = gl.isExtensionAvailable("GL_ARB_texture_float"); - _supportsIntegerTextures = gl.isExtensionAvailable("GL_EXT_texture_integer"); - _supportsOneTwoComponentTextures = gl.isExtensionAvailable("GL_ARB_texture_rg"); - + // Support for texture formats + _supportsFloatTextures = gl.isExtensionAvailable("GL_ARB_texture_float"); + _supportsIntegerTextures = gl.isExtensionAvailable("GL_EXT_texture_integer"); + _supportsOneTwoComponentTextures = gl.isExtensionAvailable("GL_ARB_texture_rg"); + // Check for support of fixed function dot3 environment settings _supportsEnvDot3 = gl.isExtensionAvailable("GL_ARB_texture_env_dot3"); @@ -172,8 +177,8 @@ public class JoglContextCapabilities extends ContextCapabilities { } // Now determine the maximum number of supported texture units - _numTotalTexUnits = Math.max(_numFragmentTexCoordUnits, Math.max(_numFixedTexUnits, Math.max( - _numFragmentTexUnits, _numVertexTexUnits))); + _numTotalTexUnits = Math.max(_numFragmentTexCoordUnits, + Math.max(_numFixedTexUnits, Math.max(_numFragmentTexUnits, _numVertexTexUnits))); // Check for S3 texture compression capability. _supportsS3TCCompression = gl.isExtensionAvailable("GL_EXT_texture_compression_s3tc"); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java index 63eb6ee..2613f25 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java @@ -21,7 +21,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; -import javax.media.opengl.glu.GLU; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.Scene; @@ -76,7 +75,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { if (tex.getType() != Type.TwoDimensional) { throw new IllegalArgumentException("Unsupported type: " + tex.getType()); } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(RenderState.StateType.Texture); @@ -99,8 +98,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { // Initialize our texture with some default data. final int internalFormat = JoglTextureUtil.getGLInternalFormat(tex.getTextureStoreFormat()); final int dataFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(tex.getTextureStoreFormat()); - final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); - + final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, null); // Setup filtering and wrap @@ -236,7 +235,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); JoglTextureStateUtil.doTextureBind(tex, 0, true); @@ -245,7 +244,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { @Override protected void clearBuffers(final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glDisable(GL.GL_SCISSOR_TEST); _parentRenderer.clearBuffers(clear); @@ -320,7 +319,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { ContextManager.getCurrentContext().enforceStates(_enforcedStates); if (_bgColorDirty) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), _backgroundColor.getAlpha()); @@ -357,7 +356,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { } } else { // XXX: Is this WGL specific query right? - if (GLU.getCurrentGL().isExtensionAvailable("WGL_ARB_render_texture")) { + if (GLContext.getCurrentGL().isExtensionAvailable("WGL_ARB_render_texture")) { logger.fine("Render to Texture Pbuffer supported!"); _useDirectRender = true; } else { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java index 7812aa6..4747dfd 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java @@ -90,12 +90,12 @@ import com.ardor3d.scene.state.jogl.JoglZBufferStateUtil; import com.ardor3d.scene.state.jogl.util.JoglRendererUtil; import com.ardor3d.scene.state.jogl.util.JoglTextureUtil; import com.ardor3d.scenegraph.AbstractBufferData; +import com.ardor3d.scenegraph.AbstractBufferData.VBOAccessMode; import com.ardor3d.scenegraph.FloatBufferData; import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Renderable; import com.ardor3d.scenegraph.Spatial; -import com.ardor3d.scenegraph.AbstractBufferData.VBOAccessMode; import com.ardor3d.scenegraph.hint.NormalsMode; import com.ardor3d.util.Ardor3dException; import com.ardor3d.util.Constants; @@ -122,7 +122,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setBackgroundColor(final ReadOnlyColorRGBA c) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); _backgroundColor.set(c); gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), @@ -163,7 +163,7 @@ public class JoglRenderer extends AbstractRenderer { } public void clearBuffers(final int buffers, final boolean strict) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int clear = 0; @@ -214,7 +214,7 @@ public class JoglRenderer extends AbstractRenderer { } public void flushFrame(final boolean doSwap) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); renderBuckets(); @@ -240,7 +240,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setOrtho() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_inOrthoMode) { throw new Ardor3dException("Already in Orthographic mode."); @@ -261,7 +261,7 @@ public class JoglRenderer extends AbstractRenderer { } public void unsetOrtho() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!_inOrthoMode) { throw new Ardor3dException("Not in Orthographic mode."); @@ -278,7 +278,7 @@ public class JoglRenderer extends AbstractRenderer { public void grabScreenContents(final ByteBuffer store, final ImageDataFormat format, final int x, final int y, final int w, final int h) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int pixFormat = JoglTextureUtil.getGLPixelFormat(format); gl.glReadPixels(x, y, w, h, pixFormat, GL.GL_UNSIGNED_BYTE, store); @@ -303,23 +303,23 @@ public class JoglRenderer extends AbstractRenderer { * re-initializes the GL context for rendering of another piece of geometry. */ protected void postdrawGeometry(final Mesh g) { - // Nothing to do here yet + // Nothing to do here yet } public void flushGraphics() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glFlush(); } public void finishGraphics() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glFinish(); } public void applyNormalsMode(final NormalsMode normalsMode, final ReadOnlyTransform worldTransform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); if (normalsMode != NormalsMode.Off) { @@ -403,17 +403,17 @@ public class JoglRenderer extends AbstractRenderer { } public void applyDefaultColor(final ReadOnlyColorRGBA defaultColor) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (defaultColor != null) { - gl.getGL2().glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), defaultColor - .getAlpha()); + gl.getGL2().glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), + defaultColor.getAlpha()); } else { gl.getGL2().glColor4f(1, 1, 1, 1); } } public void deleteVBOs(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer idBuffer = BufferUtils.createIntBuffer(ids.size()); idBuffer.clear(); for (final Integer i : ids) { @@ -428,7 +428,7 @@ public class JoglRenderer extends AbstractRenderer { } public void deleteDisplayLists(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); for (final Integer i : ids) { if (i != null && i != 0) { gl.getGL2().glDeleteLists(i, 1); @@ -441,7 +441,7 @@ public class JoglRenderer extends AbstractRenderer { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -492,7 +492,7 @@ public class JoglRenderer extends AbstractRenderer { final int srcOffsetX, final int srcOffsetY, final int srcOffsetZ, final int srcTotalWidth, final int srcTotalHeight, final Face dstFace) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // Ignore textures that do not have an id set if (destination.getTextureIdForContext(ContextManager.getCurrentContext().getGlContextRep()) == 0) { @@ -537,12 +537,12 @@ public class JoglRenderer extends AbstractRenderer { } // Grab pixel format - final int pixelFormat; - if (destination.getImage() != null) { - pixelFormat = JoglTextureUtil.getGLPixelFormat(destination.getImage().getDataFormat()); - } else { - pixelFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(destination.getTextureStoreFormat()); - } + final int pixelFormat; + if (destination.getImage() != null) { + pixelFormat = JoglTextureUtil.getGLPixelFormat(destination.getImage().getDataFormat()); + } else { + pixelFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(destination.getTextureStoreFormat()); + } // bind... JoglTextureStateUtil.doTextureBind(destination, 0, false); @@ -577,12 +577,12 @@ public class JoglRenderer extends AbstractRenderer { GL.GL_UNSIGNED_BYTE, source); break; case OneDimensional: - gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, GL.GL_UNSIGNED_BYTE, - source); + gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, + GL.GL_UNSIGNED_BYTE, source); break; case ThreeDimensional: - gl.getGL2GL3().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, dstWidth, dstHeight, - dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); + gl.getGL2GL3().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, + dstWidth, dstHeight, dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); break; case CubeMap: gl.glTexSubImage2D(JoglTextureStateUtil.getGLCubeMapFace(dstFace), 0, dstOffsetX, dstOffsetY, @@ -621,7 +621,7 @@ public class JoglRenderer extends AbstractRenderer { } public void checkCardError() throws Ardor3dException { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final GLU glu = new GLU(); try { @@ -645,7 +645,7 @@ public class JoglRenderer extends AbstractRenderer { } public boolean doTransforms(final ReadOnlyTransform transform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // set world matrix if (!transform.isIdentity()) { @@ -663,7 +663,7 @@ public class JoglRenderer extends AbstractRenderer { } public void undoTransforms(final ReadOnlyTransform transform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); JoglRendererUtil.switchMode(matRecord, GLMatrixFunc.GL_MODELVIEW); @@ -671,7 +671,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupVertexData(final FloatBufferData vertexBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer vertexBuffer = vertexBufferData != null ? vertexBufferData.getBuffer() : null; @@ -685,7 +685,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupNormalData(final FloatBufferData normalBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer normalBuffer = normalBufferData != null ? normalBufferData.getBuffer() : null; @@ -699,7 +699,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupColorData(final FloatBufferData colorBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer colorBuffer = colorBufferData != null ? colorBufferData.getBuffer() : null; @@ -713,7 +713,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupFogData(final FloatBufferData fogBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer fogBuffer = fogBufferData != null ? fogBufferData.getBuffer() : null; @@ -727,7 +727,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupTextureData(final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -791,7 +791,7 @@ public class JoglRenderer extends AbstractRenderer { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int type = getGLDataType(indices); if (indexLengths == null) { @@ -802,8 +802,8 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawElements(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer()); } else { - gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer(), - primcount); + gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, + indices.getBuffer(), primcount); } if (Constants.stats) { @@ -844,7 +844,7 @@ public class JoglRenderer extends AbstractRenderer { return 0; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord rendRecord = context.getRendererRecord(); int vboID = data.getVBOID(context.getGlContextRep()); @@ -873,12 +873,11 @@ public class JoglRenderer extends AbstractRenderer { private static void updateVBO(final AbstractBufferData<? extends Buffer> data, final RendererRecord rendRecord, final int vboID, final int offsetBytes) { if (data.isNeedsRefresh()) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Buffer dataBuffer = data.getBuffer(); dataBuffer.rewind(); JoglRendererUtil.setBoundVBO(rendRecord, vboID); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offsetBytes, dataBuffer.limit() * data.getByteCount(), - dataBuffer); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offsetBytes, dataBuffer.limit() * data.getByteCount(), dataBuffer); data.setNeedsRefresh(false); } } @@ -889,7 +888,7 @@ public class JoglRenderer extends AbstractRenderer { return 0; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int vboID = data.getVBOID(context.getGlContextRep()); if (vboID != 0) { @@ -897,8 +896,7 @@ public class JoglRenderer extends AbstractRenderer { final Buffer dataBuffer = data.getBuffer(); dataBuffer.rewind(); JoglRendererUtil.setBoundElementVBO(rendRecord, vboID); - gl.glBufferSubData(GL.GL_ELEMENT_ARRAY_BUFFER, 0, dataBuffer.limit() * data.getByteCount(), - dataBuffer); + gl.glBufferSubData(GL.GL_ELEMENT_ARRAY_BUFFER, 0, dataBuffer.limit() * data.getByteCount(), dataBuffer); data.setNeedsRefresh(false); } @@ -923,7 +921,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupVertexDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -940,7 +938,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupNormalDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -957,7 +955,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupColorDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -974,7 +972,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupFogDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -996,7 +994,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupTextureDataVBO(final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1071,7 +1069,7 @@ public class JoglRenderer extends AbstractRenderer { public void setupInterleavedDataVBO(final FloatBufferData interleaved, final FloatBufferData vertexCoords, final FloatBufferData normalCoords, final FloatBufferData colorCoords, final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1157,7 +1155,8 @@ public class JoglRenderer extends AbstractRenderer { } // send data - gl.getGL2().glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, offsetBytes); + gl.getGL2().glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, + offsetBytes); offsetBytes += textureBufferData.getBufferLimit() * 4; } } @@ -1188,7 +1187,7 @@ public class JoglRenderer extends AbstractRenderer { interleaved.getBuffer().rewind(); interleaved.getBuffer().put(bufferSize); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord rendRecord = context.getRendererRecord(); final ContextCapabilities caps = context.getCapabilities(); @@ -1198,21 +1197,17 @@ public class JoglRenderer extends AbstractRenderer { rendRecord.invalidateVBO(); JoglRendererUtil.setBoundVBO(rendRecord, vboID); - gl - .glBufferData(GL.GL_ARRAY_BUFFER, bufferSize, null, getGLVBOAccessMode(interleaved - .getVboAccessMode())); + gl.glBufferData(GL.GL_ARRAY_BUFFER, bufferSize, null, getGLVBOAccessMode(interleaved.getVboAccessMode())); int offset = 0; if (normalCoords != null) { normalCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, normalCoords.getBufferLimit() * 4, normalCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, normalCoords.getBufferLimit() * 4, normalCoords.getBuffer()); offset += normalCoords.getBufferLimit() * 4; } if (colorCoords != null) { colorCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, colorCoords.getBufferLimit() * 4, colorCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, colorCoords.getBufferLimit() * 4, colorCoords.getBuffer()); offset += colorCoords.getBufferLimit() * 4; } if (textureCoords != null) { @@ -1236,8 +1231,7 @@ public class JoglRenderer extends AbstractRenderer { } if (vertexCoords != null) { vertexCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, vertexCoords.getBufferLimit() * 4, vertexCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, vertexCoords.getBufferLimit() * 4, vertexCoords.getBuffer()); } interleaved.setNeedsRefresh(false); @@ -1245,7 +1239,7 @@ public class JoglRenderer extends AbstractRenderer { public void drawElementsVBO(final IndexBufferData<?> indices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1262,8 +1256,8 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawElements(glIndexMode, indices.getBufferLimit(), type, 0); } else { - gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer(), - primcount); + gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, + indices.getBuffer(), primcount); } if (Constants.stats) { @@ -1306,7 +1300,7 @@ public class JoglRenderer extends AbstractRenderer { public void drawArrays(final FloatBufferData vertexBuffer, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); @@ -1331,7 +1325,7 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawArrays(glIndexMode, offset, count); } else { - gl.getGL2GL3().glDrawArraysInstanced(glIndexMode, offset, count, primcount); + gl.getGL2GL3().glDrawArraysInstanced(glIndexMode, offset, count, primcount); } if (Constants.stats) { @@ -1348,7 +1342,7 @@ public class JoglRenderer extends AbstractRenderer { } private static int makeVBOId() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer idBuff = BufferUtils.createIntBuffer(1); gl.glGenBuffers(1, idBuff); @@ -1457,7 +1451,7 @@ public class JoglRenderer extends AbstractRenderer { } private void loadMatrix(final FloatBuffer matrix) { - GLU.getCurrentGL().getGL2().glLoadMatrixf(matrix); + GLContext.getCurrentGL().getGL2().glLoadMatrixf(matrix); } public FloatBuffer getModelViewMatrix(final FloatBuffer store) { @@ -1473,16 +1467,16 @@ public class JoglRenderer extends AbstractRenderer { if (result.remaining() < 16) { result = BufferUtils.createFloatBuffer(16); } - GLU.getCurrentGL().glGetFloatv(matrixType, store); + GLContext.getCurrentGL().glGetFloatv(matrixType, store); return result; } public void setViewport(final int x, final int y, final int width, final int height) { - GLU.getCurrentGL().glViewport(x, y, width, height); + GLContext.getCurrentGL().glViewport(x, y, width, height); } public void setDepthRange(final double depthRangeNear, final double depthRangeFar) { - GLU.getCurrentGL().glDepthRange(depthRangeNear, depthRangeFar); + GLContext.getCurrentGL().glDepthRange(depthRangeNear, depthRangeFar); } public void setDrawBuffer(final DrawBufferTarget target) { @@ -1531,14 +1525,14 @@ public class JoglRenderer extends AbstractRenderer { break; } - GLU.getCurrentGL().getGL2GL3().glDrawBuffer(buffer); + GLContext.getCurrentGL().getGL2GL3().glDrawBuffer(buffer); record.setDrawBufferTarget(target); } } public void setupLineParameters(final float lineWidth, final int stippleFactor, final short stipplePattern, final boolean antialiased) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final LineRecord lineRecord = ContextManager.getCurrentContext().getLineRecord(); @@ -1588,7 +1582,7 @@ public class JoglRenderer extends AbstractRenderer { final boolean useDistanceAttenuation, final FloatBuffer attenuationCoefficients, final float minPointSize, final float maxPointSize) { final RenderContext context = ContextManager.getCurrentContext(); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // TODO: make this into a pointrecord call gl.getGL2GL3().glPointSize(pointSize); @@ -1683,7 +1677,7 @@ public class JoglRenderer extends AbstractRenderer { * @return id of new display list */ public int startDisplayList() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int id = gl.getGL2().glGenLists(1); @@ -1696,14 +1690,14 @@ public class JoglRenderer extends AbstractRenderer { * Ends a display list. Will likely cause an OpenGL exception is a display list is not currently being generated. */ public void endDisplayList() { - GLU.getCurrentGL().getGL2().glEndList(); + GLContext.getCurrentGL().getGL2().glEndList(); } /** * Draw the given display list. */ public void renderDisplayList(final int displayListID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2().glCallList(displayListID); } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java index 99719df..2c68ec1 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java @@ -18,7 +18,7 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.framework.Scene; import com.ardor3d.image.Texture; @@ -75,7 +75,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { throw new IllegalArgumentException("Texture type not supported: " + tex.getType()); } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(RenderState.StateType.Texture); @@ -101,8 +101,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); if (tex.getType() == Type.TwoDimensional) { - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, - null); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, null); } else { for (final Face face : Face.values()) { gl.glTexImage2D(JoglTextureStateUtil.getGLCubeMapFace(face), 0, internalFormat, _width, _height, 0, @@ -138,7 +137,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { private void render(final List<? extends Spatial> toDrawA, final Spatial toDrawB, final Scene toDrawC, final List<Texture> texs, final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int maxDrawBuffers = ContextManager.getCurrentContext().getCapabilities().getMaxFBOColorAttachments(); @@ -217,8 +216,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { final Texture tex = depths.removeFirst(); // Set up our depth texture if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_TEXTURE_2D, tex.getTextureIdForContext(context.getGlContextRep()), 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, + tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), @@ -229,8 +228,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { _usingDepthRB = false; } else if (!_usingDepthRB) { // setup our default depth render buffer if not already set - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_RENDERBUFFER, _depthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, + _depthRBID); _usingDepthRB = true; } @@ -266,20 +265,18 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void setupForSingleTexDraw(final Texture tex) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final int textureId = tex.getTextureIdForContext(context.getGlContextRep()); if (tex.getTextureStoreFormat().isDepthFormat()) { // No color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, - 0); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, 0); // Setup depth texture into FBO if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, - textureId, 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); @@ -292,8 +289,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } else { // Set color texture into FBO if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, - textureId, 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); @@ -302,8 +298,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } // setup depth RB - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, - _depthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, _depthRBID); setDrawBuffer(GL.GL_COLOR_ATTACHMENT0); setReadBuffer(GL.GL_COLOR_ATTACHMENT0); @@ -314,19 +309,19 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } private void setReadBuffer(final int attachVal) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glReadBuffer(attachVal); } private void setDrawBuffer(final int attachVal) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glDrawBuffer(attachVal); } private void setDrawBuffers(final int maxEntry) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (maxEntry <= 1) { setDrawBuffer(maxEntry != 0 ? GL.GL_COLOR_ATTACHMENT0 : GL.GL_NONE); @@ -340,7 +335,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void takedownForSingleTexDraw(final Texture tex) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // automatically generate mipmaps for our texture. if (tex.getMinificationFilter().usesMipMapLevels()) { @@ -351,19 +346,19 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void setMSFBO() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _msfboID); } @Override protected void blitMSFBO() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, _msfboID); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _fboID); - gl.getGL2GL3().glBlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, GL.GL_COLOR_BUFFER_BIT - | GL.GL_DEPTH_BUFFER_BIT, GL.GL_NEAREST); + gl.getGL2GL3().glBlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, + GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT, GL.GL_NEAREST); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); @@ -377,7 +372,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { * an id to use for log messages, particularly if there are any issues. */ public static void checkFBOComplete(final int fboID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); switch (status) { @@ -414,7 +409,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); JoglTextureStateUtil.doTextureBind(tex, 0, true); @@ -430,7 +425,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void clearBuffers(final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glDisable(GL.GL_SCISSOR_TEST); _parentRenderer.clearBuffers(clear); @@ -438,7 +433,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void activate() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // Lazy init if (_fboID == 0) { @@ -488,7 +483,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { // set up renderbuffer properties gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, _mscolorRBID); - gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, GL.GL_RGBA, _width, _height); + gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, GL.GL_RGBA, _width, + _height); gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, _msdepthRBID); gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, format, _width, _height); @@ -496,10 +492,10 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, 0); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, _msfboID); - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, - GL.GL_RENDERBUFFER, _mscolorRBID); - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_RENDERBUFFER, _msdepthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, + _mscolorRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, + _msdepthRBID); // check for errors checkFBOComplete(_msfboID); @@ -536,7 +532,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void deactivate() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_active == 1) { final ReadOnlyColorRGBA bgColor = _parentRenderer.getBackgroundColor(); @@ -552,7 +548,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } public void cleanup() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_fboID != 0) { final IntBuffer id = BufferUtils.createIntBuffer(1); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java index b2d433c..a93e0cf 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java @@ -1,49 +1,49 @@ -/**
- * Copyright (c) 2008-2010 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.renderer.jogl;
-
-import java.util.logging.Logger;
-
-import com.ardor3d.framework.DisplaySettings;
-import com.ardor3d.renderer.ContextCapabilities;
-import com.ardor3d.renderer.Renderer;
-import com.ardor3d.renderer.TextureRenderer;
-import com.ardor3d.renderer.TextureRendererProvider;
-
-public class JoglTextureRendererProvider implements TextureRendererProvider {
-
- private static final Logger logger = Logger.getLogger(JoglTextureRendererProvider.class.getName());
-
- public TextureRenderer createTextureRenderer(final int width, final int height, final Renderer renderer,
- final ContextCapabilities caps) {
- return createTextureRenderer(width, height, 0, 0, renderer, caps);
- }
-
- public TextureRenderer createTextureRenderer(final int width, final int height, final int depthBits,
- final int samples, final Renderer renderer, final ContextCapabilities caps) {
- return createTextureRenderer(new DisplaySettings(width, height, depthBits, samples), false, renderer, caps);
- }
-
- public TextureRenderer createTextureRenderer(final DisplaySettings settings, final boolean forcePbuffer,
- final Renderer renderer, final ContextCapabilities caps) {
- if (!forcePbuffer && caps.isFBOSupported()) {
- return new JoglTextureRenderer(settings.getWidth(), settings.getHeight(), settings.getDepthBits(), settings
- .getSamples(), renderer, caps);
- } else if (caps.isPbufferSupported()) {
- return new JoglPbufferTextureRenderer(settings, renderer, caps);
- } else {
- logger.severe("No texture renderer support (FBO or Pbuffer).");
- return null;
- }
-
- }
-
-}
+/** + * Copyright (c) 2008-2010 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.renderer.jogl; + +import java.util.logging.Logger; + +import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.renderer.ContextCapabilities; +import com.ardor3d.renderer.Renderer; +import com.ardor3d.renderer.TextureRenderer; +import com.ardor3d.renderer.TextureRendererProvider; + +public class JoglTextureRendererProvider implements TextureRendererProvider { + + private static final Logger logger = Logger.getLogger(JoglTextureRendererProvider.class.getName()); + + public TextureRenderer createTextureRenderer(final int width, final int height, final Renderer renderer, + final ContextCapabilities caps) { + return createTextureRenderer(width, height, 0, 0, renderer, caps); + } + + public TextureRenderer createTextureRenderer(final int width, final int height, final int depthBits, + final int samples, final Renderer renderer, final ContextCapabilities caps) { + return createTextureRenderer(new DisplaySettings(width, height, depthBits, samples), false, renderer, caps); + } + + public TextureRenderer createTextureRenderer(final DisplaySettings settings, final boolean forcePbuffer, + final Renderer renderer, final ContextCapabilities caps) { + if (!forcePbuffer && caps.isFBOSupported()) { + return new JoglTextureRenderer(settings.getWidth(), settings.getHeight(), settings.getDepthBits(), settings + .getSamples(), renderer, caps); + } else if (caps.isPbufferSupported()) { + return new JoglPbufferTextureRenderer(settings, renderer, caps); + } else { + logger.severe("No texture renderer support (FBO or Pbuffer)."); + return null; + } + + } + +} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java index 39f0221..bde9535 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java @@ -14,7 +14,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; @@ -37,7 +37,7 @@ public abstract class JoglBlendStateUtil { final ContextCapabilities caps = context.getCapabilities(); context.setCurrentState(StateType.Blend, state); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state.isEnabled()) { applyBlendEquations(gl, state.isBlendEnabled(), state, record, caps); @@ -128,7 +128,8 @@ public abstract class JoglBlendStateUtil { if (applyConstant && caps.isConstantBlendColorSupported()) { final ReadOnlyColorRGBA constant = state.getConstantColor(); if (!record.isValid() || (caps.isConstantBlendColorSupported() && !record.blendColor.equals(constant))) { - gl.getGL2GL3().glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), constant.getAlpha()); + gl.getGL2GL3().glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), + constant.getAlpha()); record.blendColor.set(constant); } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java index df673aa..a64cf95 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java @@ -12,7 +12,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -50,7 +50,7 @@ public abstract class JoglClipStateUtil { private static void enableClipPlane(final int planeIndex, final boolean enable, final ClipState state, final ClipStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enable) { if (!record.isValid() || !record.planeEnabled[planeIndex]) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java index a0316e0..ca685a8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java @@ -11,7 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -23,7 +23,7 @@ import com.ardor3d.renderer.state.record.ColorMaskStateRecord; public abstract class JoglColorMaskStateUtil { public static void apply(final JoglRenderer renderer, final ColorMaskState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java index d93eb33..a2f3fd8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java @@ -11,7 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -62,7 +62,7 @@ public abstract class JoglCullStateUtil { } private static void setCullEnabled(final boolean enable, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.enabled != enable) { if (enable) { @@ -75,7 +75,7 @@ public abstract class JoglCullStateUtil { } private static void setCull(final int face, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.face != face) { gl.glCullFace(face); @@ -85,7 +85,7 @@ public abstract class JoglCullStateUtil { private static void setGLPolygonWind(final PolygonWind windOrder, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.windOrder != windOrder) { switch (windOrder) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java index 19b1b0f..a36649a 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java @@ -13,7 +13,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; @@ -30,7 +30,7 @@ import com.ardor3d.renderer.state.record.FogStateRecord; public abstract class JoglFogStateUtil { public static void apply(final JoglRenderer renderer, final FogState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -78,7 +78,7 @@ public abstract class JoglFogStateUtil { } private static void enableFog(final boolean enable, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { @@ -99,13 +99,13 @@ public abstract class JoglFogStateUtil { } private static void applyFogColor(final ReadOnlyColorRGBA color, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !color.equals(record.fogColor)) { record.fogColor.set(color); record.colorBuff.clear(); - record.colorBuff.put(record.fogColor.getRed()).put(record.fogColor.getGreen()).put( - record.fogColor.getBlue()).put(record.fogColor.getAlpha()); + record.colorBuff.put(record.fogColor.getRed()).put(record.fogColor.getGreen()) + .put(record.fogColor.getBlue()).put(record.fogColor.getAlpha()); record.colorBuff.flip(); gl.getGL2ES1().glFogfv(GL2ES1.GL_FOG_COLOR, record.colorBuff); } @@ -113,7 +113,7 @@ public abstract class JoglFogStateUtil { private static void applyFogSource(final CoordinateSource source, final FogStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isFogCoordinatesSupported()) { if (!record.isValid() || !source.equals(record.source)) { @@ -127,7 +127,7 @@ public abstract class JoglFogStateUtil { } private static void applyFogMode(final DensityFunction densityFunction, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int glMode = 0; switch (densityFunction) { @@ -149,7 +149,7 @@ public abstract class JoglFogStateUtil { } private static void applyFogHint(final Quality quality, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int glHint = 0; switch (quality) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java index 5b8d068..f71e4f5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java @@ -16,7 +16,7 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -35,7 +35,7 @@ public final class JoglFragmentProgramStateUtil { * message. */ private static void checkProgramError() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position @@ -48,7 +48,7 @@ public final class JoglFragmentProgramStateUtil { } private static int create(final ByteBuffer program) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer buf = BufferUtils.createIntBuffer(1); @@ -58,8 +58,8 @@ public final class JoglFragmentProgramStateUtil { final byte array[] = new byte[program.limit()]; program.rewind(); program.get(array); - gl.getGL2().glProgramStringARB(GL2.GL_FRAGMENT_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, new String( - array)); // TODO Check cost of using non-buffer + gl.getGL2().glProgramStringARB(GL2.GL_FRAGMENT_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, + new String(array)); // TODO Check cost of using non-buffer checkProgramError(); @@ -67,7 +67,7 @@ public final class JoglFragmentProgramStateUtil { } public static void apply(final JoglRenderer renderer, final FragmentProgramState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -106,8 +106,8 @@ public final class JoglFragmentProgramStateUtil { for (int i = 0; i < state._getParameters().length; i++) { if (state._getParameters()[i] != null) { gl.getGL2().glProgramLocalParameter4fARB(GL2.GL_FRAGMENT_PROGRAM_ARB, i, - state._getParameters()[i][0], state._getParameters()[i][1], state - ._getParameters()[i][2], state._getParameters()[i][3]); + state._getParameters()[i][0], state._getParameters()[i][1], + state._getParameters()[i][2], state._getParameters()[i][3]); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java index 3050d67..489fdd4 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java @@ -13,8 +13,8 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.light.DirectionalLight; import com.ardor3d.light.Light; @@ -163,7 +163,7 @@ public abstract class JoglLightStateUtil { private static void setSingleLightEnabled(final boolean enable, final int index, final LightStateRecord record, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.isEnabled() != enable) { if (enable) { @@ -177,7 +177,7 @@ public abstract class JoglLightStateUtil { } private static void setLightEnabled(final boolean enable, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isEnabled() != enable) { if (enable) { @@ -190,7 +190,7 @@ public abstract class JoglLightStateUtil { } private static void setTwoSided(final boolean twoSided, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isTwoSidedOn() != twoSided) { if (twoSided) { @@ -203,7 +203,7 @@ public abstract class JoglLightStateUtil { } private static void setLocalViewer(final boolean localViewer, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isLocalViewer() != localViewer) { if (localViewer) { @@ -216,7 +216,7 @@ public abstract class JoglLightStateUtil { } private static void setSpecularControl(final boolean separateSpecularOn, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isSeparateSpecular() != separateSpecularOn) { if (separateSpecularOn) { @@ -229,7 +229,7 @@ public abstract class JoglLightStateUtil { } private static void setModelAmbient(final LightStateRecord record, final ReadOnlyColorRGBA globalAmbient) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !record.globalAmbient.equals(globalAmbient)) { record.lightBuffer.clear(); @@ -245,7 +245,7 @@ public abstract class JoglLightStateUtil { private static void setAmbient(final int index, final LightStateRecord record, final ReadOnlyColorRGBA ambient, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.ambient.equals(ambient)) { record.lightBuffer.clear(); @@ -254,14 +254,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO + // Check + // for + // float lr.ambient.set(ambient); } } private static void setDiffuse(final int index, final LightStateRecord record, final ReadOnlyColorRGBA diffuse, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.diffuse.equals(diffuse)) { record.lightBuffer.clear(); @@ -270,14 +273,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(diffuse.getBlue()); record.lightBuffer.put(diffuse.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO + // Check + // for + // float lr.diffuse.set(diffuse); } } private static void setSpecular(final int index, final LightStateRecord record, final ReadOnlyColorRGBA specular, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.specular.equals(specular)) { record.lightBuffer.clear(); @@ -286,14 +292,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(specular.getBlue()); record.lightBuffer.put(specular.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO + // Check + // for + // float lr.specular.set(specular); } } private static void setPosition(final int index, final LightStateRecord record, final float positionX, final float positionY, final float positionZ, final float positionW, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // From OpenGL Docs: // The light position is transformed by the contents of the current top @@ -321,15 +330,15 @@ public abstract class JoglLightStateUtil { gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_POSITION, record.lightBuffer); lr.position.set(positionX, positionY, positionZ, positionW); - if (!Camera.getCurrentCamera().isFrameDirty()) { - lr.modelViewMatrix.set(modelViewMatrix); - } + if (!Camera.getCurrentCamera().isFrameDirty()) { + lr.modelViewMatrix.set(modelViewMatrix); + } } } private static void setSpotDirection(final int index, final LightStateRecord record, final float directionX, final float directionY, final float directionZ, final float value) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // From OpenGL Docs: // The light position is transformed by the contents of the current top @@ -346,11 +355,14 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(directionZ); record.lightBuffer.put(value); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, record.lightBuffer); // TODO + // Check + // for + // float } private static void setConstant(final int index, final float constant, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || constant != lr.getConstant()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_CONSTANT_ATTENUATION, constant); @@ -359,7 +371,7 @@ public abstract class JoglLightStateUtil { } private static void setLinear(final int index, final float linear, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || linear != lr.getLinear()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_LINEAR_ATTENUATION, linear); @@ -368,7 +380,7 @@ public abstract class JoglLightStateUtil { } private static void setQuadratic(final int index, final float quad, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || quad != lr.getQuadratic()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_QUADRATIC_ATTENUATION, quad); @@ -392,7 +404,7 @@ public abstract class JoglLightStateUtil { private static void setSpotExponent(final int index, final LightStateRecord record, final float exponent, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotExponent() != exponent) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_EXPONENT, exponent); @@ -402,7 +414,7 @@ public abstract class JoglLightStateUtil { private static void setSpotCutoff(final int index, final LightStateRecord record, final float cutoff, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotCutoff() != cutoff) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_CUTOFF, cutoff); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java index 4a20143..9fc3490 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java @@ -11,8 +11,8 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextManager; @@ -63,7 +63,7 @@ public abstract class JoglMaterialStateUtil { private static void applyColor(final ColorMaterial glMatColor, final ReadOnlyColorRGBA frontColor, final ReadOnlyColorRGBA backColor, final MaterialStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int glMat = getGLColorMaterial(glMatColor); if (frontColor.equals(backColor)) { @@ -120,11 +120,11 @@ public abstract class JoglMaterialStateUtil { case Emissive: return record.colorMaterial == ColorMaterial.Emissive; case AmbientAndDiffuse: - break; + break; case None: - break; + break; default: - break; + break; } return false; } @@ -132,7 +132,7 @@ public abstract class JoglMaterialStateUtil { private static void applyColorMaterial(final ColorMaterial colorMaterial, final MaterialFace face, final MaterialStateRecord record) { if (!record.isValid() || face != record.colorMaterialFace || colorMaterial != record.colorMaterial) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (colorMaterial == ColorMaterial.None) { gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); @@ -151,22 +151,25 @@ public abstract class JoglMaterialStateUtil { private static void applyShininess(final float frontShininess, final float backShininess, final MaterialStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (frontShininess == backShininess) { // consolidate to one call if (!record.isValid() || frontShininess != record.frontShininess || record.backShininess != backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, frontShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, + frontShininess); record.backShininess = record.frontShininess = frontShininess; } } else { if (!record.isValid() || frontShininess != record.frontShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, frontShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, + frontShininess); record.frontShininess = frontShininess; } if (!record.isValid() || backShininess != record.backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, backShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, + backShininess); record.backShininess = backShininess; } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java index b2cd05a..ec48484 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java @@ -12,7 +12,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -55,7 +55,7 @@ public abstract class JoglOffsetStateUtil { private static void setOffsetEnabled(final OffsetType type, final boolean typeEnabled, final OffsetStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int glType = getGLType(type); if (!record.isValid() || typeEnabled != record.enabledOffsets.contains(type)) { @@ -68,7 +68,7 @@ public abstract class JoglOffsetStateUtil { } private static void setOffset(final float factor, final float units, final OffsetStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.factor != factor || record.units != units) { gl.glPolygonOffset(factor, units); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java index f254b29..bb5fa05 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java @@ -19,8 +19,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL3; -import javax.media.opengl.GL4; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -38,7 +37,7 @@ public abstract class JoglShaderObjectsStateUtil { private static final Logger logger = Logger.getLogger(JoglShaderObjectsStateUtil.class.getName()); protected static void sendToGL(final GLSLShaderObjectsState state, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state.getVertexShader() == null && state.getFragmentShader() == null) { logger.warning("Could not find shader resources!" + "(both inputbuffers are null)"); @@ -122,7 +121,8 @@ public abstract class JoglShaderObjectsStateUtil { // Compile the geometry shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._geometryShaderID); - gl.getGL2().glGetObjectParameterivARB(state._geometryShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + gl.getGL2().glGetObjectParameterivARB(state._geometryShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, + compiled); checkProgramError(compiled, state._geometryShaderID, state._geometryShaderName); // Attach the program @@ -132,7 +132,7 @@ public abstract class JoglShaderObjectsStateUtil { state._geometryShaderID = -1; } } - + if (caps.isTessellationShadersSupported()) { if (state.getTessellationControlShader() != null) { if (state._tessellationControlShaderID != -1) { @@ -145,19 +145,20 @@ public abstract class JoglShaderObjectsStateUtil { final byte array[] = new byte[state.getTessellationControlShader().limit()]; state.getTessellationControlShader().rewind(); state.getTessellationControlShader().get(array); - gl.getGL2().glShaderSourceARB(state._tessellationControlShaderID, 1, new String[] { new String(array) }, - new int[] { array.length }, 0); + gl.getGL2().glShaderSourceARB(state._tessellationControlShaderID, 1, + new String[] { new String(array) }, new int[] { array.length }, 0); // Compile the tessellation control shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._tessellationControlShaderID); - gl.getGL2().glGetObjectParameterivARB(state._tessellationControlShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + gl.getGL2().glGetObjectParameterivARB(state._tessellationControlShaderID, + GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); checkProgramError(compiled, state._tessellationControlShaderID, state._tessellationControlShaderName); // Attach the program gl.getGL2().glAttachObjectARB(state._programID, state._tessellationControlShaderID); } else if (state._tessellationControlShaderID != -1) { - removeTessControlShader(state); + removeTessControlShader(state); state._tessellationControlShaderID = -1; } if (state.getTessellationEvaluationShader() != null) { @@ -165,25 +166,27 @@ public abstract class JoglShaderObjectsStateUtil { removeTessEvalShader(state); } - state._tessellationEvaluationShaderID = gl.getGL2().glCreateShaderObjectARB(GL4.GL_TESS_CONTROL_SHADER); + state._tessellationEvaluationShaderID = gl.getGL2().glCreateShaderObjectARB(GL3.GL_TESS_CONTROL_SHADER); // Create the sources final byte array[] = new byte[state.getTessellationEvaluationShader().limit()]; state.getTessellationEvaluationShader().rewind(); state.getTessellationEvaluationShader().get(array); - gl.getGL2().glShaderSourceARB(state._tessellationEvaluationShaderID, 1, new String[] { new String(array) }, - new int[] { array.length }, 0); + gl.getGL2().glShaderSourceARB(state._tessellationEvaluationShaderID, 1, + new String[] { new String(array) }, new int[] { array.length }, 0); // Compile the tessellation control shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._tessellationEvaluationShaderID); - gl.getGL2().glGetObjectParameterivARB(state._tessellationEvaluationShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); - checkProgramError(compiled, state._tessellationEvaluationShaderID, state._tessellationEvaluationShaderName); + gl.getGL2().glGetObjectParameterivARB(state._tessellationEvaluationShaderID, + GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + checkProgramError(compiled, state._tessellationEvaluationShaderID, + state._tessellationEvaluationShaderName); // Attach the program gl.getGL2().glAttachObjectARB(state._programID, state._tessellationEvaluationShaderID); } else if (state._tessellationEvaluationShaderID != -1) { - removeTessEvalShader(state); + removeTessEvalShader(state); state._tessellationEvaluationShaderID = -1; } } @@ -195,7 +198,7 @@ public abstract class JoglShaderObjectsStateUtil { } private static void checkLinkError(final int programId) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glGetObjectParameterivARB(programId, GL2ES2.GL_LINK_STATUS, compiled); @@ -221,7 +224,7 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the fragment shader */ private static void removeFragShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._fragmentShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._fragmentShaderID); @@ -231,7 +234,7 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the vertex shader */ private static void removeVertShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._vertexShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._vertexShaderID); @@ -241,27 +244,27 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the geometry shader */ private static void removeGeomShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._geometryShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._geometryShaderID); gl.getGL2().glDeleteObjectARB(state._geometryShaderID); } } - + /** Removes the tessellation control shader */ private static void removeTessControlShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._tessellationControlShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._tessellationControlShaderID); gl.getGL2().glDeleteObjectARB(state._tessellationControlShaderID); } } - + /** Removes the tessellation evaluation shader */ private static void removeTessEvalShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._tessellationEvaluationShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._tessellationEvaluationShaderID); @@ -278,7 +281,7 @@ public abstract class JoglShaderObjectsStateUtil { * shader's id */ private static void checkProgramError(final IntBuffer compiled, final int id, final String shaderName) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (compiled.get(0) == GL.GL_FALSE) { final IntBuffer iVal = BufferUtils.createIntBuffer(1); @@ -298,13 +301,13 @@ public abstract class JoglShaderObjectsStateUtil { logger.severe(out); - final String nameString = shaderName.equals("") ? "" : " [ " + shaderName + " ]"; + final String nameString = shaderName.equals("") ? "" : " [ " + shaderName + " ]"; throw new Ardor3dException("Error compiling GLSL shader " + nameString + ": " + out); } } public static void apply(final JoglRenderer renderer, final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java index ba3dea0..426befb 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java @@ -11,21 +11,21 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.ShadingState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.ShadingState; import com.ardor3d.renderer.state.ShadingState.ShadingMode; import com.ardor3d.renderer.state.record.ShadingStateRecord; public abstract class JoglShadingStateUtil { public static void apply(final JoglRenderer renderer, final ShadingState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java index fd7204f..d624b60 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java @@ -12,14 +12,14 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.StencilState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.StencilState; import com.ardor3d.renderer.state.StencilState.StencilFunction; import com.ardor3d.renderer.state.StencilState.StencilOperation; import com.ardor3d.renderer.state.record.StencilStateRecord; @@ -27,7 +27,7 @@ import com.ardor3d.renderer.state.record.StencilStateRecord; public abstract class JoglStencilStateUtil { public static void apply(final JoglRenderer renderer, final StencilState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -40,25 +40,26 @@ public abstract class JoglStencilStateUtil { if (state.isUseTwoSided() && caps.isTwoSidedStencilSupported()) { gl.getGL2().glActiveStencilFaceEXT(GL.GL_BACK); applyMask(state.getStencilWriteMaskBack(), record, 2); - applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(), state - .getStencilFuncMaskBack(), record, 2); - applyOp(getGLStencilOp(state.getStencilOpFailBack(), caps), getGLStencilOp(state - .getStencilOpZFailBack(), caps), getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2); + applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(), + state.getStencilFuncMaskBack(), record, 2); + applyOp(getGLStencilOp(state.getStencilOpFailBack(), caps), + getGLStencilOp(state.getStencilOpZFailBack(), caps), + getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2); gl.getGL2().glActiveStencilFaceEXT(GL.GL_FRONT); applyMask(state.getStencilWriteMaskFront(), record, 1); applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(), state.getStencilFuncMaskFront(), record, 1); - applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), getGLStencilOp(state - .getStencilOpZFailFront(), caps), getGLStencilOp(state.getStencilOpZPassFront(), caps), record, - 1); + applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), + getGLStencilOp(state.getStencilOpZFailFront(), caps), + getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 1); } else { applyMask(state.getStencilWriteMaskFront(), record, 0); applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(), state.getStencilFuncMaskFront(), record, 0); - applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), getGLStencilOp(state - .getStencilOpZFailFront(), caps), getGLStencilOp(state.getStencilOpZPassFront(), caps), record, - 0); + applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), + getGLStencilOp(state.getStencilOpZFailFront(), caps), + getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 0); } } @@ -119,7 +120,7 @@ public abstract class JoglStencilStateUtil { private static void setEnabled(final boolean enable, final boolean twoSided, final StencilStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { @@ -141,7 +142,7 @@ public abstract class JoglStencilStateUtil { private static void setTwoSidedEnabled(final boolean enable, final StencilStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isTwoSidedStencilSupported()) { if (record.isValid()) { @@ -162,7 +163,7 @@ public abstract class JoglStencilStateUtil { } private static void applyMask(final int writeMask, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || writeMask != record.writeMask[face]) { gl.glStencilMask(writeMask); @@ -172,7 +173,7 @@ public abstract class JoglStencilStateUtil { private static void applyFunc(final int glfunc, final int stencilRef, final int funcMask, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || glfunc != record.func[face] || stencilRef != record.ref[face] // || funcMask != record.funcMask[face]) { @@ -185,7 +186,7 @@ public abstract class JoglStencilStateUtil { private static void applyOp(final int fail, final int zfail, final int zpass, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || fail != record.fail[face] || zfail != record.zfail[face] // || zpass != record.zpass[face]) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java index e98ced2..0cb091c 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java @@ -20,6 +20,7 @@ import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; import javax.media.opengl.glu.GLU; @@ -27,10 +28,6 @@ import javax.media.opengl.glu.gl2.GLUgl2; import com.ardor3d.image.Image; import com.ardor3d.image.Texture; -import com.ardor3d.image.Texture1D; -import com.ardor3d.image.Texture2D; -import com.ardor3d.image.Texture3D; -import com.ardor3d.image.TextureCubeMap; import com.ardor3d.image.Texture.ApplyMode; import com.ardor3d.image.Texture.CombinerFunctionAlpha; import com.ardor3d.image.Texture.CombinerFunctionRGB; @@ -40,6 +37,10 @@ import com.ardor3d.image.Texture.CombinerSource; import com.ardor3d.image.Texture.Type; import com.ardor3d.image.Texture.WrapAxis; import com.ardor3d.image.Texture.WrapMode; +import com.ardor3d.image.Texture1D; +import com.ardor3d.image.Texture2D; +import com.ardor3d.image.Texture3D; +import com.ardor3d.image.TextureCubeMap; import com.ardor3d.image.util.ImageUtils; import com.ardor3d.math.MathUtils; import com.ardor3d.math.type.ReadOnlyColorRGBA; @@ -47,8 +48,8 @@ import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.record.RendererRecord; import com.ardor3d.renderer.state.record.TextureRecord; import com.ardor3d.renderer.state.record.TextureStateRecord; @@ -70,7 +71,7 @@ public class JoglTextureStateUtil { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); if (context == null) { logger.warning("RenderContext is null for texture: " + texture); @@ -126,7 +127,7 @@ public class JoglTextureStateUtil { // our texture type: final Texture.Type type = texture.getType(); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final GLU glu = new GLUgl2(); // bind our texture id to this unit. @@ -160,9 +161,8 @@ public class JoglTextureStateUtil { + image.getWidth() + " x " + image.getHeight()); } if (actualWidth > maxSize || actualHeight > maxSize) { - logger - .warning("(card unsupported) Attempted to apply texture with size bigger than max texture size [" - + maxSize + "]: " + image.getWidth() + " x " + image.getHeight()); + logger.warning("(card unsupported) Attempted to apply texture with size bigger than max texture size [" + + maxSize + "]: " + image.getWidth() + " x " + image.getHeight()); } int w = actualWidth; @@ -211,19 +211,20 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(0).rewind(); // send top level to card - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(0)); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), + image.getHeight(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); break; case OneDimensional: // ensure the buffer is ready for reading image.getData(0).rewind(); // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), + hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); break; case ThreeDimensional: if (caps.isTexture3DSupported()) { @@ -250,9 +251,10 @@ public class JoglTextureStateUtil { data.flip(); } // send top level to card - gl.getGL2GL3().glTexImage3D(GL2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), image.getDepth(), - hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { logger.warning("This card does not support Texture3D."); @@ -266,19 +268,21 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send top level to card - gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getWidth(), hasBorder ? 1 - : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(face.ordinal())); + gl.glTexImage2D(getGLCubeMapFace(face), 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { logger.warning("This card does not support Cubemaps."); } break; case Rectangle: - break; + break; default: - break; + break; } } else if (texture.getMinificationFilter().usesMipMapLevels() && !image.hasMipmaps() && !texture.getTextureStoreFormat().isCompressed()) { @@ -299,16 +303,18 @@ public class JoglTextureStateUtil { image.getData(0).rewind(); if (caps.isAutomaticMipmapsSupported()) { // send top level to card - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(0)); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } else { // send to card - glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } break; case OneDimensional: @@ -316,15 +322,15 @@ public class JoglTextureStateUtil { image.getData(0).rewind(); if (caps.isAutomaticMipmapsSupported()) { // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } else { // Note: JOGL's GLU class does not support // gluBuild1DMipmaps. - logger - .warning("non-fbo 1d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); + logger.warning("non-fbo 1d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); return; } break; @@ -354,16 +360,15 @@ public class JoglTextureStateUtil { data.flip(); } // send top level to card - gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), image - .getDepth(), hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image - .getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), - data); + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { // Note: JOGL's GLU class does not support // gluBuild3DMipmaps. - logger - .warning("non-fbo 3d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); + logger.warning("non-fbo 3d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); return; } } else { @@ -380,22 +385,24 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send top level to card - gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), - image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image - .getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(face.ordinal())); + gl.glTexImage2D(getGLCubeMapFace(face), 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { for (final TextureCubeMap.Face face : TextureCubeMap.Face.values()) { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send to card - glu.gluBuild2DMipmaps(getGLCubeMapFace(face), JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), - image.getWidth(), JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(face - .ordinal())); + glu.gluBuild2DMipmaps(getGLCubeMapFace(face), + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } } else { @@ -404,9 +411,9 @@ public class JoglTextureStateUtil { } break; case Rectangle: - break; + break; default: - break; + break; } if (texture.getTextureMaxLevel() >= 0) { @@ -432,7 +439,7 @@ public class JoglTextureStateUtil { } // set max mip level - gl.glTexParameteri(getGLCubeMapFace(face), GL2.GL_TEXTURE_MAX_LEVEL, max - 1); + gl.glTexParameteri(getGLCubeMapFace(face), GL2GL3.GL_TEXTURE_MAX_LEVEL, max - 1); for (int m = 0; m < max; m++) { final int width = Math.max(1, image.getWidth() >> m); @@ -442,13 +449,14 @@ public class JoglTextureStateUtil { data.limit(pos + mipSizes[m]); if (texture.getTextureStoreFormat().isCompressed()) { - gl.glCompressedTexImage2D(getGLCubeMapFace(face), m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, mipSizes[m], data); + gl.glCompressedTexImage2D(getGLCubeMapFace(face), m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.glTexImage2D(getGLCubeMapFace(face), m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + gl.glTexImage2D(getGLCubeMapFace(face), m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } pos += mipSizes[m]; @@ -480,12 +488,12 @@ public class JoglTextureStateUtil { case OneDimensional: gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL2GL3.GL_TEXTURE_MAX_LEVEL, max - 1); break; - case CubeMap: - break; - case Rectangle: - break; - default: - break; + case CubeMap: + break; + case Rectangle: + break; + default: + break; } if (type == Type.ThreeDimensional) { @@ -527,48 +535,51 @@ public class JoglTextureStateUtil { switch (type) { case TwoDimensional: if (texture.getTextureStoreFormat().isCompressed()) { - gl.glCompressedTexImage2D(GL.GL_TEXTURE_2D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, mipSizes[m], data); + gl.glCompressedTexImage2D(GL.GL_TEXTURE_2D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.glTexImage2D(GL.GL_TEXTURE_2D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, height, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.glTexImage2D(GL.GL_TEXTURE_2D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case OneDimensional: if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, hasBorder ? 1 - : 0, mipSizes[m], data); + gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case ThreeDimensional: final int depth = Math.max(1, image.getDepth() >> m); // already checked for support above... if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2GL3().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - depth, hasBorder ? 1 : 0, mipSizes[m], data); + gl.getGL2GL3().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, height, depth, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case CubeMap: - break; + break; case Rectangle: - break; + break; default: - break; + break; } pos += mipSizes[m]; @@ -582,7 +593,7 @@ public class JoglTextureStateUtil { } public static void apply(final JoglRenderer renderer, final TextureState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -769,7 +780,7 @@ public class JoglTextureStateUtil { private static void disableTexturing(final TextureUnitRecord unitRecord, final TextureStateRecord record, final int unit, final Type exceptedType, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (exceptedType != Type.TwoDimensional) { if (!unitRecord.isValid() || unitRecord.enabled[Type.TwoDimensional.ordinal()]) { @@ -811,7 +822,7 @@ public class JoglTextureStateUtil { private static void disableTexturing(final TextureUnitRecord unitRecord, final TextureStateRecord record, final int unit, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid() || unitRecord.enabled[Type.TwoDimensional.ordinal()]) { // Check we are in the right unit @@ -849,7 +860,7 @@ public class JoglTextureStateUtil { public static void applyCombineFactors(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // check that this is a valid fixed function unit. glTexEnv is only // supported for unit < GL_MAX_TEXTURE_UNITS @@ -877,7 +888,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, texture.getCombineScaleRGB().floatValue()); + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, + texture.getCombineScaleRGB().floatValue()); unitRecord.envRGBScale = texture.getCombineScaleRGB(); } // Then Alpha Combine scale if (!unitRecord.isValid() || unitRecord.envAlphaScale != texture.getCombineScaleAlpha()) { @@ -885,7 +897,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, texture.getCombineScaleAlpha().floatValue()); + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, + texture.getCombineScaleAlpha().floatValue()); unitRecord.envAlphaScale = texture.getCombineScaleAlpha(); } @@ -896,7 +909,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, + JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); unitRecord.rgbCombineFunc = rgbCombineFunc; } @@ -906,7 +920,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB0 = combSrcRGB; } @@ -916,7 +931,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB0 = combOpRGB; } @@ -929,7 +945,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB1 = combSrcRGB; } @@ -939,7 +956,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB1 = combOpRGB; } @@ -952,7 +970,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB2 = combSrcRGB; } @@ -962,7 +981,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB2 = combOpRGB; } @@ -976,8 +996,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, JoglTextureUtil - .getGLCombineFuncAlpha(alphaCombineFunc)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, + JoglTextureUtil.getGLCombineFuncAlpha(alphaCombineFunc)); unitRecord.alphaCombineFunc = alphaCombineFunc; } @@ -987,7 +1007,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha0 = combSrcAlpha; } @@ -997,7 +1018,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha0 = combOpAlpha; } @@ -1010,7 +1032,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha1 = combSrcAlpha; } @@ -1020,7 +1043,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha1 = combOpAlpha; } @@ -1033,7 +1057,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha2 = combSrcAlpha; } @@ -1043,8 +1068,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, JoglTextureUtil - .getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha2 = combOpAlpha; } } @@ -1053,25 +1078,26 @@ public class JoglTextureStateUtil { public static void applyEnvMode(final ApplyMode mode, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid() || unitRecord.envMode != mode) { checkAndSetUnit(unit, record, caps); - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, JoglTextureUtil.getGLEnvMode(mode)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, + JoglTextureUtil.getGLEnvMode(mode)); unitRecord.envMode = mode; } } public static void applyBlendColor(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBlend = texture.getConstantColor(); if (!unitRecord.isValid() || !unitRecord.blendColor.equals(texBlend)) { checkAndSetUnit(unit, record, caps); TextureRecord.colorBuffer.clear(); - TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()).put( - texBlend.getAlpha()); + TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()) + .put(texBlend.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.getGL2ES1().glTexEnvfv(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); unitRecord.blendColor.set(texBlend); @@ -1080,7 +1106,7 @@ public class JoglTextureStateUtil { public static void applyLodBias(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isTextureLodBiasSupported()) { final float bias = texture.getLodBias() < caps.getMaxLodBias() ? texture.getLodBias() : caps @@ -1095,13 +1121,13 @@ public class JoglTextureStateUtil { public static void applyBorderColor(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBorder = texture.getBorderColor(); if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); - TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()).put( - texBorder.getAlpha()); + TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) + .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.glTexParameterfv(getGLType(texture.getType()), GL2GL3.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); texRecord.borderColor.set(texBorder); @@ -1110,7 +1136,7 @@ public class JoglTextureStateUtil { public static void applyTextureTransforms(final Texture texture, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final boolean needsReset = !record.units[unit].identityMatrix; @@ -1141,7 +1167,7 @@ public class JoglTextureStateUtil { public static void applyTexCoordGeneration(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (texture.getEnvironmentalMapMode()) { case None: @@ -1234,13 +1260,13 @@ public class JoglTextureStateUtil { gl.getGL2ES1().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenSMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenTMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenRMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenQMode = GL2.GL_OBJECT_LINEAR; } @@ -1261,7 +1287,7 @@ public class JoglTextureStateUtil { private static void setTextureGen(final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps, final boolean genS, final boolean genT, final boolean genR, final boolean genQ) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid()) { checkAndSetUnit(unit, record, caps); @@ -1329,7 +1355,7 @@ public class JoglTextureStateUtil { // If we support multitexturing, specify the unit we are affecting. public static void checkAndSetUnit(final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // No need to worry about valid record, since invalidate sets record's // currentUnit to -1. @@ -1354,7 +1380,7 @@ public class JoglTextureStateUtil { */ public static void applyShadow(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Type type = texture.getType(); @@ -1398,7 +1424,7 @@ public class JoglTextureStateUtil { */ public static void applyFilter(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Type type = texture.getType(); @@ -1441,7 +1467,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture3D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!caps.isTexture3DSupported()) { return; @@ -1480,7 +1506,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture1D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); @@ -1524,7 +1550,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture2D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); @@ -1553,7 +1579,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final TextureCubeMap cubeMap, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!caps.isTextureCubeMapSupported()) { return; @@ -1581,7 +1607,7 @@ public class JoglTextureStateUtil { } public static void deleteTexture(final Texture texture) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1603,7 +1629,7 @@ public class JoglTextureStateUtil { } public static void deleteTextureIds(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1627,7 +1653,7 @@ public class JoglTextureStateUtil { * Useful for external jogl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1660,9 +1686,9 @@ public class JoglTextureStateUtil { case CubeMap: return GL.GL_TEXTURE_CUBE_MAP; case Rectangle: - break; + break; default: - break; + break; } throw new IllegalArgumentException("invalid texture type: " + type); } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java index 50258b8..3cf3149 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java @@ -16,14 +16,14 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.VertexProgramState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.VertexProgramState; import com.ardor3d.renderer.state.record.VertexProgramStateRecord; import com.ardor3d.util.geom.BufferUtils; @@ -35,7 +35,7 @@ public abstract class JoglVertexProgramStateUtil { * message. */ private static void checkProgramError() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position @@ -48,7 +48,7 @@ public abstract class JoglVertexProgramStateUtil { } private static int create(final ByteBuffer program) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer buf = BufferUtils.createIntBuffer(1); @@ -58,9 +58,8 @@ public abstract class JoglVertexProgramStateUtil { final byte array[] = new byte[program.limit()]; program.rewind(); program.get(array); - gl.getGL2() - .glProgramStringARB(GL2.GL_VERTEX_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, new String( - array)); + gl.getGL2().glProgramStringARB(GL2.GL_VERTEX_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, + new String(array)); checkProgramError(); @@ -68,7 +67,7 @@ public abstract class JoglVertexProgramStateUtil { } public static void apply(final JoglRenderer renderer, final VertexProgramState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -97,10 +96,11 @@ public abstract class JoglVertexProgramStateUtil { // load environmental parameters... for (int i = 0; i < VertexProgramState._getEnvParameters().length; i++) { if (VertexProgramState._getEnvParameters()[i] != null) { - gl.getGL2().glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, VertexProgramState - ._getEnvParameters()[i][0], VertexProgramState._getEnvParameters()[i][1], - VertexProgramState._getEnvParameters()[i][2], VertexProgramState - ._getEnvParameters()[i][3]); + gl.getGL2().glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, + VertexProgramState._getEnvParameters()[i][0], + VertexProgramState._getEnvParameters()[i][1], + VertexProgramState._getEnvParameters()[i][2], + VertexProgramState._getEnvParameters()[i][3]); } } @@ -110,8 +110,8 @@ public abstract class JoglVertexProgramStateUtil { for (int i = 0; i < state._getParameters().length; i++) { if (state._getParameters()[i] != null) { gl.getGL2().glProgramLocalParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, - state._getParameters()[i][0], state._getParameters()[i][1], state - ._getParameters()[i][2], state._getParameters()[i][3]); + state._getParameters()[i][0], state._getParameters()[i][1], + state._getParameters()[i][2], state._getParameters()[i][3]); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java index bf8b026..7172fc0 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java @@ -12,13 +12,13 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.WireframeState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.WireframeState; import com.ardor3d.renderer.state.record.WireframeStateRecord; public abstract class JoglWireframeStateUtil { @@ -54,7 +54,7 @@ public abstract class JoglWireframeStateUtil { } private static void applyPolyMode(final int frontMode, final int backMode, final WireframeStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (frontMode == backMode && (record.frontMode != frontMode || record.backMode != backMode)) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java index b806b02..4763ced 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java @@ -11,6 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.glu.GLU; import com.ardor3d.renderer.ContextManager; @@ -67,7 +68,7 @@ public abstract class JoglZBufferStateUtil { } private static void enableDepthTest(final boolean enable, final ZBufferStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enable && (!record.depthTest || !record.isValid())) { gl.glEnable(GL.GL_DEPTH_TEST); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java index 96927ae..006cdb8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java @@ -13,9 +13,8 @@ package com.ardor3d.scene.state.jogl.shader; import java.util.logging.Logger; import javax.media.opengl.GL; -import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -104,10 +103,11 @@ public abstract class JoglShaderUtil { * shader program context ID */ public static void updateUniformLocation(final ShaderVariable variable, final int programID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2GL3().glGetUniformLocation(programID, variable.name); // TODO Check variable.name + variable.variableID = gl.getGL2GL3().glGetUniformLocation(programID, variable.name); // TODO Check + // variable.name if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader uniform [" + variable.name + "] could not be located in shader"); @@ -117,45 +117,50 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableInt shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform1i(shaderUniform.variableID, shaderUniform.value1); } private static void updateShaderUniform(final ShaderVariableInt2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform2i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); } private static void updateShaderUniform(final ShaderVariableInt3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3); + gl.getGL2GL3().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); } private static void updateShaderUniform(final ShaderVariableInt4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3, - shaderUniform.value4); + gl.getGL2GL3().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); } private static void updateShaderUniform(final ShaderVariableIntArray shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (shaderUniform.size) { case 1: - gl.getGL2GL3().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 2: - gl.getGL2GL3().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 3: - gl.getGL2GL3().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 4: - gl.getGL2GL3().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -163,45 +168,50 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableFloat shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform1f(shaderUniform.variableID, shaderUniform.value1); } private static void updateShaderUniform(final ShaderVariableFloat2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform2f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); } private static void updateShaderUniform(final ShaderVariableFloat3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3); + gl.getGL2GL3().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); } private static void updateShaderUniform(final ShaderVariableFloat4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3, - shaderUniform.value4); + gl.getGL2GL3().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); } private static void updateShaderUniform(final ShaderVariableFloatArray shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (shaderUniform.size) { case 1: - gl.getGL2GL3().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 2: - gl.getGL2GL3().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 3: - gl.getGL2GL3().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 4: - gl.getGL2GL3().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -209,28 +219,31 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableMatrix2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix4Array shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); // count == number of matrices we are sending, or iotw, limit / 16 @@ -247,10 +260,11 @@ public abstract class JoglShaderUtil { * shader program context ID */ public static void updateAttributeLocation(final ShaderVariable variable, final int programID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2GL3().glGetAttribLocation(programID, variable.name); // TODO Check variable.name + variable.variableID = gl.getGL2GL3().glGetAttribLocation(programID, variable.name); // TODO Check + // variable.name if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader attribute [" + variable.name + "] could not be located in shader"); @@ -307,7 +321,7 @@ public abstract class JoglShaderUtil { public static void useShaderProgram(final int id, final ShaderObjectsStateRecord record) { if (record.shaderId != id) { - GLU.getCurrentGL().getGL2().glUseProgramObjectARB(id); + GLContext.getCurrentGL().getGL2().glUseProgramObjectARB(id); record.shaderId = id; } } @@ -315,9 +329,9 @@ public abstract class JoglShaderUtil { private static void enableVertexAttribute(final ShaderVariable var, final ShaderObjectsStateRecord record) { if (!record.enabledAttributes.contains(var)) { if (var.getSize() == 1) { - GLU.getCurrentGL().getGL2GL3().glEnableVertexAttribArray(var.variableID); + GLContext.getCurrentGL().getGL2GL3().glEnableVertexAttribArray(var.variableID); } else { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); for (int i = 0, max = var.getSize(); i < max; i++) { gl.getGL2GL3().glEnableVertexAttribArray(var.variableID + i); } @@ -333,18 +347,24 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, - variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, - variable.normalized, variable.stride, variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } private static void updateShaderAttribute(final ShaderVariablePointerFloatMatrix variable, final ShaderObjectsStateRecord record, final boolean useVBO) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int size = variable.size; final int length = variable.data.getBuffer().capacity() / size; final RenderContext context = ContextManager.getCurrentContext(); @@ -355,12 +375,13 @@ public abstract class JoglShaderUtil { if (useVBO) { final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, 0, pos); + gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, + 0, pos); } else { variable.data.getBuffer().limit(pos + length - 1); variable.data.getBuffer().position(pos); - gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, 0, - variable.data.getBuffer()); + gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, + 0, variable.data.getBuffer()); } } } @@ -372,13 +393,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, + 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, + variable.data.getBuffer()); } } @@ -389,13 +417,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } @@ -406,13 +441,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java index 88f006e..4c87387 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java @@ -13,7 +13,7 @@ package com.ardor3d.scene.state.jogl.util; import java.util.Stack; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.Rectangle2; import com.ardor3d.math.type.ReadOnlyRectangle2; @@ -22,7 +22,7 @@ import com.ardor3d.renderer.state.record.RendererRecord; public abstract class JoglRendererUtil { public static void switchMode(final RendererRecord rendRecord, final int mode) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isMatrixValid() || rendRecord.getMatrixMode() != mode) { gl.getGL2().glMatrixMode(mode); @@ -32,7 +32,7 @@ public abstract class JoglRendererUtil { } public static void setBoundVBO(final RendererRecord rendRecord, final int id) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isVboValid() || rendRecord.getCurrentVboId() != id) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, id); @@ -42,7 +42,7 @@ public abstract class JoglRendererUtil { } public static void setBoundElementVBO(final RendererRecord rendRecord, final int id) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isElementVboValid() || rendRecord.getCurrentElementVboId() != id) { gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id); @@ -52,7 +52,7 @@ public abstract class JoglRendererUtil { } public static void applyScissors(final RendererRecord rendRecord) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Stack<ReadOnlyRectangle2> clips = rendRecord.getScissorClips(); if (clips.size() > 0) { @@ -93,7 +93,7 @@ public abstract class JoglRendererUtil { } public static void setClippingEnabled(final RendererRecord rendRecord, final boolean enabled) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enabled && (!rendRecord.isClippingTestValid() || !rendRecord.isClippingTestEnabled())) { gl.glEnable(GL.GL_SCISSOR_TEST); |