Example usage for org.lwjgl.opengl GL20 glBindAttribLocation

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

Introduction

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

Prototype

public static void glBindAttribLocation(@NativeType("GLuint") int program, @NativeType("GLuint") int index,
        @NativeType("GLchar const *") CharSequence name) 

Source Link

Document

Associates a generic vertex attribute index with a named attribute variable.

Usage

From source file:engine.render.Shader.PlayerShader.java

@Override
public void bindAttributeLocations() {
    GL20.glBindAttribLocation(programID, 0, "in_Position");
    // Color information will be attribute 1
    GL20.glBindAttribLocation(programID, 1, "in_Color");
    // Textute information will be attribute 2
    GL20.glBindAttribLocation(programID, 2, "in_TextureCoord");

    linkAndAttach(vsid);//w ww  .j a v a2s .  c om
    linkAndAttach(fsid);
}

From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java

private static void setupShaders() {
    int vsId = GraphicMotor.loadShader("resources/shader/ship.vert", GL20.GL_VERTEX_SHADER);
    int fsId = GraphicMotor.loadShader("resources/shader/ship.frag", GL20.GL_FRAGMENT_SHADER);

    instance.shipShaderId = GL20.glCreateProgram();
    GL20.glAttachShader(instance.shipShaderId, vsId);
    GL20.glAttachShader(instance.shipShaderId, fsId);
    GL20.glBindAttribLocation(instance.shipShaderId, 0, "in_Position");
    GL20.glBindAttribLocation(instance.shipShaderId, 1, "Normal");
    GL20.glBindAttribLocation(instance.shipShaderId, 2, "in_Color");
    GL20.glBindAttribLocation(instance.shipShaderId, 3, "in_TextureCoord");

    GL20.glLinkProgram(instance.shipShaderId);
    GL20.glValidateProgram(instance.shipShaderId);

    instance.projectionMatrixLocation = GL20.glGetUniformLocation(instance.shipShaderId, "projectionMatrix");
    instance.viewMatrixLocation = GL20.glGetUniformLocation(instance.shipShaderId, "viewMatrix");
    instance.modelMatrixLocation = GL20.glGetUniformLocation(instance.shipShaderId, "modelMatrix");

    instance.useTextureLocation = GL20.glGetUniformLocation(instance.shipShaderId, "use_texture");

    GraphicMotor.exitOnGLError("setupShaders");
}

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

License:Apache License

public static void glBindAttribLocation(int program, int index, String name) {
    GL20.glBindAttribLocation(program, index, name);
}

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

License:Open Source License

@Override
public void bindAttribLocation(int program, int index, String name) {
    GL20.glBindAttribLocation(program, index, name);
}

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

License:Open Source License

private void SetupShaders(String shaderPath, String fragPath) {
    // Load the vertex shader and fragment shader
    vsId = ShaderHandler.loadShader(shaderPath);
    fsId = ShaderHandler.loadFrag(fragPath);

    // Create a new shader program that links both shaders
    pId = GL20.glCreateProgram();//  w  w w . j  av a  2s . co  m
    GL20.glAttachShader(pId, vsId);
    GL20.glAttachShader(pId, fsId);

    // Position information will be attribute 0
    GL20.glBindAttribLocation(pId, 0, "in_Position");
    // Color information will be attribute 1
    GL20.glBindAttribLocation(pId, 1, "in_Color");
    // Textute information will be attribute 2
    GL20.glBindAttribLocation(pId, 2, "in_TextureCoord");

    GL20.glLinkProgram(pId);
    GL20.glValidateProgram(pId);

    // Get matrices uniform locations
    projectionMatrixLocation = GL20.glGetUniformLocation(pId, "projectionMatrix");
    viewMatrixLocation = GL20.glGetUniformLocation(pId, "viewMatrix");
    modelMatrixLocation = GL20.glGetUniformLocation(pId, "modelMatrix");

    decayLocation = GL20.glGetUniformLocation(pId, "decay");

    Game.exitOnGLError("setupShaders");
}

