Example usage for org.lwjgl.opengl GL20 glGetAttribLocation

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

Introduction

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

Prototype

@NativeType("GLint")
public static int glGetAttribLocation(@NativeType("GLuint") int program,
        @NativeType("GLchar const *") CharSequence name) 

Source Link

Document

Returns the location of an attribute variable.

Usage

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public int glGetAttribLocation(int program, String name) {
    return GL20.glGetAttribLocation(program, name);
}

From source file:com.google.gapid.glviewer.gl.Shader.java

License:Apache License

private static Attribute[] getActiveAttributes(int program) {
    int maxAttribNameLength = GL20.glGetProgrami(program, GL20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
    int numAttributes = GL20.glGetProgrami(program, GL20.GL_ACTIVE_ATTRIBUTES);
    IntBuffer size = createIntBuffer(1), type = createIntBuffer(1);

    Attribute[] result = new Attribute[numAttributes];
    for (int i = 0; i < numAttributes; i++) {
        String name = GL20.glGetActiveAttrib(program, i, maxAttribNameLength, size, type);
        result[i] = new Attribute(GL20.glGetAttribLocation(program, name), name, type.get(0));
    }/*from  w ww  .ja  va 2s  . co  m*/
    return result;
}

From source file:com.google.gapid.glviewer.gl.Util.java

License:Apache License

public static AttributeOrUniform[] getActiveAttributes(int program) {
    int maxAttribNameLength = getProgramiv(program, GL20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
    int numAttributes = getProgramiv(program, GL20.GL_ACTIVE_ATTRIBUTES);
    IntBuffer size = createIntBuffer(1), type = createIntBuffer(1);

    AttributeOrUniform[] result = new AttributeOrUniform[numAttributes];
    for (int i = 0; i < numAttributes; i++) {
        String name = GL20.glGetActiveAttrib(program, i, maxAttribNameLength, size, type);
        result[i] = new AttributeOrUniform(GL20.glGetAttribLocation(program, name), name, type.get(0),
                size.get(0));/* w  w  w  . j  a  v a2  s.  c  om*/
    }
    return result;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Returns the location of the attribute with the given name, or -1 if none
 * with the given name exists.//from   w  ww .  j a v  a2s .co  m
 * 
 * @param name The name of the attribute to find.
 * @return The location of the attribute.
 */
public int getAttributeLocation(String name) {
    return GL20.glGetAttribLocation(id, name);
}

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

License:Apache License

public static int glGetAttribLocation(int program, String name) {
    return GL20.glGetAttribLocation(program, name);
}

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

License:Open Source License

@Override
public int getAttribLocation(int program, String name) {
    return GL20.glGetAttribLocation(program, name);
}

From source file:net.neilcsmith.praxis.video.opengl.internal.ShaderProgram.java

License:Apache License

private int fetchAttributeLocation(String name) {
    Integer location;/*from w  ww  . j  a va 2s  .  com*/
    if ((location = attributes.get(name)) == null) {
        location = GL20.glGetAttribLocation(program, name);
        if (location != -1)
            attributes.put(name, location);
    }
    return location;
}

From source file:net.neilcsmith.praxis.video.opengl.internal.ShaderProgram.java

License:Apache License

private void fetchAttributes() {
    params.clear();//from   ww w . j  a v a  2s  . co  m
    GL20.glGetProgram(program, GL20.GL_ACTIVE_ATTRIBUTES, params);
    int numAttributes = params.get(0);

    attributeNames = new String[numAttributes];

    for (int i = 0; i < numAttributes; i++) {
        params.clear();
        params.put(0, 256);
        type.clear();
        String name = glGetActiveAttrib(program, i, params, type);
        int location = GL20.glGetAttribLocation(program, name);
        attributes.put(name, location);
        attributeTypes.put(name, type.get(0));
        attributeNames[i] = name;
    }
}

From source file:opengl.test.object.CaroTable.java

/**
 * Method nay duoc tach rieng ra tu initVertex 
 * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer
 *///from   ww w  . jav  a2  s  .c  om
@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4);
    // size = 3 --> vec3

    int texcoordID = GL20.glGetAttribLocation(programID, "texcoord");
    GL20.glEnableVertexAttribArray(texcoordID);
    GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4);
    // size = 2 --> vec2
}

From source file:opengl.test.object.cube.wall.java

@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4);
    // size = 3 --> vec3

    int texcoordID = GL20.glGetAttribLocation(programID, "texcoord");
    GL20.glEnableVertexAttribArray(texcoordID);
    GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4);
    // size = 2 --> vec2
}