Search code examples
androidimagexamarin.androidopentk

Load png with OpenTK and MonoDroid


I'm looking for an example of loading a png-file on MonoDroid using OpenTK. Anyone?

Thanks!


Solution

  • Put TexLib into your code and do the following:

    1. save the texture into your Assets folder and give it the Build Action "AndroidAsset"
    2. Add the following function to the TexLib.cs:

      public static int CreateTextureFromStream (InputStream stream)
       {
           return CreateTextureFromBitmap (new Bitmap (Bitmap.FromStream (stream)));
       }
      
    3. Call the function with your asset:

      int textureId = TexUtil.CreateTextureFromStream (Assets.Open ("my_texture.png"));