私は3つのGLSLは、しかし、私はエラーにOpenGLのシェーダカントbind属性
を取得しています、私の頂点シェーダ
glBindAttribLocation(program, 0, "Position");
glBindAttribLocation(program, 1, "Normal");
glBindAttribLocation(program, 2, "UV");
を使用して結合イム
attribute highp vec4 Position;
attribute mediump vec4 UV;
attribute mediump vec3 Normal;
に属性を持っていますBindAttributeLocation要求に一致する頂点シェーダ属性 'Normal'を見つけることができませんでした。
[位置]属性と[UV]属性は検索できますが、[標準]属性は検索できないのはなぜですか。
私はかなり混乱しているので、どんな助けも高く評価されます。
乾杯
編集: 私はAndroidのOpenGLES20に同じ問題を持っています。 私は、サンプルコードを追加します:クラスの残りの部分は公式GLSurfaceViewチュートリアル
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
String mVertexShader = "uniform mat4 uMVPMatrix;\n " +
"attribute vec4 aPosition;\n " +
"attribute vec4 aNormal; \n " + //this is the line I added
"attribute vec2 aTextureCoord;\n " +
"varying vec2 vTextureCoord;\n " +
"void main() {\n " +
"gl_Position = uMVPMatrix * aPosition;\n" +
" vTextureCoord = aTextureCoord;\n" +
"}\n";
mProgram = createProgram(mVertexShader, mFragmentShader); // cf tutorial
if (mProgram == 0) {
return;
}
initShaderHandles(); //initializes the rest of the handles (cf tutorial)
// my little additional code
int maNormalHandle = GLES20.glGetAttribLocation(mProgram, "aNormal");
Log.d("ATTRIB LOCATION Normal: ", maNormalHandle + "");
checkGlError("glGetAttribLocation normal");
if (maNormalHandle == -1) {
throw new RuntimeException(
"Could not get attrib location for normal");
}
// ...and we crash.
}
シェーダをテストして、修正が正しく機能していることを確認しましたが、まだノーマルアトリビュートをバインドできません。 – user346443
どこからこのエラーが発生しますか? – kvark
私は、Android OpenGLES20ではまったく同じ問題が「時には」あることを指摘しておきます。チュートリアルを取り、サンプルのシェーダコードに "normal"、 "aNormal"、 "norm"、 "whatever"を追加し、直後にバインドしようとするとクラッシュします。 –