List of usage examples for org.lwjgl.opengl GL20 glEnableVertexAttribArray
public static void glEnableVertexAttribArray(@NativeType("GLuint") int index)
From source file:com.xrbpowered.gl.res.StaticMesh.java
License:Open Source License
public void enableDraw(int[] attribMask) { GL30.glBindVertexArray(vaoId);//from www . j av a 2 s . com if (attribMask == null) { for (int i = 0; i < countAttribs; i++) GL20.glEnableVertexAttribArray(i); } else { for (int i = 0; i < attribMask.length; i++) GL20.glEnableVertexAttribArray(attribMask[i]); } }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public void enableVertexAttributes() { // JavaFX apparently uses attributes in [0,3], see drawIndexedQuads() GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1);/* ww w . ja v a 2 s . co m*/ GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); }
From source file:cuchaz.jfxgl.prism.TexturedQuad.java
License:Open Source License
public TexturedQuad(int x, int y, int w, int h, int texId, Shader shader) { this.shader = shader; this.texId = texId; // make the vertex array vaoId = GL30.glGenVertexArrays();/*w w w. j av a 2 s.c o m*/ GL30.glBindVertexArray(vaoId); try (MemoryStack m = MemoryStack.stackPush()) { // make the indices ByteBuffer indexBuf = m.bytes(new byte[] { 0, 1, 2, 0, 2, 3 }); iboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, iboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, indexBuf, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, iboId); // make the vertices FloatBuffer vertexBuf = m.floats( new float[] { x + 0, y + 0, 0, 0, x + w, y + 0, 1, 0, x + w, y + h, 1, 1, x + 0, y + h, 0, 1 }); vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuf, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, Float.BYTES * 4, 0); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, Float.BYTES * 4, Float.BYTES * 2); } // unbind things GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
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);/*ww w . ja v a 2s . c om*/ 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:de.ikosa.mars.viewer.glviewer.engine.GLMesh.java
License:Open Source License
public void use() { GL30.glBindVertexArray(vertexArrayObjectId); GL20.glEnableVertexAttribArray(0); if (hasNormals) GL20.glEnableVertexAttribArray(1); else/* ww w . j a v a 2 s .c om*/ GL20.glDisableVertexAttribArray(1); if (hasTexCoords) GL20.glEnableVertexAttribArray(2); else GL20.glDisableVertexAttribArray(2); }
From source file:de.ikosa.mars.viewer.glviewer.GLHeightMapMesh.java
License:Open Source License
public void use() { GL30.glBindVertexArray(vertexArrayObjectId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1);//from www. ja va2 s . c o m GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexVboId); }
From source file:engine.render.TexturedQuad.java
public void renderQuad() { int shaderID = shader.getProgramID(); GL20.glUseProgram(shaderID);/*from ww w. ja v a 2s. c om*/ 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 create() { // create objects if (holdsSolid) { this.ibo_handle_solid = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_solid); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_buffer_solid, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); this.vbo_handle_solid = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_solid); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, this.vbo_buffer_solid, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); this.vao_handle_solid = GL30.glGenVertexArrays(); GL30.glBindVertexArray(this.vao_handle_solid); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_solid); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.positionByteOffset); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.colorByteCount);//w w w.j ava2s .c om GL20.glEnableVertexAttribArray(2); GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.textureByteOffset); GL20.glEnableVertexAttribArray(3); GL20.glVertexAttribPointer(3, Vertex.normalElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.normalByteOffset); GL20.glEnableVertexAttribArray(4); GL20.glVertexAttribPointer(4, Vertex.aoElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.aoByteOffset); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_solid); GL30.glBindVertexArray(0); } if (holdsTransparent) { this.ibo_handle_transparent = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_transparent); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_buffer_transparent, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); this.vbo_handle_transparent = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_transparent); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, this.vbo_buffer_transparent, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); this.vao_handle_transparent = GL30.glGenVertexArrays(); GL30.glBindVertexArray(this.vao_handle_transparent); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_transparent); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.positionByteOffset); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.colorByteOffset); GL20.glEnableVertexAttribArray(2); GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.textureByteOffset); GL20.glEnableVertexAttribArray(3); GL20.glVertexAttribPointer(3, Vertex.normalElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.normalByteOffset); GL20.glEnableVertexAttribArray(4); GL20.glVertexAttribPointer(4, Vertex.aoElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.aoByteOffset); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_transparent); GL30.glBindVertexArray(0); } // System.out.println("created ChunkVAO with " + this.vertexData.length + " vertices"); }
From source file:eu.over9000.veya.rendering.Shadow.java
License:Open Source License
public void renderQuad() { if (quadVAO == 0) { final float[] quadVertices = { // Positions // Texture Coords -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, }; // Setup plane VAO final FloatBuffer fb = BufferUtils.createFloatBuffer(quadVertices.length); fb.put(quadVertices);//from w w w.j av a 2 s . co m fb.flip(); quadVAO = GL30.glGenVertexArrays(); quadVBO = GL15.glGenBuffers(); GL30.glBindVertexArray(quadVAO); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, quadVBO); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, fb, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 5 * Float.BYTES, 0); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 5 * Float.BYTES, 3 * Float.BYTES); } GL30.glBindVertexArray(quadVAO); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4); GL30.glBindVertexArray(0); }
From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java
public static void draw() { GraphicMotor.checkInstance();//from w w w . ja v a2 s. com 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); }