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:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}// w w w . ja v a 2 s . com */ @Override public void glDrawElements(int primitive, int count, int format, int offset) { GL11.glDrawElements(primitive, count, format, offset); }
From source file:br.com.perin.renderEngine.Renderer.java
public void render(RawModel model) { GL30.glBindVertexArray(model.getVaoId()); GL20.glEnableVertexAttribArray(0);//from w w w.ja v a 2 s .c o m GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(), GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); }
From source file:br.com.perin.renderEngine.Renderer.java
public void render(TexturedModel model) { RawModel raw = model.getRawModel();/* ww w .j av a 2s . c o m*/ GL30.glBindVertexArray(raw.getVaoId()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getId()); // Essa linha est com problemas. GL11.glDrawElements(GL11.GL_TRIANGLES, raw.getVertexCount(), GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL30.glBindVertexArray(0); }
From source file:com.a2client.corex.Mesh.java
License:Open Source License
public void Render() { Material mat = material.ModeMat.get(Render.Mode); if (mat == null) return;/*www .j a v a2s . com*/ mat.bind(); // collect skin joints if (data.Attrib.contains(Const.MATERIAL_ATTRIB.maJoint) && skeleton != null) { for (int i = 0; i < JIndex.length; i++) { if (JIndex[i] > -1) { skeleton.updateJoint(JIndex[i]); if (skeleton.joint[JIndex[i]] == null) { Log.debug("fail1"); return; } else JQuat[i] = skeleton.joint[JIndex[i]].mul(skeleton.data.base[JIndex[i]].bind); } } mat.uniform[Const.muJoint_idx].setValue(JQuat); } // set vertex attributes data.VertexBuf.bind(); int offset = 0; for (Const.MATERIAL_ATTRIB ma : data.Attrib) { ShaderAttrib sa = mat.Attrib.get(ma); // enable attrib sa.enable(); // set attrib value : data.VertexBuf.stride, data.VertexBuf.data, offset sa.setValue(data.VertexBuf.Stride, 0, offset); offset += Const.getAttribSize(ma); } if (data.IndexBuf != null) { data.IndexBuf.bind(); // if (test_shader.use_draw_elements) GL11.glDrawElements(Const.getMeshMode(data.Mode), data.IndexBuf.Count, data.IndexBuf.IndexType, 0); // else // GL12.glDrawRangeElements(Const.getMeshMode(data.Mode), 0, data.IndexBuf.Count, (data.IndexBuf.Count), data.IndexBuf.IndexType, 0); } // ? ( ) for (Const.MATERIAL_ATTRIB ma : data.Attrib) { mat.Attrib.get(ma).disable(); } }
From source file:com.adavr.player.context.QuadContext.java
License:Open Source License
@Override public void loop() { VertexArray.bind(vao);/*from w w w . jav a 2s . c o m*/ { vao.enableAttributes(); VertexBuffer.bind(indicesVBO); { GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); } VertexBuffer.unbind(indicesVBO); vao.disableAttributes(); } VertexArray.unbind(); }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
@Override public void drawElementsVBO(final IndexBufferData<?> indices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); final int vboID = setupIndicesVBO(indices, context, rendRecord); LwjglRendererUtil.setBoundElementVBO(rendRecord, vboID); if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); final int type = getGLDataType(indices); if (primcount < 0) { GL11.glDrawElements(glIndexMode, indices.getBufferLimit(), type, 0); } else {/* ww w . j ava 2 s .c o m*/ GL31.glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, 0, primcount); } if (Constants.stats) { addStats(indexModes[0], indices.getBufferLimit()); } } else { int offset = 0; int indexModeCounter = 0; for (int i = 0; i < indexLengths.length; i++) { final int count = indexLengths[i]; final int glIndexMode = getGLIndexMode(indexModes[indexModeCounter]); final int type = getGLDataType(indices); final int byteSize = indices.getByteCount(); // offset in this call is done in bytes. if (primcount < 0) { GL11.glDrawElements(glIndexMode, count, type, offset * byteSize); } else { GL31.glDrawElementsInstanced(glIndexMode, count, type, offset * byteSize, primcount); } if (Constants.stats) { addStats(indexModes[indexModeCounter], count); } offset += count; if (indexModeCounter < indexModes.length - 1) { indexModeCounter++; } } } }
From source file:com.auroraengine.opengl.model.IndexBuffer.java
License:Open Source License
public void draw() { GL11.glDrawElements(GL11.GL_TRIANGLES, ib.remaining(), GL11.GL_UNSIGNED_INT, ib.position()); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glDrawElements(int mode, int count, int type, int indices) { GL11.glDrawElements(mode, count, type, indices); }
From source file:com.dinasgames.engine.graphics.GL.java
public static void render(Vertex[] verts) { init();// www .j ava2s . co m int numberIndices = verts.length / 3; vertexBuffer = BufferUtils.createFloatBuffer(verts.length * 2); colorBuffer = BufferUtils.createFloatBuffer(verts.length); indexBuffer = BufferUtils.createFloatBuffer(verts.length); vertexBuffer.clear(); colorBuffer.clear(); indexBuffer.clear(); for (Vertex vert : verts) { vertexBuffer.put(vert.x); vertexBuffer.put(vert.y); GLColor c = vert.color.toGLColor(); colorBuffer.put(c.getRed()); colorBuffer.put(c.getGreen()); colorBuffer.put(c.getBlue()); colorBuffer.put(c.getAlpha()); } vertexBufferData(vertexBufferID, vertexBuffer); colorBufferData(colorBufferID, colorBuffer); // Push verticies to OpenGL GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBufferID); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); // Push color values to OpenGL GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorBufferID); GL11.glColorPointer(4, GL11.GL_FLOAT, 0, 0); // Draw the shape GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBufferID); GL11.glDrawElements(GL11.GL_TRIANGLES, numberIndices, GL11.GL_UNSIGNED_INT, 0); // Disalble client state for vertex and color GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20VertexArray.java
License:MIT License
@Override public void draw() { checkCreated();//from w ww. j ava 2s . c o m 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); // Set the polygon mode GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode.getGLConstant()); // 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(); }