1111import java .nio .ByteOrder ;
1212import java .nio .FloatBuffer ;
1313
14- public class ARBackground {
14+ public class BackgroundRenderer {
1515
1616 private static final int COORDS_PER_VERTEX = 3 ;
1717 private static final int TEXCOORDS_PER_VERTEX = 2 ;
@@ -28,24 +28,17 @@ public class ARBackground {
2828 private int textureId = -1 ;
2929
3030 static private URL screenquad_vertex =
31- ARBackground .class .getResource ("/assets/shaders/screenquad_vertex.glsl" );
31+ BackgroundRenderer .class .getResource ("/assets/shaders/screenquad_vertex.glsl" );
3232 static private URL screenquad_fragment =
33- ARBackground .class .getResource ("/assets/shaders/screenquad_fragment.glsl" );
33+ BackgroundRenderer .class .getResource ("/assets/shaders/screenquad_fragment.glsl" );
3434
3535 private String VERTICES_ERROR = "Unexpected number of vertices in BackgroundRenderer" ;
3636 private String ERROR_TAG = "Error" ;
3737 private String CREATION_ERROR = "Program creation" ;
3838 private String PARAMETERS_ERROR = "Program parameters" ;
3939 private String DRAW_ERROR = "Draw" ;
4040
41- public ARBackground () {
42- }
43-
44- public int getTextureId () {
45- return textureId ;
46- }
47-
48- public void createOnGlThread (Context context ) {
41+ public BackgroundRenderer (Context context ) {
4942 int [] textures = new int [1 ];
5043 GLES20 .glGenTextures (1 , textures , 0 );
5144 textureId = textures [0 ];
@@ -68,22 +61,22 @@ public void createOnGlThread(Context context) {
6861 quadVertices .position (0 );
6962
7063 ByteBuffer bbTexCoords =
71- ByteBuffer .allocateDirect (numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE );
64+ ByteBuffer .allocateDirect (numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE );
7265 bbTexCoords .order (ByteOrder .nativeOrder ());
7366 quadTexCoord = bbTexCoords .asFloatBuffer ();
7467 quadTexCoord .put (QUAD_TEXCOORDS );
7568 quadTexCoord .position (0 );
7669
7770 ByteBuffer bbTexCoordsTransformed =
78- ByteBuffer .allocateDirect (numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE );
71+ ByteBuffer .allocateDirect (numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE );
7972 bbTexCoordsTransformed .order (ByteOrder .nativeOrder ());
8073 quadTexCoordTransformed = bbTexCoordsTransformed .asFloatBuffer ();
8174
8275 int vertexShader =
83- Utils .loadGLShader (ERROR_TAG , context , GLES20 .GL_VERTEX_SHADER , screenquad_vertex );
76+ Utils .loadGLShader (ERROR_TAG , context , GLES20 .GL_VERTEX_SHADER , screenquad_vertex );
8477 int fragmentShader =
85- Utils .loadGLShader (
86- ERROR_TAG , context , GLES20 .GL_FRAGMENT_SHADER , screenquad_fragment );
78+ Utils .loadGLShader (
79+ ERROR_TAG , context , GLES20 .GL_FRAGMENT_SHADER , screenquad_fragment );
8780
8881 quadProgram = GLES20 .glCreateProgram ();
8982 GLES20 .glAttachShader (quadProgram , vertexShader );
@@ -99,6 +92,10 @@ public void createOnGlThread(Context context) {
9992 Utils .checkGLError (ERROR_TAG , PARAMETERS_ERROR );
10093 }
10194
95+ public int getTextureId () {
96+ return textureId ;
97+ }
98+
10299 public void draw (Frame frame ) {
103100
104101 if (frame .hasDisplayGeometryChanged ()) {
0 commit comments