public Floor() { // make a floor ByteBuffer bbFloorVertices = ByteBuffer.allocateDirect(FLOOR_COORDS.length * 4); bbFloorVertices.order(ByteOrder.nativeOrder()); floorVertices = bbFloorVertices.asFloatBuffer(); floorVertices.put(FLOOR_COORDS); floorVertices.position(0); ByteBuffer bbFloorNormals = ByteBuffer.allocateDirect(FLOOR_NORMALS.length * 4); bbFloorNormals.order(ByteOrder.nativeOrder()); floorNormals = bbFloorNormals.asFloatBuffer(); floorNormals.put(FLOOR_NORMALS); floorNormals.position(0); ByteBuffer bbFloorColors = ByteBuffer.allocateDirect(FLOOR_COLORS.length * 4); bbFloorColors.order(ByteOrder.nativeOrder()); floorColors = bbFloorColors.asFloatBuffer(); floorColors.put(FLOOR_COLORS); floorColors.position(0); // now setup the shaders and program object int vertexShader = myStereoRenderer.LoadShader(GLES30.GL_VERTEX_SHADER, light_vertex); int gridShader = myStereoRenderer.LoadShader(GLES30.GL_FRAGMENT_SHADER, grid_fragment); int programObject; int[] linked = new int[1]; // Create the program object programObject = GLES30.glCreateProgram(); if (programObject == 0) { Log.e(TAG, "So some kind of error, but what?"); return; } GLES30.glAttachShader(programObject, vertexShader); GLES30.glAttachShader(programObject, gridShader); // Link the program GLES30.glLinkProgram(programObject); // Check the link status GLES30.glGetProgramiv(programObject, GLES30.GL_LINK_STATUS, linked, 0); if (linked[0] == 0) { Log.e(TAG, "Error linking program:"); Log.e(TAG, GLES30.glGetProgramInfoLog(programObject)); GLES30.glDeleteProgram(programObject); return; } // Store the program object mProgramObject = programObject; }
public static void deleteProgram(final GLProgram _program) { // During the build process a programs // shaders list has already been detached // and destroyed. GLES30.glDeleteProgram(_program.id[0]); }