public abstract getResources ( ) : global::android.content.res.Resources | ||
Результат | global::android.content.res.Resources |
public static unsafe Texture LoadResource(Context context, int resource) { Texture ret = new Texture(); uint tex; gl.GenTextures(1, &tex); ret.myName = tex; gl.BindTexture(gl.GL_TEXTURE_2D, ret.myName); // do stuff to load it var inputStream = context.getResources().openRawResource(resource); try { var bitmap = BitmapFactory.decodeStream(inputStream); ret.myWidth = bitmap.Width; ret.myHeight = bitmap.Height; GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); } finally { inputStream.close(); } gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); ret.myPositionCoords = new float[] { 0, -ret.Height, 0, 0, 0, 0, ret.myWidth, -ret.myHeight, 0, ret.myWidth, 0, 0 }; return ret; }
public static int loadTexture(Context context, int resourceId) { int[] textureHandle = new int[1]; GLES20.glGenTextures(1, textureHandle, 0); if (textureHandle[0] != 0) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = false; // No pre-scaling // Read in the resource Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options); // Bind to the texture in OpenGL GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]); // Set filtering GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); // Load the bitmap into the bound texture. GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); // Recycle the bitmap, since its data has been loaded into OpenGL. bitmap.recycle(); } if (textureHandle[0] == 0) { //throw new RuntimeException("Error loading texture."); throw null; } return textureHandle[0]; }
public static InputStream openFileFromAssets(string spath, Context mycontext) { InputStream value = null; try { value = mycontext.getResources().getAssets().open(spath); } catch { } return value; }