Example usage for org.lwjgl.opengl GL20 glUseProgram

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

Introduction

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

Prototype

public static void glUseProgram(@NativeType("GLuint") int program) 

Source Link

Document

Installs a program object as part of current rendering state.

Usage

From source file:renderEngine.ShaderProgram.java

/**
 * Starts the program.
 */
public final void start() {
    GL20.glUseProgram(programID);
}

From source file:renderEngine.ShaderProgram.java

/**
 * Stops the program.
 */
public final void stop() {
    GL20.glUseProgram(0);
}

From source file:se.angergard.engine.graphics.RenderUtil.java

License:Apache License

/** Unbind's all shaders, */
public static void unbindShader() {
    GL20.glUseProgram(0);
}

From source file:se.angergard.engine.graphics.ShaderProgram.java

License:Apache License

/** Binds the program to the graphic card.
 * @return This ShaderProgram */
public ShaderProgram bind() {
    GL20.glUseProgram(program);
    return this;
}

From source file:thebounzer.org.lwgldemo.Chapter3.java

License:Open Source License

@Override
public void loopCycle() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GL20.glUseProgram(program.getId());

    vaoId = GL30.glGenVertexArrays();//from   w  w  w.j  a  v  a  2  s.  c om
    GL30.glBindVertexArray(vaoId);
    attributesBind(time += 0.01f);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
    GL20.glUseProgram(0);
}

From source file:thebounzer.org.lwgldemo.Chapter5.java

License:Open Source License

@Override
public void loopCycle() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    float f = (float) (time * Math.PI * 0.1f);
    Matrix4f modelViewM = new Matrix4f();
    Matrix4f mat = new Matrix4f();
    Matrix4f transOne = new Matrix4f();
    Matrix4f transTwo = new Matrix4f();
    Matrix4f rotaOne = new Matrix4f();
    Matrix4f rotaTwo = new Matrix4f();
    Matrix4f.translate(new Vector3f(0.0f, 0.0f, -0.4f), mat, transOne);
    Matrix4f.translate(new Vector3f((float) Math.sin(2.1f * f) * 0.5f, (float) Math.cos(1.7f * f) * 0.5f,
            (float) Math.sin(1.3f * f) * (float) Math.cos(1.5 * f) * 2.0f), mat, transTwo);
    Matrix4f.rotate(time * 45.0f, new Vector3f(0.0f, 1.0f, 0.0f), mat, rotaOne);
    Matrix4f.rotate(time * 81.0f, new Vector3f(1.0f, 0.0f, 0.0f), mat, rotaTwo);
    Matrix4f.mul(modelViewM, transOne, modelViewM);
    Matrix4f.mul(modelViewM, transTwo, modelViewM);
    Matrix4f.mul(modelViewM, rotaOne, modelViewM);
    Matrix4f.mul(modelViewM, rotaTwo, modelViewM);

    GL20.glUseProgram(program.getId());
    FloatBuffer matrixBuf = BufferUtils.createFloatBuffer(16);
    modelViewM.store(matrixBuf);//w  ww. j ava 2  s. c o m
    matrixBuf.flip();
    int uniLoc = GL20.glGetUniformLocation(program.getId(), "mv_matrix");
    GL20.glUniformMatrix4(uniLoc, false, matrixBuf);
    int uniProjMatLoc = GL20.glGetUniformLocation(program.getId(), "proj_matrix");
    GL20.glUniformMatrix4(uniProjMatLoc, false, matrixBuf);
    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);
    GL11.glDrawArrays(GL11.GL_POINTS, 0, 36);
    GL20.glUseProgram(0);
    time += 0.001f;
}

From source file:thebounzer.org.lwgldemo.glutils.ShaderProgram.java

License:Open Source License

public void destroy() {
    GL20.glUseProgram(0);
    for (GenericShader shader : programShaders)
        deleteShader(shader);
    GL20.glDeleteProgram(pId);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glUseProgram(int a) {
    GL20.glUseProgram(a);
    currentProgram = a;
}

From source file:uk.co.ifs_studios.engine.shader.ShaderProgram.java

License:Open Source License

/**
 * Use program.
 */
public void use() {
    GL20.glUseProgram(this.id);
}

From source file:uk.co.ifs_studios.engine.shader.ShaderProgram.java

License:Open Source License

/**
 * Set used program to null.
 */
public void unuse() {
    GL20.glUseProgram(0);
}