summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-10-22 19:32:27 +0000
committerKenneth Russel <[email protected]>2005-10-22 19:32:27 +0000
commit80492a519b1db64c262bfb6a1370a57adcf38930 (patch)
treeecd04cbbbab8a26c682062a5a64a4fed5717db8c
parent0af8e0875209f2a9a2a61031bdc00401a6a808b2 (diff)
Fixed crash bug in HWShadowapsSimple demo caused by incorrect buffer JSR-231
offsets and implicit slicing (copied makeRGBTexture from VertexProgRefract demo) git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JSR-231@142 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
-rw-r--r--src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
index 69dd3db..0078df1 100644
--- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
+++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
@@ -477,36 +477,35 @@ public class HWShadowmapsSimple extends Demo {
}
private void makeRGBTexture(GL gl, 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, ByteBuffer.wrap(data));
+ } else {
+ gl.glTexImage2D(target, 0, GL.GL_RGB, img.getWidth(), img.getHeight(), 0,
+ GL.GL_RGB, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap(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, IntBuffer.wrap(data));
+ } else {
+ gl.glTexImage2D(target, 0, GL.GL_RGB, img.getWidth(), img.getHeight(), 0,
+ GL.GL_RGB, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(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 eye_linear_texgen(GL gl) {