Android + NDK + OpenGLES Development Environment configuration, ndkopengles
1. Download Resources
(1) Android eclipse Development Environment
I use adt-bundle-windows-x86, and the official main page can be downloaded. This is the package. Run eclipse.exe directly to start it.
(2) NDK
Download NDK (download it online)
(3) cygwin64
Used to simulate the linux running environment (download it online)
2. Environment Configuration
(1) eclipse import Project
Import the HelloGl program in NDK example
(2) compile C ++ code
A、open cygwin((mintty.exe)
B,
Run cd/cygdrive/e/android/wps2/HelloGL (go to The HelloGL directory of the sample, where e/android/wps2/HelloGL is the directory of your example)
C. compile c ++
Run/cygdrive/e/android/android-ndk-r8/ndk-build to compile c ++ gl code
3. run
Right-click the project and choose Run Android Application.
Note:
Can run on the terminal
Set NDK =/cygdrive/e/android/Co., android-ndk-r8/
Export NDK
Set environment variables to make it easier. Write $ NDK/ndk-build for the call.
Using Android NDK to develop OpenGLES
Finally, I want to get a method. I can generate a texture ing directly on the android upper layer, and then pass the texture ing address to JNI. In this way, I can use the Bitmap on the upper layer to generate a texture ing. Of course, this is not the best method, but because of its limited current capabilities, we can only rely on this method for the time being. If someone knows how to correctly use Bitmap to generate texture ing in C ++, welcome to communicate with me. (I used Bitmap to generate texture ing in C ++, but the texture is garbled, rather than the correct texture. It should be because the pixel array of the Bitmap I generated has a problem .) The following is my practice for reference. If you have a better method, please let us know: I want to draw text in OpenGLES, so first I use Canvas to generate the desired Bitmap, then, a texture ing is generated on the android layer to pass the binding address of the texture ing to JNI: public void onSurfaceCreated (GL10 gl10, EGLConfig eglconfig) {// generate the required Bitmap String s = "Beijing"; Bitmap bitmap; // construct the Bitmap. Its width and height must be the n bitmap = Bitmap of 2. createBitmap (512,512, Bitmap. config. ARGB_8888); Canvas canvas = new Canvas (bitmap); // set the canvas background to transparent. In this way, only the text is displayed in the texture, but the Canvas is not colored. drawColor (Color. TRANSPARENT); Paint p = new Paint (); // set the font, font size, and font color. String familyName = ""; Typeface font = Typeface. create (familyName, Typeface. BOLD); p. setColor (Color. RED); p. setTypeface (font); p. setTextSize (50); // draw the text canvas on Bitmap. drawText (s, 300, 60, p); s = "overcast, 23 degrees Celsius"; canvas. drawText (s, 0,120, p); s = "high temperature: 26, low temperature: 18"; canvas. drawText (s, 0,240, p); // until now, the Bitmap construction is complete. // from here, the texture ing gl10.glGenTextures (1, TextureString, 0) is generated ); // Create Nearest Filtered Texture and bind it to texture 0gl10. glBindTexture (GL10.GL _ TEXTURE_2D, TextureString [0]); GL10.GL _ TEXTURE_2D, GL10.GL _ 2D, GL10.GL _ NEAREST); GL10.GL _ TEXTURE_2D, GL10.GL _ 2D, GL10.GL _ NEAREST); GLUtils. texImage2D (GL10.GL _ TEXTURE_2D, 0, bitmap, 0 );&#...... remaining full text>
Build an NDK android Environment
It seems that the tutorial you are reading is old. Now there is no NDK option in the new Android Eclipse, you can use window --> prefrences --> C/C ++ --> Build --> Environment, and then Add a variable, the key NDK, whose value is the NDK directory. If you have any questions during NDK development, please contact us again.