【发布时间】:2014-08-30 03:04:22
【问题描述】:
// Application to vertex shader
varying vec3 N;
varying vec3 I;
varying vec4 Cs;
void main()
{
vec4 P = gl_ModelViewMatrix * gl_Vertex;
I = P.xyz - vec3 (0);
N = gl_NormalMatrix * gl_Normal;
Cs = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
此着色器适用于我在 OSX 上运行的 3D 模型。但是,我正在尝试为 openFrameworks 和适用于 Android 的 openGL ES 2.0 运行相同的模型。我的 3D 模型正在正确加载,并且我的片段着色器似乎正在为 openGL ES 2.0 正确编译。但是,我的顶点着色器不会编译。有谁知道我可以如何更改此代码以便在 Android 上运行?
这是我在 LogCat 中看到的:
08-29 13:47:24.499: V/ofShader(26349): checkAndCreateProgram(): creating GLSL program
08-29 13:47:24.499: E/ofShader(26349): setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
08-29 13:47:24.499: E/(26349): ofShader: GL_VERTEX_SHADER shader reports:
08-29 13:47:24.499: E/(26349): Vertex shader compilation failed.
08-29 13:47:24.499: E/(26349): ERROR: 0:8: 'gl_ModelViewMatrix' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:8: 'gl_Vertex' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:8: '=' : cannot convert from 'float' to '4-component vector of float'
08-29 13:47:24.499: E/(26349): ERROR: 0:10: 'gl_NormalMatrix' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:10: 'gl_Normal' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:10: 'assign' : cannot convert from 'float' to 'varying 3-component vector of float'
08-29 13:47:24.499: E/(26349): ERROR: 0:11: 'gl_Color' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:11: 'assign' : cannot convert from 'float' to 'varying 4-component vector of float'
08-29 13:47:24.499: E/(26349): ERROR: 0:12: 'gl_ModelViewProjectionMatrix' : undeclared identifier
08-29 13:47:24.499: E/(26349): ERROR: 0:12: 'assign' : cannot convert from 'float' to 'Position 4-component vector of float'
08-29 13:47:24.499: E/(26349): ERROR: 10 compilation errors. No code generated.
08-29 13:47:24.499: V/ofShader(26349): setupShaderFromSource(): GL_FRAGMENT_SHADER shader compiled
08-29 13:47:24.499: V/(26349): linkProgram(): attaching GL_FRAGMENT_SHADER shader to program 22
08-29 13:47:24.499: E/ofShader(26349): checkProgramLinkStatus(): program failed to link
【问题讨论】:
-
您在 GL 日志中看到了什么错误?
-
我编辑了帖子以包含 LogCat 输出;谢谢。