diff options
author | Kenneth Russel <[email protected]> | 2005-07-08 16:02:53 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-08 16:02:53 +0000 |
commit | c6d6bcbcaceaa229944f380437a28af3a84f1dcd (patch) | |
tree | 5415f8a6a956de81ffe7abd01451f99c76f23824 /src/net | |
parent | 0fa2740c8c186b0908baa5b7629bef657fe38527 (diff) |
Fixed Windows port after changes to GlueGen to include array offsets.
Ported all demos to new API. Temporarily added back in GLU entry
points taking primitive arrays as the underlying APIs (in particular,
glTexImage2D) do not yet support non-direct Buffers. Changed C code
generation to only add in array offset if array is non-null. Fixed bug
in GLU tesselator demo's vertex callback.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@318 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net')
5 files changed, 68 insertions, 20 deletions
diff --git a/src/net/java/games/gluegen/CMethodBindingEmitter.java b/src/net/java/games/gluegen/CMethodBindingEmitter.java index 0c41d3aa2..5cf2833d9 100644 --- a/src/net/java/games/gluegen/CMethodBindingEmitter.java +++ b/src/net/java/games/gluegen/CMethodBindingEmitter.java @@ -702,9 +702,19 @@ public class CMethodBindingEmitter extends FunctionEmitter } // end of data copy if (EMIT_NULL_CHECKS) { - writer.println(" }"); - } + writer.print(" }"); + if (needsDataCopy) { + writer.println(); + } else { + // Zero out array offset in the case of a null pointer + // being passed down to prevent construction of arbitrary + // pointers + writer.println(" else {"); + writer.println(" " + binding.getArgumentName(i) + "_offset = 0;"); + writer.println(" }"); + } + } } else if (javaArgType.isString()) { if (emittingPrimitiveArrayCritical) { continue; diff --git a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java index 1790207a8..922f60794 100644 --- a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java +++ b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java @@ -148,7 +148,7 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter } else if (javaType.isArray() && !javaType.isNIOBufferArray() &&!javaType.isStringArray()) { String argName = binding.getArgumentName(i); String offsetArg = argName + "_offset"; - writer.println(" if(" + argName + ".length <= " + offsetArg + ")"); + writer.println(" if(" + argName + " != null && " + argName + ".length <= " + offsetArg + ")"); writer.print(" throw new " + getRuntimeExceptionType()); writer.println("(\"array offset argument \\\"" + offsetArg + "\\\" equals or exceeds array length\");"); } diff --git a/src/net/java/games/jogl/impl/mipmap/Mipmap.java b/src/net/java/games/jogl/impl/mipmap/Mipmap.java index 052d39fa2..8b697f37c 100644 --- a/src/net/java/games/jogl/impl/mipmap/Mipmap.java +++ b/src/net/java/games/jogl/impl/mipmap/Mipmap.java @@ -642,7 +642,26 @@ public class Mipmap { ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - } + } else if( data instanceof byte[] ) { + byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + } else if( data instanceof short[] ) { + short[] array = (short[])data; + buffer = ByteBuffer.allocateDirect( array.length * 2 ); + ShortBuffer sb = buffer.asShortBuffer(); + sb.put( array ); + } else if( data instanceof int[] ) { + int[] array = (int[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + IntBuffer ib = buffer.asIntBuffer(); + ib.put( array ); + } else if( data instanceof float[] ) { + float[] array = (float[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + FloatBuffer fb = buffer.asFloatBuffer(); + fb.put( array ); + } return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, width, height, format, type, userLevel, baseLevel, @@ -678,7 +697,26 @@ public class Mipmap { ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - } + } else if( data instanceof byte[] ) { + byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + } else if( data instanceof short[] ) { + short[] array = (short[])data; + buffer = ByteBuffer.allocateDirect( array.length * 2 ); + ShortBuffer sb = buffer.asShortBuffer(); + sb.put( array ); + } else if( data instanceof int[] ) { + int[] array = (int[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + IntBuffer ib = buffer.asIntBuffer(); + ib.put( array ); + } else if( data instanceof float[] ) { + float[] array = (float[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + FloatBuffer fb = buffer.asFloatBuffer(); + fb.put( array ); + } return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0, diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index e838c68aa..e938c8023 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -394,11 +394,11 @@ public abstract class WindowsGLContext extends GLContext { int[] pformats = new int[MAX_PFORMATS]; int[] numFormatsTmp = new int[1]; if (dummyGL.wglChoosePixelFormatARB(hdc, - iattributes, - fattributes, + iattributes, 0, + fattributes, 0, MAX_PFORMATS, - pformats, - numFormatsTmp)) { + pformats, 0, + numFormatsTmp, 0)) { numFormats = numFormatsTmp[0]; if (numFormats > 0) { // Remove one-basing of pixel format (added on later) @@ -434,7 +434,7 @@ public abstract class WindowsGLContext extends GLContext { // window, to a pbuffer, or to a pixmap) niattribs = 0; iattributes[0] = GL.WGL_NUMBER_PIXEL_FORMATS_ARB; - if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, iresults)) { + if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { numFormats = iresults[0]; // Should we be filtering out the pixel formats which aren't // applicable, as we are doing here? @@ -463,7 +463,7 @@ public abstract class WindowsGLContext extends GLContext { availableCaps = new GLCapabilities[numFormats]; for (int i = 0; i < numFormats; i++) { - if (!dummyGL.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, iresults)) { + if (!dummyGL.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] = iattributes2GLCapabilities(iattributes, iresults, niattribs, true); diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java index 1d5d78296..26108a5cd 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java @@ -261,11 +261,11 @@ public class WindowsPbufferGLContext extends WindowsGLContext { int nformats; int[] nformatsTmp = new int[1]; if (!gl.wglChoosePixelFormatARB(parentHdc, - iattributes, - fattributes, + iattributes, 0, + fattributes, 0, MAX_PFORMATS, - pformats, - nformatsTmp)) { + pformats, 0, + nformatsTmp, 0)) { throw new GLException("pbuffer creation error: wglChoosePixelFormatARB() failed"); } nformats = nformatsTmp[0]; @@ -287,7 +287,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { iattributes[8] = GL.WGL_DRAW_TO_PBUFFER_ARB; int[] ivalues = new int[9]; for (int i = 0; i < nformats; i++) { - if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, ivalues)) { + if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, 0, ivalues, 0)) { throw new GLException("Error while querying pixel format " + pformats[i] + "'s (index " + i + "'s) capabilities for debugging"); } @@ -349,7 +349,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { iattributes[niattribs++] = 0; - tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes); + tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes, 0); ++whichFormat; } while ((tmpBuffer == 0) && (whichFormat < nformats)); @@ -372,9 +372,9 @@ public class WindowsPbufferGLContext extends WindowsGLContext { // Determine the actual width and height we were able to create. int[] tmp = new int[1]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp ); + gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); width = tmp[0]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp ); + gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); height = tmp[0]; if (DEBUG) { @@ -431,7 +431,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { textureTarget = GL.GL_TEXTURE_2D; } int[] tmp = new int[1]; - gl.glGenTextures(1, tmp); + gl.glGenTextures(1, tmp, 0); texture = tmp[0]; gl.glBindTexture(textureTarget, texture); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); |