void executeRasterDepth(Context ctx, float posX, float posY, float posZ,
int srcOffsetX, int srcOffsetY, int rasterWidth, int rasterHeight,
int depthWidth, int depthHeight, int depthFormat, Object depthData) {
if (VERBOSE) System.err.println("JoglPipeline.executeRasterDepth()");
GLContext context = context(ctx);
GL2 gl = context.getGL().getGL2();
gl.glRasterPos3f(posX, posY, posZ);
int[] drawBuf = new int[1];
gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuf, 0);
/* disable draw buffer */
gl.glDrawBuffer(GL.GL_NONE);
/*
* raster position is upper left corner, default for Java3D
* ImageComponent currently has the data reverse in Y
*/
gl.glPixelZoom(1.0f, -1.0f);
gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, depthWidth);
if (srcOffsetX >= 0) {
gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, srcOffsetX);
if (srcOffsetX + rasterWidth > depthWidth) {
rasterWidth = depthWidth - srcOffsetX;
}
} else {
rasterWidth += srcOffsetX;
if (rasterWidth > depthWidth) {
rasterWidth = depthWidth;
}
}
if (srcOffsetY >= 0) {
gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, srcOffsetY);
if (srcOffsetY + rasterHeight > depthHeight) {
rasterHeight = depthHeight - srcOffsetY;
}
} else {
rasterHeight += srcOffsetY;
if (rasterHeight > depthHeight) {
rasterHeight = depthHeight;
}
}
if (depthFormat == DepthComponentRetained.DEPTH_COMPONENT_TYPE_INT) {
gl.glDrawPixels(rasterWidth, rasterHeight, GL2.GL_DEPTH_COMPONENT,
GL.GL_UNSIGNED_INT, IntBuffer.wrap((int[]) depthData));
} else { /* DepthComponentRetained.DEPTH_COMPONENT_TYPE_FLOAT */
gl.glDrawPixels(rasterWidth, rasterHeight, GL2.GL_DEPTH_COMPONENT,
GL.GL_FLOAT, FloatBuffer.wrap((float[]) depthData));
}
/* re-enable draw buffer */
gl.glDrawBuffer(drawBuf[0]);
gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, 0);
gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, 0);
gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, 0);
}