如何在android相机中使用anyFile.vsh和anyFile.fsh提供着色器效果?

发布于 2024-12-11 03:58:13 字数 186 浏览 0 评论 0原文

在我的应用程序中,我必须使用 Android 相机和 OpenGLES。 我还必须使用两个名为 one.vsh 和 one.fsh 的文件为相机视觉提供效果,但我不知道如何在 OpenGLES 中实现该文件。

即使我也不知道如何实现 android 相机与 OPENGLES 一起使用这两个文件来实现效果。

请帮助我。 谢谢。

In My application i have to use the Android Camera, and OpenGLES.
I have also have to give the effect to the Camera Vision with two files called one.vsh and one.fsh But i dont know how to implement that file in OpenGLES.

Even i also dont know how to implement android camera to work with OPENGLES to do effect with that two files.

Please help me for this.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不如归去 2024-12-18 03:58:13

嗯,我没有对Android相机进行过测试来使用这种效果。
当然,您可以在 onSurfaceCreated 方法中使用着色器文件,如下所示:

//
// Initialize the shader and program object
//
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    String vShaderStr = "uniform mat4 u_mvpMatrix;         \n"
            + "attribute vec4 a_position;                  \n"
            + "void main()                                 \n"
            + "{                                           \n"
            + "   gl_Position = u_mvpMatrix * a_position;  \n"
            + "}                                           \n";


    String fShaderStr = "precision mediump float;                  \n"
            + "void main()                                         \n"
            + "{                                                   \n"
            + "  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );        \n"
            + "}                                                   \n";

    // Load the shaders and get a linked program object
    mProgramObject = ESShader.loadProgram(vShaderStr, fShaderStr);

    // Get the attribute locations
    mPositionLoc = GLES20.glGetAttribLocation(mProgramObject, "position");

    // Get the uniform locations
    mMVPLoc = GLES20.glGetUniformLocation(mProgramObject, "u_mvpMatrix");

    // Generate the vertex data
    mCube.genCube(1.0f);

    // Starting rotation angle for the cube
    mAngle = 45.0f;

    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

只需替换要用于顶点着色器和片段着色器的 String 即可。
希望这有帮助。

Well, I don't have a test about Android camera to use such effect on it.
But ofcourse, you can use the shader file in the onSurfaceCreated method as like below:

//
// Initialize the shader and program object
//
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    String vShaderStr = "uniform mat4 u_mvpMatrix;         \n"
            + "attribute vec4 a_position;                  \n"
            + "void main()                                 \n"
            + "{                                           \n"
            + "   gl_Position = u_mvpMatrix * a_position;  \n"
            + "}                                           \n";


    String fShaderStr = "precision mediump float;                  \n"
            + "void main()                                         \n"
            + "{                                                   \n"
            + "  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );        \n"
            + "}                                                   \n";

    // Load the shaders and get a linked program object
    mProgramObject = ESShader.loadProgram(vShaderStr, fShaderStr);

    // Get the attribute locations
    mPositionLoc = GLES20.glGetAttribLocation(mProgramObject, "position");

    // Get the uniform locations
    mMVPLoc = GLES20.glGetUniformLocation(mProgramObject, "u_mvpMatrix");

    // Generate the vertex data
    mCube.genCube(1.0f);

    // Starting rotation angle for the cube
    mAngle = 45.0f;

    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

Just replace the String that you want to use for vertex shader and fragment shader.
Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文