diff options
author | Kenneth Russel <[email protected]> | 2008-05-13 11:50:41 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-05-13 11:50:41 +0000 |
commit | 0e27cbfe6f60f0c39e826fcf374b7e7e03babe4f (patch) | |
tree | 6bc223b9bb1d7474179a6ec9e89a14ebc0c4f371 /src/classes/com/sun/opengl/impl/egl | |
parent | 1f9c829513f1d6ca08081976bfed84822eecb385 (diff) |
Refactorings to support building JOGL for OpenGL ES 1 and OpenGL ES 2.
"ant -Djogl.es1=1" builds JOGL for OpenGL ES 1.
"ant -Djogl.es2=1" builds JOGL for OpenGL ES 2.
"ant" builds JOGL for desktop OpenGL (2.1).
Building desktop OpenGL is currently broken (FIXME) -- more
refactorings are necessary.
When compiling, it is currently necessary to specify
-Djogl.noglnatives=1 on the ant command line as well, because the
generated native code does not link properly since we do not have
OpenGL ES libraries on the desktop. Building the generated native code
using a cross-compiler is not yet hooked up into the ant build
mechanism. It is necessary to build the generated native code with
external tools.
Also incorporated spatialized audio framework using Windows waveOut
device; this is a temporary measure until a different workspace can be
found for this code.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1630 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/egl')
4 files changed, 476 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/classes/com/sun/opengl/impl/egl/EGLContext.java new file mode 100755 index 000000000..f1aa9172b --- /dev/null +++ b/src/classes/com/sun/opengl/impl/egl/EGLContext.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2008 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. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.opengl.impl.egl; + +import javax.media.opengl.*; +import com.sun.opengl.impl.*; +import java.nio.*; + +public abstract class EGLContext extends GLContextImpl { + public EGLContext(EGLDrawable drawable, GLContext shareWith) { + super(shareWith); + } + + public Object getPlatformGLExtensions() { + return null; + } + + public GLDrawable getGLDrawable() { + return null; + } + + public void copy(GLContext source, int mask) throws GLException { + throw new GLException("Not yet implemented"); + } + + public void bindPbufferToTexture() { + throw new GLException("Should not call this"); + } + + public void releasePbufferFromTexture() { + throw new GLException("Should not call this"); + } + + public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + throw new GLException("Should not call this"); + } + + protected String mapToRealGLFunctionName(String glFunctionName) { + return glFunctionName; + } + + protected String mapToRealGLExtensionName(String glExtensionName) { + return glExtensionName; + } + + public String getPlatformExtensionsString() { + return ""; + } + + public boolean offscreenImageNeedsVerticalFlip() { + throw new GLException("Should not call this"); + } + + public int getOffscreenContextPixelDataType() { + throw new GLException("Should not call this"); + } +} diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java new file mode 100755 index 000000000..2f0903a2b --- /dev/null +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2008 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. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.opengl.impl.egl; + +public class EGLDrawable { +} diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java new file mode 100755 index 000000000..06ba5b640 --- /dev/null +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2008 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. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.opengl.impl.egl; + +import javax.media.opengl.*; +import com.sun.opengl.impl.*; + +public class EGLDrawableFactory extends GLDrawableFactoryImpl { + static { + NativeLibLoader.loadCore(); + } + + public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + AbstractGraphicsDevice device) { + return null; + } + + public GLDrawable getGLDrawable(Object target, + GLCapabilities capabilities, + GLCapabilitiesChooser chooser) { + throw new GLException("Not yet implemented"); + } + + public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, + GLCapabilitiesChooser chooser) { + throw new GLException("Not yet implemented"); + } + + public boolean canCreateGLPbuffer() { + // Not supported on OpenGL ES + return false; + } + public GLPbuffer createGLPbuffer(final GLCapabilities capabilities, + final GLCapabilitiesChooser chooser, + final int initialWidth, + final int initialHeight, + final GLContext shareWith) { + throw new GLException("Pbuffer support not available on OpenGL ES"); + } + + public GLContext createExternalGLContext() { + return new EGLExternalContext(); + } + + public boolean canCreateExternalGLDrawable() { + return false; + } + + public GLDrawable createExternalGLDrawable() { + throw new GLException("Not yet implemented"); + } + + public void loadGLULibrary() { + } + + public long dynamicLookupFunction(String glFuncName) { + return 0; + /* + long res = WGL.wglGetProcAddress(glFuncName); + if (res == 0) { + // GLU routines aren't known to the OpenGL function lookup + if (hglu32 != 0) { + res = WGL.GetProcAddress(hglu32, glFuncName); + } + } + return res; + */ + } + + public void lockAWTForJava2D() { + } + + public void unlockAWTForJava2D() { + } + + public boolean canCreateContextOnJava2DSurface() { + return false; + } + + // FIXME: this is the OpenGL ES 2 initialization order + + // Initialize everything + public void initialize() throws GLException { + System.out.println("EGLDrawableFactory.initEGL()"); + if (!initEGL()) { + throw new GLException("EGL init failed"); + } + System.out.println("EGLDrawableFactory.chooseConfig()"); + if (!chooseConfig()) { + throw new GLException("EGL choose config failed"); + } + System.out.println("EGLDrawableFactory.checkDisplay()"); + if (!checkDisplay()) { + throw new GLException("EGL check display failed"); + } + System.out.println("EGLDrawableFactory.checkConfig()"); + if (!checkConfig()) { + throw new GLException("EGL check config failed"); + } + System.out.println("EGLDrawableFactory.createWindow()"); + if (!createWindow()) { + throw new GLException("KD window init failed"); + } + System.out.println("EGLDrawableFactory.setWindowVisible()"); + setWindowVisible(); + System.out.println("EGLDrawableFactory.setWindowFullscreen()"); + setWindowFullscreen(); + System.out.println("EGLDrawableFactory.realizeWindow()"); + if (!realizeWindow()) { + throw new GLException("EGL/GLES window realize failed"); + } + System.out.println("EGLDrawableFactory.createSurface()"); + if (!createSurface()) { + throw new GLException("EGL create window surface failed"); + } + System.out.println("EGLDrawableFactory.createContext()"); + if (!createContext()) { + throw new GLException("EGL create context failed"); + } + System.out.println("EGLDrawableFactory.makeCurrent()"); + if (!makeCurrent()) { + throw new GLException("EGL make current failed"); + } + System.out.println("EGLDrawableFactory.updateWindowSize()"); + updateWindowSize(); + } + + /* + + // FIXME: this is the OpenGL ES 1 initialization order + + // Initialize everything + public void initialize() throws GLException { + System.out.println("EGLDrawableFactory.initEGL()"); + if (!initEGL()) { + throw new GLException("EGL init failed"); + } + System.out.println("EGLDrawableFactory.chooseConfig()"); + if (!chooseConfig()) { + throw new GLException("EGL choose config failed"); + } + System.out.println("EGLDrawableFactory.checkDisplay()"); + if (!checkDisplay()) { + throw new GLException("EGL check display failed"); + } + System.out.println("EGLDrawableFactory.checkConfig()"); + if (!checkConfig()) { + throw new GLException("EGL check config failed"); + } + System.out.println("EGLDrawableFactory.createContext()"); + if (!createContext()) { + throw new GLException("EGL create context failed"); + } + // + // OpenKODE Core window system initialisation. + // + System.out.println("EGLDrawableFactory.createWindow()"); + if (!createWindow()) { + throw new GLException("KD window init failed"); + } + // System.out.println("EGLDrawableFactory.setWindowVisible()"); + // setWindowVisible(); + System.out.println("EGLDrawableFactory.setWindowFullscreen()"); + setWindowFullscreen(); + System.out.println("EGLDrawableFactory.realizeWindow()"); + if (!realizeWindow()) { + throw new GLException("EGL/GLES window realize failed"); + } + System.out.println("EGLDrawableFactory.createSurface()"); + if (!createSurface()) { + throw new GLException("EGL create window surface failed"); + } + System.out.println("EGLDrawableFactory.makeCurrent()"); + if (!makeCurrent()) { + throw new GLException("EGL make current failed"); + } + System.out.println("EGLDrawableFactory.updateWindowSize()"); + updateWindowSize(); + } + + */ + + // Process incoming events -- must be called every frame + public void processEvents() { + if (shouldExit()) { + shutdown(); + } + } + + public void swapBuffers() { + swapBuffers0(); + } + + private native boolean initEGL(); + private native boolean chooseConfig(); + private native boolean checkDisplay(); + private native boolean checkConfig(); + private native boolean createWindow(); + private native void setWindowVisible(); + private native void setWindowFullscreen(); + private native boolean realizeWindow(); + private native boolean createSurface(); + private native boolean createContext(); + private native boolean makeCurrent(); + private native void updateWindowSize(); + private native void swapBuffers0(); + + // Runs the native message loop one step and checks to see if we should exit + private native boolean shouldExit(); + public native void shutdown(); + + public void testGetDirectBufferAddress() { + java.nio.FloatBuffer buf = com.sun.opengl.util.BufferUtil.newFloatBuffer(12); + int addr = getDirectBufferAddress(buf); + System.out.println("Direct FloatBuffer's address: 0x" + Integer.toHexString(addr)); + } + public native int getDirectBufferAddress(java.nio.Buffer buf); + + /* + public GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith) + throws GLException { + throw new GLException("Unimplemented on this platform"); + } + */ +} diff --git a/src/classes/com/sun/opengl/impl/egl/EGLExternalContext.java b/src/classes/com/sun/opengl/impl/egl/EGLExternalContext.java new file mode 100755 index 000000000..6466c767d --- /dev/null +++ b/src/classes/com/sun/opengl/impl/egl/EGLExternalContext.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2008 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. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.opengl.impl.egl; + +import javax.media.opengl.*; +import com.sun.opengl.impl.*; + +public class EGLExternalContext extends EGLContext { + private boolean firstMakeCurrent = true; + private boolean created = true; + private GLContext lastContext; + + public EGLExternalContext() { + super(null, null); + GLContextShareSet.contextCreated(this); + resetGLFunctionAvailability(); + } + + public int makeCurrent() throws GLException { + // Save last context if necessary to allow external GLContexts to + // talk to other GLContexts created by this library + GLContext cur = getCurrent(); + if (cur != null && cur != this) { + lastContext = cur; + setCurrent(null); + } + return super.makeCurrent(); + } + + public void release() throws GLException { + super.release(); + setCurrent(lastContext); + lastContext = null; + } + + protected int makeCurrentImpl() throws GLException { + if (firstMakeCurrent) { + firstMakeCurrent = false; + return CONTEXT_CURRENT_NEW; + } + return CONTEXT_CURRENT; + } + + protected void releaseImpl() throws GLException { + } + + protected void destroyImpl() throws GLException { + created = false; + GLContextShareSet.contextDestroyed(this); + } + + public boolean isCreated() { + return created; + } +} |