Example usage for org.lwjgl.opengl ARBFragmentProgram GL_FRAGMENT_PROGRAM_ARB

List of usage examples for org.lwjgl.opengl ARBFragmentProgram GL_FRAGMENT_PROGRAM_ARB

Introduction

In this page you can find the example usage for org.lwjgl.opengl ARBFragmentProgram GL_FRAGMENT_PROGRAM_ARB.

Prototype

int GL_FRAGMENT_PROGRAM_ARB

To view the source code for org.lwjgl.opengl ARBFragmentProgram GL_FRAGMENT_PROGRAM_ARB.

Click Source Link

Document

Accepted by the cap parameter of Disable, Enable, and IsEnabled, by the pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev, and by the target parameter of ProgramStringARB, BindProgramARB, ProgramEnvParameter4[df][v]ARB, ProgramLocalParameter4[df][v]ARB, GetProgramEnvParameter[df]vARB, GetProgramLocalParameter[df]vARB, GetProgramivARB and GetProgramStringARB.

Usage

From source file:com.ardor3d.scene.state.lwjgl.LwjglFragmentProgramStateUtil.java

License:Open Source License

private static int create(final ByteBuffer program) {

    final IntBuffer buf = BufferUtils.createIntBuffer(1);

    ARBProgram.glGenProgramsARB(buf);//from   w w  w .j  a v a  2s.  c  o m
    ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, buf.get(0));
    ARBProgram.glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB,
            ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, program);

    checkProgramError();

    return buf.get(0);
}

From source file:com.ardor3d.scene.state.lwjgl.LwjglFragmentProgramStateUtil.java

License:Open Source License

public static void apply(final FragmentProgramState state) {
    final RenderContext context = ContextManager.getCurrentContext();
    if (context.getCapabilities().isFragmentProgramSupported()) {
        final FragmentProgramStateRecord record = (FragmentProgramStateRecord) context
                .getStateRecord(StateType.FragmentProgram);
        context.setCurrentState(StateType.FragmentProgram, state);

        if (!record.isValid() || record.getReference() != state) {
            record.setReference(state);/*from   ww w. j  av a  2s .  co  m*/
            if (state.isEnabled()) {
                // Fragment program not yet loaded
                if (state._getProgramID() == -1) {
                    if (state.getProgramAsBuffer() != null) {
                        final int id = create(state.getProgramAsBuffer());
                        state._setProgramID(id);
                    } else {
                        return;
                    }
                }

                GL11.glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
                ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, state._getProgramID());

                // load environmental parameters...
                // TODO: Reevaluate how this is done.
                /*
                 * for (int i = 0; i < envparameters.length; i++) if (envparameters[i] != null)
                 * ARBFragmentProgram.glProgramEnvParameter4fARB( ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, i,
                 * envparameters[i][0], envparameters[i][1], envparameters[i][2], envparameters[i][3]);
                 */

                // load local parameters...
                if (state.isUsingParameters()) {
                    // no parameters are used
                    for (int i = 0; i < state._getParameters().length; i++) {
                        if (state._getParameters()[i] != null) {
                            ARBProgram.glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB,
                                    i, state._getParameters()[i][0], state._getParameters()[i][1],
                                    state._getParameters()[i][2], state._getParameters()[i][3]);
                        }
                    }
                }

            } else {
                GL11.glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
            }
        }

        if (!record.isValid()) {
            record.validate();
        }
    }
}