Example usage for org.lwjgl.opengl GL20 glDisableVertexAttribArray

List of usage examples for org.lwjgl.opengl GL20 glDisableVertexAttribArray

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL20 glDisableVertexAttribArray.

Prototype

public static void glDisableVertexAttribArray(@NativeType("GLuint") int index) 

Source Link

Document

Disables a generic vertex attribute array.

Usage

From source file:game.terrain.lwjgl.TerrainRenderer.java

/**
 *
 *//*w w  w  . j a  v a  2  s . c o  m*/
private void unbindTexturedModel() {
    GL20.glDisableVertexAttribArray(VERTEX_POSITIONS);
    GL20.glDisableVertexAttribArray(TEXTURE_COORDS);
    GL20.glDisableVertexAttribArray(NORMAL_VECTORS);
    GL30.glBindVertexArray(0);
}

From source file:gui.lwjgl.GUIRenderer.java

@Override
public void render(GUIRenderable element) {
    GL30.glBindVertexArray(element.getGUIElement().getVaoID());
    GL20.glEnableVertexAttribArray(VERTEX_POSITIONS);
    GL20.glEnableVertexAttribArray(TEXTURE_COORDS);

    Matrix4f transformationMatrix = Maths.createTransformationMatrix(
            new Vector2f(((2.0f * element.getGUIElement().getPosition().x) / Display.getWidth() - 1),
                    -1 * ((2.0f * element.getGUIElement().getPosition().y) / Display.getHeight()) + 1f),
            element.getGUIElement().getRotation(),
            element.getGUIElement().getWidth() / (float) (Display.getWidth() / 2),
            element.getGUIElement().getHeight() / (float) (Display.getHeight() / 2));

    this.loadUniformMatrix("transformationMatrix", transformationMatrix);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, element.getGUIElement().getTexture().getTextureID());
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6);

    GL20.glDisableVertexAttribArray(VERTEX_POSITIONS);
    GL20.glDisableVertexAttribArray(TEXTURE_COORDS);
    GL30.glBindVertexArray(0);//from  ww w.  j  a v a2s.co  m
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glDisableVertexAttribArray(int index) {
    GL20.glDisableVertexAttribArray(index);
}

From source file:itdelatrisu.opsu.render.CurveRenderState.java

License:Open Source License

/**
 * Do the actual drawing of the curve into the currently bound framebuffer.
 * @param color the color of the curve/* w  w w.  j a va2 s  .com*/
 * @param borderColor the curve border color
 * @param curve the points along the curve
 */
private void draw_curve(Color color, Color borderColor, Vec2f[] curve) {
    staticState.initGradient();
    RenderState state = startRender();
    int vtx_buf;
    // the size is: floatsize * (position + texture coordinates) * (number of cones) * (vertices in a cone)
    FloatBuffer buff = BufferUtils
            .createByteBuffer(4 * (4 + 2) * (2 * curve.length - 1) * (NewCurveStyleState.DIVIDES + 2))
            .asFloatBuffer();
    staticState.initShaderProgram();
    vtx_buf = GL15.glGenBuffers();
    for (int i = 0; i < curve.length; ++i) {
        float x = curve[i].x;
        float y = curve[i].y;
        //if (i == 0 || i == curve.length - 1){
        fillCone(buff, x, y, NewCurveStyleState.DIVIDES);
        if (i != 0) {
            float last_x = curve[i - 1].x;
            float last_y = curve[i - 1].y;
            double diff_x = x - last_x;
            double diff_y = y - last_y;
            x = (float) (x - diff_x / 2);
            y = (float) (y - diff_y / 2);
            fillCone(buff, x, y, NewCurveStyleState.DIVIDES);
        }
    }
    buff.flip();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vtx_buf);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buff, GL15.GL_STATIC_DRAW);
    GL20.glUseProgram(staticState.program);
    GL20.glEnableVertexAttribArray(staticState.attribLoc);
    GL20.glEnableVertexAttribArray(staticState.texCoordLoc);
    GL20.glUniform1i(staticState.texLoc, 0);
    GL20.glUniform3f(staticState.colLoc, color.r, color.g, color.b);
    GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a);
    //stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w)
    //2*4 is for skipping the first 2 floats (u,v)
    GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4);
    GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0);
    for (int i = 0; i < curve.length * 2 - 1; ++i)
        GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2),
                NewCurveStyleState.DIVIDES + 2);
    GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
    GL20.glDisableVertexAttribArray(staticState.attribLoc);
    GL15.glDeleteBuffers(vtx_buf);
    endRender(state);
}

