OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FoveatedRendering.java
Go to the documentation of this file.
1 /* Copyright (c) 2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 package com.arm.malideveloper.openglessdk.foveatedrendering;
22 
23 import android.content.res.AssetManager;
24 import android.os.Bundle;
25 import android.os.Environment;
26 import android.app.Activity;
27 import android.util.Log;
28 
29 import java.io.File;
30 import java.io.InputStream;
31 import java.io.RandomAccessFile;
32 
33 public class FoveatedRendering extends Activity
34 {
35  private static String LOGTAG = "FoveatedRendering";
36  private static String assetDirectory = null;
37  private static android.content.Context applicationContext = null;
38  protected TutorialView graphicsView;
39 
40  @Override
41  protected void onCreate(Bundle savedInstanceState)
42  {
43  super.onCreate(savedInstanceState);
44  Log.i(LOGTAG, "Creating New Tutorial View");
45 
46  applicationContext = getApplicationContext();
47  assetDirectory = applicationContext.getFilesDir().getPath() + "/";
48 
49  extractAsset("room.geom");
50  extractAsset("room.geomtan");
51 
52  extractAsset("multiviewPlane.vs");
53  extractAsset("roomFoveated.vs");
54  extractAsset("roomMultiview.vs");
55  extractAsset("roomRegular.vs");
56  extractAsset("roomPBR.fs");
57  extractAsset("mask.vs");
58  extractAsset("mask.fs");
59 
60  extractAsset("T_Exterior_B.raw");
61  extractAsset("T_Exterior_D.raw");
62  extractAsset("T_Exterior_M.raw");
63  extractAsset("T_Exterior_N.raw");
64 
65  graphicsView = new TutorialView(getApplication(), assetDirectory);
66  setContentView(graphicsView);
67  }
68 
69  @Override protected void onPause()
70  {
71  super.onPause();
72  graphicsView.onPause();
73  }
74 
75  @Override protected void onResume()
76  {
77  super.onResume();
78  graphicsView.onResume();
79  }
80 
81  private void extractAsset(String assetName)
82  {
83  File fileTest = new File(assetDirectory + assetName);
84 
85  if(fileTest.exists())
86  {
87  Log.d(LOGTAG,assetName + " already exists. No extraction needed.\n");
88  }
89  else
90  {
91  Log.d(LOGTAG, assetName + " doesn't exist. Extraction needed. \n");
92  /* [extractAssetBeginning] */
93  /* [tryCatch extractAsset] */
94  try
95  {
96  RandomAccessFile out = new RandomAccessFile(assetDirectory + assetName,"rw");
97  AssetManager am = applicationContext.getResources().getAssets();
98  /* [tryCatch extractAsset] */
99  /* [readWriteFile] */
100  InputStream inputStream = am.open(assetName);
101  byte buffer[] = new byte[1024];
102  int count = inputStream.read(buffer, 0, 1024);
103 
104  while (count > 0)
105  {
106  out.write(buffer, 0, count);
107  count = inputStream.read(buffer, 0, 1024);
108  }
109 
110  out.close();
111  inputStream.close();
112  }
113  catch(Exception e)
114  {
115  Log.e(LOGTAG, "Failure in extractAssets(): " + e.toString() + " " + assetDirectory+assetName);
116  }
117  if(fileTest.exists())
118  {
119  Log.d(LOGTAG,"File extracted successfully");
120  /* [readWriteFile] */
121  }
122  }
123  }
124 
125 }
GLenum GLenum GLsizei count
Definition: gl2ext.h:133
GLenum GLuint buffer
Definition: gl2ext.h:628