From c6d6bcbcaceaa229944f380437a28af3a84f1dcd Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Fri, 8 Jul 2005 16:02:53 +0000 Subject: 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 --- src/net/java/games/jogl/impl/mipmap/Mipmap.java | 42 ++++++++++++++++++++-- .../games/jogl/impl/windows/WindowsGLContext.java | 12 +++---- .../jogl/impl/windows/WindowsPbufferGLContext.java | 18 +++++----- 3 files changed, 55 insertions(+), 17 deletions(-) (limited to 'src/net/java/games/jogl/impl') 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); -- cgit v1.2.3