本文整理汇总了Java中com.jogamp.opengl.GL4.glCreateBuffers方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glCreateBuffers方法的具体用法?Java GL4.glCreateBuffers怎么用?Java GL4.glCreateBuffers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glCreateBuffers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize * 2, null,
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
uniformPointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, uniformBlockSize * 2,
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例2: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementSize);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glCreateBuffers(Buffer.MAX, bufferName);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize * 2, null, GL_MAP_WRITE_BIT
| GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
} else {
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize * 2, null, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT
| GL_MAP_COHERENT_BIT);
}
uniformPointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM), 0, uniformBlockSize * 2,
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return true;
}
示例3: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glCreateBuffers(Buffer.MAX, bufferName);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT);
} else {
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
return true;
}
示例4: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexSize);
for (int i = 0; i < vertexCount; i++) {
vertexData[i].toBb(vertexBuffer, i);
}
vertexBuffer.rewind();
if (bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
} else {
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
}
return true;
}
示例5: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT);
} else {
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
return true;
}
示例6: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glCreateBuffers(Buffer.MAX, bufferName);
gl4.glNamedBufferData(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glNamedBufferData(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glNamedBufferData(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_DYNAMIC_DRAW);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return true;
}
示例7: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize * 2, null, GL_MAP_WRITE_BIT
| GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
} else {
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize * 2, null, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT
| GL_MAP_COHERENT_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
uniformPointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM), 0, uniformBlockSize * 2,
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
return true;
}
示例8: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
Vec2[] data = new Vec2[36];
for (int i = 0; i < data.length; ++i) {
float angle = (float) Math.PI * 2.0f * i / data.length;
data[i] = new Vec2((float) Math.sin(angle), (float) Math.cos(angle)).normalize();
}
vertexCount = 18;//static_cast<GLsizei>(Data.size() - 8);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer dataBuffer = GLBuffers.newDirectFloatBuffer(data.length * Vec2.SIZE);
for (Vec2 data1 : data) {
dataBuffer.put(data1.x).put(data1.y);
}
dataBuffer.rewind();
if (bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), data.length * Vec2.SIZE, dataBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT);
} else {
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, dataBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
return true;
}
示例9: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
Vec4 material0 = new Vec4(1.0f, 0.5f, 0.0f, 1.0f);
Vec4 material1 = new Vec4(0.0f, 0.5f, 1.0f, 1.0f);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer material0Buffer = GLBuffers.newDirectFloatBuffer(material0.toFA_());
FloatBuffer material1Buffer = GLBuffers.newDirectFloatBuffer(material1.toFA_());
gl4.glCreateBuffers(Buffer.MAX, bufferName);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexSize, vertexBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.ELEMENT), elementSize, elementBuffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glNamedBufferStorage(bufferName.get(Buffer.MATERIAL0), Vec4.SIZE, material0Buffer, 0);
gl4.glNamedBufferStorage(bufferName.get(Buffer.MATERIAL1), Vec4.SIZE, material1Buffer, 0);
} else {
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, 0);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferName.get(Buffer.MATERIAL0));
gl4.glBufferStorage(GL_SHADER_STORAGE_BUFFER, Vec4.SIZE, material0Buffer, 0);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferName.get(Buffer.MATERIAL1));
gl4.glBufferStorage(GL_SHADER_STORAGE_BUFFER, Vec4.SIZE, material1Buffer, 0);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
}
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(material0Buffer);
BufferUtils.destroyDirectBuffer(material1Buffer);
return true;
}
示例10: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
int alignement = 256;
IntBuffer bufferPageSize = GLBuffers.newDirectIntBuffer(1);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
gl4.glGetIntegerv(GL_SPARSE_BUFFER_PAGE_SIZE_ARB, bufferPageSize);
boolean validated = true;
int copyBufferSize = glm.ceilMultiple(vertexSize, alignement) + glm.ceilMultiple(elementSize, alignement);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.COPY), copyBufferSize, null, GL_MAP_WRITE_BIT);
} else {
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferName.get(Buffer.COPY));
gl4.glBufferStorage(GL_SHADER_STORAGE_BUFFER, copyBufferSize, null, GL_MAP_WRITE_BIT);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
}
ByteBuffer copyBufferPointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.COPY), 0, copyBufferSize,
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
copyBufferPointer.asFloatBuffer().put(vertexBuffer);
copyBufferPointer.position(glm.ceilMultiple(vertexSize, alignement));
copyBufferPointer.asShortBuffer().put(elementBuffer);
gl4.glUnmapNamedBuffer(bufferName.get(Buffer.COPY));
gl4.glBindBuffer(GL_COPY_READ_BUFFER, bufferName.get(Buffer.COPY));
gl4.glBindBuffer(GL_COPY_WRITE_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferStorage(GL_COPY_WRITE_BUFFER, glm.ceilMultiple(elementSize, bufferPageSize.get(0)), null,
GL_SPARSE_STORAGE_BIT_ARB);
gl4.glBufferPageCommitmentARB(GL_COPY_WRITE_BUFFER, 0, bufferPageSize.get(0), true);
gl4.glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, glm.ceilMultiple(vertexSize, alignement),
0, glm.ceilMultiple(elementSize, alignement));
gl4.glBindBuffer(GL_COPY_WRITE_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_COPY_WRITE_BUFFER, glm.ceilMultiple(vertexSize, bufferPageSize.get(0)), null,
GL_SPARSE_STORAGE_BIT_ARB);
gl4.glBufferPageCommitmentARB(GL_COPY_WRITE_BUFFER, 0, bufferPageSize.get(0), true);
gl4.glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, glm.ceilMultiple(vertexSize, alignement));
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), uniformBlockSize, null, GL_MAP_WRITE_BIT
| GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
} else {
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT
| GL_MAP_COHERENT_BIT);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(bufferPageSize);
return validated;
}
示例11: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer constants = GLBuffers.newDirectIntBuffer(3);
gl4.glCreateBuffers(Buffer.MAX, bufferName);
Mat4 mvp = glm.ortho_(0.0f, windowSize.x * 1.0f, 0.0f, windowSize.y * 1f);
FloatBuffer mvpBuffer = GLBuffers.newDirectFloatBuffer(mvp.toFa_());
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.TRANSFORM), mvp.SIZE, mvpBuffer, 0);
} else {
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, mvp.SIZE, mvpBuffer, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
gl4.glGetIntegerv(GL_WARP_SIZE_NV, constants);
constants.position(1);
gl4.glGetIntegerv(GL_WARPS_PER_SM_NV, constants);
constants.position(2);
gl4.glGetIntegerv(GL_SM_COUNT_NV, constants);
constants.rewind();
System.out.println("GL_WARP_SIZE_NV: " + constants.get(0));
System.out.println("GL_WARPS_PER_SM_NV: " + constants.get(1));
System.out.println("GL_SM_COUNT_NV: " + constants.get(2));
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.CONSTANT), constants.capacity() * Integer.BYTES, constants, 0);
} else {
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.CONSTANT));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, constants.capacity() * Integer.BYTES, constants, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
int windowDiv = 1;
vertexCount = (windowSize.x / windowDiv) * (windowSize.y / windowDiv) * 6 * quadOverlapCount;
float[] vertexPosition = new float[vertexCount * 2];
for (int quadCoordIndexY = 0, quadCoordCountY = windowSize.y / windowDiv; quadCoordIndexY < quadCoordCountY;
quadCoordIndexY++) {
for (int quadCoordIndexX = 0, quadCoordCountX = windowSize.x / windowDiv; quadCoordIndexX < quadCoordCountX;
quadCoordIndexX++) {
for (int quadOverlapIndex = 0; quadOverlapIndex < quadOverlapCount; quadOverlapIndex++) {
int quadIndex = (quadCoordIndexX + quadCoordCountX * quadCoordIndexY) * quadOverlapCount
+ quadOverlapIndex;
vertexPosition[(quadIndex * 6 + 0) * 2 + 0] = quadCoordIndexX * 1 + 0;
vertexPosition[(quadIndex * 6 + 0) * 2 + 1] = quadCoordIndexY * 1 + 0;
vertexPosition[(quadIndex * 6 + 1) * 2 + 0] = quadCoordIndexX * 1 + 1;
vertexPosition[(quadIndex * 6 + 1) * 2 + 1] = quadCoordIndexY * 1 + 0;
vertexPosition[(quadIndex * 6 + 2) * 2 + 0] = quadCoordIndexX * 1 + 1;
vertexPosition[(quadIndex * 6 + 2) * 2 + 1] = quadCoordIndexY * 1 + 1;
vertexPosition[(quadIndex * 6 + 3) * 2 + 0] = quadCoordIndexX * 1 + 0;
vertexPosition[(quadIndex * 6 + 3) * 2 + 1] = quadCoordIndexY * 1 + 0;
vertexPosition[(quadIndex * 6 + 4) * 2 + 0] = quadCoordIndexX * 1 + 1;
vertexPosition[(quadIndex * 6 + 4) * 2 + 1] = quadCoordIndexY * 1 + 1;
vertexPosition[(quadIndex * 6 + 5) * 2 + 0] = quadCoordIndexX * 1 + 0;
vertexPosition[(quadIndex * 6 + 5) * 2 + 1] = quadCoordIndexY * 1 + 1;
}
}
}
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexPosition);
if (!bug1287) {
gl4.glNamedBufferStorage(bufferName.get(Buffer.VERTEX), vertexPosition.length * Float.BYTES, vertexBuffer, 0);
} else {
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_UNIFORM_BUFFER, vertexBuffer.capacity() * Float.BYTES, vertexBuffer, 0);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
BufferUtils.destroyDirectBuffer(constants);
BufferUtils.destroyDirectBuffer(mvpBuffer);
BufferUtils.destroyDirectBuffer(constants);
return true;
}