Search in sources :

Example 91 with IntBuffer

use of java.nio.IntBuffer in project ArsMagica2 by Mithion.

the class AMGuiHelper method createFBO.

public static int createFBO(int textureID, int w, int h, boolean depthBuffer) {
    boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
    if (!FBOEnabled)
        return -1;
    // allocate a 1 int byte buffer
    IntBuffer buffer = ByteBuffer.allocateDirect(1 * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
    // generate
    EXTFramebufferObject.glGenFramebuffersEXT(buffer);
    int myFBOId = buffer.get();
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId);
    EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0);
    int framebuffer = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT);
    switch(framebuffer) {
        case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT:
            break;
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception");
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception");
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception");
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception");
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception");
        case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
            throw new RuntimeException("FrameBuffer: " + myFBOId + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception");
        default:
            throw new RuntimeException("Unexpected reply from glCheckFramebufferStatusEXT: " + framebuffer);
    }
    return myFBOId;
}
Also used : IntBuffer(java.nio.IntBuffer)

Example 92 with IntBuffer

use of java.nio.IntBuffer in project jmonkeyengine by jMonkeyEngine.

the class LodGenerator method makeLod.

private VertexBuffer makeLod(Mesh mesh) {
    VertexBuffer indexBuffer = mesh.getBuffer(VertexBuffer.Type.Index);
    boolean isShortBuffer = indexBuffer.getFormat() == VertexBuffer.Format.UnsignedShort;
    // Create buffers.	
    VertexBuffer lodBuffer = new VertexBuffer(VertexBuffer.Type.Index);
    int bufsize = indexCount == 0 ? 3 : indexCount;
    if (isShortBuffer) {
        lodBuffer.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.UnsignedShort, BufferUtils.createShortBuffer(bufsize));
    } else {
        lodBuffer.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.UnsignedInt, BufferUtils.createIntBuffer(bufsize));
    }
    lodBuffer.getData().rewind();
    //Check if we should fill it with a "dummy" triangle.
    if (indexCount == 0) {
        if (isShortBuffer) {
            for (int m = 0; m < 3; m++) {
                ((ShortBuffer) lodBuffer.getData()).put((short) 0);
            }
        } else {
            for (int m = 0; m < 3; m++) {
                ((IntBuffer) lodBuffer.getData()).put(0);
            }
        }
    }
    // Fill buffers.       
    Buffer buf = lodBuffer.getData();
    buf.rewind();
    for (Triangle triangle : triangleList) {
        if (!triangle.isRemoved) {
            //    assert (indexCount != 0);
            if (isShortBuffer) {
                for (int m = 0; m < 3; m++) {
                    ((ShortBuffer) buf).put((short) triangle.vertexId[m]);
                }
            } else {
                for (int m = 0; m < 3; m++) {
                    ((IntBuffer) buf).put(triangle.vertexId[m]);
                }
            }
        }
    }
    buf.clear();
    lodBuffer.updateData(buf);
    return lodBuffer;
}
Also used : VertexBuffer(com.jme3.scene.VertexBuffer) FloatBuffer(java.nio.FloatBuffer) ShortBuffer(java.nio.ShortBuffer) IntBuffer(java.nio.IntBuffer) Buffer(java.nio.Buffer) VertexBuffer(com.jme3.scene.VertexBuffer) IntBuffer(java.nio.IntBuffer) ShortBuffer(java.nio.ShortBuffer)

Example 93 with IntBuffer

use of java.nio.IntBuffer in project jmonkeyengine by jMonkeyEngine.

the class AndroidGL method glGetQueryObjectiv.

@Override
public int glGetQueryObjectiv(int query, int pname) {
    IntBuffer buff = IntBuffer.allocate(1);
    GLES30.glGetQueryiv(query, pname, buff);
    return buff.get(0);
}
Also used : IntBuffer(java.nio.IntBuffer)

Example 94 with IntBuffer

use of java.nio.IntBuffer in project jmonkeyengine by jMonkeyEngine.

the class AndroidGL method glGetQueryObjectui64.

@Override
public long glGetQueryObjectui64(int query, int pname) {
    IntBuffer buff = IntBuffer.allocate(1);
    //FIXME This is wrong IMO should be glGetQueryObjectui64v with a LongBuffer but it seems the API doesn't provide it.
    GLES30.glGetQueryObjectuiv(query, pname, buff);
    return buff.get(0);
}
Also used : IntBuffer(java.nio.IntBuffer)

Example 95 with IntBuffer

use of java.nio.IntBuffer in project jmonkeyengine by jMonkeyEngine.

the class JoalAL method alGenSources.

public int alGenSources() {
    IntBuffer ib = BufferUtils.createIntBuffer(1);
    joalAl.alGenSources(1, ib);
    return ib.get(0);
}
Also used : IntBuffer(java.nio.IntBuffer)

Aggregations

IntBuffer (java.nio.IntBuffer)286 ByteBuffer (java.nio.ByteBuffer)97 FloatBuffer (java.nio.FloatBuffer)47 ShortBuffer (java.nio.ShortBuffer)36 Test (org.junit.Test)35 Bitmap (android.graphics.Bitmap)18 DoubleBuffer (java.nio.DoubleBuffer)18 IOException (java.io.IOException)14 BaseTest (org.apache.jena.atlas.junit.BaseTest)14 FileOutputStream (java.io.FileOutputStream)13 CharBuffer (java.nio.CharBuffer)11 LongBuffer (java.nio.LongBuffer)11 UTF8CodePointDecoder (org.antlr.v4.runtime.UTF8CodePointDecoder)11 ArrayList (java.util.ArrayList)10 File (java.io.File)9 Buffer (java.nio.Buffer)9 VertexBuffer (com.jme3.scene.VertexBuffer)7 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)6 BufferOverflowException (java.nio.BufferOverflowException)6 FileChannel (java.nio.channels.FileChannel)6