本文整理汇总了Java中com.jogamp.opengl.GL4.glGetIntegerv方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glGetIntegerv方法的具体用法?Java GL4.glGetIntegerv怎么用?Java GL4.glGetIntegerv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glGetIntegerv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
BufferUtils.destroyDirectBuffer(elementBuffer);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例2: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferName.get(Buffer.VERTEX));
FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData);
gl4.glBufferData(GL_SHADER_STORAGE_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW);
BufferUtils.destroyDirectBuffer(positionBuffer);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
gl4.glBindBuffer(GL_QUERY_BUFFER, bufferName.get(Buffer.QUERY));
gl4.glBufferData(GL_QUERY_BUFFER, Integer.BYTES * queryName.capacity(), null, GL_DYNAMIC_COPY);
// gl4.glBufferData(GL_QUERY_BUFFER, 500, null, GL_DYNAMIC_COPY);
gl4.glBindBuffer(GL_QUERY_BUFFER, 0);
return checkError(gl4, "initBuffer");
}
示例3: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexSize);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
for (int i = 0; i < vertexCount; i++) {
vertexData[i].toDbb(vertexBuffer, i * Vec2.SIZE);
}
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
uniformBufferOffset);
int uniformBlockSize = Math.max(Transform.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return true;
}
示例4: logImplementationDependentLimit
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
protected void logImplementationDependentLimit(GL4 gl4, int value, String string) {
IntBuffer result = GLBuffers.newDirectIntBuffer(1);
gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_LOW, 0, null, true);
gl4.glGetIntegerv(value, result);
String limit = string + ": " + result.get(0);
if (gl4.isExtensionAvailable("GL_KHR_debug")) {
gl4.glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 1, GL_DEBUG_SEVERITY_LOW,
limit.length(), limit);
}
gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_LOW, 0, null, false);
BufferUtils.destroyDirectBuffer(result);
}
示例5: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
boolean validated = true;
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return validated;
}
示例6: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM0));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.TRANSFORM_ARRAY));
gl4.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.FEEDBACK));
gl4.glBufferData(GL_ARRAY_BUFFER, 2 * Vec4.SIZE * vertexCount, null, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
BufferUtils.destroyDirectBuffer(positionBuffer);
return checkError(gl4, "initArrayBuffer");
}
示例7: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexSize);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
for (int i = 0; i < vertexCount; i++) {
vertexData[i].toBb(vertexBuffer, i);
}
vertexBuffer.rewind();
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE * 3, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return checkError(gl4, "initBuffer");
}
示例8: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
gl4.glGenBuffers(Buffer.MAX, bufferName);
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
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_SHADER_STORAGE_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferStorage(GL_SHADER_STORAGE_BUFFER, vertexSize, vertexBuffer, 0);
gl4.glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
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);
uniformPointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT
| GL_MAP_COHERENT_BIT);
DrawElementsIndirectCommand command = new DrawElementsIndirectCommand(elementCount, 1, 0, 0, 0);
IntBuffer commandBuffer = GLBuffers.newDirectIntBuffer(command.toIa_());
gl4.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, bufferName.get(Buffer.INDIRECT));
gl4.glBufferStorage(GL_DRAW_INDIRECT_BUFFER, DrawElementsIndirectCommand.SIZE, commandBuffer, 0);
gl4.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
BufferUtils.destroyDirectBuffer(commandBuffer);
return true;
}
示例9: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return true;
}
示例10: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
int[] uniformBufferOffset = {0};
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData);
gl4.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW);
BufferUtils.destroyDirectBuffer(positionBuffer);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
int uniformTransformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformTransformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
uniformMaterialOffset = Math.max(4 * Float.BYTES, uniformBufferOffset[0]);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.MATERIAL));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformMaterialOffset * 2, null, GL_STATIC_DRAW);
{
ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, uniformMaterialOffset * 2,
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
pointer.asFloatBuffer().put(new float[]{0.0f, 0.5f, 1.0f, 1.0f});
pointer.position(uniformMaterialOffset);
pointer.asFloatBuffer().put(new float[]{1.0f, 0.5f, 0.0f, 1.0f});
pointer.rewind();
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
return checkError(gl4, "initBuffer");
}
示例11: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
boolean validated = true;
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return validated;
}
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:32,代码来源:Gl_430_program_compute_variable_group_size.java
示例12: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
gl4.glBindBuffer(GL_TEXTURE_BUFFER, bufferName.get(Buffer.PICKING));
gl4.glBufferData(GL_TEXTURE_BUFFER, Float.BYTES, null, GL_DYNAMIC_READ);
gl4.glBindBuffer(GL_TEXTURE_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(vertexBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return true;
}
示例13: 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;
}
示例14: initBuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initBuffer(GL4 gl4) {
ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData);
FloatBuffer texCoordBuffer = GLBuffers.newDirectFloatBuffer(texCoordData);
FloatBuffer colorBuffer = GLBuffers.newDirectFloatBuffer(colorData);
gl4.glGenBuffers(Buffer.MAX, bufferName);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.POSITION_INPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, positionSize * 2, null, GL_STATIC_DRAW);
gl4.glBufferSubData(GL_ARRAY_BUFFER, 0, positionSize, positionBuffer);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.TEXCOORD_INPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, texCoordSize * 2, texCoordBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.COLOR_INPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, colorSize * 2, colorBuffer, GL_STATIC_DRAW);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.POSITION_OUTPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, positionSize * 2, null, GL_STATIC_COPY);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.TEXCOORD_OUTPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, texCoordSize * 2, null, GL_STATIC_COPY);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.COLOR_OUTPUT));
gl4.glBufferData(GL_ARRAY_BUFFER, colorSize * 2, null, GL_STATIC_COPY);
gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);
IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
gl4.glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
uniformBufferOffset);
int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
BufferUtils.destroyDirectBuffer(elementBuffer);
BufferUtils.destroyDirectBuffer(positionBuffer);
BufferUtils.destroyDirectBuffer(texCoordBuffer);
BufferUtils.destroyDirectBuffer(colorBuffer);
BufferUtils.destroyDirectBuffer(uniformBufferOffset);
return checkError(gl4, "initBuffer");
}
示例15: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
assert (!texture.empty());
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(Texture.MAX, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), format.internal.value,
texture.dimensions(0)[0], texture.dimensions(0)[1]);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexSubImage2D(GL_TEXTURE_2D, level,
0, 0,
texture.dimensions(level)[0], texture.dimensions(level)[1],
format.external.value, format.type.value,
texture.data(level));
}
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
int[] textureBufferOffset = {0};
gl4.glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, textureBufferOffset, 0);
int textureBufferRange = Math.max(positionSize, textureBufferOffset[0]);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.POSITION_INPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.POSITION_INPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.TEXCOORD_INPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.TEXCOORD_INPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.COLOR_INPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.COLOR_INPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.POSITION_OUTPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.POSITION_OUTPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.TEXCOORD_OUTPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.TEXCOORD_OUTPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.COLOR_OUTPUT));
gl4.glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferName.get(Buffer.COLOR_OUTPUT), 0,
textureBufferRange);
gl4.glBindTexture(GL_TEXTURE_BUFFER, 0);
} catch (IOException ex) {
Logger.getLogger(Gl_430_program_compute_image.class.getName()).log(Level.SEVERE, null, ex);
}
return checkError(gl4, "initTexture");
}