OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NormalMapping.java
Go to the documentation of this file.
1 /* Copyright (c) 2013-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.normalmapping;
22 
23 import java.io.File;
24 import java.io.InputStream;
25 import java.io.RandomAccessFile;
26 
27 import android.os.Bundle;
28 import android.app.Activity;
29 import android.content.res.AssetManager;
30 import android.util.Log;
31 
32 public class NormalMapping extends Activity
33 {
34  /* [classMembers] */
35  private static String LOGTAG = "NormalMapping";
36  private static String assetDirectory = null;
37  protected TutorialView graphicsView;
38 
39  private static android.content.Context applicationContext = null;
40  /* [classMembers] */
41  @Override
42  protected void onCreate(Bundle savedInstanceState)
43  {
44  super.onCreate(savedInstanceState);
45  graphicsView = new TutorialView(getApplication());
46 
47  /* [onCreateNew] */
48  applicationContext = getApplicationContext();
49  assetDirectory = applicationContext.getFilesDir().getPath() + "/";
50 
51 
52  extractAsset("normalMap256.raw");
53  /* [onCreateNew] */
54  setContentView(graphicsView);
55  }
56  @Override protected void onPause()
57  {
58  super.onPause();
59  graphicsView.onPause();
60  }
61  @Override protected void onResume()
62  {
63  super.onResume();
64  graphicsView.onResume();
65  }
66  /* [extractAssetBeginning] */
67  private void extractAsset(String assetName)
68  {
69  File fileTest = new File(assetDirectory + assetName);
70 
71  if(fileTest.exists())
72  {
73  Log.d(LOGTAG,assetName + " already exists no extraction needed\n");
74  }
75  else
76  {
77  Log.d(LOGTAG, assetName + " doesn't exist extraction needed \n");
78  /* [extractAssetBeginning] */
79  /* [tryCatchExtractAsset] */
80  try
81  {
82  RandomAccessFile out = new RandomAccessFile(assetDirectory + assetName,"rw");
83  AssetManager am = applicationContext.getResources().getAssets();
84  /* [tryCatchExtractAsset] */
85  /* [readWriteFile] */
86  InputStream inputStream = am.open(assetName);
87  byte buffer[] = new byte[1024];
88  int count = inputStream.read(buffer, 0, 1024);
89 
90  while (count > 0)
91  {
92  out.write(buffer, 0, count);
93  count = inputStream.read(buffer, 0, 1024);
94  }
95  out.close();
96  inputStream.close();
97  }
98  catch(Exception e)
99  {
100  Log.e(LOGTAG, "Failure in extractAssets(): " + e.toString() + " " + assetDirectory+assetName);
101  }
102  if(fileTest.exists())
103  {
104  Log.d(LOGTAG,"File Extracted successfully");
105  /* [readWriteFile] */
106  }
107  }
108  }
109 }
GLenum GLenum GLsizei count
Definition: gl2ext.h:133
GLenum GLuint buffer
Definition: gl2ext.h:628