From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public void disableVertexAttribArray(int id) {
    GL20.glDisableVertexAttribArray(id);
}

From source file:main.EntityRenderer.java

private void unbindTextureModel() {
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL30.glBindVertexArray(0);
}

From source file:main.java.com.YeAJG.game.entity.Entity.java

License:Open Source License

@Override
public void Render(float interpolation) {

    GL20.glUseProgram(pId);//from w w  w . j av a 2  s . co m

    // Bind the texture
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

    // Bind to the VAO that has all the information about the vertices
    GL30.glBindVertexArray(vaoId);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    // Bind to the index VBO that has all the information about the order of the vertices
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId);

    // Draw the vertices
    GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0);

    // Put everything back to default (deselect)
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL30.glBindVertexArray(0);

    GL20.glUseProgram(0);

    Game.exitOnGLError("renderCycle");
}

From source file:main.java.com.YeAJG.game.entity.Entity.java

License:Open Source License

public void destroy() {
    // Delete the Program
    GL20.glUseProgram(0);//from w w w .j a v  a 2 s. c o m
    GL20.glDeleteProgram(pId);

    // Select the VAO
    GL30.glBindVertexArray(vaoId);

    // Disable the VBO index from the VAO attributes list
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);

    // Delete the vertex VBO
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboId);

    // Delete the index VBO
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboiId);

    // Delete the VAO
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vaoId);
}

From source file:me.sunchiro.game.engine.gl.Graphic.java

License:Open Source License

private synchronized void render() {
    GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL20.glUseProgram(shader.getPID());/* w  w  w .  ja  v  a  2  s . co  m*/
    //

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL30.glBindVertexArray(vaoId);

    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid));
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId);
    long offset = 0;
    int shift = 0;
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    for (Drawable object : objects) {
        Matrix4f finalMVP = new Matrix4f(mvpMat);
        Matrix4f modelMat = new Matrix4f();
        Matrix4f scaler = new Matrix4f();
        scaler.scale(object.scale * allScale);
        modelMat.translate(object.translation);
        modelMat.rotateXYZ(object.rotation.x, object.rotation.y, object.rotation.z);
        finalMVP.mul(modelMat);
        finalMVP.mul(scaler);
        finalMVP.get(0, matBuff);
        if (object.isChar) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid_charmap));
        }
        GL20.glUniformMatrix4fv(shader.getMVPLocation(), false, matBuff);
        GL20.glUniform1i(shader.getInverseLocation(), object.inverseAlpha ? 1 : 0);
        if (object.isVisible())
            GL32.glDrawElementsBaseVertex(GL11.GL_TRIANGLES, object.getIndices().length, GL11.GL_UNSIGNED_BYTE,
                    offset, shift);

        offset += object.getIndices().length;
        shift += object.getVertex().length;
        if (object.isChar) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid));
        }
    }
    render2d(offset, shift);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL30.glBindVertexArray(0);
    //
    GL20.glUseProgram(0);
    glfwSwapBuffers(window);
    glfwPollEvents();

}

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30VertexArray.java

License:Open Source License

@Override
public void addAttribute(int index, int size, TFloatList data) {
    ensureCreated("VertexArray must be created to add an attribute.");

    if (index > GL11.glGetInteger(GL_MAX_VERTEX_ATTRIBS)) {
        throw new IllegalArgumentException("Vertex attribute index exceeds maximum vertex attribute index.");
    }/*from w  w w  . j a va 2s  .  c  o  m*/
    // Put the indices into an FloatBuffer
    final FloatBuffer buffer = BufferUtils.createFloatBuffer(data.size());
    data.forEach((float f) -> {
        buffer.put(f);
        return true;
    });
    buffer.flip();

    // Bind the VAO
    GL30.glBindVertexArray(vao);
    // Generate and bind the attribute buffer
    final int id = GL15.glGenBuffers();
    GL15.glBindBuffer(GL_ARRAY_BUFFER, id);
    // Set the attribute data
    GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
    // Enable the vertex attribute
    GL20.glEnableVertexAttribArray(index);
    // Set the vertex attribute settings
    GL20.glVertexAttribPointer(index, size, DataType.FLOAT.getGLConstant(), false, 0, 0L);
    // Disable the vertex attribute
    GL20.glDisableVertexAttribArray(index);
    // Unbind the attribute buffer
    GL15.glBindBuffer(GL_ARRAY_BUFFER, 0);
    // Unbind the VAO
    GL30.glBindVertexArray(vao);

    // Add the buffer id to the attributes list
    this.attributes.insert(index, id);

    // Check for errors
    RenderUtil.checkGLError();
}