From source file:model.ModelMD2.java

public void setupShader() {
    vsId = ShaderUtils.makeShader(ShaderUtils.loadText("Resources/shaders/animation.vert"),
            GL20.GL_VERTEX_SHADER);//from  w w  w .  j av  a 2 s .  c  om
    // Load the fragment shader
    fsId = ShaderUtils.makeShader(ShaderUtils.loadText("Resources/shaders/animation.frag"),
            GL20.GL_FRAGMENT_SHADER);

    // Create a new shader program that links both shaders
    shader_id = ShaderUtils.makeProgram(vsId, fsId);

    GL20.glBindAttribLocation(shader_id, 0, "in_Position_0");
    GL20.glBindAttribLocation(shader_id, 1, "in_TextureCoord_0");
    GL20.glBindAttribLocation(shader_id, 2, "in_Normal_0");

    GL20.glBindAttribLocation(shader_id, 3, "in_Position_1");
    GL20.glBindAttribLocation(shader_id, 4, "in_TextureCoord_1");
    GL20.glBindAttribLocation(shader_id, 5, "in_Normal_1");

    GL20.glValidateProgram(shader_id);
    GLUtil.cerror(getClass().getName() + " setupShader");
}

From source file:net.smert.frameworkgl.opengl.helpers.ShaderHelper.java

License:Apache License

public void bindAttribLocation(int programID, int index, CharSequence chars) {
    GL20.glBindAttribLocation(programID, index, chars);
}

From source file:org.oscim.gdx.LwjglGL20.java

License:Apache License

public void bindAttribLocation(int program, int index, String name) {
    GL20.glBindAttribLocation(program, index, name);
}

From source file:org.spout.renderer.lwjgl.gl20.GL20Program.java

License:Open Source License

@Override
public void link() {
    checkCreated();/*from  ww  w  . j  a v  a 2  s . co m*/
    // Add the attribute layouts to the program state
    final TObjectIntIterator<String> iterator = attributeLayouts.iterator();
    while (iterator.hasNext()) {
        iterator.advance();
        // Bind the index to the name
        GL20.glBindAttribLocation(id, iterator.value(), iterator.key());
    }
    // Link program
    GL20.glLinkProgram(id);
    // Check program link status
    if (GL20.glGetProgrami(id, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
        throw new IllegalStateException("Program could not be linked\n" + GL20.glGetProgramInfoLog(id, 1000));
    }
    if (CausticUtil.isDebugEnabled()) {
        // Validate program
        GL20.glValidateProgram(id);
        // Check program validation status
        if (GL20.glGetProgrami(id, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
            final Logger logger = CausticUtil.getCausticLogger();
            logger.log(Level.WARNING,
                    "Program validation failed. This doesn''t mean it won''t work, so you maybe able to ignore it\n{0}",
                    GL20.glGetProgramInfoLog(id, 1000));
        }
    }
    // Load uniforms
    uniforms.clear();
    final int uniformCount = GL20.glGetProgrami(id, GL20.GL_ACTIVE_UNIFORMS);
    for (int i = 0; i < uniformCount; i++) {
        final ByteBuffer nameBuffer = CausticUtil.createByteBuffer(256);
        GL20.glGetActiveUniform(id, i, CausticUtil.createIntBuffer(1), CausticUtil.createIntBuffer(1),
                CausticUtil.createIntBuffer(1), nameBuffer);
        nameBuffer.rewind();
        final byte[] nameBytes = new byte[256];
        nameBuffer.get(nameBytes);
        // Simplify array names
        final String name = new String(nameBytes).trim().replaceFirst("\\[\\d+\\]", "");
        uniforms.put(name, GL20.glGetUniformLocation(id, name));
    }
    // Check for errors
    LWJGLUtil.checkForGLError();
}

From source file:playn.java.JavaGL20.java

License:Apache License

@Override
public void glBindAttribLocation(int program, int index, String name) {
    GL20.glBindAttribLocation(program, index, name);
}