gpt4 book ai didi

android - 如何在 C 中将 *.vert 和 *.frag 转换为 char?

转载 作者:太空宇宙 更新时间:2023-11-04 04:22:21 25 4
gpt4 key购买 nike

<分区>

我正在用 NDK 示例编写一个 OpenGL。

main.c 中我的着色器代码:

const char vShaderStr[] =
"#version 300 es \n"
"uniform mat4 u_mvpMatrix; \n"
"layout(location = 0) in vec4 a_position; \n"
"layout(location = 1) in vec4 a_color; \n"
"out vec4 v_color; \n"
"void main() \n"
"{ \n"
" v_color = a_color; \n"
" gl_Position = u_mvpMatrix * a_position; \n"
"} \n";

const char fShaderStr[] =
"#version 300 es \n"
"precision mediump float; \n"
"in vec4 v_color; \n"
"layout(location = 0) out vec4 outColor; \n"
"void main() \n"
"{ \n"
" outColor = v_color; \n"
"} \n";

userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );

我试过这个snippet转换(我也在main.c中改变了create shader的方式),但是失败了:

我想通过在 main.c 中读取它们来使用外部着色器文件。

如何转换?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com