jmo*_*ggr 4 c++ opengl glsl emscripten
我无法让emscripten使用openGL着色器.该项目使用emscripten和gcc编译得很好但是当我尝试运行emscripten输出时失败.
我从编译顶点着色器得到的错误:
ERROR: 0:1: 'core' : invalid version directive
ERROR: 0:3: 'layout' : syntax error
Run Code Online (Sandbox Code Playgroud)
我从编译片段着色器得到的错误:
ERROR: 0:1: 'core' : invalid version directive
ERROR: 0:3: 'in' : storage qualifier supported in GLSL ES 3.00 only
ERROR: 0:3: '' : No precision specified for (float)
ERROR: 0:5: 'out' : storage qualifier supported in GLSL ES 3.00 only
ERROR: 0:5: '' : No precision specified for (float)
Run Code Online (Sandbox Code Playgroud)
我正在使用以下命令编译此项目:
em++ src/*.cpp -Iinclude/ -o test.html -std=c++11 -s USE_GLFW=3 -s FULL_ES3=1
Run Code Online (Sandbox Code Playgroud)
顶点着色器源:
#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 in_color;
uniform mat4 model;
uniform mat4 projection;
out vec3 out_color;
void main()
{
gl_Position = projection * model * vec4(position, 1.0f);
out_color = in_color;
}
Run Code Online (Sandbox Code Playgroud)
片段着色器源:
#version 330 core
in vec3 out_color;
out vec4 color;
void main()
{
color = vec4(out_color, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
着色器作为char数组从xxd -i我在linux上的c ++ 11中提供的输出中加载.当我以原生方式运行程序时,该程序运行正常,我尝试在Firefox和chrome中运行emscripten输出.
这似乎是不同版本之间的问题.有没有办法让emscripten与我现在拥有的东西一起工作,或者我必须以不同的方式编写着色器吗?如果我必须重写我的着色器,我该怎么写呢?