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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations