diff options
author | Kenneth Russel <[email protected]> | 2005-06-05 20:44:29 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-06-05 20:44:29 +0000 |
commit | 52860f43a13c1b3c92e776dce821f1da159ecd9c (patch) | |
tree | fbce37f62342f3d4547b55319a37e3cdb2afc56c /src/demos/jrefract | |
parent | 483803a232e95f1f3fa64883bd8fd668988b5b42 (diff) |
Got rid of useless copy of texture data pointed out by tomas on
javagaming.org forums
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@88 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/jrefract')
-rwxr-xr-x | src/demos/jrefract/JRefract.java | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/demos/jrefract/JRefract.java b/src/demos/jrefract/JRefract.java index bc7606f..f47cfda 100755 --- a/src/demos/jrefract/JRefract.java +++ b/src/demos/jrefract/JRefract.java @@ -618,36 +618,35 @@ public class JRefract { } private void makeRGBTexture(GL gl, GLU glu, BufferedImage img, int target, boolean mipmapped) { - ByteBuffer dest = null; switch (img.getType()) { case BufferedImage.TYPE_3BYTE_BGR: case BufferedImage.TYPE_CUSTOM: { byte[] data = ((DataBufferByte) img.getRaster().getDataBuffer()).getData(); - dest = ByteBuffer.allocateDirect(data.length); - dest.order(ByteOrder.nativeOrder()); - dest.put(data, 0, data.length); + if (mipmapped) { + glu.gluBuild2DMipmaps(target, GL.GL_RGB8, img.getWidth(), img.getHeight(), GL.GL_RGB, + GL.GL_UNSIGNED_BYTE, data); + } else { + gl.glTexImage2D(target, 0, GL.GL_RGB, img.getWidth(), img.getHeight(), 0, + GL.GL_RGB, GL.GL_UNSIGNED_BYTE, data); + } break; } case BufferedImage.TYPE_INT_RGB: { int[] data = ((DataBufferInt) img.getRaster().getDataBuffer()).getData(); - dest = ByteBuffer.allocateDirect(data.length * BufferUtils.SIZEOF_INT); - dest.order(ByteOrder.nativeOrder()); - dest.asIntBuffer().put(data, 0, data.length); + if (mipmapped) { + glu.gluBuild2DMipmaps(target, GL.GL_RGB8, img.getWidth(), img.getHeight(), GL.GL_RGB, + GL.GL_UNSIGNED_BYTE, data); + } else { + gl.glTexImage2D(target, 0, GL.GL_RGB, img.getWidth(), img.getHeight(), 0, + GL.GL_RGB, GL.GL_UNSIGNED_BYTE, data); + } break; } default: throw new RuntimeException("Unsupported image type " + img.getType()); } - - if (mipmapped) { - glu.gluBuild2DMipmaps(target, GL.GL_RGB8, img.getWidth(), img.getHeight(), GL.GL_RGB, - GL.GL_UNSIGNED_BYTE, dest); - } else { - gl.glTexImage2D(target, 0, GL.GL_RGB, img.getWidth(), img.getHeight(), 0, - GL.GL_RGB, GL.GL_UNSIGNED_BYTE, dest); - } } private void initExtension(GL gl, String glExtensionName) { |