List of usage examples for org.lwjgl.opengl GL20 glEnableVertexAttribArray
public static void glEnableVertexAttribArray(@NativeType("GLuint") int index)
From source file:com.redthirddivision.quad.rendering.renderers.EntityRenderer.java
License:Apache License
protected void prepare(Model model) { GL30.glBindVertexArray(model.getVaoID()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1);//from w ww . j av a2 s . c o m GL20.glEnableVertexAttribArray(2); Material material = model.getMaterial(); shader.loadNumRows(material.getNumRows()); if (material.hasTransparency()) Util.disableCulling(); shader.loadFakeLighting(material.isUseingFakeLighting()); shader.loadShine(material.getShineDamper(), material.getReflectivity()); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getMaterial().getTextureID()); }
From source file:com.redthirddivision.quad.rendering.renderers.GuiRenderer.java
License:Apache License
@Override public void render(ArrayList<GuiTexture> elements) { shader.start();//from w w w. jav a 2s . com GL30.glBindVertexArray(quad.getVaoID()); GL20.glEnableVertexAttribArray(0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_DEPTH_TEST); for (GuiTexture gui : elements) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture()); Matrix4f matrix = MathHelper.createTransformationMatrix(gui.getPosition(), gui.getScale(), new Vector2f(0, 0)); shader.loadTransformation(matrix); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount()); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); shader.stop(); }
From source file:com.redthirddivision.quad.rendering.renderers.TerrainRenderer.java
License:Apache License
@Override protected void prepare(Terrain terrain) { Model prim = terrain.getModel();//from w ww. j a v a 2 s .c o m GL30.glBindVertexArray(prim.getVaoID()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); bindTextures(terrain); shader.loadShine(1, 0); }
From source file:com.rfdickerson.openworld.CubeGeometry.java
@Override void draw(SceneNode node) { if (!this.isLoaded) { this.init(); } else {/*from w w w . ja v a 2s .c o m*/ GLSLShaderService shaderService = GLSLShaderService.getInstance(); // use shader Shader basic = shaderService.findShader("basic"); if (basic == null) { log.error("Could not find shader"); } else { //shaderService.useShader(basic); //basic.setUniform4f("projectionMatrix", c.getProjectionMatrix()); //basic.setUniform4f("viewMatrix", c.getViewMatrix()); //basic.setUniform4f("modelMatrix", t); basic.setUniform4f("MVPMatrix", node.getMVPMatrix()); basic.setUniform4f("MVMatrix", node.getMVMatrix()); basic.setUniform3f("NormalMatrix", node.getNormalMatrix()); shaderService.useShader(basic); GL20.glBindAttribLocation(basic.getProgramID(), 0, "in_Position"); } GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL11.glDrawElements(GL11.GL_TRIANGLE_FAN, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); } exitOnGLError("draw terrain patch"); }
From source file:com.rfdickerson.openworld.RenderSurface.java
@Override void draw(SceneNode node) { if (!this.isLoaded) { this.init(); } else {//from ww w . j a v a 2s .c om GLSLShaderService shaderService = GLSLShaderService.getInstance(); // use shader Shader basic = shaderService.findShader("basic"); if (basic == null) { log.error("Could not find shader"); } else { //shaderService.useShader(basic); //basic.setUniform4f("projectionMatrix", c.getProjectionMatrix()); //basic.setUniform4f("viewMatrix", c.getViewMatrix()); //basic.setUniform4f("modelMatrix", t); shaderService.useShader(basic); GL20.glBindAttribLocation(basic.getProgramID(), 0, "in_Position"); } GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); } exitOnGLError("draw terrain patch"); }
From source file:com.runescape.client.revised.client.lwjgl.Mesh.java
License:Open Source License
public void draw() { GL20.glEnableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.getVbo()); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, Vertex.getSize() * 4, 0); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.getSize()); GL20.glDisableVertexAttribArray(0);//from w w w. j av a 2s .c om }
From source file:com.samrj.devil.gl.VAO.java
private VAO(Pair<VertexData, ShaderProgram> pair) { DGL.checkState();// www. ja v a2 s . co m if (!DGL.getCapabilities().OpenGL30) throw new UnsupportedOperationException("Vertex arrays unsupported in OpenGL < 3.0"); id = GL30.glGenVertexArrays(); this.pair = pair; bind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, pair.a.vbo()); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, pair.a.ibo()); for (ShaderProgram.Attribute satt : pair.b.getAttributes()) { VertexData.Attribute att = pair.a.getAttribute(satt.name); if (att != null) { AttributeType type = att.getType(); for (int layer = 0; layer < type.layers; layer++) { int location = satt.location + layer; GL20.glEnableVertexAttribArray(location); vertexAttribPointer(location, type, att.getStride(), att.getOffset() + layer * type.size); } } } }
From source file:com.voxelplugineering.voxelsniper.render.buffer.BufferManager.java
License:Open Source License
public void renderSections() { GL30.glBindVertexArray(vaoId);/* ww w . java2 s .c o m*/ GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); for (BufferSection b : this.sections) { b.draw(); } GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); }
From source file:com.xrbpowered.gl.res.shaders.InstanceBuffer.java
License:Open Source License
public void enable() { int offs = 0; for (int i = 0; i < elemCount.length; i++) { GL20.glEnableVertexAttribArray(attribId + i); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, iboId); GL20.glVertexAttribPointer(attribId + i, elemCount[i], GL11.GL_FLOAT, false, stride, offs); offs += 4 * elemCount[i];//from www.j a va2 s . c om GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL33.glVertexAttribDivisor(attribId + i, divisor); // GL20.glGetVertexAttrib(attribId, GL33.GL_VERTEX_ATTRIB_ARRAY_DIVISOR, testParam); Client.checkError(); } }
From source file:com.xrbpowered.gl.res.shaders.VertexInfo.java
License:Open Source License
public void enableAttribs() { for (int i = 0; i < getAttributeCount(); i++) { GL20.glEnableVertexAttribArray(i); } }