本文整理匯總了Java中javax.media.opengl.GL2.glBufferData方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glBufferData方法的具體用法?Java GL2.glBufferData怎麽用?Java GL2.glBufferData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glBufferData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
if(clContext == null) {
// find gl compatible device
CLDevice[] devices = CLPlatform.getDefault().listCLDevices();
CLDevice device = null;
for (CLDevice d : devices) {
if(d.isGLMemorySharingSupported()) {
device = d;
break;
}
}
if(null==device) {
throw new RuntimeException("couldn't find any CL/GL memory sharing devices ..");
}
// create OpenCL context before creating any OpenGL objects
// you want to share with OpenCL (AMD driver requirement)
clContext = CLGLContext.create(drawable.getContext(), device);
// enable GL error checking using the composable pipeline
drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));
// OpenGL initialization
GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval(1);
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
gl.glGenBuffers(glObjects.length, glObjects, 0);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]);
// gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
final int bsz = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT;
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
gl.glBufferData(GL2.GL_ARRAY_BUFFER, bsz, null, GL2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
pushPerspectiveView(gl);
gl.glFinish();
// init OpenCL
initCL(gl, bsz);
// start rendering thread
Animator animator = new Animator(drawable);
animator.start();
}
}