• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Shader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jme3.shader.Shader的典型用法代码示例。如果您正苦于以下问题:Java Shader类的具体用法?Java Shader怎么用?Java Shader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Shader类属于com.jme3.shader包,在下文中一共展示了Shader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deleteShader

import com.jme3.shader.Shader; //导入依赖的package包/类
public void deleteShader(Shader shader) {
        if (shader.getId() == -1) {
            logger.warning("Shader is not uploaded to GPU, cannot delete.");
            return;
        }
        for (ShaderSource source : shader.getSources()) {
            if (source.getId() != -1) {
                glDetachShader(shader.getId(), source.getId());
                // the next part is done by the GLObjectManager automatically
//                glDeleteShader(source.getId());
            }
        }
        // kill all references so sources can be collected
        // if needed.
        shader.resetSources();
        glDeleteProgram(shader.getId());

        statistics.onDeleteShader();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:LwjglRenderer.java


示例2: NodePanel

import com.jme3.shader.Shader; //导入依赖的package包/类
/**
 * Creates new form NodePanel
 */
@SuppressWarnings("LeakingThisInConstructor")
public NodePanel(ShaderNodeBlock node, ShaderNodeDefinition def) {
    super();
    shaderType = def.getType();
    if (def.getType() == Shader.ShaderType.Vertex) {
        type = NodePanel.NodeType.Vertex;
    } else {
        type = NodePanel.NodeType.Fragment;
    }
    init(def.getInputs(), def.getOutputs());

    node.addPropertyChangeListener(WeakListeners.propertyChange(this, node));
    this.addPropertyChangeListener(WeakListeners.propertyChange(node, this));
    refresh(node);
    addKeyListener(this);
    this.filePaths.addAll(def.getShadersPath());
    String defPath = ((DefinitionBlock) node.getContents().get(0)).getPath();
    this.filePaths.add(defPath);
    toolBar = new NodeToolBar(this);        
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:NodePanel.java


示例3: updateUniformLocation

import com.jme3.shader.Shader; //导入依赖的package包/类
/*********************************************************************\
 |* Shaders                                                           *|
 \*********************************************************************/
protected void updateUniformLocation(Shader shader, Uniform uniform) {
    stringBuf.setLength(0);
    stringBuf.append(uniform.getName()).append('\0');
    updateNameBuffer();
    if (verboseLogging) {
        logger.log(Level.INFO, "GLES20.glGetUniformLocation({0}, {1})", new Object[]{shader.getId(), uniform.getName()});
    }
    int loc = Gdx.gl20.glGetUniformLocation(shader.getId(), uniform.getName());
    checkGLError();
    if (loc < 0) {
        uniform.setLocation(-1);
        // uniform is not declared in shader
        if (verboseLogging) {
            logger.log(Level.WARNING, "Uniform [{0}] is not declared in shader.", uniform.getName());
        }
    } else {
        uniform.setLocation(loc);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:GdxRenderer.java


示例4: updateUniformLocation

import com.jme3.shader.Shader; //导入依赖的package包/类
/*********************************************************************\
|* Shaders                                                           *|
\*********************************************************************/
protected void updateUniformLocation(Shader shader, Uniform uniform) {
    stringBuf.setLength(0);
    stringBuf.append(uniform.getName()).append('\0');
    updateNameBuffer();
    if (verboseLogging) {
        logger.log(Level.INFO, "GLES20.glGetUniformLocation({0}, {1})", new Object[]{shader.getId(), uniform.getName()});
    }
    int loc = GLES20.glGetUniformLocation(shader.getId(), uniform.getName());
    checkGLError();
    if (loc < 0) {
        uniform.setLocation(-1);
        // uniform is not declared in shader
        if (verboseLogging) {
            logger.log(Level.WARNING, "Uniform [{0}] is not declared in shader.", uniform.getName());
        }
    } else {
        uniform.setLocation(loc);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:OGLESShaderRenderer.java


示例5: updateUniform

import com.jme3.shader.Shader; //导入依赖的package包/类
protected void updateUniform(Shader shader, Uniform uniform) {
    if (glslVer != -1) {
        int shaderId = shader.getId();

        assert uniform.getName() != null;
        assert shader.getId() > 0;
        if (context.boundShaderProgram != shaderId) {
            helper.useProgram(shaderId);
            statistics.onShaderUse(shader, true);
            boundShader = shader;
            context.boundShaderProgram = shaderId;
        }
        else {
            statistics.onShaderUse(shader, false);
        }

        updateUniformVar(shader, uniform);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:20,代码来源:AbstractRenderer.java


示例6: updateUniformLocation

import com.jme3.shader.Shader; //导入依赖的package包/类
protected void updateUniformLocation(Shader shader, Uniform uniform) {
    if (glslVer != -1) {
        stringBuf.setLength(0);
        stringBuf.append(uniform.getName()).append('\0');
        updateNameBuffer();
        int loc = getUniformLocation(shader);
        if (loc < 0) {
            uniform.setLocation(-1);
            // uniform is not declared in shader
            logger.log(Level.WARNING, "Uniform {0} is not declared in shader.",
                    uniform.getName());
        }
        else {
            uniform.setLocation(loc);
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:18,代码来源:AbstractRenderer.java


示例7: deleteShader

import com.jme3.shader.Shader; //导入依赖的package包/类
public void deleteShader(Shader shader) {
    if (glslVer != -1) {
        if (shader.getId() == -1) {
            logger.warning("Shader is not uploaded to GPU, cannot delete.");
            return;
        }
        GL gl = GLContext.getCurrentGL();
        for (ShaderSource source : shader.getSources()) {
            if (source.getId() != -1) {
                gl.getGL2().glDetachShader(shader.getId(), source.getId());
                // the next part is done by the GLObjectManager automatically
                // glDeleteShader(source.getId());
            }
        }
        // kill all references so sources can be collected
        // if needed.
        shader.resetSources();
        gl.getGL2().glDeleteProgram(shader.getId());

        statistics.onDeleteShader();
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:JoglRenderer.java


示例8: deleteShader

import com.jme3.shader.Shader; //导入依赖的package包/类
public void deleteShader(Shader shader) {
    if (shader.getId() == -1) {
        logger.warning("Shader is not uploaded to GPU, cannot delete.");
        return;
    }

    for (ShaderSource source : shader.getSources()) {
        if (source.getId() != -1) {
            glDetachShader(shader.getId(), source.getId());
            deleteShaderSource(source);
        }
    }

    // kill all references so sources can be collected
    // if needed.
    shader.resetSources();
    glDeleteProgram(shader.getId());

    statistics.onDeleteShader();
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:21,代码来源:LwjglRenderer.java


示例9: containsShader

import com.jme3.shader.Shader; //导入依赖的package包/类
/**
 * Check a material definition on containing a shader.
 *
 * @param materialDef the material definition.
 * @param assetPath   the path of the shader.
 * @return true if the material definition contains the shader.
 */
private static boolean containsShader(@NotNull final MaterialDef materialDef, @NotNull final String assetPath) {

    final List<TechniqueDef> defaultTechniques = materialDef.getTechniqueDefs("Default");

    for (final TechniqueDef technique : defaultTechniques) {
        final EnumMap<Shader.ShaderType, String> shaderProgramNames = technique.getShaderProgramNames();
        if (shaderProgramNames.containsValue(assetPath)) return true;
    }

    return false;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:19,代码来源:MaterialUtils.java


示例10: updateUniformLocation

import com.jme3.shader.Shader; //导入依赖的package包/类
/*********************************************************************\
|* Shaders                                                           *|
\*********************************************************************/
protected void updateUniformLocation(Shader shader, Uniform uniform) {
    stringBuf.setLength(0);
    stringBuf.append(uniform.getName()).append('\0');
    updateNameBuffer();
    int loc = glGetUniformLocation(shader.getId(), nameBuf);
    if (loc < 0) {
        uniform.setLocation(-1);
        // uniform is not declared in shader
        logger.log(Level.INFO, "Uniform {0} is not declared in shader.", uniform.getName());
    } else {
        uniform.setLocation(loc);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:LwjglRenderer.java


示例11: updateShaderUniforms

import com.jme3.shader.Shader; //导入依赖的package包/类
protected void updateShaderUniforms(Shader shader) {
        ListMap<String, Uniform> uniforms = shader.getUniformMap();
//        for (Uniform uniform : shader.getUniforms()){
        for (int i = 0; i < uniforms.size(); i++) {
            Uniform uniform = uniforms.getValue(i);
            if (uniform.isUpdateNeeded()) {
                updateUniform(shader, uniform);
            }
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:LwjglRenderer.java


示例12: resetUniformLocations

import com.jme3.shader.Shader; //导入依赖的package包/类
protected void resetUniformLocations(Shader shader) {
        ListMap<String, Uniform> uniforms = shader.getUniformMap();
//        for (Uniform uniform : shader.getUniforms()){
        for (int i = 0; i < uniforms.size(); i++) {
            Uniform uniform = uniforms.getValue(i);
            uniform.reset(); // e.g check location again
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:LwjglRenderer.java


示例13: onShaderUse

import com.jme3.shader.Shader; //导入依赖的package包/类
/**
 * Called by the Renderer when a shader has been utilized.
 * 
 * @param shader The shader that was used
 * @param wasSwitched If true, the shader has required a state switch
 */
public void onShaderUse(Shader shader, boolean wasSwitched){
    assert shader.id >= 1;

    if (!shadersUsed.contains(shader.id))
        shadersUsed.add(shader.id);

    if (wasSwitched)
        numShaderSwitches++;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:Statistics.java


示例14: preload

import com.jme3.shader.Shader; //导入依赖的package包/类
/**
 * Preloads this material for the given render manager.
 * <p>
 * Preloading the material can ensure that when the material is first
 * used for rendering, there won't be any delay since the material has
 * been already been setup for rendering.
 * 
 * @param rm The render manager to preload for
 */
public void preload(RenderManager rm) {
    autoSelectTechnique(rm);

    Renderer r = rm.getRenderer();
    TechniqueDef techDef = technique.getDef();

    Collection<MatParam> params = paramValues.values();
    for (MatParam param : params) {
        if (param instanceof MatParamTexture) {
            MatParamTexture texParam = (MatParamTexture) param;
            r.setTexture(0, texParam.getTextureValue());
        } else {
            if (!techDef.isUsingShaders()) {
                continue;
            }

            technique.updateUniformParam(param.getName(),
                    param.getVarType(),
                    param.getValue(), true);
        }
    }

    Shader shader = technique.getShader();
    if (techDef.isUsingShaders()) {
        r.setShader(shader);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:Material.java


示例15: clearUniformsSetByCurrent

import com.jme3.shader.Shader; //导入依赖的package包/类
private void clearUniformsSetByCurrent(Shader shader) {
    ListMap<String, Uniform> uniforms = shader.getUniformMap();
    for (int i = 0; i < uniforms.size(); i++) {
        Uniform u = uniforms.getValue(i);
        u.clearSetByCurrentMaterial();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:Material.java


示例16: resetUniformsNotSetByCurrent

import com.jme3.shader.Shader; //导入依赖的package包/类
private void resetUniformsNotSetByCurrent(Shader shader) {
    ListMap<String, Uniform> uniforms = shader.getUniformMap();
    for (int i = 0; i < uniforms.size(); i++) {
        Uniform u = uniforms.getValue(i);
        if (!u.isSetByCurrentMaterial()) {
            u.clearValue();
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:Material.java


示例17: read

import com.jme3.shader.Shader; //导入依赖的package包/类
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = im.getCapsule(this);
    def = (TechniqueDef) ic.readSavable("def", null);
    worldBindUniforms = ic.readSavableArrayList("worldBindUniforms", null);
    defines = (DefineList) ic.readSavable("defines", null);
    shader = (Shader) ic.readSavable("shader", null);
    //if (shader != null)
    //    owner.updateUniformLinks();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:Technique.java


示例18: createDoc

import com.jme3.shader.Shader; //导入依赖的package包/类
private void createDoc(ShaderNodeDefinition def) {
    JTextPane doc = new JTextPane();
    doc.setEditable(false);
    //doc.setBackground(new java.awt.Color(240, 240, 240));
    doc.setMaximumSize(new java.awt.Dimension(300, 300));
    doc.setMinimumSize(new java.awt.Dimension(300, 300));
    doc.setPreferredSize(new java.awt.Dimension(300, 300));
    JScrollPane defPanel = new JScrollPane();
    defPanel.setViewportView(doc);

    jTabbedPane1.addTab(def.getName(), def.getType() == Shader.ShaderType.Vertex ? Icons.vert : Icons.frag, defPanel);
    doc.setText("");
    DocFormatter.addDoc(def, doc.getStyledDocument());
    doc.setCaretPosition(0);
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:16,代码来源:AddNodeDialog.java


示例19: getType

import com.jme3.shader.Shader; //导入依赖的package包/类
public Shader.ShaderType getType() {
    if (btnGroup.isSelected(vertButton.getModel())) {
        return Shader.ShaderType.Vertex;
    } else {
        return Shader.ShaderType.Fragment;
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:8,代码来源:ShaderVisualToolBar.java


示例20: getImageIcon

import com.jme3.shader.Shader; //导入依赖的package包/类
private Image getImageIcon() {
    if (def.getType() == Shader.ShaderType.Vertex) {
        return Icons.vert.getImage();
    } else {
        return Icons.frag.getImage();
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:8,代码来源:ShaderNodeNode.java



注:本文中的com.jme3.shader.Shader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TypedArrayData类代码示例发布时间:2022-05-23
下一篇:
Java MimePartDataSource类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap