List of usage examples for org.lwjgl.opengl GL11 glDrawArrays
public static void glDrawArrays(@NativeType("GLenum") int mode, @NativeType("GLint") int first, @NativeType("GLsizei") int count)
From source file:com.xrbpowered.gl.res.StaticMesh.java
License:Open Source License
public void drawCall() { if (vboiId != GL11.GL_INVALID_VALUE) { GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL11.glDrawElements(drawMode, countElements, GL11.GL_UNSIGNED_SHORT, 0); } else {/* w ww . jav a2 s . com*/ GL11.glDrawArrays(drawMode, 0, countElements); } }
From source file:Data.Building.java
License:Apache License
@Override public void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // Bind to the VAO that has all the information about the quad vertices GL30.glBindVertexArray(vaoId);/* w w w . ja v a 2 s.c o m*/ GL20.glEnableVertexAttribArray(0); // Draw the vertices GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount); // Put everything back to default (deselect) GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); Util.exitOnGLError("Error in Building render"); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void renderLineList(ArrayList lineList) { E3DLine line = null;//from w w w. ja v a 2s . co m if (lineList == null) return; int listSize = lineList.size(); if (listSize <= 0) return; int bufferSize = listSize * 3; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 3.0); renderLineList((ArrayList) lineList.subList(maxLength, lineList.size())); lineList = (ArrayList) lineList.subList(0, maxLength); } // FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(bufferSize); // FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(bufferSize); vertexBuffer.clear(); colorBuffer.clear(); for (int i = 0; i < listSize; i++) { line = (E3DLine) lineList.get(i); line.appendFloatVertexBuffer(vertexBuffer); line.appendFloatVertexColorBuffer(colorBuffer); } // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); // vertexBuffer.clear(); // colorBuffer.clear(); GL11.glDrawArrays(GL11.GL_LINES, 0, listSize * 2); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of triangles using vertexarrays. It assumes that the list * of triangles all share the same texture! * @param triangleList List of triangles to render all containing the same texture *//*from w w w .j a v a2 s . c o m*/ private void renderSolidTriangleList(List triangleList) { if (triangleList == null) return; E3DTriangle triangle = null; List renderList = null; int listSize = triangleList.size(); if (listSize <= 0) return; //Get vertex buffers int bufferSize = listSize * 12; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 12.0); renderSolidTriangleList(triangleList.subList(maxLength, triangleList.size())); renderList = triangleList.subList(0, maxLength); } else renderList = triangleList; vertexBuffer.clear(); colorBuffer.clear(); for (int i = 0; i < renderList.size(); i++) { triangle = (E3DTriangle) renderList.get(i); triangle.appendVertexBuffer(vertexBuffer); triangle.appendVertexColorBuffer(colorBuffer); } disableAllTextureUnits(); // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, renderList.size() * 3); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of triangles using vertexarrays. It assumes that the list * of triangles all share the same texture! * @param triangleList List of triangles to render all containing the same texture */// w w w . j a va 2s. co m private void renderTexturedTriangleList(List triangleList) { if (triangleList == null) return; E3DTriangle triangle = null; List renderList = null; int listSize = triangleList.size(); if (listSize <= 0) return; //Get vertex buffers int bufferSize = listSize * 12; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 12.0); renderTexturedTriangleList(triangleList.subList(maxLength, triangleList.size())); renderList = triangleList.subList(0, maxLength); } else renderList = triangleList; vertexBuffer.clear(); colorBuffer.clear(); texCoordBuffer.clear(); texCoordDetail0Buffer.clear(); texCoordDetail1Buffer.clear(); for (int i = 0; i < renderList.size(); i++) { triangle = (E3DTriangle) renderList.get(i); triangle.appendVertexBuffer(vertexBuffer); triangle.appendTexCoordBuffer(texCoordBuffer); triangle.appendVertexColorBuffer(colorBuffer); triangle.appendTexCoordDetail0Buffer(texCoordDetail0Buffer); triangle.appendTexCoordDetail1Buffer(texCoordDetail1Buffer); } int detail0TextureID = -1; int detail1TextureID = -1; if (triangle.isTextureDetail0Available()) detail0TextureID = triangle.getTextureDetail0().getGlTextureID(); if (triangle.isTextureDetail1Available()) detail1TextureID = triangle.getTextureDetail1().getGlTextureID(); // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); texCoordBuffer.rewind(); texCoordDetail0Buffer.rewind(); texCoordDetail1Buffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); //Draw vertices ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordBuffer); if (detail0TextureID != -1 && getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 2) { ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE1_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordDetail0Buffer); if (detail1TextureID != -1 && getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 3) { ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE2_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordDetail1Buffer); } } GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, renderList.size() * 3); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of triangles using vertexarrays. It assumes that the list * of triangles all share the same texture! * @param triangleList List of triangles to render all containing the same texture *//*from w ww. j a va 2s .c o m*/ private void renderWireframeTriangleList(List triangleList) { E3DTriangle triangle = null; List renderList = null; if (triangleList == null) return; int listSize = triangleList.size(); if (listSize <= 0) return; int bufferSize = listSize * 24; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 24.0); renderWireframeTriangleList(triangleList.subList(maxLength, triangleList.size())); renderList = triangleList.subList(0, maxLength); } else renderList = triangleList; vertexBuffer.clear(); colorBuffer.clear(); for (int i = 0; i < renderList.size(); i++) { triangle = (E3DTriangle) renderList.get(i); triangle.appendVertexBuffer(vertexBuffer); triangle.appendVertexBuffer(vertexBuffer); triangle.appendVertexColorBuffer(colorBuffer); triangle.appendVertexColorBuffer(colorBuffer); } disableAllTextureUnits(); // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); GL11.glDrawArrays(GL11.GL_LINES, 0, renderList.size() * 6); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of quads using vertexarrays. It assumes that the list * of quadss all share the same texture! * @param quadList List of quads to render all containing the same texture *//* ww w .j a va2 s . co m*/ private void renderSolidQuadList(List quadList) { if (quadList == null) return; E3DQuad quad = null; List renderList; int listSize = quadList.size(); if (listSize <= 0) return; int bufferSize = listSize * 16; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 16.0); renderSolidQuadList(quadList.subList(maxLength, quadList.size())); renderList = quadList.subList(0, maxLength); } else renderList = quadList; vertexBuffer.clear(); colorBuffer.clear(); for (int i = 0; i < renderList.size(); i++) { quad = (E3DQuad) renderList.get(i); quad.appendVertexBuffer(vertexBuffer); quad.appendVertexColorBuffer(colorBuffer); } // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); GL11.glDrawArrays(GL11.GL_QUADS, 0, renderList.size() * 4); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of quads using vertexarrays. It assumes that the list * of quadss all share the same texture! * @param quadList List of quads to render all containing the same texture *///from ww w. j av a 2 s . c om private void renderTexturedQuadList(List quadList) { if (quadList == null) return; E3DQuad quad = null; List renderList; int listSize = quadList.size(); if (listSize <= 0) return; int bufferSize = listSize * 16; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 16.0); renderTexturedQuadList(quadList.subList(maxLength, quadList.size())); renderList = quadList.subList(0, maxLength); } else renderList = quadList; vertexBuffer.clear(); colorBuffer.clear(); texCoordBuffer.clear(); texCoordDetail0Buffer.clear(); texCoordDetail1Buffer.clear(); for (int i = 0; i < renderList.size(); i++) { quad = (E3DQuad) renderList.get(i); quad.appendVertexBuffer(vertexBuffer); quad.appendTexCoordBuffer(texCoordBuffer); quad.appendVertexColorBuffer(colorBuffer); quad.appendTexCoordDetail0Buffer(texCoordDetail0Buffer); quad.appendTexCoordDetail1Buffer(texCoordDetail1Buffer); } //Setup textures // int glTextureID = -1; int detail0TextureID = -1; int detail1TextureID = -1; // if(quad.isTextureAvailable()) // glTextureID = quad.getTexture().getGlTextureID(); if (quad.isTextureDetail0Available()) detail0TextureID = quad.getTextureDetail0().getGlTextureID(); if (quad.isTextureDetail1Available()) detail1TextureID = quad.getTextureDetail1().getGlTextureID(); // disableAllTextureUnits(); // if(textured) // setupTextureUnits(glTextureID, detail0TextureID, detail1TextureID); // int glBuffer; // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); texCoordBuffer.rewind(); texCoordDetail0Buffer.rewind(); texCoordDetail1Buffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); //Draw vertices ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordBuffer); if (getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 2 && detail0TextureID != -1) { ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE1_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordDetail0Buffer); if (getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 3 && detail1TextureID != -1) { ARBMultitexture.glClientActiveTextureARB(ARBMultitexture.GL_TEXTURE2_ARB); // GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoordDetail1Buffer); } } GL11.glDrawArrays(GL11.GL_QUADS, 0, renderList.size() * 4); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * This will render a list of quads using vertexarrays. It assumes that the list * of quadss all share the same texture! * @param quadList List of quads to render all containing the same texture *//*from w w w . ja v a 2s .c om*/ private void renderWireframeQuadList(List quadList) { if (quadList == null) return; E3DQuad quad = null; List renderList; int listSize = quadList.size(); if (listSize <= 0) return; int bufferSize = listSize * 32; if (bufferSize > MAX_BUFFER_SIZE) { int maxLength = (int) (MAX_BUFFER_SIZE / 32.0); renderWireframeQuadList((ArrayList) quadList.subList(maxLength, quadList.size())); renderList = quadList.subList(0, maxLength); } else renderList = quadList; vertexBuffer.clear(); colorBuffer.clear(); for (int i = 0; i < renderList.size(); i++) { quad = (E3DQuad) renderList.get(i); quad.appendVertexBuffer(vertexBuffer); quad.getVertexPosB().appendToBuffer(vertexBuffer); quad.getVertexPosC().appendToBuffer(vertexBuffer); quad.getVertexPosD().appendToBuffer(vertexBuffer); quad.getVertexPosA().appendToBuffer(vertexBuffer); quad.appendVertexColorBuffer(colorBuffer); quad.getVertexPosB().appendToBuffer(colorBuffer); quad.getVertexPosC().appendToBuffer(colorBuffer); quad.getVertexPosD().appendToBuffer(colorBuffer); quad.getVertexPosA().appendToBuffer(colorBuffer); } disableAllTextureUnits(); // Put arrays in float buffers and REWIND them (very important). vertexBuffer.rewind(); colorBuffer.rewind(); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); GL11.glDrawArrays(GL11.GL_LINES, 0, renderList.size() * 8); //five things since we list the first vertex twice (to make the line list complete }
From source file:espresso3d.engine.renderer.particle.E3DParticleRendererARBPointSprite.java
License:Open Source License
public void renderParticleList(List particleList, int renderMode) { if (particleList == null) return;/*from w ww . j av a 2 s . co m*/ E3DParticle particle = null; List renderList; int listSize = particleList.size(); if (listSize <= 0) return; int bufferSize = listSize * 12; //use 12 to account for the quad (for vertex colors, etc) even though there aren't that many vertices if (bufferSize > E3DGeometryRenderer.MAX_BUFFER_SIZE) { int maxLength = (int) (E3DGeometryRenderer.MAX_BUFFER_SIZE / 12.0); renderParticleList(particleList.subList(maxLength, particleList.size()), renderMode); renderList = particleList.subList(0, maxLength); } else renderList = particleList; getEngine().getGeometryRenderer().vertexBuffer.clear(); getEngine().getGeometryRenderer().colorBuffer.clear(); E3DVector3F position = null; for (int i = 0; i < renderList.size(); i++) { particle = (E3DParticle) renderList.get(i); position = particle.getOrientation().getPosition(); getEngine().getGeometryRenderer().vertexBuffer.put((float) position.getX()); getEngine().getGeometryRenderer().vertexBuffer.put((float) position.getY()); getEngine().getGeometryRenderer().vertexBuffer.put((float) position.getZ()); particle.getQuad().appendVertexColorBuffer(getEngine().getGeometryRenderer().colorBuffer); } setupPointSpriteParameters(particle.getSize()); //Setup textures int glTextureID = -1; int detail0TextureID = -1; int detail1TextureID = -1; if (particle.getQuad().isTextureAvailable()) glTextureID = particle.getQuad().getTexture().getGlTextureID(); if (particle.getQuad().isTextureDetail0Available()) detail0TextureID = particle.getQuad().getTextureDetail0().getGlTextureID(); if (particle.getQuad().isTextureDetail1Available()) detail1TextureID = particle.getQuad().getTextureDetail1().getGlTextureID(); getEngine().getGeometryRenderer().disableAllTextureUnits(); // if(textured) getEngine().getGeometryRenderer().setupTextureUnits(glTextureID, detail0TextureID, detail1TextureID); // Put arrays in float buffers and REWIND them (very important). getEngine().getGeometryRenderer().vertexBuffer.rewind(); getEngine().getGeometryRenderer().colorBuffer.rewind(); GL11.glEnable(ARBPointSprite.GL_POINT_SPRITE_ARB); // Send float buffers to LWJGL. GL11.glVertexPointer(3, 0, getEngine().getGeometryRenderer().vertexBuffer); GL11.glColorPointer(3, 0, getEngine().getGeometryRenderer().colorBuffer); GL11.glDrawArrays(GL11.GL_POINTS, 0, renderList.size()); GL11.glDisable(ARBPointSprite.GL_POINT_SPRITE_ARB); }