OpenGL-shader-cant bind-Attribut

ich habe drei glsl Attribute in meiner vertex-shader

attribute highp   vec4  Position;
attribute mediump vec4  UV;
attribute mediump vec3  Normal;

dass im Bindung mit

glBindAttribLocation(program, 0, "Position");
glBindAttribLocation(program, 1, "Normal");
glBindAttribLocation(program, 2, "UV");

Aber ich erhalte eine Fehlermeldung

Konnte nicht finden, vertex-shader-Attribut 'Normal' zu entsprechen BindAttributeLocation Anfrage.

Warum kann es die Position finden und UV-Eigenschaften, aber nicht das Normale Attribut.

Jede Hilfe wäre sehr geschätzt, wie ich bin ziemlich verwirrt.

Cheers

Bearbeiten:
Ich habe das gleiche Problem auf Android OpenGLES20.
Ich werde hinzufügen von Beispielcode : der rest der Klasse ist die offizielle GLSurfaceView tutorial

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.

}
  • Ich sollte hinzufügen, dass ich getestet habe, die shader um sicherzustellen, dass die änderungen korrekt sind, aber noch keinen binden Sie das Normale Attribut
  • Wo bekommst du diesen Fehler?
  • Ich sollte darauf hinweisen, dass ich genau das gleiche problem "manchmal" auf Android-OpenGLES20. Nehmen Sie das tutorial, fügen Sie "normal", "aNormal", "norm", "whatever", um die sample-shader-code, versuchen Sie binden es direkt nach und es stürzt ab.
  • Haben Sie gerade Hinzugefügt haben, in Ihren "me-too" - Kommentar in einem anderen Benutzer Frage? Das kann ganz schön verwirrend.
  • yup, sorry, mein Fehler - es ist nur so, dass ich merkte, ich hatte die Beispiel-code, die jemand brauchen könnte, um die Antwort auf diese Frage. Nur dann habe ich verstanden, Rickard Antwort. Ich verstehe, wie verwirrend es ist geworden. Sorry nochmal!
InformationsquelleAutor user346443 | 2011-07-12
Schreibe einen Kommentar