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:cuchaz.jfxgl.prism.TexturedQuad.java
License:Open Source License
public void render() { // bind stuff shader.bind();//from w w w .j a v a 2 s . co m GL30.glBindVertexArray(vaoId); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // draw it! GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, 0); // unbind things GL30.glBindVertexArray(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:de.codesourcery.flocking.LWJGLRenderer.java
License:Apache License
private void renderWorld(World world) { final double modelMax = world.getSimulationParameters().modelMax; xInc = Display.getWidth() / modelMax; yInc = Display.getHeight() / modelMax; GL11.glEnable(GL11.GL_DEPTH_TEST);//from w w w. j av a 2 s . c o m GL11.glDepthMask(true); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glColor3f(0.5f, 0.5f, 1.0f); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); final int triangleCount = world.getPopulationCount(); // setup vertex data final int vertexArrayLen = triangleCount * 3 * 2; // one triangle = 3 vertices * 2 int's per vertex final MyIntBuffer vertexBuffer = getVertexBuffer(vertexArrayLen); final IntBuffer vertexIntBuffer = vertexBuffer.getBuffer(); final IBoidVisitor visitor = new IBoidVisitor() { @Override public void visit(Boid boid) { drawBoid(boid, vertexIntBuffer); } }; world.visitAllBoids(visitor); vertexBuffer.rewind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer.getBuffer(), GL15.GL_DYNAMIC_DRAW); GL11.glVertexPointer(2, GL11.GL_INT, 0, 0); // setup index data MyIntBuffer indexBuffer = getIndexBuffer(triangleCount * 3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getBuffer(), GL15.GL_STATIC_DRAW); GL11.glDrawElements(GL11.GL_TRIANGLES, triangleCount * 3, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLSSQScene.java
License:Open Source License
public void Pass(GLScene.PassType passType) { ssqMesh.use();//from www . j a v a 2 s . c om for (int m = 0; m < ssqMesh.getSubMeshCount(); m++) { GLSubMesh subMesh = ssqMesh.getSubMesh(m); GLMaterial ssqMaterial = subMesh.getMaterial(); GLShader ssqShader = ssqMaterial.preparePass(passType, GLScene.DrawModifier.None); if (ssqShader != null) { GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, subMesh.getIndexVboId()); GL11.glDrawElements(GL11.GL_TRIANGLES, subMesh.getIndexCount(), GL11.GL_UNSIGNED_INT, 0); } } }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLSubMesh.java
License:Open Source License
public void draw() { GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL11.GL_UNSIGNED_INT, 0); }
From source file:engine.render.TexturedQuad.java
public void renderQuad() { int shaderID = shader.getProgramID(); GL20.glUseProgram(shaderID);/*from w ww . j a v a2s . com*/ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID()); GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); glUniform2f(glGetUniformLocation(shaderID, "scale"), scale.x, scale.y); glUniform2f(glGetUniformLocation(shaderID, "translation"), translation.x, translation.y); glUniform2f(glGetUniformLocation(shaderID, "cameraOffset"), cameraOffset.x, cameraOffset.y); glUniform1f(glGetUniformLocation(shaderID, "rotation"), rotation); glUniform2f(glGetUniformLocation(shaderID, "resolution"), resolution.x, resolution.y); GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); glDisable(GL_BLEND); GL20.glUseProgram(0); }
From source file:eu.over9000.veya.rendering.ChunkVAO.java
License:Open Source License
public void render(final boolean solid) { try {/* w w w. j a v a 2s .com*/ if (solid) { if (holdsSolid) { GL30.glBindVertexArray(this.vao_handle_solid); if (Veya.wireframeSwitch) { GL11.glDrawElements(GL11.GL_LINE_STRIP, this.index_length_solid, GL11.GL_UNSIGNED_INT, 0); } else { GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, this.index_length_solid, GL11.GL_UNSIGNED_INT, 0); } GL30.glBindVertexArray(0); } } else { if (holdsTransparent) { GL30.glBindVertexArray(this.vao_handle_transparent); if (Veya.wireframeSwitch) { GL11.glDrawElements(GL11.GL_LINE_STRIP, this.index_length_transparent, GL11.GL_UNSIGNED_INT, 0); } else { GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, this.index_length_transparent, GL11.GL_UNSIGNED_INT, 0); } GL30.glBindVertexArray(0); } } } catch (final OpenGLException e) { System.out.println("vao_handle_solid: " + this.vao_handle_solid); e.printStackTrace(); } }
From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java
public static void draw() { GraphicMotor.checkInstance();/*from ww w . ja v a2s.c o m*/ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL20.glUseProgram(instance.shipShaderId); GL20.glUniform1i(instance.useTextureLocation, instance.drawPolygonFrame ? 0 : 1); int drawStyle = instance.drawPolygonFrame ? GL11.GL_LINE_LOOP : GL11.GL_TRIANGLES; GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, instance.shipTextureId); GL30.glBindVertexArray(instance.shipVaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, instance.shipVboiId); GL11.glDrawElements(drawStyle, instance.shipVboiLenght, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); GL20.glUseProgram(0); }
From source file:fr.ign.cogit.geoxygene.appli.render.DisplayableRenderer.java
License:Open Source License
/** * do a GL draw call for all complex meshes * /*from w w w .j a v a 2 s . co m*/ * @param primitive * primitive to render */ protected final static void drawComplex(GLComplex primitive) { RenderingStatistics.drawGLComplex(primitive); for (GLMesh mesh : primitive.getMeshes()) { RenderingStatistics.doDrawCall(); GL11.glDrawElements(mesh.getGlType(), mesh.getLastIndex() - mesh.getFirstIndex() + 1, GL11.GL_UNSIGNED_INT, mesh.getFirstIndex() * (Integer.SIZE / 8)); } }
From source file:fr.ign.cogit.geoxygene.appli.render.LwjglLayerRenderer.java
License:Open Source License
/** * Perform an OpenGL drawcall on a primitive and render it in the active * FrameBuffer. Any preloaded glprogram will be applied. <b>THIS METHOD * SHOULD NOT BE HERE!<b>/*from w w w . j a va 2s. c om*/ * * @param primitive * primitive to render */ // XXX THIS METHOD SHOULD NOT BE HERE! public static void drawComplex(GLComplex primitive) { RenderingStatistics.drawGLComplex(primitive); for (GLMesh mesh : primitive.getMeshes()) { RenderingStatistics.doDrawCall(); GL11.glDrawElements(mesh.getGlType(), mesh.getLastIndex() - mesh.getFirstIndex() + 1, GL11.GL_UNSIGNED_INT, mesh.getFirstIndex() * (Integer.SIZE / 8)); } }
From source file:game.entity.lwjgl.EntityRenderer.java
/** * Renders a batch of entities with a single textured model. * * @param entityBatch A map entry containing a textured model (key) and a * list of entities (value).//from ww w . j av a 2 s . com */ public void renderBatch(Entry<TexturedModel, List<Entity>> entityBatch) { this.prepareTexturedModel(entityBatch.getKey()); entityBatch.getValue().stream().forEach(x -> { this.loadModelMatrix(x); GL11.glDrawElements(GL11.GL_TRIANGLES, x.getModel().getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); }); this.unbindTexturedModel(entityBatch.getKey()); }