Example usage for org.lwjgl.opengl GL12 nglTexSubImage3D

List of usage examples for org.lwjgl.opengl GL12 nglTexSubImage3D

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL12 nglTexSubImage3D.

Prototype

public static void nglTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width,
        int height, int depth, int format, int type, long pixels) 

Source Link

Document

Unsafe version of: #glTexSubImage3D TexSubImage3D

Usage

From source file:com.samrj.devil.gl.Texture3DAbstract.java

/**
 * Overwrites the stored image layer with the given image. This texture must
 * already have allocated storage.//w  ww .  jav  a  2 s.c o m
 * 
 * @param image The image to overwrite the 
 * @param depth The image layer to overwrite.
 * @param format The texture format to store the image as.
 * @return This texture.
 */
public T subimage(Image image, int depth, int format) {
    if (image.deleted())
        throw new IllegalStateException("Image is deleted.");

    int dataFormat = TexUtil.getBaseFormat(format);
    if (image.bands != TexUtil.getBands(dataFormat))
        throw new IllegalArgumentException("Incompatible format bands.");

    if (depth < 0 || depth >= this.depth)
        throw new IllegalArgumentException("Illegal depth specified.");

    if (image.width != width || image.height != height)
        throw new IllegalArgumentException("Incompatible image dimensions.");

    int primType = TexUtil.getPrimitiveType(format);
    int oldID = tempBind();
    GL12.nglTexSubImage3D(target, 0, 0, 0, depth, width, height, 1, dataFormat, primType, image.address());
    tempUnbind(oldID);
    return getThis();
}