I´m doing my own game framework and I found a very strange behaviour. When calling to GLES20.glUniform1i(samplerLocation, GLES20.GL_TEXTURE0) and checking if any error is found with GLES20.glGetError() I get an 1281 error (bad value) if executing in Genymotion emulating a Nexus 6 device. If I try the same with my moto g (2014 edition) I dont get any error with GLES20.glUniform1i, but instead when calling drawElements I get this other error:

03-20 15:09:23.087    9260-9692/com.manu.juegos.half_hero V/GLSurfaceView﹕ glGetString(7937) returns Adreno (TM) 305;
03-20 15:10:15.727    9260-9692/com.manu.juegos.half_hero W/Adreno-ES20﹕ <validate_samplers:252>: GL_INVALID_OPERATION
03-20 15:10:16.628    9260-9692/com.manu.juegos.half_hero E/framework.GLProg error:﹕ post Vertices3D.draw(): glError 1282

What do you think I could be doing wrong ?

EDIT:

This is how I upload texture units to sampler uniforms:

public void uploadUniformData(String uniformName, Object value){
    // triplet: locator, dataType, dataValue
    Map<String, Triplet<Integer, Integer, Object>> mapa_programa = GlProgram.m_Uniform_Cache_Store.get(m_GL_Program_ID);
    if (mapa_programa == null){
        throw new RuntimeException("GlProgram.uploadUniformData: mapa de programa no inicializado");
    }
    Triplet<Integer, Integer, Object> uniform_data = mapa_programa.get(uniformName);

    if (uniform_data == null){
        return; // por ejemplo normal texture no está implementado y no estará declarado en el shader
    }

    uniform_data.m_Z = value;
    Integer dataType = uniform_data.m_Y;
    Integer location = uniform_data.m_X;

    int[] intValArr = null;
    float[] floatValArr = null;
    int matrixCounterToUpload = 1;
    Integer intVal = null;

    switch (dataType) { // tipo de dato del uniform
        case GLES20.GL_INT:
            intVal = (Integer) value;
            GLES20.glUniform1i(location, intVal);
            break;
        case GLES20.GL_INT_VEC2:
            intValArr = (int[]) value;
            GLES20.glUniform2i(location, intValArr[0], intValArr[1]);
            break;
        case GLES20.GL_INT_VEC3:
            intValArr = (int[]) value;
            GLES20.glUniform3i(location, intValArr[0], intValArr[1], intValArr[2]);
            break;
        case GLES20.GL_INT_VEC4:
            intValArr = (int[]) value;
            GLES20.glUniform4i(location, intValArr[0], intValArr[1], intValArr[2], intValArr[3]);
            break;
        case GLES20.GL_FLOAT:
            Float floatVal = (Float) value;
            GLES20.glUniform1f(location, floatVal);
            break;
        case GLES20.GL_FLOAT_VEC2:
            floatValArr = (float[]) value;
            GLES20.glUniform2f(location, floatValArr[0], floatValArr[1]);
            break;
        case GLES20.GL_FLOAT_VEC3:
            floatValArr = (float[]) value;
            GLES20.glUniform3f(location, floatValArr[0], floatValArr[1], floatValArr[2]);
            break;
        case GLES20.GL_FLOAT_VEC4:
            floatValArr = (float[]) value;
            GLES20.glUniform4f(location, floatValArr[0], floatValArr[1], floatValArr[2], floatValArr[3]);
            break;
        case GLES20.GL_FLOAT_MAT2:
            floatValArr = (float[]) value;
            matrixCounterToUpload = 1; // no subimos array de matrices sino solo una matriz, al menos aquí
            GLES20.glUniformMatrix2fv(location, matrixCounterToUpload, false, floatValArr, 0);
            break;
        case GLES20.GL_FLOAT_MAT3:
            floatValArr = (float[]) value;
            matrixCounterToUpload = 1; // no subimos array de matrices sino solo una matriz, al menos aquí
            GLES20.glUniformMatrix3fv(location, matrixCounterToUpload, false, floatValArr, 0);
            break;
        case GLES20.GL_FLOAT_MAT4:
            floatValArr = (float[]) value;
            matrixCounterToUpload = 1; // no subimos array de matrices sino solo una matriz, al menos aquí
            GLES20.glUniformMatrix4fv(location, matrixCounterToUpload, false, floatValArr, 0);
            break;
        case GLES20.GL_BOOL:
            intVal = (Integer) value;
            GLES20.glUniform1i(location, intVal);
            break;
        case GLES20.GL_BOOL_VEC2:
            intValArr = (int[]) value;
            GLES20.glUniform2i(location, intValArr[0], intValArr[1]);
            break;
        case GLES20.GL_BOOL_VEC3:
            intValArr = (int[]) value;
            GLES20.glUniform3i(location, intValArr[0], intValArr[1], intValArr[2]);
            break;
        case GLES20.GL_BOOL_VEC4:
            intValArr = (int[]) value;
            GLES20.glUniform4i(location, intValArr[0], intValArr[1], intValArr[2], intValArr[3]);
            break;
        case GLES20.GL_SAMPLER_2D:
            GLES20.glUseProgram(this.m_GL_Program_ID);
            intVal = (Integer) value;
            int intvalue = intVal.intValue();

            GLES20.glUniform1i(location, intvalue);
            break;
    }
    this.checkGLError("- error uploading uniform -" + uniformName);
}

Related posts

Recent Viewed