diff options
author | Michael Bien <[email protected]> | 2010-03-30 14:01:15 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-03-30 14:01:15 +0200 |
commit | 44b93b2d63539bca4c7e3facfee90d5f3bbb67cf (patch) | |
tree | 528cb1b0c5e965cc07cfd390196caf05aba9aa7f /src/jogl/classes | |
parent | f250183bc3d8eb4ef87cecb3311eae554dcafe53 (diff) | |
parent | 62dcd1a3fe345c4d2c0e42472d2c7646fe224e8f (diff) |
Merge branch 'master' of github.com:mbien/jogl
Diffstat (limited to 'src/jogl/classes')
9 files changed, 58 insertions, 53 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java index 42d4588b5..ec2677559 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java @@ -158,13 +158,13 @@ public abstract class EGLContext extends GLContextImpl { long eglDisplay = ((EGLDrawable)drawable).getDisplay(); EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration(); GLProfile glProfile = drawable.getGLProfile(); - _EGLConfig eglConfig = config.getNativeConfig(); + long eglConfig = config.getNativeConfig(); long shareWith = EGL.EGL_NO_CONTEXT; if (eglDisplay == 0) { throw new GLException("Error: attempted to create an OpenGL context without a display connection"); } - if (eglConfig == null) { + if (eglConfig == 0) { throw new GLException("Error: attempted to create an OpenGL context without a graphics configuration"); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java index f3695ed16..db5ee6ac6 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java @@ -75,7 +75,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle); + protected abstract long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle); private void recreateSurface() { // create a new EGLSurface .. diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java index 33f9db140..43c99a422 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java @@ -41,12 +41,13 @@ import javax.media.nativewindow.egl.*; import javax.media.opengl.*; import com.jogamp.opengl.impl.*; import com.jogamp.gluegen.runtime.NativeLibrary; +import com.jogamp.gluegen.runtime.PointerBuffer; public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable { protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration"); - public _EGLConfig getNativeConfig() { - return _config; + public long getNativeConfig() { + return config; } public int getNativeConfigID() { @@ -55,10 +56,10 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple public EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen, GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser, - _EGLConfig cfg, int cfgID) { + long cfg, int cfgID) { super(absScreen, capsChosen, capsRequested); this.chooser = chooser; - _config = cfg; + config = cfg; configID = cfgID; } @@ -72,9 +73,9 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple throw new GLException("Invalid EGL display: "+absDevice); } GLProfile glp = capsRequested.getGLProfile(); - _EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID); - GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer()); - return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), _cfg, cfgID); + long cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID); + GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer()); + return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), cfg, cfgID); } public Object clone() { @@ -89,7 +90,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple if(null!=newConfig) { // FIXME: setScreen( ... ); setChosenCapabilities(newConfig.getChosenCapabilities()); - _config = newConfig.getNativeConfig(); + config = newConfig.getNativeConfig(); configID = newConfig.getNativeConfigID(); if(DEBUG) { System.err.println("!!! updateGraphicsConfiguration: "+this); @@ -97,23 +98,23 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple } } - public static _EGLConfig EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) { + public static long EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) { int[] attrs = new int[] { EGL.EGL_CONFIG_ID, configID, EGL.EGL_NONE }; - _EGLConfig[] configs = new _EGLConfig[1]; + PointerBuffer configs = PointerBuffer.allocateDirect(1); int[] numConfigs = new int[1]; if (!EGL.eglChooseConfig(display, attrs, 0, configs, 1, numConfigs, 0)) { - return null; + return 0; } if (numConfigs[0] == 0) { - return null; + return 0; } - return configs[0]; + return configs.get(0); } public static boolean EGLConfigDrawableTypeVerify(int val, boolean onscreen, boolean usePBuffer) { @@ -131,53 +132,53 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple return res; } - public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config, + public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config, boolean relaxed, boolean onscreen, boolean usePBuffer) { GLCapabilities caps = new GLCapabilities(glp); int[] val = new int[1]; // Read the actual configuration into the choosen caps - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_RED_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val, 0)) { caps.setRedBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_GREEN_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_GREEN_SIZE, val, 0)) { caps.setGreenBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_BLUE_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_BLUE_SIZE, val, 0)) { caps.setBlueBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_ALPHA_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_ALPHA_SIZE, val, 0)) { caps.setAlphaBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_STENCIL_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_STENCIL_SIZE, val, 0)) { caps.setStencilBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_DEPTH_SIZE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val, 0)) { caps.setDepthBits(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_SAMPLES, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SAMPLES, val, 0)) { caps.setSampleBuffers(val[0]>0?true:false); caps.setNumSamples(val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_TYPE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val, 0)) { caps.setBackgroundOpaque(val[0] != EGL.EGL_TRANSPARENT_RGB); } if(!caps.isBackgroundOpaque()) { - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_RED_VALUE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_RED_VALUE, val, 0)) { caps.setTransparentRedValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val, 0)) { caps.setTransparentGreenValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]); } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val, 0)) { caps.setTransparentBlueValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]); } /** Not defined in EGL - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val, 0)) { caps.setTransparentAlphaValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]); } */ } - if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_SURFACE_TYPE, val, 0)) { + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SURFACE_TYPE, val, 0)) { if(EGLConfigDrawableTypeVerify(val[0], onscreen, usePBuffer)) { caps.setDoubleBuffered(onscreen); caps.setOnscreen(onscreen); @@ -300,7 +301,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple } private GLCapabilitiesChooser chooser; - private _EGLConfig _config; + private long config; private int configID; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java index 0a9edd239..f315a514c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java @@ -40,6 +40,8 @@ import com.jogamp.nativewindow.impl.*; import javax.media.opengl.*; import com.jogamp.opengl.impl.*; +import com.jogamp.gluegen.runtime.PointerBuffer; + /** Subclass of GraphicsConfigurationFactory used when non-AWT tookits are used on X11 platforms. Toolkits will likely need to delegate to this one to change the accepted and returned types of the @@ -115,10 +117,10 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor chooser = new DefaultGLCapabilitiesChooser(); } - _EGLConfig[] configs = new _EGLConfig[10]; + PointerBuffer configs = PointerBuffer.allocateDirect(10); int[] numConfigs = new int[1]; - if(!EGL.eglGetConfigs(eglDisplay, configs, configs.length, numConfigs, 0)) { + if(!EGL.eglGetConfigs(eglDisplay, configs, configs.capacity(), numConfigs, 0)) { throw new GLException("Graphics configuration fetch (eglGetConfigs) failed"); } if (numConfigs[0] == 0) { @@ -205,11 +207,11 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor AbstractGraphicsScreen absScreen) { GLProfile glp = capsChosen0.getGLProfile(); int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen0); - _EGLConfig[] configs = new _EGLConfig[1]; + PointerBuffer configs = PointerBuffer.allocateDirect(1); int[] numConfigs = new int[1]; if (!EGL.eglChooseConfig(eglDisplay, attrs, 0, - configs, configs.length, + configs, configs.capacity(), numConfigs, 0)) { throw new GLException("Graphics configuration selection (eglChooseConfig) failed for "+capsChosen0); } @@ -222,14 +224,14 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor } int[] val = new int[1]; // get the configID - if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) { + if(!EGL.eglGetConfigAttrib(eglDisplay, configs.get(0), EGL.EGL_CONFIG_ID, val, 0)) { if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capsChosen0+", error 0x"+Integer.toHexString(EGL.eglGetError())); } return null; } - GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0], + GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs.get(0), true, capsChosen0.isOnscreen(), capsChosen0.isPBuffer()); if(null!=capsChosen1) { if(DEBUG) { @@ -237,7 +239,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor ", eglConfig ID 0x"+Integer.toHexString(val[0])+ ", "+capsChosen0+" -> "+capsChosen1); } - return new EGLGraphicsConfiguration(absScreen, capsChosen1, capsRequested, chooser, configs[0], val[0]); + return new EGLGraphicsConfiguration(absScreen, capsChosen1, capsRequested, chooser, configs.get(0), val[0]); } if(DEBUG) { System.err.println("eglChooseConfig couldn't verify: eglDisplay 0x"+Long.toHexString(eglDisplay)+ @@ -253,11 +255,11 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor return null; } - protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num, + protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, PointerBuffer configs, int num, boolean onscreen, boolean usePBuffer) { GLCapabilities[] caps = new GLCapabilities[num]; for(int i=0; i<num; i++) { - caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i], + caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs.get(i), true, onscreen, usePBuffer); } return caps; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java index 2f5bbf359..3286367e5 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java @@ -54,7 +54,7 @@ public class EGLOnscreenDrawable extends EGLDrawable { return new EGLOnscreenContext(this, shareWith); } - protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle) { + protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { return EGL.eglCreateWindowSurface(eglDpy, eglNativeCfg, surfaceHandle, null); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java index a86045789..03b02b77e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java @@ -73,7 +73,7 @@ public class EGLPbufferDrawable extends EGLDrawable { } - protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle) { + protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { NativeWindow nw = getNativeWindow(); int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat); long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java index 131375338..aacd2c38e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java @@ -6,6 +6,7 @@ import java.util.*; import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.impl.*; +import com.jogamp.gluegen.runtime.PointerBuffer; public class MacOSXPbufferCGLContext extends MacOSXCGLContext { protected MacOSXPbufferCGLDrawable drawable; @@ -312,29 +313,29 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { } // Use attribute array to select pixel format - long[] fmt = new long[1]; + PointerBuffer fmt = PointerBuffer.allocateDirect(1); long[] numScreens = new long[1]; - int res = CGL.CGLChoosePixelFormat(attrs, 0, fmt, 0, numScreens, 0); + int res = CGL.CGLChoosePixelFormat(attrs, 0, fmt, numScreens, 0); if (res != CGL.kCGLNoError) { throw new GLException("Error code " + res + " while choosing pixel format"); } // Create new context - long[] ctx = new long[1]; + PointerBuffer ctx = PointerBuffer.allocateDirect(1); if (DEBUG) { System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share)); } - res = CGL.CGLCreateContext(fmt[0], share, ctx, 0); - CGL.CGLDestroyPixelFormat(fmt[0]); + res = CGL.CGLCreateContext(fmt.get(0), share, ctx); + CGL.CGLDestroyPixelFormat(fmt.get(0)); if (res != CGL.kCGLNoError) { throw new GLException("Error code " + res + " while creating context"); } // Attach newly-created context to the pbuffer - res = CGL.CGLSetPBuffer(ctx[0], drawable.getPbuffer(), 0, 0, 0); + res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getPbuffer(), 0, 0, 0); if (res != CGL.kCGLNoError) { throw new GLException("Error code " + res + " while attaching context to pbuffer"); } - return ctx[0]; + return ctx.get(0); } public boolean destroy(long ctx) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index eb6de929d..95609aee5 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -42,6 +42,7 @@ package com.jogamp.opengl.impl.macosx.cgl; import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.impl.*; +import com.jogamp.gluegen.runtime.PointerBuffer; public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { private static final boolean DEBUG = Debug.debug("MacOSXPbufferCGLDrawable"); @@ -232,12 +233,12 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { // CGL implementation class CGLImpl implements Impl { public long create(int renderTarget, int internalFormat, int width, int height) { - long[] pbuffer = new long[1]; - int res = CGL.CGLCreatePBuffer(width, height, renderTarget, internalFormat, 0, pbuffer, 0); + PointerBuffer pbuffer = PointerBuffer.allocateDirect(1); + int res = CGL.CGLCreatePBuffer(width, height, renderTarget, internalFormat, 0, pbuffer); if (res != CGL.kCGLNoError) { throw new GLException("Error creating CGL-based pbuffer: error code " + res); } - return pbuffer[0]; + return pbuffer.get(0); } public void destroy(long pbuffer) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index e0c70bd8c..bf466d455 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -99,7 +99,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { } ((SurfaceChangeable)nw).setSurfaceHandle(hdc); - hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, 0, 0, 0); + hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, null, 0, 0); if (hbitmap == 0) { WGL.DeleteDC(hdc); hdc = 0; |