I'm new here since I'm creating my first serious Android App using OpenGL|ES 1.0. I'm actually comming from C++ with OpenGL 2.0, Direct3D9 etc. on PCs.
So my first question is about the drawText of the Canvas class using in combination with GL10.
Actually it looks pretty good but only on the emulator. On my Galaxy S the text is not visible, just the rectangular area in the color, the text is to be drawn.
This is my code, maybe I did something wrong so that it only runs correct on the emulator.
Using java Syntax Highlighting
- /* Initialization */
- int width = 256;
- int height = 32;
- String text = "Test string";
- int size = 32;
- int[] textureName = new int[1];
- /* ... generate OpenGL texture etc. ... */
- /* Create an empty, mutable bitmap */
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- bitmap.eraseColor(0);
- /* Create the paint object */
- Paint paint = new Paint();
- /* Draw transparent background */
- paint.setColor(Color.TRANSPARENT);
- paint.setStyle(Style.FILL);
- canvas.drawPaint(paint);
- /* Draw the text */
- paint.setColor(Color.WHITE);
- paint.setTextSize(size);
- paint.setAntiAlias(true);
- canvas.drawText(text, 0, (float)size, paint);
- /* Create the texture finally */
- gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName[0]);
- gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
- gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
- GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
- bitmap.recycle();
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
I hope you can help me
greetings,
Lukas



