android - load a simple image (bitmap from drawable directory) into opengl renderer -


I am fairly new in Opelagles, I am trying to load a simple bitmap. I found this in a tutorial, but, what should I write in Surface Creative and on-DraftMemeMe?

  Private Zero Init Image (GL10GL) {int [] Texture = New Int [1]; Gl.glGenTextures (1, texture, 0); Gl.glBindTexture (GL10.GL_TEXTURE_2D, Texture [0]); Gl.glTexParameterf (GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); Gl.glTexParameterf (GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); Gl.glTexParameterf (GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); Gl.glTexParameterf (GL10.GL_TEXTURE_2D, GL 10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); Gl.glTexEnvf (GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE); In InputStream = context.getResources () OpenRawResource (R.drawable.ic_launcher); bitmap image; {Image = try BitmapFactory.decodeStream (in); } Finally {try {in.close ()}} hold (IOException e) {}} GLUtils.texImage2D (GL10.GL_TEXTURE_2D, 0, image, 0); Image.recycle (); }    

I decodeResource method by bitmapfactor For this purpose, with its naming in the past, this call will appear as:

  Bitmap image = BitMapFrenchtic DCRSOS (References.GetterSourcedes (RDRAY.AC_Luncher);   

You should probably also work, but the above versions seem simple.

You should put it at onSurfaceCreated () . You may want to store the texture id in a member of a class, so that you can tie it to onDrawFrame () . It is not strictly necessary if you use only one texture because you can keep it in that case. But this is cleaner, and if you use multiple textures in the future, you'll scale it.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -