OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MinMaxBlending.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.minMaxBlending;
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 MinMaxBlending extends Activity
33 {
34  /* [classMembers] */
35  private static String LOGTAG = "MinMaxBlending";
36  private static String assetDirectory = null;
37  private static android.content.Context applicationContext = null;
38  protected TutorialView graphicsView;
39  /* [classMembers] */
40  @Override
41  protected void onCreate(Bundle savedInstanceState)
42  {
43  super.onCreate(savedInstanceState);
44 
45  graphicsView = new TutorialView(getApplication());
46 
47  /* [onCreateNew] */
48  applicationContext = getApplicationContext();
49  assetDirectory = applicationContext.getFilesDir().getPath() + "/";
50 
51  extractAsset("Min_Max_Blending_shader.frag");
52  extractAsset("Min_Max_Blending_shader.vert");
53 
54  for (int i = 1; i <= 109; i++)
55  {
56  extractAsset("MRbrain." + i);
57  }
58 
59  /* [onCreateNew] */
60  setContentView(graphicsView);
61  }
62  @Override protected void onPause()
63  {
64  super.onPause();
65  graphicsView.onPause();
66  }
67  @Override protected void onResume()
68  {
69  super.onResume();
70  graphicsView.onResume();
71  }
72  @Override protected void onDestroy()
73  {
74  super.onDestroy();
75  }
76  /* [extractAssetBeginning] */
77  private void extractAsset(String assetName)
78  {
79  File fileTest = new File(assetDirectory + assetName);
80 
81  if(fileTest.exists())
82  {
83  Log.d(LOGTAG,assetName + " already exists. No extraction needed.\n");
84  }
85  else
86  {
87  Log.d(LOGTAG, assetName + " doesn't exist. Extraction needed. \n");
88  /* [extractAssetBeginning] */
89  /* [tryCatch extractAsset] */
90  try
91  {
92  RandomAccessFile out = new RandomAccessFile(assetDirectory + assetName,"rw");
93  AssetManager am = applicationContext.getResources().getAssets();
94  /* [tryCatch extractAsset] */
95  /* [readWriteFile] */
96  InputStream inputStream = am.open(assetName);
97  byte buffer[] = new byte[1024];
98  int count = inputStream.read(buffer, 0, 1024);
99 
100  while (count > 0)
101  {
102  out.write(buffer, 0, count);
103  count = inputStream.read(buffer, 0, 1024);
104  }
105 
106  out.close();
107  inputStream.close();
108  }
109  catch(Exception e)
110  {
111  Log.e(LOGTAG, "Failure in extractAssets(): " + e.toString() + " " + assetDirectory+assetName);
112  }
113  if(fileTest.exists())
114  {
115  Log.d(LOGTAG,"File extracted successfully");
116  /* [readWriteFile] */
117  }
118  }
119  }
120 }
GLenum GLenum GLsizei count
Definition: gl2ext.h:133
GLenum GLuint buffer
Definition: gl2ext.h:628