From b5ce9cce6223810c6df7b66cf1a51318309fdc90 Mon Sep 17 00:00:00 2001 From: sg215889 Date: Wed, 29 Jul 2009 06:27:46 -0700 Subject: Fixed GL* documentation. Moved common GL functions to GLBase. Moved glAllocateMemoryNV to GL2GL3 only. Add GL2GL3 interface. Fix some GL2 signatures. BroadcomEGL disable custom setSize(). --- make/config/jogl/gl-common.cfg | 204 +++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 132 deletions(-) (limited to 'make/config/jogl/gl-common.cfg') diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 50c2ff004..19e0eb8e4 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -481,70 +481,87 @@ RangeCheck glDeleteVertexArraysAPPLE 1 {0} # Javadoc for the GL class ClassJavadoc GL /** -ClassJavadoc GL *

The basic interface to OpenGL, providing access to core -ClassJavadoc GL * functionality up through the OpenGL 2.0 specification as well as -ClassJavadoc GL * all vendor extensions.

-ClassJavadoc GL * -ClassJavadoc GL *

While the APIs for vendor extensions are unconditionally -ClassJavadoc GL * exposed, the underlying functions may not be present. The method -ClassJavadoc GL * {@link #isFunctionAvailable} should be used to query the -ClassJavadoc GL * availability of any non-core function before it is used for the -ClassJavadoc GL * first time; for example, -ClassJavadoc GL * gl.isFunctionAvailable("glProgramStringARB"). On -ClassJavadoc GL * certain platforms (Windows in particular), the most "core" -ClassJavadoc GL * functionality is only OpenGL 1.1, so in theory any routines first -ClassJavadoc GL * exposed in OpenGL 1.2, 1.3, and 1.4, 1.5, or 2.0 as well as vendor -ClassJavadoc GL * extensions should all be queried. Calling an unavailable function -ClassJavadoc GL * will cause a {@link GLException} to be raised.

-ClassJavadoc GL * -ClassJavadoc GL * {@link #isExtensionAvailable} may also be used to determine whether -ClassJavadoc GL * a specific extension is available before calling the routines or -ClassJavadoc GL * using the functionality it exposes: for example, -ClassJavadoc GL * gl.isExtensionAvailable("GL_ARB_vertex_program");. -ClassJavadoc GL * However, in this case it is up to the end user to know which -ClassJavadoc GL * routines or functionality are associated with which OpenGL -ClassJavadoc GL * extensions. It may also be used to test for the availability of a -ClassJavadoc GL * particular version of OpenGL: for example, -ClassJavadoc GL * gl.isExtensionAvailable("GL_VERSION_1_5");. -ClassJavadoc GL * -ClassJavadoc GL *

Exceptions to the window system extension naming rules: -ClassJavadoc GL * -ClassJavadoc GL *

-ClassJavadoc GL * +ClassJavadoc GL *

Common interface containing the subset of all profiles, GL3, GL2, GLES1 and GLES2.
+ClassJavadoc GL * This interface reflects common data types, texture and framebuffer functionality.

ClassJavadoc GL */ +ClassJavadoc GL2ES1 /** +ClassJavadoc GL2ES1 *

+ClassJavadoc GL2ES1 * Interface containing the common subset of GL2 and GLES1.
+ClassJavadoc GL2ES1 * This interface reflects only the fixed functionality of OpenGL
+ClassJavadoc GL2ES1 *

+ClassJavadoc GL2ES1 */ + +ClassJavadoc GL2ES2 /** +ClassJavadoc GL2ES2 *

+ClassJavadoc GL2ES2 * Interface containing the common subset of GL3, GL2 and GLES2.
+ClassJavadoc GL2ES2 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
+ClassJavadoc GL2ES2 *

+ClassJavadoc GL2ES2 */ + +ClassJavadoc GL2GL3 /** +ClassJavadoc GL2GL3 *

+ClassJavadoc GL2GL3 * Interface containing the common subset of GL3 and GL2.
+ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
+ClassJavadoc GL2GL3 *

+ClassJavadoc GL2GL3 */ + +ClassJavadoc GL2 /** +ClassJavadoc GL2 *

+ClassJavadoc GL2 * This interface contains all core desktop OpenGL methods through +ClassJavadoc GL2 * version 3.0, inclusive, as well as most of it's extensions defined at the +ClassJavadoc GL2 * time of this specification. Early OpenGL extensions whose functionality +ClassJavadoc GL2 * was incorporated into core OpenGL by version 2.0, inclusive, are specifically +ClassJavadoc GL2 * excluded. +ClassJavadoc GL2 *

+ClassJavadoc GL2 */ + +ClassJavadoc GL3 /** +ClassJavadoc GL3 *

+ClassJavadoc GL3 * This interface contains all core desktop OpenGL methods starting from 3.1, +ClassJavadoc GL3 * inclusive - forward compatible only, as well as most of it's extensions defined at the +ClassJavadoc GL3 * time of this specification.
+ClassJavadoc GL3 *

+ClassJavadoc GL3 */ + +ClassJavadoc GLES1 /** +ClassJavadoc GLES1 *

+ClassJavadoc GLES1 * This interface contains all core embedded OpenGL methods of ES 1.x, with x >= 0, +ClassJavadoc GLES1 * inclusive, as well as most of it's extensions defined at the +ClassJavadoc GLES1 * time of this specification. +ClassJavadoc GLES1 *

+ClassJavadoc GLES1 */ + +ClassJavadoc GLES2 /** +ClassJavadoc GLES2 *

+ClassJavadoc GLES2 * This interface contains all core embedded OpenGL methods of ES 2.x, with x >= 0, +ClassJavadoc GLES2 * inclusive, as well as most of it's extensions defined at the +ClassJavadoc GLES2 * time of this specification. +ClassJavadoc GLES2 *

+ClassJavadoc GLES2 */ + +# Javadoc for the EGL class +ClassJavadoc EGL /** +ClassJavadoc EGL * Provides access to the embedded-specific OpenGL vendor extensions. +ClassJavadoc EGL * See {@link GLBase} for more information. +ClassJavadoc EGL */ + # Javadoc for the WGL class ClassJavadoc WGL /** ClassJavadoc WGL * Provides access to the Windows-specific OpenGL vendor extensions. -ClassJavadoc WGL * See {@link GL} for more information. +ClassJavadoc WGL * See {@link GLBase} for more information. ClassJavadoc WGL */ # Javadoc for the GLX class ClassJavadoc GLX /** ClassJavadoc GLX * Provides access to the X11-specific OpenGL vendor extensions. -ClassJavadoc GLX * See {@link GL} for more information. +ClassJavadoc GLX * See {@link GLBase} for more information. ClassJavadoc GLX */ # Javadoc for the CGL class ClassJavadoc CGL /** ClassJavadoc CGL * Provides access to the MacOSX-specific OpenGL vendor extensions. -ClassJavadoc CGL * See {@link GL} for more information. +ClassJavadoc CGL * See {@link GLBase} for more information. ClassJavadoc CGL */ # Javadoc for the XVisualInfo class @@ -556,86 +573,9 @@ ClassJavadoc XVisualInfo */ # Custom code for querying extensions and exposing # wglAllocateMemoryNV/glXAllocateMemoryNV -CustomJavaCode GL /** -CustomJavaCode GL * Returns true if the specified OpenGL core- or extension-function can be -CustomJavaCode GL * used successfully through this GL instance given the current host (OpenGL -CustomJavaCode GL * client) and display (OpenGL server) configuration.

-CustomJavaCode GL * By "successfully" we mean that the function is both callable -CustomJavaCode GL * on the machine running the program and available on the current -CustomJavaCode GL * display.

-CustomJavaCode GL * -CustomJavaCode GL * In order to call a function successfully, the function must be both -CustomJavaCode GL * callable on the machine running the program and available on -CustomJavaCode GL * the display device that is rendering the output (note: on non-networked, -CustomJavaCode GL * single-display machines these two conditions are identical; on networked and/or -CustomJavaCode GL * multi-display machines this becomes more complicated). These conditions are -CustomJavaCode GL * met if the function is either part of the core OpenGL version supported by -CustomJavaCode GL * both the host and display, or it is an OpenGL extension function that both -CustomJavaCode GL * the host and display support.

-CustomJavaCode GL * -CustomJavaCode GL * A GL function is callable if it is successfully linked at runtime, -CustomJavaCode GL * hence the GLContext must be made current at least once. -CustomJavaCode GL * -CustomJavaCode GL * @param glFunctionName the name of the OpenGL function (e.g., use -CustomJavaCode GL * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link -CustomJavaCode GL * #glBindRenderbuffer(int,int)} is available). -CustomJavaCode GL */ -CustomJavaCode GL public boolean isFunctionAvailable(String glFunctionName); - -CustomJavaCode GL /** -CustomJavaCode GL * Returns true if the specified OpenGL extension can be -CustomJavaCode GL * used successfully through this GL instance given the current host (OpenGL -CustomJavaCode GL * client) and display (OpenGL server) configuration.

-CustomJavaCode GL * -CustomJavaCode GL * @param glExtensionName the name of the OpenGL extension (e.g., -CustomJavaCode GL * "GL_ARB_vertex_program"). -CustomJavaCode GL */ -CustomJavaCode GL public boolean isExtensionAvailable(String glExtensionName); - -CustomJavaCode GL /** -CustomJavaCode GL * Provides platform-independent access to the wglAllocateMemoryNV / -CustomJavaCode GL * glXAllocateMemoryNV extension. -CustomJavaCode GL */ -CustomJavaCode GL public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); - -CustomJavaCode GL /** Provides a platform-independent way to specify the minimum swap -CustomJavaCode GL interval for buffer swaps. An argument of 0 disables -CustomJavaCode GL sync-to-vertical-refresh completely, while an argument of 1 -CustomJavaCode GL causes the application to wait until the next vertical refresh -CustomJavaCode GL until swapping buffers. The default, which is platform-specific, -CustomJavaCode GL is usually either 0 or 1. This function is not guaranteed to -CustomJavaCode GL have an effect, and in particular only affects heavyweight -CustomJavaCode GL onscreen components. */ -CustomJavaCode GL public void setSwapInterval(int interval); - -CustomJavaCode GL /** -CustomJavaCode GL * Returns an object through which platform-specific OpenGL extensions -CustomJavaCode GL * (WGL, GLX, etc.) may be accessed. The data type of the returned -CustomJavaCode GL * object and its associated capabilities are undefined. Most -CustomJavaCode GL * applications will never need to call this method. It is highly -CustomJavaCode GL * recommended that any applications which do call this method perform -CustomJavaCode GL * all accesses on the returned object reflectively to guard -CustomJavaCode GL * themselves against changes to the implementation. -CustomJavaCode GL */ -CustomJavaCode GL public Object getPlatformGLExtensions(); - -CustomJavaCode GL /** -CustomJavaCode GL * Returns an object providing access to the specified OpenGL -CustomJavaCode GL * extension. This is intended to provide a mechanism for vendors who -CustomJavaCode GL * which to provide access to new OpenGL extensions without changing -CustomJavaCode GL * the public API of the core package. For example, a user may request -CustomJavaCode GL * access to extension "GL_VENDOR_foo" and receive back an object -CustomJavaCode GL * which implements a vendor-specified interface which can call the -CustomJavaCode GL * OpenGL extension functions corresponding to that extension. It is -CustomJavaCode GL * up to the vendor to specify both the extension name and Java API -CustomJavaCode GL * for accessing it, including which class or interface contains the -CustomJavaCode GL * functions. -CustomJavaCode GL * -CustomJavaCode GL *

-CustomJavaCode GL * -CustomJavaCode GL * Note: it is the intent to add new extensions as quickly as possible -CustomJavaCode GL * to the core GL API. Therefore it is unlikely that most vendors will -CustomJavaCode GL * use this extension mechanism, but it is being provided for -CustomJavaCode GL * completeness. -CustomJavaCode GL */ -CustomJavaCode GL public Object getExtension(String extensionName); +CustomJavaCode GL2GL3 /** +CustomJavaCode GL2GL3 * Provides platform-independent access to the wglAllocateMemoryNV / +CustomJavaCode GL2GL3 * glXAllocateMemoryNV extension. +CustomJavaCode GL2GL3 */ +CustomJavaCode GL2GL3 public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); + -- cgit v1.2.3 From 786b056afb90311a8c06a57fc24f242f8df713e1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 31 Jul 2009 11:52:46 -0700 Subject: Gluegen: - Fix array element type name and const qualifier JOGL: - GL3: Set ArgumentIsString for GL3.1 methods - JAR file creation: Add 'filesonly' option - GLU: Static check of available impl., better fallback for GL2 without GLUgl2. - WGL: (Performance + Java2D/GL FBO works again) - Refactor WGL_ARB_pixel_format's HDC -> GLCapabilities: HDC2Caps - Revert change where we always create a dummy drawable/context for WGL selection (HDC2Caps). In case of no multisampling, use PFD2Caps only. - Update config using HDC2Caps (WGL_ARB_pixel_format) after context creation, if not done already -> updateCapabilitiesByWGL(). - profile.jogl: Add debug jars --- etc/profile.jogl | 14 +- make/build-jogl.xml | 80 +++++------ make/build-nativewindow.xml | 18 +-- make/build-newt.xml | 34 ++--- make/config/jogl/gl-common.cfg | 32 +++-- make/config/jogl/glu-CustomJavaCode-base.java | 43 +++--- make/make.jogl.all.win32.bat | 2 +- .../com/sun/opengl/impl/GLDrawableImpl.java | 6 +- .../windows/wgl/WindowsExternalWGLContext.java | 7 +- .../windows/wgl/WindowsExternalWGLDrawable.java | 4 +- .../windows/wgl/WindowsPbufferWGLDrawable.java | 4 +- .../opengl/impl/windows/wgl/WindowsWGLContext.java | 5 + .../wgl/WindowsWGLGraphicsConfiguration.java | 149 +++++++++++++++++++-- .../WindowsWGLGraphicsConfigurationFactory.java | 112 ++++------------ .../com/sun/javafx/newt/windows/WindowsWindow.java | 7 +- 15 files changed, 306 insertions(+), 211 deletions(-) (limited to 'make/config/jogl/gl-common.cfg') diff --git a/etc/profile.jogl b/etc/profile.jogl index c1daef85d..24cac910f 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -30,25 +30,25 @@ JOGL_AWT="jogl.awt.jar jogl.util.awt.jar newt.awt.jar nativewindow.awt.jar" JOGL_CORE="nativewindow.core.jar nativewindow.x11.jar jogl.core.jar newt.core.jar newt.$OSS.jar newt.ogl.jar jogl.util.jar" -JOGL_JAR_ALL="$JOGL_CORE jogl.gles1.jar jogl.gles1.dbg.jar jogl.gles2.jar jogl.gles2.dbg.jar jogl.egl.jar jogl.gl2es12.$OSS.jar jogl.gl2es12.dbg.jar jogl.gl2.$OSS.jar jogl.gl2.dbg.jar jogl.util.gl2.jar jogl.glu.tess.jar jogl.glu.mipmap.jar jogl.glu.gl2.jar jogl.util.gl2.jar jogl.util.fixedfuncemu.jar $JOGL_AWT jogl.cg.jar" +JOGL_JAR_ALL="$JOGL_CORE jogl.gles1.jar jogl.gles1.dbg.jar jogl.gles2.jar jogl.gles2.dbg.jar jogl.egl.jar jogl.gl2es12.$OSS.jar jogl.gl2.$OSS.jar jogl.gl2.dbg.jar jogl.util.gl2.jar jogl.glu.tess.jar jogl.glu.mipmap.jar jogl.glu.gl2.jar jogl.util.gl2.jar jogl.util.fixedfuncemu.jar $JOGL_AWT jogl.cg.jar" JOGL_LIB_ALL="libjogl_gl2.so libjogl_es1.so libjogl_es2.so libnewt.so libjogl_awt.so" -JOGL_JAR_ES1_MIN="$JOGL_CORE jogl.gles1.jar jogl.egl.jar" +JOGL_JAR_ES1_MIN="$JOGL_CORE jogl.gles1.jar jogl.gles1.dbg.jar jogl.egl.jar" JOGL_JAR_ES1_MAX="$JOGL_CORE jogl.gles1.jar jogl.gles1.dbg.jar jogl.egl.jar jogl.glu.tess.jar jogl.glu.mipmap.jar $JOGL_AWT" JOGL_LIB_ES1_MIN="libjogl_es1.so libnewt.so" JOGL_LIB_ES1_MAX="libjogl_es1.so libnewt.so libjogl_awt.so libnativewindow_x11.so libnativewindow_awt.so" -JOGL_JAR_ES2_MIN="$JOGL_CORE jogl.gles2.jar jogl.egl.jar jogl.util.fixedfuncemu.jar" -JOGL_JAR_ES2_MAX="$JOGL_CORE jogl.gles2.jar jogl.egl.jar jogl.util.fixedfuncemu.jar jogl.glu.tess.jar $JOGL_AWT" +JOGL_JAR_ES2_MIN="$JOGL_CORE jogl.gles2.jar jogl.gles2.dbg.jar jogl.egl.jar jogl.util.fixedfuncemu.jar" +JOGL_JAR_ES2_MAX="$JOGL_CORE jogl.gles2.jar jogl.gles2.dbg.jar jogl.egl.jar jogl.util.fixedfuncemu.jar jogl.glu.tess.jar $JOGL_AWT" JOGL_LIB_ES2_MIN="libjogl_es2.so libnewt.so" JOGL_LIB_ES2_MAX="libjogl_es2.so libnewt.so libjogl_awt.so libnativewindow_x11.so libnativewindow_awt.so" -JOGL_JAR_GL2ES12_MIN="$JOGL_CORE jogl.gl2es12.$OSS.jar jogl.util.fixedfuncemu.jar" -JOGL_JAR_GL2ES12_MAX="$JOGL_CORE jogl.gl2es12.$OSS.jar jogl.util.fixedfuncemu.jar jogl.gl2es12.dbg.jar jogl.glu.tess.jar jogl.glu.mipmap.jar $JOGL_AWT" +JOGL_JAR_GL2ES12_MIN="$JOGL_CORE jogl.gl2es12.$OSS.jar jogl.gles1.dbg.jar jogl.gles2.dbg.jar jogl.util.fixedfuncemu.jar" +JOGL_JAR_GL2ES12_MAX="$JOGL_CORE jogl.gl2es12.$OSS.jar jogl.gles1.dbg.jar jogl.gles2.dbg.jar jogl.util.fixedfuncemu.jar jogl.gl2es12.dbg.jar jogl.glu.tess.jar jogl.glu.mipmap.jar $JOGL_AWT" JOGL_LIB_GL2ES12_MIN="libjogl_gl2es12.so libnewt.so libnativewindow_x11.so libnativewindow_awt.so" JOGL_LIB_GL2ES12_MAX="libjogl_gl2es12.so libnewt.so libnativewindow_x11.so libnativewindow_awt.so" -JOGL_JAR_GL2_MIN="$JOGL_CORE jogl.gl2.$OSS.jar" +JOGL_JAR_GL2_MIN="$JOGL_CORE jogl.gl2.$OSS.jar jogl.gl2.dbg.jar" JOGL_JAR_GL2_MAX="$JOGL_CORE jogl.gl2.$OSS.jar jogl.gl2.dbg.jar jogl.glu.tess.jar jogl.glu.mipmap.jar jogl.glu.gl2.jar jogl.util.gl2.jar $JOGL_AWT jogl.cg.jar" JOGL_LIB_GL2_MIN="libjogl_gl2.so libnewt.so libnativewindow_x11.so libnativewindow_awt.so" JOGL_LIB_GL2_MAX="libjogl_gl2.so libnewt.so libnativewindow_x11.so libnativewindow_awt.so" diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 0f9a230a2..08f0d6ef2 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1591,12 +1591,12 @@ - + - + @@ -1660,24 +1660,24 @@ - + - + - + - + @@ -1685,43 +1685,43 @@ - + - + - + - + - + - + - + - + @@ -1729,44 +1729,44 @@ - + - + - + - + - + - + - + - + @@ -1780,7 +1780,7 @@ - + @@ -1791,25 +1791,25 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -1849,29 +1849,29 @@ - + - + - + - + - + - + - + - + @@ -830,7 +830,7 @@ - + @@ -838,20 +838,20 @@ - + - + - + @@ -861,7 +861,7 @@ - + @@ -871,7 +871,7 @@ - + @@ -880,7 +880,7 @@ - + diff --git a/make/build-newt.xml b/make/build-newt.xml index acf78f09a..079d2e154 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -623,12 +623,12 @@ - + - + @@ -686,73 +686,73 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -760,7 +760,7 @@ - + @@ -768,7 +768,7 @@ - + diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 19e0eb8e4..a26c6a6b3 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -289,6 +289,14 @@ ReturnValueCapacity glXAllocateMemoryNV {0} # Pass arguments to ARB_vertex_program, ARB_fragment_program, # ARB_shader_objects, NV_vertex_program, NV_fragment_program, and # ARB_vertex_shader as Strings +ArgumentIsString glBindAttribLocation 2 +ArgumentIsString glBindAttribLocationARB 2 +ArgumentIsString glGetAttribLocation 1 +ArgumentIsString glGetAttribLocationARB 1 +ArgumentIsString glGetProgramNamedParameterfvNV 2 +ArgumentIsString glGetProgramNamedParameterdvNV 2 +ArgumentIsString glGetUniformLocation 1 +ArgumentIsString glGetUniformLocationARB 1 ArgumentIsString glLoadProgramNV 3 ArgumentIsString glProgramString 3 ArgumentIsString glProgramStringARB 3 @@ -296,16 +304,24 @@ ArgumentIsString glProgramNamedParameter4fNV 2 ArgumentIsString glProgramNamedParameter4dNV 2 ArgumentIsString glProgramNamedParameter4fvNV 2 ArgumentIsString glProgramNamedParameter4dvNV 2 -ArgumentIsString glGetProgramNamedParameterfvNV 2 -ArgumentIsString glGetProgramNamedParameterdvNV 2 ArgumentIsString glShaderSource 2 ArgumentIsString glShaderSourceARB 2 -ArgumentIsString glGetUniformLocation 1 -ArgumentIsString glGetUniformLocationARB 1 -ArgumentIsString glBindAttribLocation 2 -ArgumentIsString glBindAttribLocationARB 2 -ArgumentIsString glGetAttribLocation 1 -ArgumentIsString glGetAttribLocationARB 1 + +ArgumentIsString glBindFragDataLocation 2 +ArgumentIsString glGetFragDataLocation 1 +ArgumentIsString glGetUniformIndices 2 +ArgumentIsString glGetUniformBlockIndex 1 +ArgumentIsString glTransformFeedbackVaryings 2 + +# String output values: +# ArgumentIsString glGetActiveAttrib 6 +# ArgumentIsString glGetActiveUniformBlockName 4 +# ArgumentIsString glGetActiveUniformName 4 +# ArgumentIsString glGetActiveUniform 6 +# ArgumentIsString glGetProgramInfoLog 3 +# ArgumentIsString glGetShaderInfoLog 3 +# ArgumentIsString glGetShaderSource 3 +# ArgumentIsString glGetTransformFeedbackVarying 6 # # Directives for Vertex Buffer Object and Pixel Buffer Object checking diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java index 6949cfb68..78c067606 100755 --- a/make/config/jogl/glu-CustomJavaCode-base.java +++ b/make/config/jogl/glu-CustomJavaCode-base.java @@ -76,8 +76,19 @@ public boolean isFunctionAvailable(String gluFunctionName) // Utility routines // -private static Class gl2Class; -private static Class gl2es1Class; +private static final Class gl2Class; +private static final Class gl2es1Class; + +static { + Class _gl2Class=null; + Class _gl2es1Class=null; + try { + _gl2Class = Class.forName("javax.media.opengl.glu.gl2.GLUgl2"); + _gl2es1Class = Class.forName("javax.media.opengl.glu.gl2es1.GLUgl2es1"); + } catch (Throwable t) {} + gl2Class = _gl2Class; + gl2es1Class = _gl2es1Class; +} /** * Instantiates a GLU implementation object in respect to the given GL profile @@ -94,32 +105,20 @@ public static final GLU createGLU() throws GLException { public static final GLU createGLU(GL gl) throws GLException { try { Class c = null; - if(gl.isGL2()) { - if (gl2Class == null) { - gl2Class = Class.forName("javax.media.opengl.glu.gl2.GLUgl2"); - } + if(gl.isGL2() && null!=gl2Class) { c = gl2Class; - } else if (gl.isGL2ES1()) { - if (gl2es1Class == null) { - gl2es1Class = Class.forName("javax.media.opengl.glu.gl2es1.GLUgl2es1"); - } + } else if(gl.isGL2ES1() && null!=gl2es1Class) { c = gl2es1Class; + /** There is no specialized ES 2 GLU at this time + } else if(gl.isGL2ES2() && null!=gl2es2Class) { + c = gl2es2Class; */ + } else { + c = GLU.class; } - if (c != null) { - return (GLU) c.newInstance(); - } + return (GLU) c.newInstance(); } catch (Exception e) { throw new GLException(e); } - // There is no specialized ES 2 GLU at this time - /* - try { - if(GLProfile.GL2ES12.equals(profile) || GLProfile.GL2.equals(profile) || GLProfile.GLES2.equals(profile)) { - return (GLU) NWReflection.createInstance("javax.media.opengl.glu.gl2es2.GLUgl2es2"); - } - } catch (GLException e) { e.printStackTrace(); } - */ - return new GLU(); } public GLU() diff --git a/make/make.jogl.all.win32.bat b/make/make.jogl.all.win32.bat index f4a52fa75..9ab77b051 100644 --- a/make/make.jogl.all.win32.bat +++ b/make/make.jogl.all.win32.bat @@ -9,4 +9,4 @@ REM -DuseOpenMAX=true REM -DuseKD=true REM -Djogl.cg=1 -D-Dwindows.cg.lib=C:\Cg-2.2 -ant -Drootrel.build=build-win32 -Djogl.cg=1 -Dwindows.cg.lib=C:\Cg-2.2\lib > make.jogl.all.win32.log 2>&1 +ant -Dbuild.noarchives=true -Dc.compiler.debug=true -Drootrel.build=build-win32 -Djogl.cg=1 -Dwindows.cg.lib=C:\Cg-2.2\lib > make.jogl.all.win32.log 2>&1 diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java index 15ccc0f96..81fc0b78b 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -140,10 +140,10 @@ public abstract class GLDrawableImpl implements GLDrawable { public String toString() { return getClass().getName()+"[realized "+getRealized()+ - ",\n\trequested "+getRequestedGLCapabilities()+ - ",\n\tchosen "+getChosenGLCapabilities()+ + ",\n\tfactory "+getFactory()+ ",\n\twindow "+getNativeWindow()+ - ",\n\tfactory "+getFactory()+"]"; + ",\n\trequested "+getRequestedGLCapabilities()+ + ",\n\tchosen "+getChosenGLCapabilities()+"]"; } protected GLDrawableFactory factory; diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java index b9fc80156..31e65fc8c 100755 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java @@ -51,7 +51,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { private boolean created = true; private GLContext lastContext; - private WindowsExternalWGLContext(Drawable drawable, long hglrc) { + private WindowsExternalWGLContext(Drawable drawable, long hglrc, WindowsWGLGraphicsConfiguration cfg) { super(drawable, null); this.hglrc = hglrc; if (DEBUG) { @@ -59,6 +59,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { } GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false); + cfg.updateCapabilitiesByWGL(this); } protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) { @@ -76,12 +77,12 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true); NullWindow nw = new NullWindow(cfg); nw.setSurfaceHandle(hdc); - return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc); + return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc, cfg); } public int makeCurrent() throws GLException { diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java index 706675893..9b87afc38 100755 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java @@ -61,12 +61,12 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true); NullWindow nw = new NullWindow(cfg); nw.setSurfaceHandle(hdc); - // cfg.updateGraphicsConfiguration(factory, nw); + cfg.updateGraphicsConfiguration(factory, nw); return new WindowsExternalWGLDrawable(factory, nw); } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index f54e8f1a0..79dda9049 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -295,7 +295,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if(newCaps.isOnscreen()) { throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps); } - config.setCapsPFD(newCaps, pfd, pformats[whichFormat]); + config.setCapsPFD(newCaps, pfd, pformats[whichFormat], true); } else { PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor(); if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) { @@ -305,7 +305,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if(newCaps.isOnscreen()) { throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps); } - config.setCapsPFD(newCaps, pfd, pformats[whichFormat]); + config.setCapsPFD(newCaps, pfd, pformats[whichFormat], false); } } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java index 92a563445..578279586 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -264,6 +264,11 @@ public class WindowsWGLContext extends GLContextImpl { if (created) { setGLFunctionAvailability(false); + + WindowsWGLGraphicsConfiguration config = + (WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + config.updateCapabilitiesByWGL(this); + return CONTEXT_CURRENT_NEW; } return CONTEXT_CURRENT; diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 1a8d45465..844e72841 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -49,6 +49,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio private int pixelfmtID; private boolean isChosen = false; private GLCapabilitiesChooser chooser; + private boolean choosenByWGLPixelFormat=false; public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested, PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) { @@ -58,17 +59,26 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio this.pixelfmtID = pixelfmtID; } - public static WindowsWGLGraphicsConfiguration create(GLProfile glp, AbstractGraphicsScreen screen, long hdc, int pfdID, boolean onscreen, boolean usePBuffer) { - PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(); - if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) { - throw new GLException("Unable to describe pixel format " + pfdID); + public static WindowsWGLGraphicsConfiguration create(long hdc, int pfdID, + GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen, boolean usePBuffer) + { + if(pfdID<=0) { + throw new GLException("Invalid pixelformat id "+pfdID); } if(null==glp) { glp = GLProfile.getDefault(); } + PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(); + if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) { + throw new GLException("Unable to describe pixel format " + pfdID); + } + GLCapabilities caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer); + if(null==caps) { + throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID); + } WindowsWGLGraphicsConfiguration cfg = new WindowsWGLGraphicsConfiguration(screen, caps, caps, pfd, pfdID, new DefaultGLCapabilitiesChooser()); - cfg.setCapsPFD(caps, pfd, pfdID); + cfg.setCapsPFD(caps, pfd, pfdID, false); return cfg; } @@ -77,15 +87,40 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio return super.clone(); } + /** Update config - before having a valid context */ protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeWindow nativeWindow) { WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, nativeWindow); } - protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID) { - // FIXME: setScreen ( .. ) + + /** Update config - after having a valid and current context */ + protected void updateCapabilitiesByWGL(GLContextImpl context) { + if(choosenByWGLPixelFormat) return; // already done .. + + GLCapabilities capabilities = (GLCapabilities) getRequestedCapabilities(); + boolean onscreen = capabilities.isOnscreen(); + boolean usePBuffer = capabilities.isPBuffer(); + GLProfile glp = capabilities.getGLProfile(); + + WGLExt wglExt = (WGLExt) context.getPlatformGLExtensions(); + GLDrawable drawable = context.getGLDrawable(); + NativeWindow nativeWindow = drawable.getNativeWindow(); + long hdc = nativeWindow.getSurfaceHandle(); + + GLCapabilities[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer); + if(null!=caps && null!=caps[0]) { + setCapsPFD(caps[0], getPixelFormat(), getPixelFormatID(), true); + } + } + + protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) { this.pixelfmt = pfd; this.pixelfmtID = pfdID; setChosenCapabilities(caps); - isChosen=true; + this.isChosen=true; + this.choosenByWGLPixelFormat=choosenByWGLPixelFormat; + if (DEBUG) { + System.err.println("*** setCapsPFD: WGL-Choosen "+choosenByWGLPixelFormat+", pfdID "+pfdID+", "+caps); + } } public boolean getCapabilitiesChosen() { @@ -94,6 +129,102 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio public PIXELFORMATDESCRIPTOR getPixelFormat() { return pixelfmt; } public int getPixelFormatID() { return pixelfmtID; } + public boolean isChoosenByWGL() { return choosenByWGLPixelFormat; } + + private static int haveWGLChoosePixelFormatARB = -1; + private static int haveWGLARBMultisample = -1; + + public static GLCapabilities[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly, + GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) { + + if(haveWGLChoosePixelFormatARB<0) { + haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format")?1:0; + } + if(haveWGLARBMultisample<0) { + haveWGLARBMultisample = wglExt.isExtensionAvailable("WGL_ARB_multisample")?1:0; + } + if (0==haveWGLChoosePixelFormatARB) { + return null; + } + + // Produce a list of GLCapabilities to give to the + // GLCapabilitiesChooser. + // Use wglGetPixelFormatAttribivARB instead of + // DescribePixelFormat to get higher-precision information + // about the pixel format (should make the GLCapabilities + // more precise as well...i.e., remove the + // "HardwareAccelerated" bit, which is basically + // meaningless, and put in whether it can render to a + // window, to a pbuffer, or to a pixmap) + GLCapabilities[] availableCaps = null; + int numFormats = 0; + int niattribs = 0; + int[] iattributes = new int [2*MAX_ATTRIBS]; + int[] iresults = new int [2*MAX_ATTRIBS]; + + iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB; + if (wglExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { + numFormats = iresults[0]; + + if (DEBUG) { + System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats); + } + + if(pfdIDOnly>0 && pfdIDOnly>numFormats) { + throw new GLException("Invalid pixelformat ID " + pfdIDOnly + " (should be between 1 and " + numFormats + ")"); + } + + // Should we be filtering out the pixel formats which aren't + // applicable, as we are doing here? + // We don't have enough information in the GLCapabilities to + // represent those that aren't... + iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB; + iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB; + iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB; + iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB; + iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; + iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB; + iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB; + if (1==haveWGLARBMultisample) { + iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB; + iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB; + } + + if(pfdIDOnly>0) { + availableCaps = new GLCapabilities[1]; + if (!wglExt.wglGetPixelFormatAttribivARB(hdc, pfdIDOnly, 0, niattribs, iattributes, 0, iresults, 0)) { + throw new GLException("Error getting pixel format attributes for pixel format " + pfdIDOnly + " of device context"); + } + availableCaps[0] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults, + relaxed, onscreen, usePBuffer); + } else { + availableCaps = new GLCapabilities[numFormats]; + for (int i = 0; i < numFormats; i++) { + if (!wglExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) { + throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context"); + } + availableCaps[i] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults, + relaxed, onscreen, usePBuffer); + } + } + } else { + long lastErr = WGL.GetLastError(); + // Intel Extreme graphics fails with a zero error code + if (lastErr != 0) { + throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError()); + } + } + return availableCaps; + } public static boolean GLCapabilities2AttribList(GLCapabilities caps, int[] iattributes, @@ -498,7 +629,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio } public String toString() { - return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + + return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + ", wglChoosen "+choosenByWGLPixelFormat+ ",\n\trequested " + getRequestedCapabilities() + ",\n\tchosen " + getChosenCapabilities() + "]"; diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index f5974dc61..98ad83313 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -99,6 +99,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } + boolean choosenBywGLPixelFormat = false; WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities(); boolean onscreen = capabilities.isOnscreen(); @@ -113,7 +114,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } PIXELFORMATDESCRIPTOR pfd = null; - int pixelFormat = -1; + int pixelFormat = -1; // 1-based pixel format boolean pixelFormatSet = false; GLCapabilities chosenCaps = null; @@ -125,7 +126,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio // - or the Java2D/OpenGL pipeline's configuration if (DEBUG) { System.err.println("!!!! NOTE: pixel format already chosen for HDC: 0x" + Long.toHexString(hdc)+ - ", pixelformat "+WGL.GetPixelFormat(hdc)); + ", pixelformat "+pixelFormat); } pixelFormatSet = true; } @@ -138,27 +139,25 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio WindowsWGLDrawable dummyDrawable = null; GLContextImpl dummyContext = null; WGLExt dummyWGLExt = null; - dummyDrawable = new WindowsDummyWGLDrawable(factory); - dummyContext = (GLContextImpl) dummyDrawable.createContext(null); - if (dummyContext != null) { - dummyContext.makeCurrent(); - dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions(); - } - int recommendedPixelFormat = pixelFormat - 1; + if (capabilities.getSampleBuffers()) { + dummyDrawable = new WindowsDummyWGLDrawable(factory); + dummyContext = (GLContextImpl) dummyDrawable.createContext(null); + if (dummyContext != null) { + dummyContext.makeCurrent(); + dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions(); + } + } + int recommendedPixelFormat = pixelFormat; // 1-based pixel format boolean haveWGLChoosePixelFormatARB = false; - boolean haveWGLARBMultisample = false; boolean gotAvailableCaps = false; if (dummyWGLExt != null) { try { haveWGLChoosePixelFormatARB = dummyWGLExt.isExtensionAvailable("WGL_ARB_pixel_format"); if (haveWGLChoosePixelFormatARB) { - haveWGLARBMultisample = dummyWGLExt.isExtensionAvailable("WGL_ARB_multisample"); - - int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; - int[] iresults = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; - float[] fattributes = new float[1]; - if(pixelFormat<=0) { + int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; + float[] fattributes = new float[1]; + if(WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities, iattributes, dummyWGLExt, @@ -174,8 +173,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio numFormatsTmp, 0)) { numFormats = numFormatsTmp[0]; if (recommendedPixelFormat<=0 && numFormats > 0) { - // Remove one-basing of pixel format (added on later) - recommendedPixelFormat = pformats[0] - 1; + recommendedPixelFormat = pformats[0]; if (DEBUG) { System.err.println(getThreadName() + ": Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat); } @@ -187,7 +185,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } } if (DEBUG) { - if (recommendedPixelFormat < 0) { + if (recommendedPixelFormat <= 0) { System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format"); if (capabilities.getSampleBuffers()) { System.err.print(" for multisampled GLCapabilities"); @@ -198,65 +196,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } } - // Produce a list of GLCapabilities to give to the - // GLCapabilitiesChooser. - // Use wglGetPixelFormatAttribivARB instead of - // DescribePixelFormat to get higher-precision information - // about the pixel format (should make the GLCapabilities - // more precise as well...i.e., remove the - // "HardwareAccelerated" bit, which is basically - // meaningless, and put in whether it can render to a - // window, to a pbuffer, or to a pixmap) - int niattribs = 0; - iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB; - if (dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { - numFormats = iresults[0]; - - if (DEBUG) { - System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats); - } - - // Should we be filtering out the pixel formats which aren't - // applicable, as we are doing here? - // We don't have enough information in the GLCapabilities to - // represent those that aren't... - iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB; - iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB; - iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB; - iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB; - iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB; - iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB; - iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB; - iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB; - if (haveWGLARBMultisample) { - iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB; - iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB; - } - - availableCaps = new GLCapabilities[numFormats]; - for (int i = 0; i < numFormats; i++) { - if (!dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) { - throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context"); - } - availableCaps[i] = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, iresults, - pixelFormatSet, onscreen, usePBuffer); - } - gotAvailableCaps = true; - } else { - long lastErr = WGL.GetLastError(); - // Intel Extreme graphics fails with a zero error code - if (lastErr != 0) { - throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError()); - } - } + availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(dummyWGLExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer); + gotAvailableCaps = null!=availableCaps ; + choosenBywGLPixelFormat = gotAvailableCaps ; } } finally { dummyContext.release(); @@ -265,7 +207,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } } - // Fallback path for older cards, in particular Intel Extreme motherboard graphics if (!gotAvailableCaps) { if (DEBUG) { if (!capabilities.getSampleBuffers()) { @@ -279,8 +220,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio if (DEBUG) { System.err.println(getThreadName() + ": Recommended pixel format = " + recommendedPixelFormat); } - // Remove one-basing of pixel format (added on later) - recommendedPixelFormat -= 1; numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null); if (numFormats == 0) { @@ -305,19 +244,18 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio if(null!=chooser) { // Supply information to chooser try { - pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat); + pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat) + 1; } catch (NativeWindowException e) { throw new GLException(e); } } else { pixelFormat = recommendedPixelFormat; } - if ((pixelFormat < 0) || (pixelFormat >= numFormats)) { + if ((pixelFormat <= 0) || (pixelFormat > numFormats)) { throw new GLException("Invalid result " + pixelFormat + - " from GLCapabilitiesChooser (should be between 0 and " + - (numFormats - 1) + ")"); + " from GLCapabilitiesChooser (should be between 1 and " + + numFormats + ")"); } - pixelFormat += 1; // one-base the index } chosenCaps = availableCaps[pixelFormat-1]; if (DEBUG) { @@ -355,7 +293,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } else { capabilities = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, onscreen, usePBuffer); } - config.setCapsPFD(capabilities, pfd, pixelFormat); + config.setCapsPFD(capabilities, pfd, pixelFormat, choosenBywGLPixelFormat); } protected static String getThreadName() { diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java index a173baff0..18dc7dae3 100755 --- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -59,7 +59,7 @@ public class WindowsWindow extends Window { hmon = MonitorFromWindow(windowHandle); if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { Exception e = new Exception("!!! Window new surface handle "+Thread.currentThread().getName()+ - ",HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon)); + ", HWND 0x"+Long.toHexString(windowHandle)+", HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon)); e.printStackTrace(); } } @@ -105,6 +105,11 @@ public class WindowsWindow extends Window { throw new NativeWindowException("Error creating window"); } windowHandleClose = windowHandle; + if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { + Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+ + ", HWND 0x"+Long.toHexString(windowHandle)); + e.printStackTrace(); + } } protected void closeNative() { -- cgit v1.2.3 From 4e0a5af0b359b98b26ea3e961d023c658650be6c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 1 Aug 2009 05:37:29 -0700 Subject: GL3 Related: - Fix glGetStringi's return type to String - Fix ExtensionAvailabilityCache: GL3's glGetStringi for GL_EXTENSIONS Ensure to add GL_VERSION_2_0 in case version >= 3.0 Ensure to not exceed version 3.0 for non GL3.1 context. In case of GL 3.1, do not include GL_VERSIONS below 3.0, since this is a forward compatible context. - Add Prologue to glGetString, where the ExtensionCache is being used for GL_EXTENSIONS - if already initialized. This feature adds backward compatibility for GL3 context on GL_EXTENSION. +++ General: Add GLPipelineFactory, a convenient pipeline factory for Debug/Trace and custom ones .. Change 'void setGL(GL)' to 'GL setGL(GL)', and let it return the successful set GL, or null. --- make/config/jogl/gl-common.cfg | 9 + make/config/jogl/gl-gl2es12.cfg | 2 +- .../opengl/impl/ExtensionAvailabilityCache.java | 178 +++++++++++++++---- .../classes/com/sun/opengl/impl/GLContextImpl.java | 26 ++- .../classes/com/sun/opengl/impl/GLPbufferImpl.java | 4 +- .../opengl/util/glsl/fixedfunc/FixedFuncUtil.java | 15 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 5 +- src/jogl/classes/javax/media/opengl/GLContext.java | 4 +- .../javax/media/opengl/GLPipelineFactory.java | 195 +++++++++++++++++++++ .../classes/javax/media/opengl/awt/GLCanvas.java | 4 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 4 +- .../com/sun/javafx/newt/opengl/GLWindow.java | 4 +- 12 files changed, 405 insertions(+), 45 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/GLPipelineFactory.java (limited to 'make/config/jogl/gl-common.cfg') diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index a26c6a6b3..269ea68a7 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -230,6 +230,7 @@ IgnoreExtension GL_EXT_texture_rectangle Opaque boolean GLboolean ReturnsString glGetString +ReturnsString glGetStringi # Experimental: Only NIO function, no arrays .. # NIOOnly __ALL__ @@ -323,6 +324,14 @@ ArgumentIsString glTransformFeedbackVaryings 2 # ArgumentIsString glGetShaderSource 3 # ArgumentIsString glGetTransformFeedbackVarying 6 +# +# Use cached GL_EXTENSION if possible, +# which also allows GL3 compatibility. +# +JavaPrologue glGetString if(GL.GL_EXTENSIONS==name && _context.isExtensionCacheInitialized()) { +JavaPrologue glGetString return _context.getGLExtensions(); +JavaPrologue glGetString } + # # Directives for Vertex Buffer Object and Pixel Buffer Object checking # diff --git a/make/config/jogl/gl-gl2es12.cfg b/make/config/jogl/gl-gl2es12.cfg index 27fa138d4..36bab82ed 100644 --- a/make/config/jogl/gl-gl2es12.cfg +++ b/make/config/jogl/gl-gl2es12.cfg @@ -13,10 +13,10 @@ ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GL Style ImplOnly ImplPackage com.sun.opengl.impl.gl2es12 ImplJavaClass GL2ES12Impl +Implements GL2ES12Impl GLBase Implements GL2ES12Impl GL Implements GL2ES12Impl GL2ES1 Implements GL2ES12Impl GL2ES2 -Implements GL2ES12Impl GLBase Include gl-common-gl2.cfg Include gl-common-extensions.cfg diff --git a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java index eee308088..7931f791b 100644 --- a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java @@ -65,7 +65,25 @@ public final class ExtensionAvailabilityCache { */ public void flush() { + if(DEBUG) { + System.out.println("ExtensionAvailabilityCache: Flush availability OpenGL "+majorVersion+"."+minorVersion); + } availableExtensionCache.clear(); + initialized = false; + majorVersion = 1; + minorVersion = 0; + } + + /** + * Flush the cache and rebuild the cache. + */ + public void reset() { + flush(); + initAvailableExtensions(); + } + + public boolean isInitialized() { + return initialized && !availableExtensionCache.isEmpty() ; } public boolean isExtensionAvailable(String glExtensionName) { @@ -73,19 +91,101 @@ public final class ExtensionAvailabilityCache { return availableExtensionCache.contains(mapGLExtensionName(glExtensionName)); } - protected void initAvailableExtensions() { + public String getPlatformExtensionsString() { + initAvailableExtensions(); + return glXExtensions; + } + + public String getGLExtensions() { + initAvailableExtensions(); + if(DEBUG) { + System.err.println("ExtensionAvailabilityCache: getGLExtensions() called"); + } + return glExtensions; + } + + public int getMajorVersion() { + initAvailableExtensions(); + return majorVersion; + } + + public int getMinorVersion() { + initAvailableExtensions(); + return minorVersion; + } + + private void initAvailableExtensions() { // if hash is empty (meaning it was flushed), pre-cache it with the list // of extensions that are in the GL_EXTENSIONS string - if (availableExtensionCache.isEmpty()) { + if (availableExtensionCache.isEmpty() || !initialized) { GL gl = context.getGL(); + if (DEBUG) { - System.err.println("!!! Pre-caching extension availability"); + System.err.println("ExtensionAvailabilityCache: Pre-caching init "+gl+", GL_VERSION "+gl.glGetString(GL.GL_VERSION)); + } + + // Set version + Version version = new Version(gl.glGetString(GL.GL_VERSION)); + if (version.isValid()) { + majorVersion = version.getMajor(); + minorVersion = version.getMinor(); + + if( !gl.isGL3() && + ( majorVersion > 3 || + ( majorVersion == 3 && minorVersion >= 1 ) ) ) { + // downsize version to 3.0 in case we are not using GL3 (3.1) + majorVersion = 3; + minorVersion = 0; + } } - String allAvailableExtensions = - gl.glGetString(GL.GL_EXTENSIONS) + " " + context.getPlatformExtensionsString(); + + boolean useGetStringi = false; + + if ( majorVersion > 3 || + ( majorVersion == 3 && minorVersion >= 0 ) || + gl.isGL3() ) { + if ( ! gl.isGL2GL3() ) { + if(DEBUG) { + System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no GL2GL3 interface: "+gl.getClass().getName()); + } + } else if ( ! gl.isFunctionAvailable("glGetStringi") ) { + if(DEBUG) { + System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no glGetStringi"); + } + } else { + useGetStringi = true; + } + } + if (DEBUG) { - System.err.println("!!! Available extensions: " + allAvailableExtensions); - System.err.println("!!! GL vendor: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("ExtensionAvailabilityCache: Pre-caching extension availability OpenGL "+majorVersion+"."+minorVersion+ + ", use "+ ( useGetStringi ? "glGetStringi" : "glGetString" ) ); + } + + StringBuffer sb = new StringBuffer(); + if(useGetStringi) { + GL2GL3 gl2gl3 = gl.getGL2GL3(); + int[] numExtensions = { 0 } ; + gl2gl3.glGetIntegerv(gl2gl3.GL_NUM_EXTENSIONS, numExtensions, 0); + for (int i = 0; i < numExtensions[0]; i++) { + sb.append(gl2gl3.glGetStringi(gl2gl3.GL_EXTENSIONS, i)); + if(i < numExtensions[0]) { + sb.append(" "); + } + } + } else { + sb.append(gl.glGetString(GL.GL_EXTENSIONS)); + } + glExtensions = sb.toString(); + glXExtensions = context.getPlatformExtensionsString(); + + sb.append(" "); + sb.append(glXExtensions); + + String allAvailableExtensions = sb.toString(); + if (DEBUG_AVAILABILITY) { + System.err.println("ExtensionAvailabilityCache: Available extensions: " + allAvailableExtensions); + System.err.println("ExtensionAvailabilityCache: GL vendor: " + gl.glGetString(GL.GL_VENDOR)); } StringTokenizer tok = new StringTokenizer(allAvailableExtensions); while (tok.hasMoreTokens()) { @@ -93,42 +193,53 @@ public final class ExtensionAvailabilityCache { availableExt = availableExt.intern(); availableExtensionCache.add(availableExt); if (DEBUG_AVAILABILITY) { - System.err.println("!!! Available: " + availableExt); + System.err.println("ExtensionAvailabilityCache: Available: " + availableExt); } } // Put GL version strings in the table as well - Version version = new Version(gl.glGetString(GL.GL_VERSION)); - if (version.isValid()) { - int major = version.getMajor(); - int minor = version.getMinor(); - // FIXME: this needs to be adjusted when the major rev changes - // beyond the known ones - while (major > 0) { - while (minor >= 0) { - availableExtensionCache.add("GL_VERSION_" + major + "_" + minor); - if (DEBUG) { - System.err.println("!!! Added GL_VERSION_" + major + "_" + minor + " to known extensions"); - } - --minor; + // FIXME: this needs to be adjusted when the major rev changes + // beyond the known ones + int major = majorVersion; + int minor = minorVersion; + while (major > 0) { + while (minor >= 0) { + availableExtensionCache.add("GL_VERSION_" + major + "_" + minor); + if (DEBUG) { + System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions"); } + --minor; + } - switch (major) { - case 2: - // Restart loop at version 1.5 - minor = 5; - break; - case 1: - break; + switch (major) { + case 2: + if(gl.isGL3() && major==2) { + // GL3 is a GL 3.1 forward compatible context, + // hence no 2.0, 1.0 - 1.5 GL versions are supported. + major=0; + } else { + // make sure 2.0 is added .. + minor = 0; + availableExtensionCache.add("GL_VERSION_" + major + "_" + minor); + if (DEBUG) { + System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions"); + } } - - --major; + // Restart loop at version 1.5 + minor = 5; + break; + case 1: + break; } + + --major; } // put a dummy var in here so that the cache is no longer empty even if // no extensions are in the GL_EXTENSIONS string availableExtensionCache.add(""); + + initialized = true; } } @@ -146,6 +257,11 @@ public final class ExtensionAvailabilityCache { // Internals only below this point // + private boolean initialized = false; + private int majorVersion = 1; + private int minorVersion = 0; + private String glExtensions = null; + private String glXExtensions = null; private HashSet availableExtensionCache = new HashSet(50); private GLContextImpl context; @@ -236,7 +352,7 @@ public final class ExtensionAvailabilityCache { { // FIXME: refactor desktop OpenGL dependencies and make this // class work properly for OpenGL ES - System.err.println("FunctionAvailabilityCache.Version.: "+e); + System.err.println("ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.: "+e); major = 1; minor = 0; /* diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java index fa7e1ade7..16eb934bd 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java @@ -228,7 +228,7 @@ public abstract class GLContextImpl extends GLContext { return gl; } - public void setGL(GL gl) { + public GL setGL(GL gl) { if(DEBUG) { String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String(""); String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():new String(""); @@ -236,6 +236,7 @@ public abstract class GLContextImpl extends GLContext { e.printStackTrace(); } this.gl = gl; + return gl; } public abstract Object getPlatformGLExtensions(); @@ -354,7 +355,6 @@ public abstract class GLContextImpl extends GLContext { if(null==this.gl) { throw new GLException("setGLFunctionAvailability not called yet"); } - extensionAvailability.flush(); if (DEBUG) { System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table for " + this); } @@ -364,6 +364,8 @@ public abstract class GLContextImpl extends GLContext { // share them among contexts with the same capabilities } resetProcAddressTable(getGLProcAddressTable()); + + extensionAvailability.reset(); } /** @@ -426,6 +428,26 @@ public abstract class GLContextImpl extends GLContext { return extensionAvailability.isExtensionAvailable(mapToRealGLExtensionName(glExtensionName)); } + public String getPlatformExtensionsString() { + return extensionAvailability.getPlatformExtensionsString(); + } + + public String getGLExtensions() { + return extensionAvailability.getGLExtensions(); + } + + public int getMajorVersion() { + return extensionAvailability.getMajorVersion(); + } + + public int getMinorVersion() { + return extensionAvailability.getMinorVersion(); + } + + public boolean isExtensionCacheInitialized() { + return extensionAvailability.isInitialized(); + } + /** Indicates which floating-point pbuffer implementation is in use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT, or GLPbuffer.NV_FLOAT. */ diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java index e414fbc8e..8aba26fc6 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java @@ -129,8 +129,8 @@ public class GLPbufferImpl implements GLPbuffer { return getContext().getGL(); } - public void setGL(GL gl) { - getContext().setGL(gl); + public GL setGL(GL gl) { + return getContext().setGL(gl); } public void setAutoSwapBufferMode(boolean onOrOff) { diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java index 9c8a65173..4149aec69 100644 --- a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java +++ b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java @@ -14,12 +14,12 @@ import com.sun.opengl.util.glsl.fixedfunc.impl.*; */ public class FixedFuncUtil { /** - * @return If gl is a GL2ES1, return the type cast object, + * @return If gl is a GL2ES1 and force is false, return the type cast object, * otherwise create a fixed function emulation pipeline with the GL2ES2 impl. * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2 */ - public static final GL2ES1 getFixedFuncImpl(GL gl) { - if(gl.isGL2ES1()) { + public static final GL2ES1 getFixedFuncImpl(GL gl, boolean force) { + if(!force && gl.isGL2ES1()) { return gl.getGL2ES1(); } else if(gl.isGL2ES2()) { GL2ES2 es2 = gl.getGL2ES2(); @@ -31,6 +31,15 @@ public class FixedFuncUtil { throw new GLException("GL Object is neither GL2ES1 nor GL2ES2"); } + /** + * @return If gl is a GL2ES1, return the type cast object, + * otherwise create a fixed function emulation pipeline with the GL2ES2 impl. + * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2 + */ + public static final GL2ES1 getFixedFuncImpl(GL gl) { + return getFixedFuncImpl(gl, false); + } + /** * Mapping fixed function (client) array indices to * GLSL array attribute names. diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 43347c416..a94c14f33 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -208,6 +208,7 @@ public interface GLAutoDrawable extends GLDrawable { This should only be called from within the GLEventListener's callback methods, and usually only from within the init() method, in order to install a composable pipeline. See the JOGL - demos for examples. */ - public void setGL(GL gl); + demos for examples. + @return the set GL pipeline or null if not successful */ + public GL setGL(GL gl); } diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index a2bff729a..8ff52b6e9 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -205,8 +205,10 @@ public abstract class GLContext { /** * Sets the GL pipeline object for this GLContext. + * + * @return the set GL pipeline or null if not successful */ - public abstract void setGL(GL gl); + public abstract GL setGL(GL gl); /** * Returns the attached user object for the given name to this GLContext. diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java new file mode 100644 index 000000000..bb9f86911 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +package javax.media.opengl; + +import java.lang.reflect.*; +import java.util.StringTokenizer; + +import com.sun.opengl.impl.*; + +/** + * Factory for pipelining GL instances + */ +public class GLPipelineFactory { + public static final boolean DEBUG = Debug.debug("GLPipelineFactory"); + + /** + * Creates a pipelined GL instance using the given downstream downstream + * and optional arguments additionalArgs for the constructor.
+ * + * The upstream GL instance is determined as follows: + *


+ * + * @arg pipelineClazzBaseName the basename of the pipline class name + * @arg reqInterface optional requested interface to be used, may be null, in which case the first matching one is used + * @arg downstream is always the 1st argument for the upstream constructor + * @arg additionalArgs additional arguments for the upstream constructor + */ + public static final GL create(String pipelineClazzBaseName, Class reqInterface, GL downstream, Object[] additionalArgs) { + Class downstreamClazz = downstream.getClass(); + Class upstreamClazz = null; + Class interfaceClazz = null; + + if(DEBUG) { + System.out.println("GLPipelineFactory: Start "+downstreamClazz.getName()+", req. Interface: "+reqInterface+" -> "+pipelineClazzBaseName); + } + + // For all classes: child -> parent + do { + // For all interfaces: right -> left == child -> parent + // It is important that this matches with the gluegen cfg file's 'Implements' clause ! + Class[] clazzes = downstreamClazz.getInterfaces(); + for(int i=clazzes.length-1; null==upstreamClazz && i>=0; i--) { + if(DEBUG) { + System.out.println("GLPipelineFactory: Try "+downstreamClazz.getName()+" Interface["+i+"]: "+clazzes[i].getName()); + } + if( reqInterface != null && !reqInterface.getName().equals(clazzes[i].getName()) ) { + if(DEBUG) { + System.out.println("GLPipelineFactory: requested Interface "+reqInterface+" is _not_ "+ clazzes[i].getName()); + } + continue; // not the requested one .. + } + if( ! clazzes[i].isInstance(downstream) ) { + if(DEBUG) { + System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " is _not_ instance of "+ clazzes[i].getName()); + } + continue; // not a compatible one + } else { + if(DEBUG) { + System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " _is_ instance of "+ clazzes[i].getName()); + } + } + upstreamClazz = getUpstreamClazz(clazzes[i], pipelineClazzBaseName); + if( null != upstreamClazz ) { + interfaceClazz = clazzes[i]; + } + } + + if(null==upstreamClazz) { + downstreamClazz = downstreamClazz.getSuperclass(); + } + } while (null!=downstreamClazz && null==upstreamClazz); + + + if(null==upstreamClazz) { + throw new GLException("No pipeline ("+pipelineClazzBaseName+"*) available for :"+downstream.getClass().getName()); + } + + if(DEBUG) { + System.out.println("GLPipelineFactory: Got : "+ upstreamClazz.getName()+", base interface: "+interfaceClazz.getName()); + } + + Class[] cstrArgTypes = new Class[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ; + { + int i = 0; + cstrArgTypes[i++] = interfaceClazz; + for(int j=0; null!=additionalArgs && j Date: Sun, 2 Aug 2009 03:49:31 -0700 Subject: Update OpenGL GL2 profile subsumed/promoted extensions. Base is 3.0, ignore the colission-free subsumed extensions. --- make/config/jogl/gl-common.cfg | 63 +++++++++++++++++++++- make/config/jogl/gl-gl2.cfg | 2 + make/config/jogl/gl-if-CustomJavaCode-gl2.java | 40 ++++++++++++++ make/config/jogl/gl-impl-CustomJavaCode-gl2.java | 1 + make/doc/jogl/spec-overview.html | 26 ++++++--- .../javax/media/opengl/GLPipelineFactory.java | 9 ++-- 6 files changed, 128 insertions(+), 13 deletions(-) create mode 100644 make/config/jogl/gl-if-CustomJavaCode-gl2.java (limited to 'make/config/jogl/gl-common.cfg') diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 269ea68a7..3e38aa0da 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -133,6 +133,7 @@ IgnoreExtension GL_EXT_coordinate_frame # Ignore discontinued extensions IgnoreExtension GL_NV_element_array +# >>> OpenGL 1.1 # Ignore extensions subsumed in OpenGL 1.1 (from OpenGL 1.1 spec, Appendix C) IgnoreExtension GL_EXT_vertex_array IgnoreExtension GL_EXT_blend_logic_op @@ -141,7 +142,9 @@ IgnoreExtension GL_EXT_polygon_offset IgnoreExtension GL_EXT_subtexture IgnoreExtension GL_EXT_texture IgnoreExtension GL_EXT_texture_object +# <<< OpenGL 1.1 +# >>> OpenGL 1.2 # Ignore extensions subsumed in OpenGL 1.2 and 1.2.1 (from OpenGL 1.2.1 spec, Appendix D) IgnoreExtension GL_EXT_bgra IgnoreExtension GL_EXT_blend_color @@ -163,7 +166,9 @@ IgnoreExtension GL_SGI_color_matrix IgnoreExtension GL_SGI_color_table IgnoreExtension GL_SGIS_texture_edge_clamp IgnoreExtension GL_SGIS_texture_lod +# <<< OpenGL 1.2 +# >>> OpenGL 1.3 # Ignore extensions subsumed in OpenGL 1.3 (from OpenGL 1.3 spec, Appendix F) IgnoreExtension GL_ARB_multisample IgnoreExtension GL_ARB_multitexture @@ -179,7 +184,9 @@ IgnoreExtension GL_EXT_texture_env_add IgnoreExtension GL_EXT_texture_env_combine IgnoreExtension GL_EXT_texture_env_dot3 IgnoreExtension GL_SGIS_texture_border_clamp +# <<< OpenGL 1.3 +# >>> OpenGL 1.4 # Ignore extensions subsumed in OpenGL 1.4 (from OpenGL 1.4 spec, Appendix G) IgnoreExtension GL_ARB_depth_texture IgnoreExtension GL_ARB_point_parameters @@ -195,29 +202,81 @@ IgnoreExtension GL_EXT_secondary_color IgnoreExtension GL_EXT_stencil_wrap IgnoreExtension GL_NV_blend_square IgnoreExtension GL_SGIS_generate_mipmap +# <<< OpenGL 1.4 +# >>> OpenGL 1.5 # Ignore extensions subsumed in OpenGL 1.5 (from OpenGL 1.5 spec, Appendix H) IgnoreExtension GL_ARB_occlusion_query IgnoreExtension GL_ARB_vertex_buffer_object IgnoreExtension GL_EXT_shadow_funcs +# <<< OpenGL 1.5 +# >>> OpenGL 2.0 # Ignore extensions subsumed in OpenGL 2.0 (from OpenGL 2.0 spec, Appendix I) # NOTE that GL_ARB_shader_objects is NOT ignored here, because the # naming convention is too different for us to pick up the entry # points automatically (e.g. glCreateShaderObjectARB was exposed as # glCreateShader) +# IgnoreExtension GL_ARB_shader_objects IgnoreExtension GL_ARB_vertex_shader IgnoreExtension GL_ARB_fragment_shader -IgnoreExtension GL_ARB_draw_buffers IgnoreExtension GL_ARB_texture_non_power_of_two IgnoreExtension GL_ARB_point_sprite +IgnoreExtension GL_ARB_draw_buffers IgnoreExtension GL_EXT_blend_equation_separate # Don't ignore the following one since the entry point is different from anything in the core # IgnoreExtension GL_EXT_stencil_two_side +# <<< OpenGL 2.0 +# >>> OpenGL 2.1 # Ignore extensions subsumed in OpenGL 2.1 (from OpenGL 2.1 spec, Appendix J) IgnoreExtension GL_ARB_pixel_buffer_object IgnoreExtension GL_EXT_texture_sRGB +# <<< OpenGL 2.1 + +# >>> OpenGL 3.0 +# Ignore extensions subsumed in OpenGL 3.0 (from OpenGL 3.0 spec, Appendix N) +IgnoreExtension GL_EXT_gpu_shader4 + +IgnoreExtension GL_NV_conditional_render + +#Not promoted in header files: GL_APPLE_flush_buffer_range + +IgnoreExtension GL_ARB_color_buffer_float +#Not promoted in header files: GL_NV_depth_buffer_float +IgnoreExtension GL_ARB_texture_float +IgnoreExtension GL_EXT_packed_float +IgnoreExtension GL_EXT_texture_shared_exponent + +IgnoreExtension GL_EXT_framebuffer_object + +# GL_NV_half_float, GL_NV_half_float_pixel: these are also not usable for Java .. +IgnoreExtension GL_NV_half_float +IgnoreExtension GL_NV_half_float_pixel + +IgnoreExtension GL_EXT_framebuffer_multisample +IgnoreExtension GL_EXT_framebuffer_blit + +#Big gap of promoted tokens and functions: GL_EXT_texture_integer + +IgnoreExtension GL_EXT_texture_array + +IgnoreExtension GL_EXT_packed_depth_stencil + +#Not promoted in header files: GL_EXT_draw_buffers2 + +IgnoreExtension GL_EXT_texture_compression_rgtc + +IgnoreExtension GL_EXT_transform_feedback +IgnoreExtension GL_NV_transform_feedback + +IgnoreExtension GL_APPLE_vertex_array_object + +IgnoreExtension GL_EXT_framebuffer_sRGB + +# <<< OpenGL 3.0 + + # Ignore a few obsolete versions of extensions that have been subsumed into the core or ARB extensions IgnoreExtension GL_EXT_multisample @@ -536,7 +595,7 @@ ClassJavadoc GL2 *

ClassJavadoc GL2 * This interface contains all core desktop OpenGL methods through ClassJavadoc GL2 * version 3.0, inclusive, as well as most of it's extensions defined at the ClassJavadoc GL2 * time of this specification. Early OpenGL extensions whose functionality -ClassJavadoc GL2 * was incorporated into core OpenGL by version 2.0, inclusive, are specifically +ClassJavadoc GL2 * was incorporated into core OpenGL by version 3.0, inclusive, are specifically ClassJavadoc GL2 * excluded. ClassJavadoc GL2 *

ClassJavadoc GL2 */ diff --git a/make/config/jogl/gl-gl2.cfg b/make/config/jogl/gl-gl2.cfg index 55f5b9781..7b689093a 100644 --- a/make/config/jogl/gl-gl2.cfg +++ b/make/config/jogl/gl-gl2.cfg @@ -43,6 +43,8 @@ IgnoreExtension GL_EXT_point_parameters CustomJavaCode GL2 public boolean glIsPBOPackEnabled(); CustomJavaCode GL2 public boolean glIsPBOUnpackEnabled(); +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl2.java + CustomJavaCode GL2Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { CustomJavaCode GL2Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl2.java b/make/config/jogl/gl-if-CustomJavaCode-gl2.java new file mode 100644 index 000000000..fe6388cbe --- /dev/null +++ b/make/config/jogl/gl-if-CustomJavaCode-gl2.java @@ -0,0 +1,40 @@ + +/** Missed in the GL_EXT_gpu_shader4 promotion to 3.0 core */ +public static final int GL_SAMPLER_BUFFER_EXT = 0x8DC2; +/** Missed in the GL_EXT_gpu_shader4 promotion to 3.0 core */ +public static final int GL_INT_SAMPLER_2D_RECT_EXT = 0x8DCD; +/** Missed in the GL_EXT_gpu_shader4 promotion to 3.0 core */ +public static final int GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT = 0x8DD5; +/** Missed in the GL_EXT_gpu_shader4 promotion to 3.0 core */ +public static final int GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT = 0x8DD8; +/** Missed in the GL_EXT_gpu_shader4 promotion to 3.0 core */ +public static final int GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT = 0x88FD; + +/** Missed in the GL_ARB_color_buffer_float promotion to 3.0 core */ +public static final int GL_RGBA_FLOAT_MODE_ARB = 0x8820; + +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_ALPHA32F_ARB = 0x8816; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_INTENSITY32F_ARB = 0x8817; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_LUMINANCE32F_ARB = 0x8818; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_ALPHA16F_ARB = 0x881C; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_INTENSITY16F_ARB = 0x881D; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_LUMINANCE16F_ARB = 0x881E; +/** Missed in the GL_ARB_texture_float promotion to 3.0 core */ +public static final int GL_LUMINANCE_ALPHA16F_ARB = 0x881F; + +/** Missed in the GL_EXT_packed_float promotion to 3.0 core */ +public static final int GL_RGBA_SIGNED_COMPONENTS_EXT = 0x8C3C; + +/** Missed in the GL_EXT_texture_array promotion to 3.0 core */ +public static final int GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT = 0x884E; + +/** Missed in the GL_EXT_framebuffer_sRGB promotion to 3.0 core */ +public static final int GL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x8DBA; + + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2.java index 061830cb4..5928b3a0b 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2.java @@ -15,6 +15,7 @@ public void setObjectTracker(GLObjectTracker tracker) { */ + public GL2Impl(GLProfile glp, GLContextImpl context) { this._context = context; this.bufferSizeTracker = context.getBufferSizeTracker(); diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html index 4ee902719..f79e5ff23 100644 --- a/make/doc/jogl/spec-overview.html +++ b/make/doc/jogl/spec-overview.html @@ -53,7 +53,7 @@ bindings to the native OpenGL(R) 3D graphics library profiles: This interface contains all core desktop OpenGL methods through version 3.0, inclusive, as well as most of it's extensions defined at the time of this specification. Early OpenGL extensions whose functionality -was incorporated into core OpenGL by version 2.0, inclusive, are specifically +was incorporated into core OpenGL by version 3.0, inclusive, are specifically excluded.
Future extensions will be added with a maintenance update
@@ -304,11 +304,16 @@ according the following rules: