OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Mipmapping.java
Go to the documentation of this file.
1 /* Copyright (c) 2014-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.mipmapping;
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 Mipmapping extends Activity
33 {
34  private static String LOGTAG = "Mipmapping";
35  protected TutorialView graphicsView;
36  @Override
37  protected void onCreate(Bundle savedInstanceState)
38  {
39  super.onCreate(savedInstanceState);
40  String privateAssetDirectory = getFilesDir().getAbsolutePath();
41 
42  String textureName = "level0.raw";
43  extractAsset(textureName, privateAssetDirectory);
44  textureName = "level1.raw";
45  extractAsset(textureName, privateAssetDirectory);
46  textureName = "level2.raw";
47  extractAsset(textureName, privateAssetDirectory);
48  textureName = "level3.raw";
49  extractAsset(textureName, privateAssetDirectory);
50  textureName = "level4.raw";
51  extractAsset(textureName, privateAssetDirectory);
52  textureName = "level5.raw";
53  extractAsset(textureName, privateAssetDirectory);
54  textureName = "level6.raw";
55  extractAsset(textureName, privateAssetDirectory);
56  textureName = "level7.raw";
57  extractAsset(textureName, privateAssetDirectory);
58  textureName = "level8.raw";
59  extractAsset(textureName, privateAssetDirectory);
60  textureName = "level9.raw";
61  extractAsset(textureName, privateAssetDirectory);
62  textureName = "level0.pkm";
63  extractAsset(textureName, privateAssetDirectory);
64  textureName = "level1.pkm";
65  extractAsset(textureName, privateAssetDirectory);
66  textureName = "level2.pkm";
67  extractAsset(textureName, privateAssetDirectory);
68  textureName = "level3.pkm";
69  extractAsset(textureName, privateAssetDirectory);
70  textureName = "level4.pkm";
71  extractAsset(textureName, privateAssetDirectory);
72  textureName = "level5.pkm";
73  extractAsset(textureName, privateAssetDirectory);
74  textureName = "level6.pkm";
75  extractAsset(textureName, privateAssetDirectory);
76  textureName = "level7.pkm";
77  extractAsset(textureName, privateAssetDirectory);
78  textureName = "level8.pkm";
79  extractAsset(textureName, privateAssetDirectory);
80  textureName = "level9.pkm";
81  extractAsset(textureName, privateAssetDirectory);
82  graphicsView = new TutorialView(getApplication());
83  setContentView(graphicsView);
84  }
85  @Override protected void onPause()
86  {
87  super.onPause();
88  graphicsView.onPause();
89  }
90  @Override protected void onResume()
91  {
92  super.onResume();
93  graphicsView.onResume();
94  }
95  private void extractAsset(String assetName, String assetPath)
96  {
97  File fileTest = new File(assetPath, assetName);
98 
99  if(fileTest.exists())
100  {
101  Log.d(LOGTAG, assetName + " already exists no extraction needed\n");
102  }
103  else
104  {
105  Log.d(LOGTAG, assetName + " doesn't exist extraction needed \n");
106  try
107  {
108  RandomAccessFile out = new RandomAccessFile(fileTest,"rw");
109  AssetManager am = getResources().getAssets();
110 
111  InputStream inputStream = am.open(assetName);
112  byte buffer[] = new byte[1024];
113  int count = inputStream.read(buffer, 0, 1024);
114 
115  while (count > 0)
116  {
117  out.write(buffer, 0, count);
118  count = inputStream.read(buffer, 0, 1024);
119  }
120  out.close();
121  inputStream.close();
122  }
123  catch(Exception e)
124  {
125  Log.e(LOGTAG, "Failure in extractAssets(): " + e.toString() + " " + assetPath+assetName);
126  }
127  if(fileTest.exists())
128  {
129  Log.d(LOGTAG,"File Extracted successfully");
130  }
131  }
132  }
133 
134 }
void extractAsset(String assetName, String assetPath)
Definition: Mipmapping.java:95
GLenum GLenum GLsizei count
Definition: gl2ext.h:133
GLenum GLuint buffer
Definition: gl2ext.h:628