Package com.ardor3d.renderer.state.record

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


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

        if (caps.isGLSLSupported()) {
            // Ask for the current state record
            final ShaderObjectsStateRecord record = (ShaderObjectsStateRecord) context
                    .getStateRecord(StateType.GLSLShader);
            context.setCurrentState(StateType.GLSLShader, state);

            if (state.isEnabled()) {
                if (state._needSendShader) {
                    sendToGL(state, caps);
                }

                if (state._shaderDataLogic != null) {
                    state._shaderDataLogic.applyData(state, state._mesh, renderer);
                }
            }

            if (!record.isValid() || record.getReference() != state || state.needsRefresh()) {
                record.setReference(state);
                if (state.isEnabled() && state._programID != -1) {
                    // clear any previously existing attributes
                    clearEnabledAttributes(record);

                    // set our current shader
                    LwjglShaderUtil.useShaderProgram(state._programID, record);

                    for (int i = state.getShaderAttributes().size(); --i >= 0;) {
                        final ShaderVariable shaderVariable = state.getShaderAttributes().get(i);
                        if (shaderVariable.needsRefresh) {
                            LwjglShaderUtil.updateAttributeLocation(shaderVariable, state._programID);
                            shaderVariable.needsRefresh = false;
                        }
                        LwjglShaderUtil.updateShaderAttribute(renderer, shaderVariable, state.isUseAttributeVBO());
                    }

                    for (int i = state.getShaderUniforms().size(); --i >= 0;) {
                        final ShaderVariable shaderVariable = state.getShaderUniforms().get(i);
                        if (shaderVariable.needsRefresh) {
                            LwjglShaderUtil.updateUniformLocation(shaderVariable, state._programID);
                            LwjglShaderUtil.updateShaderUniform(shaderVariable);
                            shaderVariable.needsRefresh = false;
                        }
                    }
                } else {
                    LwjglShaderUtil.useShaderProgram(0, record);

                    clearEnabledAttributes(record);
                }
            }

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


        final ContextCapabilities caps = context.getCapabilities();
        if (caps.isVBOSupported() && !useVBO) {
            renderer.unbindVBO();
        }

        final ShaderObjectsStateRecord record = (ShaderObjectsStateRecord) context.getStateRecord(StateType.GLSLShader);

        if (shaderVariable instanceof ShaderVariablePointerFloat) {
            updateShaderAttribute((ShaderVariablePointerFloat) shaderVariable, record, useVBO);
        } else if (shaderVariable instanceof ShaderVariablePointerFloatMatrix) {
            updateShaderAttribute((ShaderVariablePointerFloatMatrix) shaderVariable, record, useVBO);
View Full Code Here

        }
    }

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

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

        if (caps.isGLSLSupported()) {
            // Ask for the current state record
            final ShaderObjectsStateRecord record = (ShaderObjectsStateRecord) context
                    .getStateRecord(StateType.GLSLShader);
            context.setCurrentState(StateType.GLSLShader, state);

            if (state.isEnabled()) {
                if (state._needSendShader) {
                    sendToGL(state, caps);
                }

                if (state._shaderDataLogic != null) {
                    state._shaderDataLogic.applyData(state, state._mesh, renderer);
                }
            }

            if (!record.isValid() || record.getReference() != state || state.needsRefresh()) {
                record.setReference(state);
                if (state.isEnabled() && state._programID != -1) {
                    // clear any previously existing attributes
                    clearEnabledAttributes(record, gl);

                    // set our current shader
                    JoglShaderUtil.useShaderProgram(state._programID, record);

                    final List<ShaderVariable> attribs = state.getShaderAttributes();
                    for (int i = attribs.size(); --i >= 0;) {
                        final ShaderVariable shaderVariable = attribs.get(i);
                        if (shaderVariable.needsRefresh) {
                            JoglShaderUtil.updateAttributeLocation(shaderVariable, state._programID);
                            shaderVariable.needsRefresh = false;
                        }
                        JoglShaderUtil.updateShaderAttribute(renderer, shaderVariable, state.isUseAttributeVBO());
                    }

                    final List<ShaderVariable> uniforms = state.getShaderUniforms();
                    for (int i = uniforms.size(); --i >= 0;) {
                        final ShaderVariable shaderVariable = uniforms.get(i);
                        if (shaderVariable.needsRefresh) {
                            JoglShaderUtil.updateUniformLocation(shaderVariable, state._programID);
                            JoglShaderUtil.updateShaderUniform(shaderVariable);
                            shaderVariable.needsRefresh = false;
                        }
                    }
                } else {
                    JoglShaderUtil.useShaderProgram(0, record);

                    clearEnabledAttributes(record, gl);
                }
            }

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

        final ContextCapabilities caps = context.getCapabilities();
        if (caps.isVBOSupported() && !useVBO) {
            renderer.unbindVBO();
        }

        final ShaderObjectsStateRecord record = (ShaderObjectsStateRecord) context.getStateRecord(StateType.GLSLShader);

        if (shaderVariable instanceof ShaderVariablePointerFloat) {
            updateShaderAttribute((ShaderVariablePointerFloat) shaderVariable, record, useVBO);
        } else if (shaderVariable instanceof ShaderVariablePointerFloatMatrix) {
            updateShaderAttribute((ShaderVariablePointerFloatMatrix) shaderVariable, record, useVBO);
View Full Code Here

TOP

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

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.