Example usage for org.lwjgl.opengl GL12 nglTexImage3D

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

Introduction

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

Prototype

public static void nglTexImage3D(int target, int level, int internalformat, int width, int height, int depth,
        int border, int format, int type, long pixels) 

Source Link

Document

Unsafe version of: #glTexImage3D TexImage3D

Usage

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

/**
 * Allocates space on the GPU for an image of the given size and format, but
 * does not upload any information./*from   w ww  . j  a  v  a2s.  co  m*/
 * 
 * @param width The width of the image.
 * @param height The height of the image.
 * @param depth The depth of the image.
 * @param format The format of the image.
 * @return This texture.
 */
public T image(int width, int height, int depth, int format) {
    if (width <= 0 || height <= 0 || depth <= 0)
        throw new IllegalArgumentException("Illegal image dimensions.");

    int baseFormat = TexUtil.getBaseFormat(format);
    if (baseFormat == -1)
        throw new IllegalArgumentException("Illegal image format.");

    int primType = TexUtil.getPrimitiveType(format);

    this.width = width;
    this.height = height;
    this.depth = depth;
    int oldID = tempBind();
    GL12.nglTexImage3D(target, 0, format, width, height, depth, 0, baseFormat, primType, MemoryUtil.NULL);
    tempUnbind(oldID);

    setVRAMUsage(TexUtil.getBits(format) * width * height * depth);

    return getThis();
}