Package com.ardor3d.renderer.state.record

Examples of com.ardor3d.renderer.state.record.VertexProgramStateRecord


     */
    public static void apply(final VertexProgramState state) {
        final RenderContext context = ContextManager.getCurrentContext();
        if (context.getCapabilities().isVertexProgramSupported()) {
            // ask for the current state record
            final VertexProgramStateRecord record = (VertexProgramStateRecord) context
                    .getStateRecord(StateType.VertexProgram);
            context.setCurrentState(StateType.VertexProgram, state);

            if (!record.isValid() || record.getReference() != state) {
                record.setReference(state);
                if (state.isEnabled()) {
                    // Vertex 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(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
                    ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, state._getProgramID());

                    // load environmental parameters...
                    for (int i = 0; i < VertexProgramState._getEnvParameters().length; i++) {
                        if (VertexProgramState._getEnvParameters()[i] != null) {
                            ARBProgram.glProgramEnvParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, i,
                                    VertexProgramState._getEnvParameters()[i][0],
                                    VertexProgramState._getEnvParameters()[i][1],
                                    VertexProgramState._getEnvParameters()[i][2],
                                    VertexProgramState._getEnvParameters()[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(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, i,
                                        state._getParameters()[i][0], state._getParameters()[i][1],
                                        state._getParameters()[i][2], state._getParameters()[i][3]);
                            }
                        }
                    }

                } else {
                    GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
                }
            }

            if (!record.isValid()) {
                record.validate();
            }
        }
    }
View Full Code Here


        _program = capsule.readByteBuffer("program", null);
    }

    @Override
    public StateRecord createStateRecord(final ContextCapabilities caps) {
        return new VertexProgramStateRecord();
    }
View Full Code Here

        final RenderContext context = ContextManager.getCurrentContext();
        final ContextCapabilities caps = context.getCapabilities();

        if (caps.isVertexProgramSupported()) {
            // ask for the current state record
            final VertexProgramStateRecord record = (VertexProgramStateRecord) context
                    .getStateRecord(StateType.VertexProgram);
            context.setCurrentState(StateType.VertexProgram, state);

            if (!record.isValid() || record.getReference() != state) {
                record.setReference(state);
                if (state.isEnabled()) {
                    // Vertex program not yet loaded
                    if (state._getProgramID() == -1) {
                        if (state.getProgramAsBuffer() != null) {
                            final int id = create(state.getProgramAsBuffer());
                            state._setProgramID(id);
                        } else {
                            return;
                        }
                    }

                    gl.glEnable(GL2.GL_VERTEX_PROGRAM_ARB);
                    gl.getGL2().glBindProgramARB(GL2.GL_VERTEX_PROGRAM_ARB, state._getProgramID());

                    // load environmental parameters...
                    for (int i = 0; i < VertexProgramState._getEnvParameters().length; i++) {
                        if (VertexProgramState._getEnvParameters()[i] != null) {
                            gl.getGL2().glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i,
                                    VertexProgramState._getEnvParameters()[i][0],
                                    VertexProgramState._getEnvParameters()[i][1],
                                    VertexProgramState._getEnvParameters()[i][2],
                                    VertexProgramState._getEnvParameters()[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) {
                                gl.getGL2().glProgramLocalParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i,
                                        state._getParameters()[i][0], state._getParameters()[i][1],
                                        state._getParameters()[i][2], state._getParameters()[i][3]);
                            }
                        }
                    }

                } else {
                    gl.glDisable(GL2.GL_VERTEX_PROGRAM_ARB);
                }
            }

            if (!record.isValid()) {
                record.validate();
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.renderer.state.record.VertexProgramStateRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.