List of usage examples for org.lwjgl.opengl GL11 glDrawElements
public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("GLsizei") int count, @NativeType("GLenum") int type, @NativeType("void const *") long indices)
From source file:org.meanworks.engine.render.geometry.mesh.renderers.VAOMeshRenderer.java
License:Open Source License
/** * Renders the mesh/*from w w w .j av a 2 s .c om*/ */ public void render(Material material) { if (vertexBufferArray != null) { /* * Update matrices */ material.setProperty("mProjectionView", RenderState.getProjectionViewMatrix()); material.setProperty("mModelMatrix", RenderState.getTransformMatrix()); /* * Upload material data to the graphics card */ material.apply(); vertexBufferArray.bind(); { if (indexBuffer != null) { if (EngineConfig.usingModernOpenGL) { GL11.glDrawElements(GL11.GL_TRIANGLES, numIndices, GL11.GL_UNSIGNED_INT, 0); } else { EngineLogger.error( "Tried to render using a VertexBufferRenderer while the graphics card does not support it."); } } else { GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.numVertices); } RenderState.addRenderedVertices(this.numVertices); } vertexBufferArray.unbind(); } else { EngineLogger.error("Could not render model... VAO = null"); } }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void drawElements(int mode, int count, int type, int indices) { GL11.glDrawElements(mode, count, type, indices); }
From source file:org.spout.renderer.lwjgl.gl20.GL20VertexArray.java
License:Open Source License
@Override public void draw() { checkCreated();//from w w w . jav a 2 s . com if (extension.has()) { // Bind the vao extension.glBindVertexArray(id); } else { // Enable the vertex attributes for (int i = 0; i < attributeBufferIDs.length; i++) { // Bind the buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, attributeBufferIDs[i]); // Define the attribute GL20.glVertexAttribPointer(i, attributeSizes[i], attributeTypes[i], attributeNormalizing[i], 0, 0); // Enable it GL20.glEnableVertexAttribArray(i); } // Unbind the last buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } // Bind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Draw all indices with the provided mode GL11.glDrawElements(drawingMode.getGLConstant(), indicesDrawCount, GL11.GL_UNSIGNED_INT, indicesOffset * DataType.INT.getByteSize()); // Unbind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:org.spout.renderer.lwjgl.gl30.GL30VertexArray.java
License:Open Source License
@Override public void draw() { checkCreated();/* w w w.ja va 2 s. c o m*/ // Bind the vao GL30.glBindVertexArray(id); // Bind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Draw all indices with the provided mode GL11.glDrawElements(drawingMode.getGLConstant(), indicesDrawCount, GL11.GL_UNSIGNED_INT, indicesOffset * DataType.INT.getByteSize()); // Unbind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Unbind the vao GL30.glBindVertexArray(0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:org.terasology.rendering.assets.skeletalmesh.SkeletalMesh.java
License:Apache License
public void doRender(List<Vector3f> verts, List<Vector3f> normals) { FloatBuffer vertBuffer = BufferUtils.createFloatBuffer(verts.size() * 6); for (int i = 0; i < verts.size(); ++i) { Vector3f vert = verts.get(i); vertBuffer.put(vert.x);// w w w . ja va 2 s .c o m vertBuffer.put(vert.y); vertBuffer.put(vert.z); Vector3f norm = normals.get(i); vertBuffer.put(norm.x); vertBuffer.put(norm.y); vertBuffer.put(norm.z); } vertBuffer.flip(); VertexBufferObjectManager.getInstance().bufferVboData(vboPosNormBuffer, vertBuffer, GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboPosNormBuffer); glVertexPointer(VECTOR3_SIZE, GL_FLOAT, STRIDE, 0); glNormalPointer(GL_FLOAT, STRIDE, NORMAL_OFFSET); GL11.glDrawElements(GL11.GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:org.terasology.rendering.opengl.OpenGLMesh.java
License:Apache License
public void doRender() { if (!isDisposed()) { GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0); } else {/*from w w w.j a va 2 s .c o m*/ logger.error("Attempted to render disposed mesh: {}", getURI()); } }
From source file:org.terasology.rendering.opengl.OpenGLSkeletalMesh.java
License:Apache License
public void doRender(List<Vector3f> verts, List<Vector3f> normals) { FloatBuffer vertBuffer = BufferUtils.createFloatBuffer(verts.size() * 6); for (int i = 0; i < verts.size(); ++i) { Vector3f vert = verts.get(i); vertBuffer.put(vert.x);//from w ww.ja v a2s . c o m vertBuffer.put(vert.y); vertBuffer.put(vert.z); Vector3f norm = normals.get(i); vertBuffer.put(norm.x); vertBuffer.put(norm.y); vertBuffer.put(norm.z); } vertBuffer.flip(); VertexBufferObjectUtil.bufferVboData(vboPosNormBuffer, vertBuffer, GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboPosNormBuffer); glVertexPointer(VECTOR3_SIZE, GL_FLOAT, STRIDE, 0); glNormalPointer(GL_FLOAT, STRIDE, NORMAL_OFFSET); GL11.glDrawElements(GL11.GL_TRIANGLES, data.getIndices().size(), GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:org.terasology.rendering.primitives.ChunkMesh.java
License:Apache License
private void renderVbo(int id) { if (lock.tryLock()) { try {/*from w w w . j av a 2 s. c om*/ if (vertexBuffers[id] <= 0 || disposed) { return; } glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, idxBuffers[id]); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffers[id]); glVertexPointer(SIZE_VERTEX, GL11.GL_FLOAT, STRIDE, OFFSET_VERTEX); GL13.glClientActiveTexture(GL13.GL_TEXTURE0); glTexCoordPointer(SIZE_TEX0, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_0); GL13.glClientActiveTexture(GL13.GL_TEXTURE1); glTexCoordPointer(SIZE_TEX1, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_1); glColorPointer(SIZE_COLOR * 4, GL11.GL_UNSIGNED_BYTE, STRIDE, OFFSET_COLOR); glNormalPointer(GL11.GL_FLOAT, STRIDE, OFFSET_NORMAL); GL11.glDrawElements(GL11.GL_TRIANGLES, vertexCount[id], GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } finally { lock.unlock(); } } }
From source file:org.terasology.rendering.primitives.Mesh.java
License:Apache License
public void doRender() { GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0); }
From source file:ovh.tgrhavoc.gameengine.core.Mesh.java
License:Open Source License
public void draw() { GL20.glEnableVertexAttribArray(0);/*ww w . ja v a 2 s . c o m*/ GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, Vertex.SIZE * 4, 0); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, Vertex.SIZE * 4, 12); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, Vertex.SIZE * 4, 20); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo); GL11.glDrawElements(GL11.GL_TRIANGLES, size, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); }