June 2013
Intermediate to advanced
346 pages
8h 42m
English
Now that we’ve written the code for our shaders, the next step is to load them into memory. To do that, we’ll first need to write a method to read in the code from our resources folder.
Create a new Java source package in your project, com.airhockey.android.util, and in that package, create a new class called TextResourceReader. Add the following code inside the class:
| AirHockey1/src/com/airhockey/android/util/TextResourceReader.java | |
| | public static String readTextFileFromResource(Context context, |
| | int resourceId) { |
| | StringBuilder body = new StringBuilder(); |
| | |
| | try { |
| | InputStream inputStream = |
| | context.getResources().openRawResource(resourceId); |
| | InputStreamReader inputStreamReader ... |
Read now
Unlock full access